Created
December 29, 2016 23:33
-
-
Save Lifelovinglight/478edeed7ef2e230ef83b19e11409859 to your computer and use it in GitHub Desktop.
sbcl not returning a fixnum in this scenario without specifying the explicit type of the return value breaks the model of type signatures as compiler promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(locally | |
(declaim | |
(optimize (speed 3) | |
(space 3) | |
(safety 0) | |
(debug 0) | |
(compilation-speed 0)) | |
(ftype (function (fixnum) fixnum) | |
dec-fixnum | |
dec-fixnum-fixnum)) | |
(defun dec-fixnum (n) | |
(1- n)) | |
(defun dec-fixnum-fixnum (n) | |
(the fixnum (1- n)))) | |
; CL-USER> (disassemble #'dec-fixnum-fixnum) | |
; disassembly for DEC-FIXNUM-FIXNUM | |
; Size: 13 bytes. Origin: #x10042EDCF2 | |
; 2: 4883E902 SUB RCX, 2 ; no-arg-parsing entry point | |
; 6: 488BD1 MOV RDX, RCX | |
; 9: 488BE5 MOV RSP, RBP | |
; C: F8 CLC | |
; D: 5D POP RBP | |
; E: C3 RET | |
; NIL | |
; CL-USER> (disassemble #'dec-fixnum) | |
; disassembly for DEC-FIXNUM | |
; Size: 30 bytes. Origin: #x10042ED795 | |
; 95: 4883E901 SUB RCX, 1 ; no-arg-parsing entry point | |
; 99: 488BD1 MOV RDX, RCX | |
; 9C: 48D1E2 SHL RDX, 1 | |
; 9F: 710C JNO L0 | |
; A1: 488BD1 MOV RDX, RCX | |
; A4: 41BB60060020 MOV R11D, 536872544 ; ALLOC-SIGNED-BIGNUM-IN-RDX | |
; AA: 41FFD3 CALL R11 | |
; AD: L0: 488BE5 MOV RSP, RBP | |
; B0: F8 CLC | |
; B1: 5D POP RBP | |
; B2: C3 RET | |
; NIL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment