1 USING: accessors compiler.cfg.liveness
2 compiler.cfg compiler.cfg.debugger compiler.cfg.instructions
3 compiler.cfg.predecessors compiler.cfg.registers
4 compiler.cfg.ssa.destruction.leaders compiler.cfg.utilities cpu.architecture
5 dlists namespaces sequences kernel tools.test vectors alien math
6 compiler.cfg.comparisons cpu.x86.assembler.operands assocs ;
7 IN: compiler.cfg.liveness.tests
10 ! compute-edge-live-in
12 { } 0 insns>block compute-edge-live-in
17 { "bl1" H{ { 7 7 } } }
18 { "bl2" H{ { 99 99 } } }
24 { inputs H{ { "bl1" 7 } { "bl2" 99 } } }
32 { "b-31" H{ { 192 192 } { 193 193 } { 194 194 } { 195 195 } } }
33 { "b-23" H{ { 181 181 } { 182 182 } { 183 183 } { 187 187 } } }
34 { "b-26" H{ { 188 188 } { 189 189 } { 190 190 } { 191 191 } } }
40 { inputs H{ { "b-26" 189 } { "b-23" 183 } { "b-31" 193 } } }
44 { inputs H{ { "b-26" 190 } { "b-23" 182 } { "b-31" 194 } } }
48 { inputs H{ { "b-26" 191 } { "b-23" 181 } { "b-31" 195 } } }
52 { inputs H{ { "b-26" 188 } { "b-23" 187 } { "b-31" 192 } } }
54 } 0 insns>block compute-edge-live-in
59 T{ gc-map { gc-roots { 48 } } { derived-roots V{ } } }
61 H{ { 48 tagged-rep } } representations set
63 T{ gc-map } [ fill-gc-map ] keep
67 ! only vregs that are tagged are real gc roots
74 { 123 124 125 } sets:unique gc-roots
79 H{ } dup T{ ##peek f 37 D 0 0 } kill-defs
83 H{ { 37 99 } { 99 99 } { 2 99 } } leader-map set
84 H{ { 37 37 } { 3 3 } } dup T{ ##peek f 2 D 0 0 } kill-defs
90 3 iota [ <basic-block> swap >>number ] map <basic-block>
91 [ connect-Nto1-bbs ] keep liveness-step length
96 H{ { 84 84 } } clone base-pointers set 84 lookup-base-pointer
100 { T{ ##tagged>integer f 30 15 } } 0 insns>block block>cfg compute-live-sets
101 30 lookup-base-pointer
104 ! lookup-base-pointer*
106 456 T{ ##peek f 123 D 0 } lookup-base-pointer*
113 H{ } clone dup { T{ ##replace f 37 D 1 6 } T{ ##peek f 37 D 0 0 } }
119 H{ { 48 tagged-rep } } representations set
120 48 V{ } clone HS{ } clone [ visit-gc-root ] 2keep
123 ! So the real root is 40?
124 { V{ { 48 40 } } HS{ 40 } } [
125 H{ { 48 40 } } base-pointers set
126 H{ { 48 int-rep } } representations set
127 48 V{ } clone HS{ } clone [ visit-gc-root ] 2keep
132 H{ } clone [ T{ ##peek f 0 D 0 } visit-insn ] keep
135 { H{ { 48 48 } { 37 37 } } } [
136 H{ { 48 tagged-rep } } representations set
137 H{ { 48 48 } } clone [ T{ ##replace f 37 D 1 6 } visit-insn ] keep
143 T{ gc-map { gc-roots { 93 } } { derived-roots V{ } } }
147 H{ { 93 tagged-rep } } representations set
148 H{ { 93 93 } } clone T{ ##call-gc f T{ gc-map } }
152 : test-liveness ( -- )
153 1 get block>cfg compute-live-sets ;
159 T{ ##replace f 0 D 0 }
160 T{ ##replace f 1 D 1 }
166 T{ ##replace f 2 D 0 }
171 T{ ##replace f 3 D 0 }
177 { } [ test-liveness ] unit-test
189 ! Tricky case; defs must be killed before uses
197 T{ ##add-imm f 0 0 10 }
203 { } [ test-liveness ] unit-test
205 { H{ { 0 0 } } } [ 2 get live-in ] unit-test
214 T{ ##inc { loc R 2 } }
215 T{ ##inc { loc D -2 } }
216 T{ ##peek f 21 D -1 }
217 T{ ##peek f 22 D -2 }
218 T{ ##replace f 21 R 0 }
219 T{ ##replace f 22 R 1 }
229 T{ ##inc { loc R -1 } }
230 T{ ##inc { loc D 1 } }
231 T{ ##peek f 25 R -1 }
232 T{ ##replace f 25 D 0 }
244 T{ ##peek f 27 R -1 }
247 T{ ##load-integer f 30 1 }
248 T{ ##load-integer f 31 0 }
249 T{ ##compare-imm-branch f 27 f cc/= }
263 T{ ##phi f 36 H{ { 6 30 } { 7 31 } } }
265 T{ ##unbox f 37 29 "alien_offset" int-rep }
266 T{ ##unbox f 38 28 "to_double" double-rep }
267 T{ ##unbox f 39 36 "to_cell" int-rep }
268 T{ ##alien-invoke f V{ } V{ { 37 int-rep 0 } { 38 double-rep 4 } { 39 int-rep 12 } } { { 40 int-rep EAX } } { } 0 16 "CFRunLoopRunInMode" f T{ gc-map } }
269 T{ ##box f 41 40 "from_signed_cell" int-rep T{ gc-map } }
270 T{ ##replace f 41 D 0 }
289 { } [ test-liveness ] unit-test
291 { H{ { 28 28 } { 29 29 } { 30 30 } { 31 31 } } } [ 5 get live-out ] unit-test
292 { H{ { 28 28 } { 29 29 } { 30 30 } } } [ 6 get live-in ] unit-test
293 { H{ { 28 28 } { 29 29 } { 31 31 } } } [ 7 get live-in ] unit-test
294 { H{ { 30 30 } } } [ 6 get 8 get edge-live-in ] unit-test
306 T{ ##load-integer f 0 0 }
311 T{ ##load-integer f 1 1 }
316 T{ ##phi f 2 H{ { 2 0 } { 3 1 } } }
325 T{ ##replace f 2 D 0 }
342 { } [ 0 get block>cfg dup cfg set compute-live-sets ] unit-test
344 { t } [ 0 get live-in assoc-empty? ] unit-test
346 { H{ { 2 2 } } } [ 4 get live-out ] unit-test
348 { H{ { 0 0 } } } [ 2 get 4 get edge-live-in ] unit-test
350 { H{ { 1 1 } } } [ 3 get 4 get edge-live-in ] unit-test
360 T{ ##tagged>integer f 1 0 }
361 T{ ##call-gc f T{ gc-map } }
362 T{ ##replace f 0 D 0 }
363 T{ ##call-gc f T{ gc-map } }
364 T{ ##replace f 1 D 0 }
379 } representations set
381 { } [ 0 get block>cfg dup cfg set compute-live-sets ] unit-test
383 { V{ { 1 0 } } } [ 1 get instructions>> 2 swap nth gc-map>> derived-roots>> ] unit-test
385 { { 0 } } [ 1 get instructions>> 2 swap nth gc-map>> gc-roots>> ] unit-test
387 { V{ { 1 0 } } } [ 1 get instructions>> 4 swap nth gc-map>> derived-roots>> ] unit-test
389 { { 0 } } [ 1 get instructions>> 4 swap nth gc-map>> gc-roots>> ] unit-test