]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.*: new word reset-vreg-counter, useful for making test writing more...
authorBjörn Lindqvist <bjourne@gmail.com>
Thu, 26 Mar 2015 14:19:00 +0000 (14:19 +0000)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Apr 2015 16:31:55 +0000 (09:31 -0700)
basis/compiler/cfg/builder/builder-tests.factor
basis/compiler/cfg/debugger/debugger.factor
basis/compiler/cfg/gc-checks/gc-checks-tests.factor
basis/compiler/cfg/registers/registers.factor
basis/compiler/cfg/ssa/construction/construction-tests.factor
basis/compiler/cfg/stacks/local/local-tests.factor
basis/compiler/cfg/stacks/stacks-tests.factor
basis/compiler/tests/codegen.factor

index db3e25e661a8b456b979ec9eea1c680364b12c6b..8e3ddba7b4c7be9c532d594d85dba8a2ce8d32fc 100644 (file)
@@ -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 } } }
index 8e0ad95bb9d00fde2a371fd9df618e12017e0173..d21eccc6da0536424c6e9dd0e30f05673a4fed6d 100644 (file)
@@ -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 [
index 6fc749cde3d7d62a7944cd1a6fc81b430685b194..6adf0db2c5df9fded0f755e2dbe1c705909d194d 100644 (file)
@@ -103,8 +103,6 @@ V{
 
 [ ] [ 1 get instructions>> allocation-size 123 <alien> 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> gc-call? ] unit-test
 
-30 vreg-counter set-global
+reset-vreg-counter
 
 V{
     T{ ##prologue }
index ee7256a6f256081f8bf621636d4f69276a508a03..c6b630b79ed8132941fb1f575fc48036bd944cd9 100644 (file)
@@ -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 ;
index 74f083f7684bac2b579940bdb75d2c0e5c1aeb65..975ded80d221561b398ea798b750a55fcae95459 100644 (file)
@@ -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
index 11740a97ce92478fc15c14f262ec40e7002d2a55..8a3f2091a2125593fbdb3f01575b579d081e594f 100644 (file)
@@ -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 <bihash> 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 <bihash> 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 } } } [
index 9ad2c0bd28adde02d1c1d4f8dda2d16877cda84f..baa441ecf6205b3db6a69537441f6c736e1e533b 100644 (file)
@@ -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 } }
index c21ccff5c28d266b370f8bb82543728ea7a53775..2fd590e778ac6b75a547a69d208aaf1cdc24e51c 100644 (file)
@@ -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