Split 'unbox' and 'weak-unbox' operations (different optimizations).

Normal boxes change only by set-box!; weak boxes can change to #f at any time.
This commit is contained in:
Jesse D. McDonald 2010-06-26 22:50:43 -05:00
parent 960d7917c9
commit 00718b410b
4 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@ unary-expr: up to 255, 1 out, 1 in
02 (set! out (unbox in)) 02 (set! out (unbox in))
03 (set! out (car in)) 03 (set! out (car in))
04 (set! out (cdr in)) 04 (set! out (cdr in))
05 (set! out (weak-unbox in))
08 (set! out (boolean? in)) ; value => bool 08 (set! out (boolean? in)) ; value => bool
09 (set! out (fixnum? in)) ; value => bool 09 (set! out (fixnum? in)) ; value => bool

View File

@ -407,9 +407,10 @@ static value_t eval_unary_expression(interp_state_t *state, uint8_t subcode, uin
switch (subcode) switch (subcode)
{ {
case 0x01: return ST1; case 0x01: return ST1;
case 0x02: return is_weak_box(ST1) ? _get_weak_box(ST1)->value : get_box(ST1)->value; case 0x02: return get_box(ST1)->value;
case 0x03: return get_pair(ST1)->car; case 0x03: return get_pair(ST1)->car;
case 0x04: return get_pair(ST1)->cdr; case 0x04: return get_pair(ST1)->cdr;
case 0x05: return get_weak_box(ST1)->value;
case 0x08: return boolean_value(is_boolean(ST1)); case 0x08: return boolean_value(is_boolean(ST1));
case 0x09: return boolean_value(is_fixnum(ST1)); case 0x09: return boolean_value(is_fixnum(ST1));
case 0x0a: return boolean_value(is_box(ST1)); case 0x0a: return boolean_value(is_box(ST1));

View File

@ -23,6 +23,7 @@
'((#%unbox #x02 unbox) '((#%unbox #x02 unbox)
(#%car #x03 car) (#%car #x03 car)
(#%cdr #x04 cdr) (#%cdr #x04 cdr)
(#%weak-unbox #x05 weak-unbox)
(#%boolean? #x08 boolean?) (#%boolean? #x08 boolean?)
(#%fixnum? #x09 fixnum?) (#%fixnum? #x09 fixnum?)
(#%box? #x0a box?) (#%box? #x0a box?)

View File

@ -4,6 +4,7 @@
(define (unbox x) (unbox x)) (define (unbox x) (unbox x))
(define (car x) (car x)) (define (car x) (car x))
(define (cdr x) (cdr x)) (define (cdr x) (cdr x))
(define (weak-unbox x) (weak-unbox x))
(define (boolean? x) (boolean? x)) (define (boolean? x) (boolean? x))
(define (fixnum? x) (fixnum? x)) (define (fixnum? x) (fixnum? x))
(define (box? x) (box? x)) (define (box? x) (box? x))