44
44
import com .oracle .graal .python .builtins .objects .PNone ;
45
45
import com .oracle .graal .python .builtins .objects .type .LazyPythonClass ;
46
46
import com .oracle .graal .python .builtins .objects .type .PythonAbstractClass ;
47
+ import com .oracle .graal .python .builtins .objects .type .TypeNodes ;
47
48
import com .oracle .graal .python .builtins .objects .type .TypeNodes .GetMroNode ;
48
49
import com .oracle .graal .python .builtins .objects .type .TypeNodes .GetMroStorageNode ;
49
50
import com .oracle .graal .python .nodes .PNodeWithContext ;
@@ -96,6 +97,7 @@ protected Object lookup(PythonAbstractClass klass, Object key,
96
97
}
97
98
98
99
protected final String key ;
100
+ @ Child private TypeNodes .IsSameTypeNode isSameTypeNode = TypeNodes .IsSameTypeNode .createFast ();
99
101
@ Child private GetMroStorageNode getMroNode ;
100
102
101
103
public LookupAttributeInMRONode (String key ) {
@@ -168,7 +170,7 @@ protected PythonClassAssumptionPair findAttrClassAndAssumptionInMRO(PythonAbstra
168
170
return new PythonClassAssumptionPair (attrAssumption , PNone .NO_VALUE );
169
171
}
170
172
171
- @ Specialization (guards = {"klass == cachedKlass" , "cachedClassInMROInfo != null" }, limit = "getIntOption(getContext(), AttributeAccessInlineCacheMaxDepth)" , assumptions = {
173
+ @ Specialization (guards = {"isSameType( cachedKlass, klass) " , "cachedClassInMROInfo != null" }, limit = "getIntOption(getContext(), AttributeAccessInlineCacheMaxDepth)" , assumptions = {
172
174
"cachedClassInMROInfo.assumption" })
173
175
protected Object lookupConstantMROCached (@ SuppressWarnings ("unused" ) PythonAbstractClass klass ,
174
176
@ Cached ("klass" ) @ SuppressWarnings ("unused" ) PythonAbstractClass cachedKlass ,
@@ -184,7 +186,7 @@ protected ReadAttributeFromObjectNode[] create(int size) {
184
186
return nodes ;
185
187
}
186
188
187
- @ Specialization (guards = {"klass == cachedKlass" , "mroLength < 32" }, limit = "getIntOption(getContext(), AttributeAccessInlineCacheMaxDepth)" , assumptions = "lookupStable" )
189
+ @ Specialization (guards = {"isSameType( cachedKlass, klass) " , "mroLength < 32" }, limit = "getIntOption(getContext(), AttributeAccessInlineCacheMaxDepth)" , assumptions = "lookupStable" )
188
190
@ ExplodeLoop (kind = ExplodeLoop .LoopExplosionKind .FULL_EXPLODE_UNTIL_RETURN )
189
191
protected Object lookupConstantMRO (@ SuppressWarnings ("unused" ) PythonAbstractClass klass ,
190
192
@ Cached ("klass" ) @ SuppressWarnings ("unused" ) PythonAbstractClass cachedKlass ,
@@ -243,4 +245,8 @@ public static Object lookupSlow(LazyPythonClass klass, String key) {
243
245
}
244
246
return PNone .NO_VALUE ;
245
247
}
248
+
249
+ protected boolean isSameType (PythonAbstractClass cachedKlass , PythonAbstractClass klass ) {
250
+ return isSameTypeNode .execute (cachedKlass , klass );
251
+ }
246
252
}
0 commit comments