1 USING: accessors compiler.cfg compiler.cfg.instructions
2 compiler.cfg.stack-frame compiler.cfg.utilities cpu.architecture
3 cpu.x86 kernel layouts math namespaces system tools.test ;
4 IN: cpu.architecture.tests
6 : cfg-w-spill-area-base ( base -- cfg )
7 stack-frame new swap >>spill-area-base
8 { } insns>cfg swap >>stack-frame ;
10 : expected-gc-root-offset ( slot-number spill-area-base -- offset )
11 [ spill-slot boa ] [ cfg-w-spill-area-base ] bi*
13 gc-root-offset reserved-stack-space cell / -
17 ! The offset is 1, not 0 because the return address occupies the
18 ! first position in the stack frame.
19 { 1 } [ 0 0 expected-gc-root-offset ] unit-test
21 { 10 } [ 8 64 expected-gc-root-offset ] unit-test
23 { 20 } [ 24 128 expected-gc-root-offset ] unit-test