|
48 | 48 | import com.oracle.truffle.api.dsl.Fallback;
|
49 | 49 | import com.oracle.truffle.api.dsl.Specialization;
|
50 | 50 | import com.oracle.truffle.api.nodes.ExplodeLoop;
|
| 51 | +import com.oracle.truffle.api.object.Location; |
| 52 | +import com.oracle.truffle.api.object.Property; |
| 53 | +import com.oracle.truffle.api.object.Shape; |
51 | 54 |
|
52 | 55 | public abstract class LookupAttributeInMRONode extends PBaseNode {
|
53 | 56 |
|
@@ -113,12 +116,20 @@ protected PythonClass findClassInMRO(PythonClass klass) {
|
113 | 116 | return null;
|
114 | 117 | }
|
115 | 118 |
|
116 |
| - @Specialization(guards = {"klass == cachedKlass", "cachedAttrKlass != null"}, limit = "5", assumptions = "lookupStable", rewriteOn = IllegalStateException.class) |
| 119 | + protected Location getLocationOrNull(Shape shape) { |
| 120 | + Property prop = shape.getProperty(key); |
| 121 | + return prop == null ? null : prop.getLocation(); |
| 122 | + } |
| 123 | + |
| 124 | + @Specialization(guards = {"klass == cachedKlass", "cachedAttrKlass != null"}, limit = "5", assumptions = {"lookupStable", "finalAssumption"}, rewriteOn = IllegalStateException.class) |
117 | 125 | protected Object lookupConstantMROCached(@SuppressWarnings("unused") PythonClass klass,
|
118 | 126 | @Cached("klass") @SuppressWarnings("unused") PythonClass cachedKlass,
|
119 | 127 | @Cached("cachedKlass.getLookupStableAssumption()") @SuppressWarnings("unused") Assumption lookupStable,
|
120 | 128 | @Cached("create()") ReadAttributeFromObjectNode readAttrNode,
|
121 |
| - @Cached("findClassInMRO(cachedKlass)") @SuppressWarnings("unused") PythonClass cachedAttrKlass) { |
| 129 | + @Cached("findClassInMRO(cachedKlass)") PythonClass cachedAttrKlass, |
| 130 | + @Cached("cachedAttrKlass.getStorage().getShape()") @SuppressWarnings("unused") Shape cachedShape, |
| 131 | + @Cached("getLocationOrNull(cachedShape)") @SuppressWarnings("unused") Location loc, |
| 132 | + @Cached("loc.getFinalAssumption()") @SuppressWarnings("unused") Assumption finalAssumption) { |
122 | 133 | Object value = readAttrNode.execute(cachedAttrKlass, key);
|
123 | 134 | if (value == PNone.NO_VALUE) {
|
124 | 135 | // in case the attribute was deleted
|
|
0 commit comments