Skip to content

Commit d810f76

Browse files
committed
Remove workaround for delegated int conversion
1 parent 8fd88f1 commit d810f76

File tree

2 files changed

+7
-43
lines changed

2 files changed

+7
-43
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
import com.oracle.truffle.api.dsl.Specialization;
116116
import com.oracle.truffle.api.dsl.TypeSystemReference;
117117
import com.oracle.truffle.api.frame.VirtualFrame;
118-
import com.oracle.truffle.api.interop.InteropLibrary;
119118
import com.oracle.truffle.api.interop.UnsupportedMessageException;
120119
import com.oracle.truffle.api.library.CachedLibrary;
121120
import com.oracle.truffle.api.profiles.BranchProfile;
@@ -2810,25 +2809,6 @@ static PythonNativeVoidPtr doL(PythonNativeVoidPtr self) {
28102809
@Builtin(name = SpecialMethodNames.__INDEX__, minNumOfPositionalArgs = 1)
28112810
@GenerateNodeFactory
28122811
abstract static class IndexNode extends IntNode {
2813-
// TODO: Remove again once GR-30482 is fixed
2814-
@Specialization(guards = "!isAnyPythonObject(object)", limit = "3")
2815-
static long doForeign(Object object,
2816-
@CachedLibrary("object") InteropLibrary lib) {
2817-
if (lib.isBoolean(object)) {
2818-
try {
2819-
return PInt.intValue(lib.asBoolean(object));
2820-
} catch (UnsupportedMessageException e) {
2821-
// fall through
2822-
}
2823-
} else if (lib.fitsInLong(object)) {
2824-
try {
2825-
return lib.asLong(object);
2826-
} catch (UnsupportedMessageException e) {
2827-
// fall through
2828-
}
2829-
}
2830-
throw CompilerDirectives.shouldNotReachHere("Must fix GR-30482");
2831-
}
28322812
}
28332813

28342814
@Builtin(name = SpecialMethodNames.__GETNEWARGS__, minNumOfPositionalArgs = 1)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberIndexNode.java

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
4848
import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltins;
4949
import com.oracle.graal.python.builtins.objects.PNone;
50-
import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
5150
import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject;
5251
import com.oracle.graal.python.builtins.objects.ints.PInt;
5352
import com.oracle.graal.python.nodes.ErrorMessages;
@@ -100,7 +99,7 @@ static PInt doPInt(PInt object) {
10099
}
101100

102101
@Specialization(rewriteOn = UnexpectedResultException.class)
103-
int doCallIndexInt(VirtualFrame frame, PythonAbstractObject object,
102+
int doCallIndexInt(VirtualFrame frame, Object object,
104103
@Shared("callIndex") @Cached CallIndexNode callIndex,
105104
@Shared("getClass") @Cached GetClassNode getClassNode,
106105
@Shared("isSubtype") @Cached IsSubtypeNode isSubtype) throws UnexpectedResultException {
@@ -123,17 +122,16 @@ int doCallIndexInt(VirtualFrame frame, PythonAbstractObject object,
123122
}
124123
}
125124

126-
// TODO: Accept "Object" again once GR-30482 is fixed
127125
@Specialization(replaces = "doCallIndexInt")
128-
static Object doCallIndex(VirtualFrame frame, PythonAbstractObject object,
126+
static Object doCallIndex(VirtualFrame frame, Object object,
129127
@Shared("callIndex") @Cached CallIndexNode callIndex,
130128
@Shared("getClass") @Cached GetClassNode getClassNode,
131129
@Shared("isSubtype") @Cached IsSubtypeNode isSubtype,
132-
@Shared("resultClass") @Cached GetClassNode resultClassNode,
133-
@Shared("resultSubtype") @Cached IsSubtypeNode resultSubtype,
134-
@Shared("isInt") @Cached IsBuiltinClassProfile isInt,
135-
@Shared("raiseNode") @Cached PRaiseNode raiseNode,
136-
@Shared("warnNode") @Cached WarningsModuleBuiltins.WarnNode warnNode) {
130+
@Cached GetClassNode resultClassNode,
131+
@Cached IsSubtypeNode resultSubtype,
132+
@Cached IsBuiltinClassProfile isInt,
133+
@Cached PRaiseNode raiseNode,
134+
@Cached WarningsModuleBuiltins.WarnNode warnNode) {
137135
if (isSubtype.execute(getClassNode.execute(object), PythonBuiltinClassType.PInt)) {
138136
return object;
139137
}
@@ -142,20 +140,6 @@ static Object doCallIndex(VirtualFrame frame, PythonAbstractObject object,
142140
return result;
143141
}
144142

145-
// TODO: Remove again once GR-30482 is fixed
146-
@Specialization(guards = "!isAnyPythonObject(object)")
147-
static Object doCallIndexForeign(VirtualFrame frame, Object object,
148-
@Shared("callIndex") @Cached CallIndexNode callIndex,
149-
@Shared("resultClass") @Cached GetClassNode resultClassNode,
150-
@Shared("resultSubtype") @Cached IsSubtypeNode resultSubtype,
151-
@Shared("isInt") @Cached IsBuiltinClassProfile isInt,
152-
@Shared("raiseNode") @Cached PRaiseNode raiseNode,
153-
@Shared("warnNode") @Cached WarningsModuleBuiltins.WarnNode warnNode) {
154-
Object result = callIndex.execute(frame, object);
155-
checkResult(frame, object, result, resultClassNode, resultSubtype, isInt, raiseNode, warnNode);
156-
return result;
157-
}
158-
159143
private static void checkResult(VirtualFrame frame, Object originalObject, Object result, GetClassNode getClassNode, IsSubtypeNode isSubtype, IsBuiltinClassProfile isInt, PRaiseNode raiseNode,
160144
WarningsModuleBuiltins.WarnNode warnNode) {
161145
if (!isInt.profileObject(result, PythonBuiltinClassType.PInt)) {

0 commit comments

Comments
 (0)