Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java @ 22348:dbbcd8eb5dae
Truffle DSL: fix algorithm to find guard dependencies on caches
author | Benoit Daloze <benoit.daloze@jku.at> |
---|---|
date | Thu, 05 Nov 2015 17:05:48 +0100 |
parents | 5309cc9668e3 |
children | 687bc1dda125 |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java Thu Nov 05 16:11:50 2015 +0100 +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java Thu Nov 05 17:05:48 2015 +0100 @@ -42,6 +42,7 @@ import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCacheFieldFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCacheMethodFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCacheNodeFieldFactory; +import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCachesOrderFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithCachedAndDynamicParameterFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithJustCachedParameterFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestMultipleCachesFactory; @@ -309,6 +310,35 @@ } @NodeChild + static class TestCachesOrder extends ValueNode { + + @Specialization(guards = "boundByGuard != 0") + static int do1(int value, // + @Cached("get(value)") int intermediateValue, // + @Cached("transform(intermediateValue)") int boundByGuard, // + @Cached("new()") Object notBoundByGuards) { + return intermediateValue; + } + + protected int get(int i) { + return i * 2; + } + + protected int transform(int i) { + return i * 3; + } + + } + + @Test + public void testCachesOrder() { + CallTarget root = createCallTarget(TestCachesOrderFactory.getInstance()); + assertEquals(42, root.call(21)); + assertEquals(42, root.call(22)); + assertEquals(42, root.call(23)); + } + + @NodeChild static class CachedError1 extends ValueNode { @Specialization static int do1(int value, @ExpectError("Incompatible return type int. The expression type must be equal to the parameter type double.")//