Mercurial > hg > truffle
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java @ 21077:4cba24bef2ee
Truffle-DSL: fix unnecessary cast in generated isIdentical for types used just in cached expressions .
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 22 Apr 2015 15:04:01 +0200 |
parents | 82539241ff38 |
children | 23f0f181bc05 |
comparison
equal
deleted
inserted
replaced
21076:8f67ddf0dd3b | 21077:4cba24bef2ee |
---|---|
1979 if (execution.needsCastedValues()) { | 1979 if (execution.needsCastedValues()) { |
1980 castGuards = null; // cast all | 1980 castGuards = null; // cast all |
1981 } else { | 1981 } else { |
1982 castGuards = new HashSet<>(); | 1982 castGuards = new HashSet<>(); |
1983 for (TypeGuard castGuard : group.getTypeGuards()) { | 1983 for (TypeGuard castGuard : group.getTypeGuards()) { |
1984 if (isTypeGuardUsedInAnyGuardOrCacheBelow(group, currentValues, castGuard)) { | 1984 if (isTypeGuardUsedInAnyGuardOrCacheBelow(group, currentValues, castGuard, execution.isFastPath())) { |
1985 castGuards.add(castGuard); | 1985 castGuards.add(castGuard); |
1986 } | 1986 } |
1987 } | 1987 } |
1988 } | 1988 } |
1989 | 1989 |
2057 } | 2057 } |
2058 | 2058 |
2059 return true; | 2059 return true; |
2060 } | 2060 } |
2061 | 2061 |
2062 private boolean isTypeGuardUsedInAnyGuardOrCacheBelow(SpecializationGroup group, LocalContext currentValues, TypeGuard typeGuard) { | 2062 private boolean isTypeGuardUsedInAnyGuardOrCacheBelow(SpecializationGroup group, LocalContext currentValues, TypeGuard typeGuard, boolean fastPath) { |
2063 String localName = currentValues.getValue(typeGuard.getSignatureIndex()).getName(); | 2063 String localName = currentValues.getValue(typeGuard.getSignatureIndex()).getName(); |
2064 | 2064 |
2065 SpecializationData specialization = group.getSpecialization(); | 2065 SpecializationData specialization = group.getSpecialization(); |
2066 for (GuardExpression guard : group.getGuards()) { | 2066 for (GuardExpression guard : group.getGuards()) { |
2067 if (isVariableBoundIn(specialization, guard.getExpression(), localName, currentValues)) { | 2067 if (isVariableBoundIn(specialization, guard.getExpression(), localName, currentValues)) { |
2068 return true; | 2068 return true; |
2069 } | 2069 } |
2070 } | 2070 } |
2071 if (specialization != null) { | 2071 if (!fastPath && specialization != null) { |
2072 for (CacheExpression cache : specialization.getCaches()) { | 2072 for (CacheExpression cache : specialization.getCaches()) { |
2073 if (isVariableBoundIn(specialization, cache.getExpression(), localName, currentValues)) { | 2073 if (isVariableBoundIn(specialization, cache.getExpression(), localName, currentValues)) { |
2074 return true; | 2074 return true; |
2075 } | 2075 } |
2076 } | 2076 } |
2077 } | 2077 } |
2078 | 2078 |
2079 for (SpecializationGroup child : group.getChildren()) { | 2079 for (SpecializationGroup child : group.getChildren()) { |
2080 if (isTypeGuardUsedInAnyGuardOrCacheBelow(child, currentValues, typeGuard)) { | 2080 if (isTypeGuardUsedInAnyGuardOrCacheBelow(child, currentValues, typeGuard, fastPath)) { |
2081 return true; | 2081 return true; |
2082 } | 2082 } |
2083 } | 2083 } |
2084 | 2084 |
2085 return false; | 2085 return false; |