Skip to content

Commit bf416fd

Browse files
committed
Fix bug in LookupAttributeInMRONode
1 parent 0379fe9 commit bf416fd

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
import com.oracle.truffle.api.nodes.ExplodeLoop;
7575
import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind;
7676
import com.oracle.truffle.api.nodes.Node;
77-
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
7877
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
7978
import com.oracle.truffle.api.strings.TruffleString;
8079

@@ -180,7 +179,21 @@ static Object lookupPBCTCached(PythonBuiltinClassType klass,
180179

181180
// PythonClass specializations:
182181

183-
record AttributeAssumptionPair(Assumption assumption, Object value, boolean invalidate) {
182+
static final class AttributeAssumptionPair {
183+
private final Assumption assumption;
184+
private final Object value;
185+
private final boolean invalidate;
186+
private boolean invalidateNextCall;
187+
188+
AttributeAssumptionPair(Assumption assumption, Object value, boolean invalidate) {
189+
this.assumption = assumption;
190+
this.value = value;
191+
this.invalidate = invalidate;
192+
}
193+
194+
public Assumption assumption() {
195+
return assumption;
196+
}
184197
}
185198

186199
@SuppressWarnings("serial")
@@ -233,14 +246,15 @@ static Object lookupConstantMROCached(Object klass,
233246
@Bind Node inliningTarget,
234247
@Cached("klass") Object cachedKlass,
235248
@Cached IsSameTypeNode isSameTypeNode,
236-
@Cached InlinedBranchProfile shouldInvalidate,
237249
@Cached("findAttrAndAssumptionInMRO(cachedKlass)") AttributeAssumptionPair cachedAttrInMROInfo) {
238-
if (shouldInvalidate.wasEntered(inliningTarget)) {
239-
throw InvalidateLookupException.INSTANCE;
240-
} else if (cachedAttrInMROInfo.invalidate) {
250+
if (cachedAttrInMROInfo.invalidate) {
241251
// next time we will invalidate, but this time we must return the result to avoid
242252
// triggering side effects in __eq__ multiple times
243-
shouldInvalidate.enter(inliningTarget);
253+
if (cachedAttrInMROInfo.invalidateNextCall) {
254+
CompilerDirectives.transferToInterpreterAndInvalidate();
255+
throw InvalidateLookupException.INSTANCE;
256+
}
257+
cachedAttrInMROInfo.invalidateNextCall = true;
244258
}
245259
return cachedAttrInMROInfo.value;
246260
}

0 commit comments

Comments
 (0)