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
140 { { 4 } } largest-spill-slot
141 { { } } largest-spill-slot
142 { { 2 3 } { 0 } } largest-spill-slot
143 { { 0 } } largest-spill-slot
148 T{ gc-map { scrub-d { 0 1 1 1 0 } } { scrub-r { 1 0 } } } gc-map-needed?
149 T{ gc-map { scrub-d { 0 1 1 1 } } } gc-map-needed?
153 { 3 V{ t t t f f f } } [
154 [ { { 0 0 0 } { 1 1 1 } } emit-scrub ] V{ } make
157 ! emit-gc-info-bitmaps
162 { T{ gc-map { scrub-d { 0 1 1 1 } } { scrub-r { 1 1 } } } }
163 [ emit-gc-info-bitmaps ] V{ } make
170 { T{ gc-map { scrub-d { 0 } } } }
171 [ emit-gc-info-bitmaps ] V{ } make
174 ! derived-root-offsets
175 USING: present prettyprint ;
179 T{ gc-map { derived-roots V{ { 2 4 } } } }
185 3 B{ 255 255 255 255 255 255 255 255 4 0 0 0 }
187 { T{ gc-map { derived-roots V{ { 2 4 } } } } }
188 [ emit-base-tables ] B{ } make
195 { } return-addresses set serialize-gc-maps
199 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 }
201 { 123 } return-addresses set
202 { T{ gc-map { scrub-d { 0 1 1 1 0 } } } } gc-maps set
206 ! gc-info + ret-addr + 9bits (5+2+2) = 20 + 4 + 2 = 26
210 { scrub-d { 0 1 1 1 0 } }
212 { gc-roots V{ 1 3 } }
215 { 123 } return-addresses set
216 serialize-gc-maps length
219 ! gc-info + ret-addr + 3 base-pointers + 9bits = 20 + 4 + 12 + 2 = 38
223 { scrub-d { 0 1 1 1 0 } }
225 { gc-roots V{ 1 3 } }
226 { derived-roots V{ { 2 4 } } }
229 { 123 } return-addresses set
230 serialize-gc-maps length