# HG changeset patch # User Christian Humer # Date 1429707841 -7200 # Node ID 4cba24bef2ee017642ed708b00f8343e1fc403de # Parent 8f67ddf0dd3b73ddba47c33812fac32bd88b9731 Truffle-DSL: fix unnecessary cast in generated isIdentical for types used just in cached expressions . diff -r 8f67ddf0dd3b -r 4cba24bef2ee graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java --- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java Wed Apr 22 11:00:26 2015 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java Wed Apr 22 15:04:01 2015 +0200 @@ -40,6 +40,7 @@ import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestMultipleCachesFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.UnboundCacheFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.nodes.*; @SuppressWarnings("unused") public class CachedTest { @@ -263,6 +264,26 @@ } + /* + * Node should not produce any warnings in isIdentical of the generated code. Unnecessary casts + * were generated for isIdentical on the fast path. + */ + @NodeChildren({@NodeChild, @NodeChild}) + static class RegressionTestWarningInIsIdentical extends ValueNode { + + @Specialization(guards = {"cachedName == name"}) + protected Object directAccess(String receiver, String name, // + @Cached("name") String cachedName, // + @Cached("create(receiver, name)") Object callHandle) { + return receiver; + } + + protected static Object create(String receiver, String name) { + return receiver; + } + + } + @NodeChild static class TestMultipleCaches extends ValueNode { diff -r 8f67ddf0dd3b -r 4cba24bef2ee graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java Wed Apr 22 11:00:26 2015 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java Wed Apr 22 15:04:01 2015 +0200 @@ -1981,7 +1981,7 @@ } else { castGuards = new HashSet<>(); for (TypeGuard castGuard : group.getTypeGuards()) { - if (isTypeGuardUsedInAnyGuardOrCacheBelow(group, currentValues, castGuard)) { + if (isTypeGuardUsedInAnyGuardOrCacheBelow(group, currentValues, castGuard, execution.isFastPath())) { castGuards.add(castGuard); } } @@ -2059,7 +2059,7 @@ return true; } - private boolean isTypeGuardUsedInAnyGuardOrCacheBelow(SpecializationGroup group, LocalContext currentValues, TypeGuard typeGuard) { + private boolean isTypeGuardUsedInAnyGuardOrCacheBelow(SpecializationGroup group, LocalContext currentValues, TypeGuard typeGuard, boolean fastPath) { String localName = currentValues.getValue(typeGuard.getSignatureIndex()).getName(); SpecializationData specialization = group.getSpecialization(); @@ -2068,7 +2068,7 @@ return true; } } - if (specialization != null) { + if (!fastPath && specialization != null) { for (CacheExpression cache : specialization.getCaches()) { if (isVariableBoundIn(specialization, cache.getExpression(), localName, currentValues)) { return true; @@ -2077,7 +2077,7 @@ } for (SpecializationGroup child : group.getChildren()) { - if (isTypeGuardUsedInAnyGuardOrCacheBelow(child, currentValues, typeGuard)) { + if (isTypeGuardUsedInAnyGuardOrCacheBelow(child, currentValues, typeGuard, fastPath)) { return true; } }