compiler.cfg.*: new word reset-vreg-counter, useful for making test writing more convenient

db4
Björn Lindqvist 2015-03-26 14:19:00 +00:00 committed by John Benediktsson
parent 2536943e82
commit 4390561a6e
8 changed files with 21 additions and 33 deletions

View 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 } } }

View 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 [

View 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 }

View 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 ;

View 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

View 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 } } } [

View 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 } }

View 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