From: Lynn Q. <quam@AI.SRI.COM> - 2016-04-25 01:29:31
|
Why does DISASSEMBLE not show the argument checking of functions? Below is an example of a simple function FOO with its types declared and compiled with DEBUG = 1, SAFETY = 1, SPEED = 1. When (DISASSEMBLE 'FOO) is invoked the type checking is not shown. However, when SLIME's INSPECT is used on (SB-DISASSEM::FUN-CODE #'FOO) the type checking is revealed. (defun foo (buf i) (declare (type (simple-array fixnum (*)) buf)) (declare (fixnum i)) (aref buf i)) (disassemble 'foo) ; disassembly for FOO ; Size: 73 bytes. Origin: #x1004026AFB ; AFB: 498B542460 MOV RDX, [R12+96] ; thread.binding-stack-pointer ; no-arg-parsing entry point ; B00: 488955F8 MOV [RBP-8], RDX ; B04: 483B3D75FFFFFF CMP RDI, [RIP-139] ; [#x1004026A80] = 7FFFFFFFFFFFFFF8 ; B0B: 771F JNBE L0 ; B0D: 488B51F9 MOV RDX, [RCX-7] ; B11: 488BDA MOV RBX, RDX ; B14: 488BD7 MOV RDX, RDI ; B17: F6C201 TEST DL, 1 ; B1A: 751D JNE L1 ; B1C: 4839D3 CMP RBX, RDX ; B1F: 7618 JBE L1 ; B21: 488B549101 MOV RDX, [RCX+RDX*4+1] ; B26: 488BE5 MOV RSP, RBP ; B29: F8 CLC ; B2A: 5D POP RBP ; B2B: C3 RET ; B2C: L0: 488BC7 MOV RAX, RDI ; B2F: 48D1F8 SAR RAX, 1 ; B32: CC0A BREAK 10 ; error trap ; B34: 02 BYTE #X02 ; B35: 59 BYTE #X59 ; OBJECT-NOT-INDEX-ERROR ; B36: 1E BYTE #X1E ; RAX ; B37: CC10 BREAK 16 ; Invalid argument count trap ; B39: L1: CC0A BREAK 10 ; error trap ; B3B: 08 BYTE #X08 ; B3C: 0C BYTE #X0C ; INVALID-ARRAY-INDEX-ERROR ; B3D: 9B BYTE #X9B ; RCX ; B3E: FE9A01 BYTE #XFE, #X9A, #X01 ; RBX ; B41: FE1A01 BYTE #XFE, #X1A, #X01 ; RDX SLIME INSPECT of (SB-DISASSEM::FUN-CODE #'foo) #<SB-KERNEL:CODE-COMPONENT {1004026A6F}> -------------------- CODE-SIZE: 196 ENTRY-POINTS: #<FUNCTION FOO> DEBUG-INFO: #S(SB-C::COMPILED-DEBUG-INFO ..) Constants: Code: ; Size: 196 bytes. Origin: #x1004026A80 (segment 1 of 2) ; A80: .WORD #x7FFFFFFFFFFFFFF8 ; A88: .WORD #x0000000000000000 ; A90: .ENTRY FOO(BUF I) ; (FUNCTION ; (# ..)) ; AC8: 8F4508 POP QWORD PTR [RBP+8] ; ACB: 4883F904 CMP RCX, 4 ; ACF: 7566 JNE L4 ; AD1: 488D65F8 LEA RSP, [RBP-8] ; AD5: 8D42F1 LEA EAX, [RDX-15] ; AD8: A80F TEST AL, 15 ; ADA: 7518 JNE L1 ; ADC: 807AF1BD CMP BYTE PTR [RDX-15], -67 ; AE0: 7512 JNE L1 ; AE2: 40F6C701 TEST DIL, 1 ; AE6: 7505 JNE L0 ; AE8: 488BCA MOV RCX, RDX ; AEB: EB0E JMP L2 ; AED: L0: CC0A BREAK 10 ; error trap ; AEF: 04 BYTE #X04 ; AF0: 35 BYTE #X35 ; OBJECT-NOT-FIXNUM-ERROR ; AF1: FE9B03 BYTE #XFE, #X9B, #X03 ; RDI ; AF4: L1: CC0A BREAK 10 ; error trap ; AF6: 04 BYTE #X04 ; AF7: 26 BYTE #X26 ; OBJECT-NOT-SIMPLE-ARRAY-FIXNUM-ERROR ; AF8: FE1B01 BYTE #XFE, #X1B, #X01 ; RDX ; Origin #x1004026AFB (segment 2 of 2) ; AFB: L2: 498B542460 MOV RDX, [R12+96] ; thread.binding-stack-pointer ; no-arg-parsing entry point ; B00: 488955F8 MOV [RBP-8], RDX ; B04: 483B3D75FFFFFF CMP RDI, [RIP-139] ; [#x1004026A80] = 7FFFFFFFFFFFFFF8 ; B0B: 771F JNBE L3 ; B0D: 488B51F9 MOV RDX, [RCX-7] ; B11: 488BDA MOV RBX, RDX ; B14: 488BD7 MOV RDX, RDI ; B17: F6C201 TEST DL, 1 ; B1A: 751D JNE L5 ; B1C: 4839D3 CMP RBX, RDX ; B1F: 7618 JBE L5 ; B21: 488B549101 MOV RDX, [RCX+RDX*4+1] ; B26: 488BE5 MOV RSP, RBP ; B29: F8 CLC ; B2A: 5D POP RBP ; B2B: C3 RET ; B2C: L3: 488BC7 MOV RAX, RDI ; B2F: 48D1F8 SAR RAX, 1 ; B32: CC0A BREAK 10 ; error trap ; B34: 02 BYTE #X02 ; B35: 59 BYTE #X59 ; OBJECT-NOT-INDEX-ERROR ; B36: 1E BYTE #X1E ; RAX ; B37: L4: CC10 BREAK 16 ; Invalid argument count trap ; B39: L5: CC0A BREAK 10 ; error trap ; B3B: 08 BYTE #X08 ; B3C: 0C BYTE #X0C ; INVALID-ARRAY-INDEX-ERROR ; B3D: 9B BYTE #X9B ; RCX ; B3E: FE9A01 BYTE #XFE, #X9A, #X01 ; RBX ; B41: FE1A01 BYTE #XFE, #X1A, #X01 ; RDX |