Subject: Re: What is the best Open-Source Lisp?
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 23 Feb 2006 05:31:11 -0600
Newsgroups: comp.lang.lisp
Message-ID: <-JOdnXJ9DJZiAWDeRVn-ig@speakeasy.net>
<mmcconnell17704@yahoo.com> wrote:
+---------------
| To clarify this part of the thread for the original poster:
| one key to the results of Rob's first post is the
|   (declare (optimize ...))
+---------------

Actually, my *main* reason for making that little toy example so
highly optimized was simply to shorten the size of the native
machine code to be displayed in the article!!  ;-}  ;-}

I apologize if I gave anyone the impression that you need a bunch of
declarations to get native code from CMUCL's compiler -- you don't.
Without all the declarations, CMUCL still compiles to native code,
only without omitting the safety checks there's a *lot* more of it:  ;-}

    cmu> (defun foo (a b c)
	   (* (+ a b) c))

    FOO
    cmu> (compile 'foo)
    ; Compiling LAMBDA (A B C): 
    ; Compiling Top-Level Form: 

    FOO
    NIL
    NIL
    cmu> (disassemble 'foo)
    48942418:       .ENTRY FOO(a b c)            ; (FUNCTION (T T T) NUMBER)
	  30:       POP     DWORD PTR [EBP-8]
	  33:       LEA     ESP, [EBP-32]

	  36:       CMP     ECX, 12              ; [:NON-LOCAL-ENTRY]
	  39:       JNE     L0
	  3B:       MOV     [EBP-12], EDX
	  3E:       MOV     [EBP-16], EDI
	  41:       MOV     [EBP-20], ESI

	  44:       MOV     EDX, [EBP-12]        ; No-arg-parsing entry point
						 ; [:NON-LOCAL-ENTRY]
	  47:       MOV     EDI, [EBP-16]

    ;;; [5] (+ A B)

	  4A:       CALL    #x100001D0           ; #x100001D0: GENERIC-+
						 ; [:CALL-SITE]
	  4F:       MOV     ESP, EBX             ; [:SINGLE-VALUE-RETURN]
	  51:       MOV     EDI, [EBP-20]

    ;;; [4] (* (+ A B) C)

	  54:       CALL    #x100002D0           ; #x100002D0: GENERIC-*
						 ; [:CALL-SITE]
	  59:       MOV     ESP, EBX             ; [:SINGLE-VALUE-RETURN]

	  5B:       MOV     ECX, [EBP-8]         ; [:BLOCK-START]
	  5E:       MOV     EAX, [EBP-4]
	  61:       ADD     ECX, 2
	  64:       MOV     ESP, EBP
	  66:       MOV     EBP, EAX
	  68:       JMP     ECX
	  6A:       NOP
	  6B:       NOP
	  6C:       NOP
	  6D:       NOP
	  6E:       NOP
	  6F:       NOP
	  70: L0:   BREAK   10                   ; Error trap
	  72:       BYTE    #x02
	  73:       BYTE    #x19                 ; INVALID-ARGUMENT-COUNT-ERROR
	  74:       BYTE    #x4D                 ; ECX
    cmu> 


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607