summaryrefslogtreecommitdiff
path: root/chapter11
diff options
context:
space:
mode:
Diffstat (limited to 'chapter11')
-rw-r--r--chapter11/src/main/java/com/seaofnodes/simple/Parser.java2
-rw-r--r--chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java7
2 files changed, 5 insertions, 4 deletions
diff --git a/chapter11/src/main/java/com/seaofnodes/simple/Parser.java b/chapter11/src/main/java/com/seaofnodes/simple/Parser.java
index 3b5f2721..df8d0b1c 100644
--- a/chapter11/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter11/src/main/java/com/seaofnodes/simple/Parser.java
@@ -611,7 +611,7 @@ public class Parser {
Node prior = mem().keep();
Node st = new StoreNode(name,alias,prior,ptr,val).peephole();
mem(new MemMergeNode(prior,alias,st).peephole());
- prior.unkeep();
+ if( prior.unkeep().isUnused() ) prior.kill();
}
/**
diff --git a/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java b/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java
index 8bf1debe..9a5e4677 100644
--- a/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java
+++ b/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java
@@ -290,7 +290,8 @@ while( i.x < i.len ) {
return sum;
""");
StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop16,0,(Phi(Loop,0,(Phi_x+1))+Phi_sum));", stop.toString());
+ assertEquals("return Phi(Loop16,0,(Phi(Loop,0,(Phi_$2+1))+Phi_sum));", stop.toString());
+ assertEquals(10L,Evaluator.evaluate(stop,5));
}
@@ -549,8 +550,8 @@ return 0;
if (arg) s.x=arg+1; else s.x=arg+2;
return s;
""").parse().iterate();
- // The initializing slice also remains live as the aggregate default.
- assertEquals(2,countMemoryNodes(stop,StoreNode.class,new BitSet()));
+ // Releasing the old aggregate exposes the overwritten initializing Store.
+ assertEquals(1,countMemoryNodes(stop,StoreNode.class,new BitSet()));
assertEquals(2L,((Evaluator.Obj)Evaluator.evaluate(stop,0)).fields()[0]);
assertEquals(4L,((Evaluator.Obj)Evaluator.evaluate(stop,3)).fields()[0]);
}