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

inline array refs?



I translated some code to test iterative repair alogirithms from c to LISP.
The code mainly does fixnum operations and simple-array accesses. By adding
appropriate (the fixnum ...) and (declare (type (simple-array fixnum (*))
array) 
I managed to get about half the speed of the corresponding c program
compiled with MPW on the same mac.

The disassembly of the code shows calls to subroutines
(jsr_subprim $SP-GETLONG) and
(jsr_subprim $SP-MKLONG)

I suspect that these calls slow down the programm. Does anybody know what
these routines do and how I could avoid them? I always thought that adding
enough declarations to a MCL program would give me the same speed as a
corresponding c program.

Anyhow I tried to run the same program under LIspWorks 3.2 on a Dec-Alpha
and to my surprise a quadra 650 was more than two times faster than the
alpha, even after declaring fixnum-safety = 0. From looking at the
disassembly I suspect that the arefs are not inlined in LispWorks. Does
anybody know how I could get LispWorks to inline the arefs too?

;test code for the array refs

(defun test (array index)
  (declare (optimize (speed 3)(safety 0))
           (type (simple-array fixnum (*)) array))
  (aref array index))
->
0 (SPUSH VSP)
2 (VPUSH D1)
4 (VPUSH D0)
6 (MOVE.L (VSP 4) ATEMP0)
10 (MOVE.L @VSP D1)
12 (ASR.L 1 D1)
14 (MOVE.L (ATEMP0 D1.L 7) D0)
18 (SPOP VSP)
20 (JMP_SUBPRIM $SP-MKLONG)

(defun test-1 (array index wert)
  (declare (optimize (speed 3)(safety 0))
           (type (simple-array fixnum (*)) array))
  (setf (aref array index) (the fixnum wert)))

0 (SPUSH VSP)
2 (MOVEM.L #(D2 D1 D0) -@VSP)
6 (MOVE.L (VSP 8) ATEMP0)
10 (MOVE.L (VSP 4) D1)
14 (MOVE.L @VSP D0)
16 (ASR.L 1 D1)
18 (MOVE.L D0 D4)
20 (JSR_SUBPRIM $SP-GETLONG)
24 (MOVE.L D0 (ATEMP0 D1.L 7))
28 (MOVE.L D4 D0)
30 (SPOP VSP)
32 (RTS)