diff --git a/basis/compiler/cfg/builder/builder-tests.factor b/basis/compiler/cfg/builder/builder-tests.factor index db3e25e661..8e3ddba7b4 100644 --- a/basis/compiler/cfg/builder/builder-tests.factor +++ b/basis/compiler/cfg/builder/builder-tests.factor @@ -248,9 +248,8 @@ IN: compiler.cfg.builder.tests { { T{ ##load-integer { dst 78 } { val 0 } } } } [ - initial-height-state height-state set + test-init 77 vreg-counter set-global - H{ } clone replace-mapping set [ T{ #push { literal 0 } { out-d { 8537399 } } } emit-node ] { } make @@ -260,9 +259,7 @@ IN: compiler.cfg.builder.tests { { 1 1 } { 0 0 } } H{ { D -1 4 } { D 0 4 } } } [ - 0 vreg-counter set-global - initial-height-state height-state set - H{ } clone replace-mapping set + test-init 4 D 0 replace-loc T{ #shuffle { mapping { { 2 4 } { 3 4 } } } diff --git a/basis/compiler/cfg/debugger/debugger.factor b/basis/compiler/cfg/debugger/debugger.factor index 8e0ad95bb9..d21eccc6da 100644 --- a/basis/compiler/cfg/debugger/debugger.factor +++ b/basis/compiler/cfg/debugger/debugger.factor @@ -18,12 +18,10 @@ IN: compiler.cfg.debugger GENERIC: test-builder ( quot -- cfgs ) M: callable test-builder - 0 vreg-counter set-global - build-tree optimize-tree gensym build-cfg ; + reset-vreg-counter build-tree optimize-tree gensym build-cfg ; M: word test-builder - 0 vreg-counter set-global - [ build-tree optimize-tree ] keep build-cfg ; + [ reset-vreg-counter build-tree optimize-tree ] keep build-cfg ; : test-ssa ( quot -- cfgs ) test-builder [ diff --git a/basis/compiler/cfg/gc-checks/gc-checks-tests.factor b/basis/compiler/cfg/gc-checks/gc-checks-tests.factor index 6fc749cde3..6adf0db2c5 100644 --- a/basis/compiler/cfg/gc-checks/gc-checks-tests.factor +++ b/basis/compiler/cfg/gc-checks/gc-checks-tests.factor @@ -103,8 +103,6 @@ V{ [ ] [ 1 get instructions>> allocation-size 123 size assert= ] unit-test -2 vreg-counter set-global - : gc-check? ( bb -- ? ) instructions>> { @@ -119,11 +117,9 @@ V{ T{ ##branch } } = ; -4 vreg-counter set-global - [ t ] [ gc-call? ] unit-test -30 vreg-counter set-global +reset-vreg-counter V{ T{ ##prologue } diff --git a/basis/compiler/cfg/registers/registers.factor b/basis/compiler/cfg/registers/registers.factor index ee7256a6f2..c6b630b79e 100644 --- a/basis/compiler/cfg/registers/registers.factor +++ b/basis/compiler/cfg/registers/registers.factor @@ -8,6 +8,9 @@ SYMBOL: vreg-counter : next-vreg ( -- vreg ) vreg-counter counter ; +: reset-vreg-counter ( -- ) + 0 vreg-counter set-global ; + SYMBOL: representations ERROR: bad-vreg vreg ; diff --git a/basis/compiler/cfg/ssa/construction/construction-tests.factor b/basis/compiler/cfg/ssa/construction/construction-tests.factor index 74f083f768..975ded80d2 100644 --- a/basis/compiler/cfg/ssa/construction/construction-tests.factor +++ b/basis/compiler/cfg/ssa/construction/construction-tests.factor @@ -8,8 +8,7 @@ IN: compiler.cfg.ssa.construction.tests : reset-counters ( -- ) ! Reset counters so that results are deterministic w.r.t. hash order - 0 vreg-counter set-global - 0 basic-block set-global ; + reset-vreg-counter 0 basic-block set-global ; : test-ssa ( -- ) 0 get block>cfg diff --git a/basis/compiler/cfg/stacks/local/local-tests.factor b/basis/compiler/cfg/stacks/local/local-tests.factor index 11740a97ce..8a3f2091a2 100644 --- a/basis/compiler/cfg/stacks/local/local-tests.factor +++ b/basis/compiler/cfg/stacks/local/local-tests.factor @@ -24,8 +24,8 @@ IN: compiler.cfg.stacks.local.tests { { 0 4 } { 0 -2 } } height-state>insns ] unit-test -{ 30 } [ - 29 vreg-counter set-global locs>vregs set D 0 loc>vreg +{ 1 } [ + test-init D 0 loc>vreg ] unit-test { @@ -34,8 +34,7 @@ IN: compiler.cfg.stacks.local.tests T{ ##copy { dst 2 } { src 26 } { rep any-rep } } } } [ - 0 vreg-counter set-global locs>vregs set - { { D 0 25 } { R 0 26 } } stack-changes + test-init { { D 0 25 } { R 0 26 } } stack-changes ] unit-test { 80 } [ @@ -52,8 +51,7 @@ IN: compiler.cfg.stacks.local.tests { 0 } [ V{ } 0 insns>block basic-block set - begin-stack-analysis begin-local-analysis - compute-local-kill-set assoc-size + test-init compute-local-kill-set assoc-size ] unit-test { H{ { R -4 R -4 } } } [ diff --git a/basis/compiler/cfg/stacks/stacks-tests.factor b/basis/compiler/cfg/stacks/stacks-tests.factor index 9ad2c0bd28..baa441ecf6 100644 --- a/basis/compiler/cfg/stacks/stacks-tests.factor +++ b/basis/compiler/cfg/stacks/stacks-tests.factor @@ -4,11 +4,8 @@ tools.test ; IN: compiler.cfg.stacks.tests : test-init ( -- ) - 0 vreg-counter set-global - initial-height-state height-state set - H{ } clone replace-mapping set - H{ } clone locs>vregs set - H{ } clone local-peek-set set ; + reset-vreg-counter begin-stack-analysis begin-local-analysis + H{ } clone replace-mapping set ; { H{ { D 1 4 } { D 2 3 } { D 0 5 } } diff --git a/basis/compiler/tests/codegen.factor b/basis/compiler/tests/codegen.factor index c21ccff5c2..2fd590e778 100644 --- a/basis/compiler/tests/codegen.factor +++ b/basis/compiler/tests/codegen.factor @@ -131,9 +131,9 @@ unit-test ! Regression : hellish-bug-1 ( a b -- ) 2drop ; -: hellish-bug-2 ( i array x -- x ) - 2dup 1 slot eq? [ 2drop ] [ - 2dup array-nth tombstone? [ +: hellish-bug-2 ( i array x -- x ) + 2dup 1 slot eq? [ 2drop ] [ + 2dup array-nth tombstone? [ [ [ array-nth ] 2keep [ 1 fixnum+fast ] dip array-nth pick 2dup hellish-bug-1 3drop @@ -141,7 +141,7 @@ unit-test ] unless [ 2 fixnum+fast ] dip hellish-bug-2 ] if ; inline recursive -: hellish-bug-3 ( hash array -- ) +: hellish-bug-3 ( hash array -- ) 0 swap hellish-bug-2 drop ; [ ] [ @@ -383,7 +383,7 @@ cell 4 = [ [ 2 3 1 ] [ 2 3 V{ } coalescing-bug-4 ] unit-test [ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test [ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test - + ! Global stack analysis dataflow equations are wrong : some-word ( a -- b ) 2 + ; : global-dcn-bug-1 ( a b -- c d ) @@ -532,7 +532,7 @@ TUPLE: myseq { underlying1 byte-array read-only } { underlying2 byte-array read- ! Stupid repro USE: compiler.cfg.registers -0 vreg-counter set-global +reset-vreg-counter { fib-count2 } compile