1 USING: accessors alien.c-types arrays bit-arrays classes.struct compiler.cfg
2 compiler.cfg.instructions compiler.cfg.stack-frame compiler.cfg.utilities
3 compiler.codegen.gc-maps compiler.codegen.relocation cpu.architecture
4 cpu.x86 byte-arrays make namespaces kernel layouts math sequences
5 specialized-arrays system tools.test ;
7 SPECIALIZED-ARRAY: uint
8 IN: compiler.codegen.gc-maps.tests
14 M: fake-cpu gc-root-offset ;
27 { scrub-d { 0 1 1 1 0 } }
30 { derived-roots V{ { 2 4 } } }
36 { 0 } [ "result" get length 16 mod ] unit-test
41 ! The below data is 38 bytes -- 6 bytes padding needed to
56 uint-array{ -1 -1 4 } underlying>> %
59 uint-array{ 100 } underlying>> %
61 ! GC info footer - 20 bytes
66 { derived-root-count 3 }
67 { return-address-count 1 }
72 { t } [ "result" get length "expect" get length = ] unit-test
73 { t } [ "result" get "expect" get = ] unit-test
75 ! Fix the gc root offset calculations
76 SINGLETON: linux-x86.64
77 M: linux-x86.64 reserved-stack-space 0 ;
78 M: linux-x86.64 gc-root-offset
79 n>> spill-offset cell + cell /i ;
81 : cfg-w-spill-area-base ( base -- cfg )
82 stack-frame new swap >>spill-area-base
83 { } insns>cfg swap >>stack-frame ;
86 linux-x86.64 \ cpu set
90 0 cfg-w-spill-area-base cfg [
93 T{ spill-slot { n 0 } }
94 T{ spill-slot { n 16 } }
101 32 cfg-w-spill-area-base cfg [
104 T{ spill-slot { n 8 } }
105 T{ spill-slot { n 40 } }
111 ! scrub-d scrub-r gc-roots
113 0 cfg-w-spill-area-base cfg [
116 T{ spill-slot { n 0 } }
117 T{ spill-slot { n 24 } }
120 [ emit-gc-info-bitmaps ] B{ } make drop
124 ! scrub-d scrub-r gc-roots
126 32 cfg-w-spill-area-base cfg [
129 T{ spill-slot { n 0 } }
130 T{ spill-slot { n 24 } }
133 [ emit-gc-info-bitmaps ] B{ } make drop
144 { { 4 } } largest-spill-slot
145 { { } } largest-spill-slot
146 { { 2 3 } { 0 } } largest-spill-slot
147 { { 0 } } largest-spill-slot
152 T{ gc-map { scrub-d { 0 1 1 1 0 } } { scrub-r { 1 0 } } } gc-map-needed?
153 T{ gc-map { scrub-d { 0 1 1 1 } } } gc-map-needed?
157 { 3 V{ t t t f f f } } [
158 [ { { 0 0 0 } { 1 1 1 } } emit-scrub ] V{ } make
161 ! emit-gc-info-bitmaps
166 { T{ gc-map { scrub-d { 0 1 1 1 } } { scrub-r { 1 1 } } } }
167 [ emit-gc-info-bitmaps ] V{ } make
174 { T{ gc-map { scrub-d { 0 } } } }
175 [ emit-gc-info-bitmaps ] V{ } make
178 ! derived-root-offsets
179 USING: present prettyprint ;
183 T{ gc-map { derived-roots V{ { 2 4 } } } }
189 3 B{ 255 255 255 255 255 255 255 255 4 0 0 0 }
191 { T{ gc-map { derived-roots V{ { 2 4 } } } } }
192 [ emit-base-tables ] B{ } make
199 { } return-addresses set serialize-gc-maps
203 B{ 17 123 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 }
205 { 123 } return-addresses set
206 { T{ gc-map { scrub-d { 0 1 1 1 0 } } } } gc-maps set
210 ! gc-info + ret-addr + 9bits (5+2+2) = 20 + 4 + 2 = 26
214 { scrub-d { 0 1 1 1 0 } }
216 { gc-roots V{ 1 3 } }
219 { 123 } return-addresses set
220 serialize-gc-maps length
223 ! gc-info + ret-addr + 3 base-pointers + 9bits = 20 + 4 + 12 + 2 = 38
227 { scrub-d { 0 1 1 1 0 } }
229 { gc-roots V{ 1 3 } }
230 { derived-roots V{ { 2 4 } } }
233 { 123 } return-addresses set
234 serialize-gc-maps length