Subject: Re: compiled code
From: Erik Naggum <erik@naggum.no>
Date: 12 Sep 2002 02:26:48 +0000
Newsgroups: comp.lang.lisp
Message-ID: <3240786408336302@naggum.no>

* Matthew Danish
| Very nice output =)  But how does it know that the result is a fixnum?

  Allegro CL has a compiler optimization switch that makes declared fixnums
  remain fixnums.  It defaults to true only when speed is 3 and safety 0.  If
  you turn it off, the same Common Lisp code produces more machine code:

   0: c1 f8 02    sarl	eax,$2
   3: c1 fa 02    sarl	edx,$2
   6: 03 c2       addl	eax,edx
   8: ff a7 87 00 jmp	*[edi+135]      ; sys::fixnum-or-bignum
      00 00 

  The shifts convert from the fixnum representation (two type tag bits) to the
  machine integer and the tail-called function will shift the sum back if there
  is space or cons a bignum if not.

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.