1 USING: accessors alien assocs compiler.cfg compiler.cfg.comparisons
2 compiler.cfg.def-use compiler.cfg.instructions compiler.cfg.liveness
3 compiler.cfg.registers compiler.cfg.ssa.destruction.leaders
4 compiler.cfg.utilities compiler.test compiler.utilities cpu.architecture
5 cpu.x86.assembler.operands kernel math namespaces sequences system
7 IN: compiler.cfg.liveness.tests
11 { } 0 insns>block compute-edge-live-in
16 { "bl1" H{ { 7 7 } } }
17 { "bl2" H{ { 99 99 } } }
23 { inputs H{ { "bl1" 7 } { "bl2" 99 } } }
31 { "b-31" H{ { 192 192 } { 193 193 } { 194 194 } { 195 195 } } }
32 { "b-23" H{ { 181 181 } { 182 182 } { 183 183 } { 187 187 } } }
33 { "b-26" H{ { 188 188 } { 189 189 } { 190 190 } { 191 191 } } }
39 { inputs H{ { "b-26" 189 } { "b-23" 183 } { "b-31" 193 } } }
43 { inputs H{ { "b-26" 190 } { "b-23" 182 } { "b-31" 194 } } }
47 { inputs H{ { "b-26" 191 } { "b-23" 181 } { "b-31" 195 } } }
51 { inputs H{ { "b-26" 188 } { "b-23" 187 } { "b-31" 192 } } }
53 } 0 insns>block compute-edge-live-in
58 T{ gc-map { gc-roots { 48 } } { derived-roots V{ } } }
60 H{ { 48 tagged-rep } } representations set
62 T{ gc-map } [ fill-gc-map ] keep
66 ! only vregs that are tagged are real gc roots
73 { 123 124 125 } unique gc-roots
78 H{ } clone [ T{ ##replace f 37 D: 0 0 } gen-uses ] keep
83 H{ } dup T{ ##peek f 37 D: 0 0 } kill-defs
87 H{ { 37 99 } { 99 99 } { 2 99 } } leader-map set
88 H{ { 37 37 } { 3 3 } } dup T{ ##peek f 2 D: 0 0 } kill-defs
94 3 iota [ <basic-block> swap >>number ] map <basic-block>
95 [ connect-Nto1-bbs ] keep liveness-step length
100 H{ { 84 84 } } clone base-pointers set 84 lookup-base-pointer
104 { T{ ##tagged>integer f 30 15 } } 0 insns>block block>cfg compute-live-sets
105 30 lookup-base-pointer
110 H{ } base-pointers set
111 H{ { 123 T{ ##peek { dst RCX } { loc D: 1 } { insn# 6 } } } } insns set
112 123 lookup-base-pointer
116 ! lookup-base-pointer*
118 456 T{ ##peek f 123 D: 0 } lookup-base-pointer*
125 H{ } clone dup { T{ ##replace f 37 D: 1 6 } T{ ##peek f 37 D: 0 0 } }
131 H{ { 48 tagged-rep } } representations set
132 48 V{ } clone HS{ } clone [ visit-gc-root ] 2keep
135 ! So the real root is 40?
136 { V{ { 48 40 } } HS{ 40 } } [
137 H{ { 48 40 } } base-pointers set
138 H{ { 48 int-rep } } representations set
139 48 V{ } clone HS{ } clone [ visit-gc-root ] 2keep
144 H{ } clone [ T{ ##peek f 0 D: 0 } visit-insn ] keep
147 { H{ { 48 48 } { 37 37 } } } [
148 H{ { 48 tagged-rep } } representations set
149 H{ { 48 48 } } clone [ T{ ##replace f 37 D: 1 6 } visit-insn ] keep
155 T{ gc-map { gc-roots { 93 } } { derived-roots V{ } } }
159 H{ { 93 tagged-rep } } representations set
160 H{ { 93 93 } } clone T{ ##call-gc f T{ gc-map } }
164 : test-liveness ( -- )
165 1 get block>cfg compute-live-sets ;
171 T{ ##replace f 0 D: 0 }
172 T{ ##replace f 1 D: 1 }
178 T{ ##replace f 2 D: 0 }
183 T{ ##replace f 3 D: 0 }
189 { } [ test-liveness ] unit-test
201 ! Tricky case; defs must be killed before uses
209 T{ ##add-imm f 0 0 10 }
215 { } [ test-liveness ] unit-test
217 { H{ { 0 0 } } } [ 2 get live-in ] unit-test
226 T{ ##inc { loc R: 2 } }
227 T{ ##inc { loc D: -2 } }
228 T{ ##peek f 21 D: -1 }
229 T{ ##peek f 22 D: -2 }
230 T{ ##replace f 21 R: 0 }
231 T{ ##replace f 22 R: 1 }
241 T{ ##inc { loc R: -1 } }
242 T{ ##inc { loc D: 1 } }
243 T{ ##peek f 25 R: -1 }
244 T{ ##replace f 25 D: 0 }
256 T{ ##peek f 27 R: -1 }
257 T{ ##peek f 28 D: 2 }
258 T{ ##peek f 29 D: 3 }
259 T{ ##load-integer f 30 1 }
260 T{ ##load-integer f 31 0 }
261 T{ ##compare-imm-branch f 27 f cc/= }
275 T{ ##phi f 36 H{ { 6 30 } { 7 31 } } }
277 T{ ##unbox f 37 29 "alien_offset" int-rep }
278 T{ ##unbox f 38 28 "to_double" double-rep }
279 T{ ##unbox f 39 36 "to_cell" int-rep }
280 T{ ##alien-invoke f 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 } }
281 T{ ##box f 41 40 "from_signed_cell" int-rep T{ gc-map } }
282 T{ ##replace f 41 D: 0 }
301 { } [ test-liveness ] unit-test
303 { H{ { 28 28 } { 29 29 } { 30 30 } { 31 31 } } } [ 5 get live-out ] unit-test
304 { H{ { 28 28 } { 29 29 } { 30 30 } } } [ 6 get live-in ] unit-test
305 { H{ { 28 28 } { 29 29 } { 31 31 } } } [ 7 get live-in ] unit-test
306 { H{ { 30 30 } } } [ 6 get 8 get edge-live-in ] unit-test
318 T{ ##load-integer f 0 0 }
323 T{ ##load-integer f 1 1 }
328 T{ ##phi f 2 H{ { 2 0 } { 3 1 } } }
337 T{ ##replace f 2 D: 0 }
354 { } [ 0 get block>cfg dup cfg set compute-live-sets ] unit-test
356 { t } [ 0 get live-in assoc-empty? ] unit-test
358 { H{ { 2 2 } } } [ 4 get live-out ] unit-test
360 { H{ { 0 0 } } } [ 2 get 4 get edge-live-in ] unit-test
362 { H{ { 1 1 } } } [ 3 get 4 get edge-live-in ] unit-test
372 T{ ##tagged>integer f 1 0 }
373 T{ ##call-gc f T{ gc-map } }
374 T{ ##replace f 0 D: 0 }
375 T{ ##call-gc f T{ gc-map } }
376 T{ ##replace f 1 D: 0 }
391 } representations set
393 { } [ 0 get block>cfg dup cfg set compute-live-sets ] unit-test
395 { V{ { 1 0 } } } [ 1 get instructions>> 2 swap nth gc-map>> derived-roots>> ] unit-test
397 { { 0 } } [ 1 get instructions>> 2 swap nth gc-map>> gc-roots>> ] unit-test
399 { V{ { 1 0 } } } [ 1 get instructions>> 4 swap nth gc-map>> derived-roots>> ] unit-test
401 { { 0 } } [ 1 get instructions>> 4 swap nth gc-map>> gc-roots>> ] unit-test