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 46 bytes -- 14 bytes padding needed to
56 uint-array{ -1 -1 4 } underlying>> %
59 uint-array{ 100 } underlying>> %
61 ! GC info footer - 28 bytes
68 { derived-root-count 3 }
69 { return-address-count 1 }
74 [ t ] [ "result" get length "expect" get length = ] unit-test
75 [ t ] [ "result" get "expect" get = ] unit-test
77 ! Fix the gc root offset calculations
78 SINGLETON: linux-x86.64
79 M: linux-x86.64 reserved-stack-space 0 ;
80 M: linux-x86.64 gc-root-offset
81 n>> spill-offset cell + cell /i ;
84 linux-x86.64 \ cpu set
88 T{ stack-frame { spill-area-base 0 } } stack-frame [
91 T{ spill-slot { n 0 } }
92 T{ spill-slot { n 16 } }
99 T{ stack-frame { spill-area-base 32 } } stack-frame [
102 T{ spill-slot { n 8 } }
103 T{ spill-slot { n 40 } }
109 ! scrub-d scrub-r check-d check-r gc-roots
111 T{ stack-frame { spill-area-base 0 } } stack-frame [
114 T{ spill-slot { n 0 } }
115 T{ spill-slot { n 24 } }
118 [ emit-gc-info-bitmaps ] B{ } make drop
122 ! scrub-d scrub-r check-d check-r gc-roots
124 T{ stack-frame { spill-area-base 32 } } stack-frame [
127 T{ spill-slot { n 0 } }
128 T{ spill-slot { n 24 } }
131 [ emit-gc-info-bitmaps ] B{ } make drop
140 T{ gc-map { scrub-d { 0 1 1 1 0 } } { scrub-r { 1 0 } } } gc-map-needed?
141 T{ gc-map { check-d { 0 1 1 1 } } } gc-map-needed?
145 { 3 V{ t t t f f f } } [
146 [ { { 0 0 0 } { 1 1 1 } } emit-scrub ] V{ } make
149 ! emit-gc-info-bitmaps
154 { T{ gc-map { scrub-d { 0 1 1 1 } } { scrub-r { 1 1 } } } } gc-maps set
155 [ emit-gc-info-bitmaps ] V{ } make
162 { T{ gc-map { scrub-d { 0 } } { check-d { 0 } } } } gc-maps set
163 [ emit-gc-info-bitmaps ] V{ } make
166 ! derived-root-offsets
167 USING: present prettyprint ;
171 T{ gc-map { derived-roots V{ { 2 4 } } } }
177 3 B{ 255 255 255 255 255 255 255 255 4 0 0 0 }
179 { T{ gc-map { derived-roots V{ { 2 4 } } } } } gc-maps set
180 [ emit-base-tables ] B{ } make
188 { } return-addresses set serialize-gc-maps
193 17 123 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
197 { 123 } return-addresses set
198 { T{ gc-map { scrub-d { 0 1 1 1 0 } } } } gc-maps set
202 ! gc-info + ret-addr + 9bits (5+2+2) = 28 + 4 + 2 = 34
206 { scrub-d { 0 1 1 1 0 } }
208 { gc-roots V{ 1 3 } }
211 { 123 } return-addresses set
212 serialize-gc-maps length
215 ! gc-info + ret-addr + 3 base-pointers + 9bits = 28 + 4 + 12 + 2 = 46
219 { scrub-d { 0 1 1 1 0 } }
221 { gc-roots V{ 1 3 } }
222 { derived-roots V{ { 2 4 } } }
225 { 123 } return-addresses set
226 serialize-gc-maps length