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 .profiles .ConditionProfile ;
52
51
53
52
public abstract class LookupAttributeInMRONode extends PBaseNode {
54
53
@@ -118,10 +117,13 @@ protected PythonClassAssumptionPair findAttrClassAndAssumptionInMRO(PythonClass
118
117
Assumption attrAssumption = null ;
119
118
for (int i = 0 ; i < mro .length ; i ++) {
120
119
PythonClass cls = mro [i ];
121
- if (attrAssumption == null ) {
122
- attrAssumption = cls .createAttributeInMROFinalAssumption (key );
123
- } else {
124
- cls .setAttributeInMROFinalAssumption (key , attrAssumption );
120
+ if (i > 0 ) {
121
+ assert cls != klass : "MRO chain is incorrect: '" + klass + "' was found at position " + i ;
122
+ if (attrAssumption == null ) {
123
+ attrAssumption = cls .createAttributeInMROFinalAssumption (key );
124
+ } else {
125
+ cls .addAttributeInMROFinalAssumption (key , attrAssumption );
126
+ }
125
127
}
126
128
127
129
if (cls .getStorage ().containsKey (key )) {
@@ -131,20 +133,14 @@ protected PythonClassAssumptionPair findAttrClassAndAssumptionInMRO(PythonClass
131
133
return new PythonClassAssumptionPair (null , attrAssumption );
132
134
}
133
135
134
- @ Specialization (guards = {"klass == cachedKlass" , "cachedAttributeClassAssumptionPair .cls != null" }, limit = "5" , assumptions = {"lookupStable" ,
135
- "cachedAttributeClassAssumptionPair .assumption" }, rewriteOn = IllegalStateException . class )
136
+ @ Specialization (guards = {"klass == cachedKlass" , "cachedAttributeStableInMROInfo .cls != null" }, limit = "5" , assumptions = {"lookupStable" ,
137
+ "cachedAttributeStableInMROInfo .assumption" })
136
138
protected Object lookupConstantMROCached (@ SuppressWarnings ("unused" ) PythonClass klass ,
137
139
@ Cached ("klass" ) @ SuppressWarnings ("unused" ) PythonClass cachedKlass ,
138
140
@ Cached ("cachedKlass.getLookupStableAssumption()" ) @ SuppressWarnings ("unused" ) Assumption lookupStable ,
139
141
@ Cached ("create()" ) ReadAttributeFromObjectNode readAttrNode ,
140
- @ Cached ("findAttrClassAndAssumptionInMRO(cachedKlass)" ) @ SuppressWarnings ("unused" ) PythonClassAssumptionPair cachedAttributeClassAssumptionPair ,
141
- @ Cached ("createBinaryProfile()" ) ConditionProfile attributeDeletedProfile ) {
142
- Object value = readAttrNode .execute (cachedAttributeClassAssumptionPair .cls , key );
143
- if (attributeDeletedProfile .profile (value == PNone .NO_VALUE )) {
144
- // in case the attribute was deleted
145
- throw new IllegalStateException ();
146
- }
147
- return value ;
142
+ @ Cached ("findAttrClassAndAssumptionInMRO(cachedKlass)" ) @ SuppressWarnings ("unused" ) PythonClassAssumptionPair cachedAttributeStableInMROInfo ) {
143
+ return readAttrNode .execute (cachedAttributeStableInMROInfo .cls , key );
148
144
}
149
145
150
146
protected ReadAttributeFromObjectNode [] create (int size ) {
0 commit comments