1 USING: accessors alien.c-types arrays bit-arrays classes.struct
2 compiler.cfg.instructions compiler.cfg.stack-frame
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 ;
82 linux-x86.64 \ cpu set
86 T{ stack-frame { spill-area-base 0 } } stack-frame [
89 T{ spill-slot { n 0 } }
90 T{ spill-slot { n 16 } }
97 T{ stack-frame { spill-area-base 32 } } stack-frame [
100 T{ spill-slot { n 8 } }
101 T{ spill-slot { n 40 } }
107 ! scrub-d scrub-r gc-roots
109 T{ stack-frame { spill-area-base 0 } } stack-frame [
112 T{ spill-slot { n 0 } }
113 T{ spill-slot { n 24 } }
116 [ emit-gc-info-bitmaps ] B{ } make drop
120 ! scrub-d scrub-r gc-roots
122 T{ stack-frame { spill-area-base 32 } } stack-frame [
125 T{ spill-slot { n 0 } }
126 T{ spill-slot { n 24 } }
129 [ emit-gc-info-bitmaps ] B{ } make drop
138 T{ gc-map { scrub-d { 0 1 1 1 0 } } { scrub-r { 1 0 } } } gc-map-needed?
139 T{ gc-map { scrub-d { 0 1 1 1 } } } gc-map-needed?
143 { 3 V{ t t t f f f } } [
144 [ { { 0 0 0 } { 1 1 1 } } emit-scrub ] V{ } make
147 ! emit-gc-info-bitmaps
152 { T{ gc-map { scrub-d { 0 1 1 1 } } { scrub-r { 1 1 } } } } gc-maps set
153 [ emit-gc-info-bitmaps ] V{ } make
160 { T{ gc-map { scrub-d { 0 } } } } gc-maps set
161 [ emit-gc-info-bitmaps ] V{ } make
164 ! derived-root-offsets
165 USING: present prettyprint ;
169 T{ gc-map { derived-roots V{ { 2 4 } } } }
175 3 B{ 255 255 255 255 255 255 255 255 4 0 0 0 }
177 { T{ gc-map { derived-roots V{ { 2 4 } } } } } gc-maps set
178 [ emit-base-tables ] B{ } make
185 { } return-addresses set serialize-gc-maps
189 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 }
191 { 123 } return-addresses set
192 { T{ gc-map { scrub-d { 0 1 1 1 0 } } } } gc-maps set
196 ! gc-info + ret-addr + 9bits (5+2+2) = 20 + 4 + 2 = 26
200 { scrub-d { 0 1 1 1 0 } }
202 { gc-roots V{ 1 3 } }
205 { 123 } return-addresses set
206 serialize-gc-maps length
209 ! gc-info + ret-addr + 3 base-pointers + 9bits = 20 + 4 + 12 + 2 = 38
213 { scrub-d { 0 1 1 1 0 } }
215 { gc-roots V{ 1 3 } }
216 { derived-roots V{ { 2 4 } } }
219 { 123 } return-addresses set
220 serialize-gc-maps length