43
43
import com .oracle .graal .python .builtins .objects .common .SequenceNodes .GetObjectArrayNode ;
44
44
import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
45
45
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
46
+ import com .oracle .graal .python .builtins .objects .type .TypeNodes .IsSameTypeNode ;
46
47
import com .oracle .graal .python .nodes .PNodeWithContext ;
47
48
import com .oracle .graal .python .runtime .PythonOptions ;
48
49
import com .oracle .truffle .api .CompilerDirectives ;
49
50
import com .oracle .truffle .api .dsl .Cached ;
51
+ import com .oracle .truffle .api .dsl .Cached .Shared ;
50
52
import com .oracle .truffle .api .dsl .GenerateUncached ;
51
53
import com .oracle .truffle .api .dsl .ImportStatic ;
52
54
import com .oracle .truffle .api .dsl .Specialization ;
@@ -73,8 +75,10 @@ public final boolean execute(Object derived, Object cls) {
73
75
return execute (null , derived , cls );
74
76
}
75
77
76
- @ Specialization (guards = "derived == cls" )
77
- boolean isSameClass (@ SuppressWarnings ("unused" ) Object derived , @ SuppressWarnings ("unused" ) Object cls ) {
78
+ @ Specialization (guards = "isSameTypeNode.execute(derived, cls)" , limit = "1" )
79
+ @ SuppressWarnings ("unused" )
80
+ static boolean doSameClass (Object derived , Object cls ,
81
+ @ Shared ("isSameType" ) @ Cached IsSameTypeNode isSameTypeNode ) {
78
82
return true ;
79
83
}
80
84
@@ -85,7 +89,7 @@ protected static int[] observedSize() {
85
89
}
86
90
87
91
@ Specialization (guards = {"derived != cls" , "derived == cachedDerived" , "cls == cachedCls" }, limit = "getCallSiteInlineCacheMaxDepth()" )
88
- boolean isSubclass (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object derived , @ SuppressWarnings ("unused" ) Object cls ,
92
+ static boolean doSubclass (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object derived , @ SuppressWarnings ("unused" ) Object cls ,
89
93
@ Cached (value = "observedSize()" , dimensions = 1 ) int [] observedSizeArray ,
90
94
@ Cached ("derived" ) Object cachedDerived ,
91
95
@ Cached ("cls" ) Object cachedCls ,
@@ -133,13 +137,14 @@ private static final boolean loopBases(VirtualFrame frame, Object cachedCls, Obj
133
137
return false ;
134
138
}
135
139
136
- @ Specialization (replaces = {"isSubclass " , "isSameClass " })
137
- boolean isSubclassGeneric (VirtualFrame frame , Object derived , Object cls ,
140
+ @ Specialization (replaces = {"doSubclass " , "doSameClass " })
141
+ static boolean doGeneric (VirtualFrame frame , Object derived , Object cls ,
138
142
@ Cached SequenceStorageNodes .LenNode lenNode ,
139
143
@ Cached AbstractObjectGetBasesNode getBasesNode ,
140
144
@ Cached AbstractObjectIsSubclassNode isSubclassNode ,
145
+ @ Shared ("isSameType" ) @ Cached IsSameTypeNode isSameTypeNode ,
141
146
@ Cached GetObjectArrayNode getObjectArrayNode ) {
142
- if (derived == cls ) {
147
+ if (isSameTypeNode . execute ( derived , cls ) ) {
143
148
return true ;
144
149
}
145
150
0 commit comments