|
74 | 74 | import com.oracle.truffle.api.nodes.ExplodeLoop; |
75 | 75 | import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; |
76 | 76 | import com.oracle.truffle.api.nodes.Node; |
77 | | -import com.oracle.truffle.api.profiles.InlinedBranchProfile; |
78 | 77 | import com.oracle.truffle.api.profiles.InlinedConditionProfile; |
79 | 78 | import com.oracle.truffle.api.strings.TruffleString; |
80 | 79 |
|
@@ -180,7 +179,21 @@ static Object lookupPBCTCached(PythonBuiltinClassType klass, |
180 | 179 |
|
181 | 180 | // PythonClass specializations: |
182 | 181 |
|
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 | + } |
184 | 197 | } |
185 | 198 |
|
186 | 199 | @SuppressWarnings("serial") |
@@ -233,14 +246,15 @@ static Object lookupConstantMROCached(Object klass, |
233 | 246 | @Bind Node inliningTarget, |
234 | 247 | @Cached("klass") Object cachedKlass, |
235 | 248 | @Cached IsSameTypeNode isSameTypeNode, |
236 | | - @Cached InlinedBranchProfile shouldInvalidate, |
237 | 249 | @Cached("findAttrAndAssumptionInMRO(cachedKlass)") AttributeAssumptionPair cachedAttrInMROInfo) { |
238 | | - if (shouldInvalidate.wasEntered(inliningTarget)) { |
239 | | - throw InvalidateLookupException.INSTANCE; |
240 | | - } else if (cachedAttrInMROInfo.invalidate) { |
| 250 | + if (cachedAttrInMROInfo.invalidate) { |
241 | 251 | // next time we will invalidate, but this time we must return the result to avoid |
242 | 252 | // 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; |
244 | 258 | } |
245 | 259 | return cachedAttrInMROInfo.value; |
246 | 260 | } |
|
0 commit comments