Skip to content

Commit d37e320

Browse files
cosminbascalukasstadler
authored andcommitted
cache the execution of the readAttrNode when the MRO lookup is stable and the attribute value does not change
1 parent 625863e commit d37e320

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/LookupAttributeInMRONode.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected Object lookup(Object klass, Object key) {
8484
}
8585
}
8686

87-
private final String key;
87+
protected final String key;
8888

8989
public LookupAttributeInMRONode(String key) {
9090
this.key = key;
@@ -133,14 +133,15 @@ protected PythonClassAssumptionPair findAttrClassAndAssumptionInMRO(PythonClass
133133
return new PythonClassAssumptionPair(null, attrAssumption);
134134
}
135135

136-
@Specialization(guards = {"klass == cachedKlass", "cachedAttributeStableInMROInfo.cls != null"}, limit = "5", assumptions = {"lookupStable",
137-
"cachedAttributeStableInMROInfo.assumption"})
136+
@Specialization(guards = {"klass == cachedKlass", "cachedClassInMROInfo.cls != null"}, limit = "5", assumptions = {"lookupStable",
137+
"cachedClassInMROInfo.assumption"})
138138
protected Object lookupConstantMROCached(@SuppressWarnings("unused") PythonClass klass,
139139
@Cached("klass") @SuppressWarnings("unused") PythonClass cachedKlass,
140140
@Cached("cachedKlass.getLookupStableAssumption()") @SuppressWarnings("unused") Assumption lookupStable,
141-
@Cached("create()") ReadAttributeFromObjectNode readAttrNode,
142-
@Cached("findAttrClassAndAssumptionInMRO(cachedKlass)") @SuppressWarnings("unused") PythonClassAssumptionPair cachedAttributeStableInMROInfo) {
143-
return readAttrNode.execute(cachedAttributeStableInMROInfo.cls, key);
141+
@Cached("create()") @SuppressWarnings("unused") ReadAttributeFromObjectNode readAttributeNode,
142+
@Cached("findAttrClassAndAssumptionInMRO(cachedKlass)") @SuppressWarnings("unused") PythonClassAssumptionPair cachedClassInMROInfo,
143+
@Cached("readAttributeNode.execute(cachedClassInMROInfo.cls, key)") Object value) {
144+
return value;
144145
}
145146

146147
protected ReadAttributeFromObjectNode[] create(int size) {

0 commit comments

Comments
 (0)