* (defun fx-add (x y)
(declare (optimize (speed 3) (safety 0) (debug 0))
(type fixnum x y))
(+ x y))
FX-ADD
* (disassemble #'fx-add)
; disassembly for FX-ADD
; Size: 104 bytes. Origin: #x7005970068 ; FX-ADD
; 68: 40FD4193 ASR NL0, R0, #1
; 6C: 00048B8B ADD NL0, NL0, R1, ASR #1
; 70: 0A0000AB ADDS R0, NL0, NL0
; 74: E7010054 BVC L1
; 78: BD2A00B9 STR WNULL, [THREAD, #40] ; pseudo-atomic-bits
; 7C: A97A47A9 LDP TMP, LR, [THREAD, #112] ; mixed-tlab.{free-pointer, end-addr}
; 80: 2A410091 ADD R0, TMP, #16
; 84: 5F011EEB CMP R0, LR
; 88: C8010054 BHI L2
; 8C: AA3A00F9 STR R0, [THREAD, #112] ; mixed-tlab
; 90: L0: 2A3D0091 ADD R0, TMP, #15
; 94: 3E2280D2 MOVZ LR, #273
; 98: 3E0100A9 STP LR, NL0, [TMP]
; 9C: BF3A03D5 DMB ISHST
; A0: BF2A00B9 STR WZR, [THREAD, #40] ; pseudo-atomic-bits
; A4: BE2E40B9 LDR WLR, [THREAD, #44] ; pseudo-atomic-bits
; A8: 5E0000B4 CBZ LR, L1
; AC: 200120D4 BRK #9 ; Pending interrupt trap
; B0: L1: FB031AAA MOV CSP, CFP
; B4: 5A7B40A9 LDP CFP, LR, [CFP]
; B8: BF0300F1 CMP NULL, #0
; BC: C0035FD6 RET
; C0: L2: 090280D2 MOVZ TMP, #16
; C4: 2AFCFF58 LDR R0, #x7005970048 ; SB-VM::ALLOC-TRAMP
; C8: 40013FD6 BLR R0
; CC: F1FFFF17 B L0
NIL
Are you serious? This should be 1, max 2 instructions, with no branches and no memory use.Furthermore, I’ve also decided to evaluate the debuggers available for Common Lisp. However, despite it being touted as a debugger-oriented language, I think the actual debuggers are pretty subpar, compared to debuggers available for C, C++, Java or .NET. No Common Lisp debugger supports watchpoints of any kind. If a given debugger supports breakpoints at all, they’re often done through wrapping code in code that triggers a breakpoint, or making this code run under interpreter instead of being native. Setting breakpoints in arbitrary code won’t work, it needs to be available as source code first. SBCL with SLIME doesn’t have a nice GUI where I could use the standard F[N] keys to step, continue, stop, etc. I don’t see any pane with live disassembly view. No live watch. LispWorks GUI on the other hand looks like a space station, where I struggle to orient myself. The only feature that is somewhat well-done is live code reload, but IMO it’s something far less important than well-implemented breakpoints and watchpoints in other languages, since the main thing I need the debugger for is to figure out what the hell a given piece of code is doing. Editing it is a completely secondary concern. And live code reload is also not unique to Common Lisp.
Debugger-wise, Java and .NET seem to be leading in quality, followed by C and C++.
[1]: Yes, I have read many comments about the alleged good performance of Common Lisp, but either authors of these comments live in a parallel reality with completely different benchmark results, or they’re comparing to Python. As such I treat those comments as urban legends.