[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array Register Analog in MCL?



At 8:12 PM 5/13/95, John C. Mallery wrote:
>Is there something in MCL that is analogous to array registers on the Lisp
>Machine?
>
>What is needed is a aref that works on one dimensional arrays and does not
>perform
>bounds each reference.  This provides an optimization when the calling code has
>already determined the array length.

How about this:

(defmacro fast-aref (array index)
  `(locally
     (declare (optimize (speed 3) (safety 0)))
     (svref ,array ,index)))

which compiles to 12 bytes of 68000 assembly code:

(disassemble #'(lambda (a i)
                 (fast-aref a i)))

0 (JSR_SUBPRIM $SP-TWO-ARGS-VPUSH)
=> 4 (MOVE.L (VSP 4) ATEMP0)
=> 8 (MOVE.L @VSP D1)
=> 10 (ASR.L 1 D1)
=> 12 (MOVE.L (ATEMP0 D1.L 3) D0)
16 (SPOP VSP)
18 (RTS)

Fast enough for ya?

- Steve Hain

Digitool, Inc.
______________________________________________________________________________
                       One Main Street   7th Floor   Cambridge, MA 02142   USA
                              Internet: slh@digitool.com   AppleLink: digitool
                                      World Wide Web: http://www.digitool.com/
                                         Tel: 617 441-5000   Fax: 617 576-7680