1 USING: accessors alien.c-types arrays bit-arrays byte-arrays
2 classes.struct compiler.cfg compiler.cfg.instructions
3 compiler.cfg.stack-frame compiler.cfg.utilities
4 compiler.codegen.gc-maps compiler.codegen.relocation cpu.architecture
5 cpu.x86 kernel layouts make math namespaces sequences
6 specialized-arrays system tools.test ;
8 SPECIALIZED-ARRAY: uint
9 IN: compiler.codegen.gc-maps.tests
15 M: fake-cpu gc-root-offset ;
19 V{ } clone return-addresses set
20 V{ } clone gc-maps set
30 { derived-roots V{ { 2 4 } } }
36 { 0 } [ "result" get length 16 mod ] unit-test
41 ! The below data is 29 bytes -- 15 bytes padding needed to
51 ! Derived pointers - 12 bytes
52 uint-array{ -1 -1 4 } underlying>> %
54 ! Return addresses - 4 bytes
55 uint-array{ 100 } underlying>> %
57 ! GC info footer - 12 bytes
60 { derived-root-count 3 }
61 { return-address-count 1 }
66 { t } [ "result" get length "expect" get length = ] unit-test
67 { t } [ "result" get "expect" get = ] unit-test
69 ! Fix the gc root offset calculations
70 SINGLETON: linux-x86.64
71 M: linux-x86.64 reserved-stack-space 0 ;
72 M: linux-x86.64 gc-root-offset
73 n>> spill-offset cell + cell /i ;
75 : cfg-w-spill-area-base ( base -- cfg )
76 stack-frame new swap >>spill-area-base
77 { } insns>cfg swap >>stack-frame ;
79 : array>spill-slots ( seq -- spills )
80 [ spill-slot boa ] map ;
82 : <gc-map/spills> ( spills -- gc-map )
83 array>spill-slots { } gc-map boa ;
86 linux-x86.64 \ cpu set
90 0 cfg-w-spill-area-base cfg [
91 { 0 16 } <gc-map/spills> gc-root-offsets
96 32 cfg-w-spill-area-base cfg [
97 { 8 40 } <gc-map/spills> gc-root-offsets
102 0 cfg-w-spill-area-base cfg [
103 { 0 24 } <gc-map/spills> 1array
104 [ emit-gc-info-bitmap ] B{ } make
108 ! scrub-d scrub-r gc-roots
110 32 cfg-w-spill-area-base cfg [
111 { 0 24 } <gc-map/spills> 1array
112 [ emit-gc-info-bitmap ] B{ } make
123 { { 4 } } largest-spill-slot
124 { { } } largest-spill-slot
125 { { 2 3 } { 0 } } largest-spill-slot
126 { { 0 } } largest-spill-slot
131 T{ gc-map } gc-map-needed?
134 ! emit-gc-info-bitmap
138 { T{ gc-map } } [ emit-gc-info-bitmap ] V{ } make
141 ! ! derived-root-offsets
145 T{ gc-map { derived-roots V{ { 2 4 } } } }
151 3 B{ 255 255 255 255 255 255 255 255 4 0 0 0 }
153 { T{ gc-map { derived-roots V{ { 2 4 } } } } }
154 [ emit-base-tables ] B{ } make
161 { } return-addresses set serialize-gc-maps
165 B{ 123 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 }
167 { 123 } return-addresses set
168 { T{ gc-map } } gc-maps set
172 ! gc-info + ret-addr + 9bits (5+2+2) = 20 + 4 + 2 = 26
176 { gc-roots V{ 1 3 } }
179 { 123 } return-addresses set
180 serialize-gc-maps length
183 ! gc-info + ret-addr + 3 base-pointers + 9bits = 20 + 4 + 12 + 2 = 38
187 { gc-roots V{ 1 3 } }
188 { derived-roots V{ { 2 4 } } }
191 { 123 } return-addresses set
192 serialize-gc-maps length