]> gitweb.factorcode.org Git - factor.git/blob - basis/cpu/architecture/architecture-tests.factor
1a9ef57754407e9a7caa187e23773548fe17b6de
[factor.git] / basis / cpu / architecture / architecture-tests.factor
1 USING: accessors compiler.cfg.instructions compiler.cfg.stack-frame
2 cpu.architecture cpu.x86 kernel layouts math namespaces system tools.test ;
3 IN: cpu.architecture.tests
4
5 : expected-gc-root-offset ( slot-number spill-area-base -- offset )
6     [ spill-slot boa ] [ stack-frame new swap >>spill-area-base ] bi*
7     stack-frame [
8         gc-root-offset reserved-stack-space cell / -
9     ] with-variable ;
10
11 cpu x86.64? [
12     ! The offset is 1, not 0 because the return address occupies the
13     ! first position in the stack frame.
14     { 1 } [ 0 0 expected-gc-root-offset ] unit-test
15
16     { 10 } [ 8 64 expected-gc-root-offset ] unit-test
17
18     { 20 } [ 24 128 expected-gc-root-offset ] unit-test
19 ] when