Skip to content

Commit e0414e3

Browse files
committed
[GR-14811] add missing PInt and LazyPythonClass specializations in IsSubType and LookupAndCallBinary nodes
PullRequest: graalpython/462
2 parents cc6721a + be6d1ee commit e0414e3

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,21 @@ boolean doManaged(PythonManagedClass left, PythonManagedClass right) {
588588
return left == right;
589589
}
590590

591+
@Specialization
592+
boolean doManaged(PythonBuiltinClassType left, PythonBuiltinClassType right) {
593+
return left == right;
594+
}
595+
596+
@Specialization
597+
boolean doManaged(PythonBuiltinClassType left, PythonBuiltinClass right) {
598+
return left == right.getType();
599+
}
600+
601+
@Specialization
602+
boolean doManaged(PythonBuiltinClass left, PythonBuiltinClassType right) {
603+
return left.getType() == right;
604+
}
605+
591606
@Specialization
592607
boolean doNativeSlow(PythonAbstractNativeObject left, PythonAbstractNativeObject right) {
593608
if (fastCheck) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallBinaryNode.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@
4545
import com.oracle.graal.python.builtins.objects.PNone;
4646
import com.oracle.graal.python.builtins.objects.PNotImplemented;
4747
import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
48-
import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
48+
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
4949
import com.oracle.graal.python.builtins.objects.type.TypeNodes;
5050
import com.oracle.graal.python.nodes.PNodeWithContext;
5151
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
5252
import com.oracle.graal.python.nodes.attributes.LookupInheritedAttributeNode;
5353
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
5454
import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
5555
import com.oracle.graal.python.nodes.object.GetClassNode;
56+
import com.oracle.graal.python.nodes.object.GetLazyClassNode;
5657
import com.oracle.truffle.api.CompilerDirectives;
5758
import com.oracle.truffle.api.dsl.Cached;
5859
import com.oracle.truffle.api.dsl.Specialization;
@@ -285,15 +286,15 @@ Object callObject(Object left, Object right,
285286
Object callObject(Object left, Object right,
286287
@Cached("create(name)") LookupAttributeInMRONode getattr,
287288
@Cached("create(rname)") LookupAttributeInMRONode getattrR,
288-
@Cached("create()") GetClassNode getClass,
289-
@Cached("create()") GetClassNode getClassR,
289+
@Cached("create()") GetLazyClassNode getClass,
290+
@Cached("create()") GetLazyClassNode getClassR,
290291
@Cached("create()") TypeNodes.IsSameTypeNode isSameTypeNode,
291292
@Cached("create()") IsSubtypeNode isSubtype,
292293
@Cached("createBinaryProfile()") ConditionProfile notImplementedBranch) {
293294
Object result = PNotImplemented.NOT_IMPLEMENTED;
294-
PythonAbstractClass leftClass = getClass.execute(left);
295+
LazyPythonClass leftClass = getClass.execute(left);
295296
Object leftCallable = getattr.execute(leftClass);
296-
PythonAbstractClass rightClass = getClassR.execute(right);
297+
LazyPythonClass rightClass = getClassR.execute(right);
297298
Object rightCallable = getattrR.execute(rightClass);
298299
if (leftCallable == rightCallable) {
299300
rightCallable = PNone.NO_VALUE;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/classes/IsSubtypeNode.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*/
4141
package com.oracle.graal.python.nodes.classes;
4242

43+
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
4344
import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
4445
import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroStorageNode;
4546
import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode;
@@ -114,8 +115,8 @@ boolean isSubtypeOfConstantType(@SuppressWarnings("unused") PythonAbstractClass
114115
assumptions = "mro.getLookupStableAssumption()" //
115116
)
116117
@ExplodeLoop
117-
boolean isSubtypeOfVariableType(@SuppressWarnings("unused") PythonAbstractClass derived, PythonAbstractClass cls,
118-
@Cached("derived") @SuppressWarnings("unused") PythonAbstractClass cachedDerived,
118+
boolean isSubtypeOfVariableType(@SuppressWarnings("unused") LazyPythonClass derived, LazyPythonClass cls,
119+
@Cached("derived") @SuppressWarnings("unused") LazyPythonClass cachedDerived,
119120
@Cached("getMro(cachedDerived)") MroSequenceStorage mro) {
120121
for (PythonAbstractClass n : mro.getInternalClassArray()) {
121122
if (isSameType(n, cls)) {
@@ -126,7 +127,7 @@ boolean isSubtypeOfVariableType(@SuppressWarnings("unused") PythonAbstractClass
126127
}
127128

128129
@Specialization(replaces = {"isSubtypeOfConstantType", "isSubtypeOfVariableType"})
129-
boolean issubTypeGeneric(PythonAbstractClass derived, PythonAbstractClass cls) {
130+
boolean issubTypeGeneric(LazyPythonClass derived, LazyPythonClass cls) {
130131
for (PythonAbstractClass n : getMro(derived).getInternalClassArray()) {
131132
if (isSameType(n, cls)) {
132133
return true;
@@ -153,15 +154,15 @@ public boolean isSubclass(Object derived, Object cls) {
153154
return abstractIsSubclassNode.execute(derived, cls);
154155
}
155156

156-
protected MroSequenceStorage getMro(PythonAbstractClass clazz) {
157+
protected MroSequenceStorage getMro(LazyPythonClass clazz) {
157158
if (getMroNode == null) {
158159
CompilerDirectives.transferToInterpreterAndInvalidate();
159160
getMroNode = insert(GetMroStorageNode.create());
160161
}
161162
return getMroNode.execute(clazz);
162163
}
163164

164-
private boolean isSameType(PythonAbstractClass left, PythonAbstractClass right) {
165+
private boolean isSameType(LazyPythonClass left, LazyPythonClass right) {
165166
if (isSameTypeNode == null) {
166167
CompilerDirectives.transferToInterpreterAndInvalidate();
167168
isSameTypeNode = insert(IsSameTypeNode.create());

0 commit comments

Comments
 (0)