comparison truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.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 dc83cc1f94f2
children
comparison
equal deleted inserted replaced
22347:6546703e0c76 22348:dbbcd8eb5dae
70 exception.setSpecialization(this); 70 exception.setSpecialization(this);
71 } 71 }
72 } 72 }
73 73
74 public boolean isCacheBoundByGuard(CacheExpression cacheExpression) { 74 public boolean isCacheBoundByGuard(CacheExpression cacheExpression) {
75 VariableElement cachedVariable = cacheExpression.getParameter().getVariableElement();
76
75 for (GuardExpression expression : getGuards()) { 77 for (GuardExpression expression : getGuards()) {
76 if (expression.getExpression().findBoundVariableElements().contains(cacheExpression.getParameter().getVariableElement())) { 78 if (expression.getExpression().findBoundVariableElements().contains(cachedVariable)) {
77 return true; 79 return true;
78 } 80 }
79 } 81 }
80 82
81 // check all next binding caches if they are bound by guard 83 // check all next binding caches if they are bound to a guard and use this cache variable
82 Set<VariableElement> boundVariables = cacheExpression.getExpression().findBoundVariableElements();
83 boolean found = false; 84 boolean found = false;
84 for (CacheExpression expression : getCaches()) { 85 for (CacheExpression expression : getCaches()) {
85 if (cacheExpression == expression) { 86 if (cacheExpression == expression) {
86 found = true; 87 found = true;
87 } else if (found) { 88 } else if (found) {
88 if (boundVariables.contains(expression.getParameter().getVariableElement())) { 89 if (expression.getExpression().findBoundVariableElements().contains(cachedVariable)) {
89 if (isCacheBoundByGuard(expression)) { 90 if (isCacheBoundByGuard(expression)) {
90 return true; 91 return true;
91 } 92 }
92 } 93 }
93 } 94 }