: lazy-load ( value loc -- value )
over ds-loc? pick cs-loc? or [
dupd = [
- >r alloc-reg <vreg> dup r> %peek , ! drop f
+ drop f
] [
>r alloc-reg <vreg> dup r> %peek ,
] if
0 scratch object-tag CMP
"f" get JE
! The pointer is not equal to 3. Load the object header.
- 0 output-operand ECX object-tag neg [+] MOV
+ 0 output-operand 0 scratch object-tag neg [+] MOV
! Mask off header tag, making a fixnum.
0 output-operand object-tag XOR
"end" get JMP
[ 2 3 4 ] [ 3 [ 2 swap 4 ] compile-1 ] unit-test
+[ { 1 2 3 } { 1 4 3 } 3 3 ]
+[ { 1 2 3 } { 1 4 3 } [ over tag over tag ] compile-1 ]
+
[ { 1 2 3 } { 1 4 3 } 8 8 ]
[ { 1 2 3 } { 1 4 3 } [ over type over type ] compile-1 ]
unit-test