1 USING: arrays compiler.cfg.gc-checks
2 compiler.cfg.gc-checks.private compiler.cfg.debugger
3 compiler.cfg.registers compiler.cfg.instructions compiler.cfg
4 compiler.cfg.predecessors compiler.cfg.rpo cpu.architecture
5 tools.test kernel vectors namespaces accessors sequences alien
6 memory classes make combinators.short-circuit byte-arrays ;
7 IN: compiler.cfg.gc-checks.tests
9 : test-gc-checks ( -- )
10 H{ } clone representations set
11 cfg new 0 get >>entry cfg set ;
15 T{ ##replace f 0 D 1 }
19 T{ ##box-alien f 0 1 }
24 [ ] [ test-gc-checks ] unit-test
26 [ t ] [ cfg get blocks-with-gc 1 get 1array sequence= ] unit-test
28 [ ] [ 1 get allocation-size 123 <alien> size assert= ] unit-test
30 2 \ vreg-counter set-global
32 : gc-check? ( bb -- ? )
36 [ first ##check-nursery-branch? ]
39 [ t ] [ V{ } 100 <gc-check> gc-check? ] unit-test
41 4 \ vreg-counter set-global
45 T{ ##gc-map f V{ 0 } V{ 3 } { 0 1 2 } }
51 V{ D 0 R 3 } { 0 1 2 } <gc-call> instructions>>
54 30 \ vreg-counter set-global
81 [ ] [ test-gc-checks ] unit-test
83 [ ] [ cfg get needs-predecessors drop ] unit-test
85 [ ] [ { D 1 R 2 } { 10 20 } V{ } 31337 3 get (insert-gc-check) ] unit-test
87 [ t ] [ 1 get successors>> first gc-check? ] unit-test
89 [ t ] [ 2 get successors>> first gc-check? ] unit-test
91 [ t ] [ 3 get predecessors>> first gc-check? ] unit-test
93 30 \ vreg-counter set-global
107 T{ ##allot f 1 64 byte-array }
116 T{ ##replace f 2 D 1 }
131 [ ] [ test-gc-checks ] unit-test
135 } representations set
137 [ ] [ cfg get insert-gc-checks drop ] unit-test
139 [ 2 ] [ 2 get predecessors>> length ] unit-test
141 [ t ] [ 1 get successors>> first gc-check? ] unit-test
143 [ 64 ] [ 1 get successors>> first instructions>> first size>> ] unit-test
145 [ t ] [ 2 get predecessors>> first gc-check? ] unit-test
149 T{ ##gc-map f V{ 0 1 2 } V{ } { 2 } }
153 ] [ 2 get predecessors>> second instructions>> ] unit-test
155 ! Don't forget to invalidate RPO after inserting basic blocks!
156 [ 8 ] [ cfg get reverse-post-order length ] unit-test
158 ! Do the right thing with ##phi instructions
164 T{ ##load-reference f 1 "hi" }
169 T{ ##load-reference f 2 "bye" }
174 T{ ##phi f 3 H{ { 1 1 } { 2 2 } } }
175 T{ ##allot f 1 64 byte-array }
183 [ ] [ test-gc-checks ] unit-test
189 } representations set
191 [ ] [ cfg get insert-gc-checks drop ] unit-test
192 [ t ] [ 2 get successors>> first instructions>> first ##phi? ] unit-test
193 [ 2 ] [ 3 get instructions>> length ] unit-test