[Larceny-users] petit-instr.h and tag bits

Jed Davis jdev at panix.com
Tue Feb 20 16:38:33 EST 2007


I noticed that petit-instr.h has some macros for subtracting the known
tag from a pair or vector pointer rather than masking them off, for
the obvious reason.  Alas, a few instructions weren't using them --
car:pair and vector-ref:trusted and so on, which is what Twobit appears
to actually emit (having done the checks separately).

So, I fixed that, because why not.  The result can still build itself,
so I don't seem to have broken anything, and the effect on GCC's output
is as expected, but I don't know how much it matters for performance
given the rest of the C-calling-convention-induced bloat.

-- 
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l))))))  (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k)))))))    '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))
-------------- next part --------------
--- larceny-0.93-src.orig/include/Standard-C/petit-instr.h	2006-10-18 11:24:19.000000000 -0400
+++ larceny-0.93-src/include/Standard-C/petit-instr.h	2007-02-18 16:13:38.000000000 -0500
@@ -1428,19 +1428,19 @@
   RESULT = fixnum( vector_length( RESULT ) )
 
 #define twobit_op2_402( y ) /* vector-ref:trusted */ \
-  RESULT = vector_ref( RESULT, reg(y) >> 2 )
+  RESULT = *vec_addr( RESULT, reg(y) >> 2 )
 
 #define twobit_op3_403( y, z ) /* vector-set!:trusted */	\
   do { word b=reg(y) >> 2, c=SECOND=reg(z);			\
-       vector_set( RESULT, b, c );				\
+       *vec_addr( RESULT, b) = c;				\
        BARRIER();		                                \
   } while(0)
 
 #define twobit_op1_404() /* car:pair */ \
-  RESULT = pair_car(RESULT)
+  RESULT = *car_addr(RESULT)
 
 #define twobit_op1_405() /* cdr:pair */ \
-  RESULT = pair_cdr(RESULT)
+  RESULT = *cdr_addr(RESULT)
 
 #define twobit_op2_406( y ) /* =:fix:fix */ \
   setcc((s_word)RESULT == (s_word)reg(y))
@@ -1458,7 +1458,7 @@
   setcc((s_word)RESULT > (s_word)reg(y))
 
 #define twobit_op2imm_450( k ) /* vector-ref:trusted */ \
-  RESULT = vector_ref( RESULT, (k >> 2) )
+  RESULT = *vec_addr( RESULT, (k >> 2) )
 
 #define twobit_op2imm_451( k ) /* =:fix:fix */ \
   setcc((s_word)RESULT == k)


More information about the Larceny-users mailing list