]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/stacks/uninitialized/uninitialized-tests.factor
Merge commit 'origin/master' into emacs
[factor.git] / basis / compiler / cfg / stacks / uninitialized / uninitialized-tests.factor
1 IN: compiler.cfg.stacks.uninitialized.tests
2 USING: compiler.cfg.stacks.uninitialized compiler.cfg.debugger
3 compiler.cfg.registers compiler.cfg.instructions compiler.cfg
4 compiler.cfg.predecessors cpu.architecture tools.test kernel vectors
5 namespaces accessors sequences ;
6
7 : test-uninitialized ( -- )
8     cfg new 0 get >>entry
9     compute-predecessors
10     compute-uninitialized-sets ;
11
12 V{
13     T{ ##inc-d f 3 }
14 } 0 test-bb
15
16 V{
17     T{ ##replace f V int-regs 0 D 0 }
18     T{ ##replace f V int-regs 0 D 1 }
19     T{ ##replace f V int-regs 0 D 2 }
20     T{ ##inc-r f 1 }
21 } 1 test-bb
22
23 V{
24     T{ ##peek f V int-regs 0 D 0 }
25     T{ ##inc-d f 1 }
26 } 2 test-bb
27
28 0 get 1 get 1vector >>successors drop
29 1 get 2 get 1vector >>successors drop
30
31 [ ] [ test-uninitialized ] unit-test
32
33 [ V{ D 0 D 1 D 2 } ] [ 1 get uninitialized-locs ] unit-test
34 [ V{ R 0 } ] [ 2 get uninitialized-locs ] unit-test
35
36 ! When merging, if a location is uninitialized in one branch and
37 ! initialized in another, we have to consider it uninitialized,
38 ! since it cannot be safely read from by a ##peek, or traced by GC.
39
40 V{ } 0 test-bb
41
42 V{
43     T{ ##inc-d f 1 }
44 } 1 test-bb
45
46 V{
47     T{ ##call f namestack }
48     T{ ##branch }
49 } 2 test-bb
50
51 V{
52     T{ ##return }
53 } 3 test-bb
54
55 0 get 1 get 2 get V{ } 2sequence >>successors drop
56 1 get 3 get 1vector >>successors drop
57 2 get 3 get 1vector >>successors drop
58
59 [ ] [ test-uninitialized ] unit-test
60
61 [ V{ D 0 } ] [ 3 get uninitialized-locs ] unit-test