Skip to content

Commit 6d14d4c

Browse files
committed
Pass SpecialMethodSlot to the factory methods of LookupAndCall{Binary|Ternary}Node instead of a String
1 parent 7685754 commit 6d14d4c

23 files changed

+59
-41
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ private static TriState isInstanceCheckInternal(VirtualFrame frame, Object insta
14111411

14121412
@Specialization(guards = "isPythonClass(cls)")
14131413
static boolean isInstance(VirtualFrame frame, Object instance, Object cls,
1414-
@Shared("instanceCheck") @Cached("create(__INSTANCECHECK__)") LookupAndCallBinaryNode instanceCheckNode,
1414+
@Shared("instanceCheck") @Cached("create(InstanceCheck)") LookupAndCallBinaryNode instanceCheckNode,
14151415
@Shared("boolCast") @Cached("createIfTrueNode()") CoerceToBooleanNode castToBooleanNode,
14161416
@Cached GetClassNode getClassNode,
14171417
@Cached TypeNodes.IsSameTypeNode isSameTypeNode,
@@ -1423,7 +1423,7 @@ static boolean isInstance(VirtualFrame frame, Object instance, Object cls,
14231423

14241424
@Specialization(guards = {"!isPTuple(cls)", "!isPythonClass(cls)"})
14251425
static boolean isInstance(VirtualFrame frame, Object instance, Object cls,
1426-
@Shared("instanceCheck") @Cached("create(__INSTANCECHECK__)") LookupAndCallBinaryNode instanceCheckNode,
1426+
@Shared("instanceCheck") @Cached("create(InstanceCheck)") LookupAndCallBinaryNode instanceCheckNode,
14271427
@Shared("boolCast") @Cached("createIfTrueNode()") CoerceToBooleanNode castToBooleanNode,
14281428
@Cached TypeBuiltins.InstanceCheckNode typeInstanceCheckNode) {
14291429
TriState check = isInstanceCheckInternal(frame, instance, cls, instanceCheckNode, castToBooleanNode);
@@ -1459,7 +1459,7 @@ private static boolean isSubclassCheckInternal(VirtualFrame frame, Object derive
14591459

14601460
@Specialization(guards = "!isPTuple(cls)")
14611461
static boolean isSubclass(VirtualFrame frame, Object derived, Object cls,
1462-
@Cached("create(__SUBCLASSCHECK__)") LookupAndCallBinaryNode subclassCheckNode,
1462+
@Cached("create(Subclasscheck)") LookupAndCallBinaryNode subclassCheckNode,
14631463
@Cached("createIfTrueNode()") CoerceToBooleanNode castToBooleanNode,
14641464
@Cached IsSubtypeNode isSubtypeNode) {
14651465
return isSubclassCheckInternal(frame, derived, cls, subclassCheckNode, castToBooleanNode) || isSubtypeNode.execute(frame, derived, cls);
@@ -1885,13 +1885,13 @@ public abstract static class FormatNode extends PythonBinaryBuiltinNode {
18851885

18861886
@Specialization(guards = "isNoValue(formatSpec)")
18871887
Object format(VirtualFrame frame, Object obj, @SuppressWarnings("unused") PNone formatSpec,
1888-
@Shared("callFormat") @Cached("create(__FORMAT__)") LookupAndCallBinaryNode callFormat) {
1888+
@Shared("callFormat") @Cached("create(Format)") LookupAndCallBinaryNode callFormat) {
18891889
return format(frame, obj, "", callFormat);
18901890
}
18911891

18921892
@Specialization(guards = "!isNoValue(formatSpec)")
18931893
Object format(VirtualFrame frame, Object obj, Object formatSpec,
1894-
@Shared("callFormat") @Cached("create(__FORMAT__)") LookupAndCallBinaryNode callFormat) {
1894+
@Shared("callFormat") @Cached("create(Format)") LookupAndCallBinaryNode callFormat) {
18951895
Object res = callFormat.executeObject(frame, obj, formatSpec);
18961896
if (res == NO_VALUE) {
18971897
throw raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_FORMAT, obj);
@@ -1921,7 +1921,7 @@ public static String ascii(VirtualFrame frame, Object obj,
19211921
public abstract static class RoundNode extends PythonBuiltinNode {
19221922
@Specialization
19231923
Object round(VirtualFrame frame, Object x, @SuppressWarnings("unused") PNone n,
1924-
@Cached("create(__ROUND__)") LookupAndCallUnaryNode callRound) {
1924+
@Cached("create(Round)") LookupAndCallUnaryNode callRound) {
19251925
Object result = callRound.executeObject(frame, x);
19261926
if (result == PNone.NO_VALUE) {
19271927
throw raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, x, __ROUND__);
@@ -1931,7 +1931,7 @@ Object round(VirtualFrame frame, Object x, @SuppressWarnings("unused") PNone n,
19311931

19321932
@Specialization(guards = "!isPNone(n)")
19331933
Object round(VirtualFrame frame, Object x, Object n,
1934-
@Cached("create(__ROUND__)") LookupAndCallBinaryNode callRound) {
1934+
@Cached("create(Round)") LookupAndCallBinaryNode callRound) {
19351935
Object result = callRound.executeObject(frame, x, n);
19361936
if (result == NOT_IMPLEMENTED) {
19371937
throw raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, x, __ROUND__);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PythonCextBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3392,7 +3392,7 @@ PTuple doRepr(VirtualFrame frame, Object module, double val, int formatCode, int
33923392

33933393
@Specialization(guards = "!isReprFormatCode(formatCode)")
33943394
Object doGeneric(VirtualFrame frame, Object module, double val, int formatCode, int precision, @SuppressWarnings("unused") int flags,
3395-
@Cached("create(__FORMAT__)") LookupAndCallBinaryNode callReprNode,
3395+
@Cached("create(Format)") LookupAndCallBinaryNode callReprNode,
33963396
@Cached CastToJavaStringNode castToStringNode,
33973397
@Cached GetNativeNullNode getNativeNullNode) {
33983398
try {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ Object getItem(VirtualFrame frame, PDict self, Object key,
300300
}
301301
}
302302

303-
@ImportStatic(SpecialMethodNames.class)
303+
@ImportStatic(SpecialMethodSlot.class)
304304
protected abstract static class DispatchMissingNode extends Node {
305305

306306
protected abstract Object execute(VirtualFrame frame, Object self, Object key);
307307

308308
@Specialization
309309
protected static Object misssing(VirtualFrame frame, Object self, Object key,
310-
@Cached("create(__MISSING__)") LookupAndCallBinaryNode callMissing,
310+
@Cached("create(Missing)") LookupAndCallBinaryNode callMissing,
311311
@Cached DefaultMissingNode defaultMissing) {
312312
Object result = callMissing.executeObject(frame, self, key);
313313
if (result == PNotImplemented.NOT_IMPLEMENTED) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import com.oracle.graal.python.builtins.objects.set.PSet;
7979
import com.oracle.graal.python.builtins.objects.set.SetNodes;
8080
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
81+
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
8182
import com.oracle.graal.python.lib.PyObjectGetIter;
8283
import com.oracle.graal.python.lib.PyObjectRichCompareBool;
8384
import com.oracle.graal.python.lib.PyObjectSizeNode;
@@ -282,7 +283,7 @@ private GetNextNode getNext() {
282283
private LookupAndCallBinaryNode getContains() {
283284
if (contains == null) {
284285
CompilerDirectives.transferToInterpreterAndInvalidate();
285-
contains = insert(LookupAndCallBinaryNode.create(SpecialMethodNames.__CONTAINS__));
286+
contains = insert(LookupAndCallBinaryNode.create(SpecialMethodSlot.Contains));
286287
}
287288
return contains;
288289
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ private double doOperation(double left, double right, BranchProfile negativeRais
487487

488488
@Specialization(rewriteOn = UnexpectedResultException.class)
489489
double doDD(VirtualFrame frame, double left, double right, @SuppressWarnings("unused") PNone none,
490-
@Shared("powCall") @Cached("create(__POW__)") LookupAndCallTernaryNode callPow,
490+
@Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow,
491491
@Shared("negativeRaise") @Cached BranchProfile negativeRaise) throws UnexpectedResultException {
492492
if (doSpecialCases(left, right, negativeRaise) == 1) {
493493
return 1.0;
@@ -502,7 +502,7 @@ private double doOperation(double left, double right, BranchProfile negativeRais
502502

503503
@Specialization(replaces = "doDD")
504504
Object doDDToComplex(VirtualFrame frame, double left, double right, PNone none,
505-
@Shared("powCall") @Cached("create(__POW__)") LookupAndCallTernaryNode callPow,
505+
@Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow,
506506
@Shared("negativeRaise") @Cached BranchProfile negativeRaise) {
507507
if (doSpecialCases(left, right, negativeRaise) == 1) {
508508
return 1.0;
@@ -516,28 +516,28 @@ Object doDDToComplex(VirtualFrame frame, double left, double right, PNone none,
516516

517517
@Specialization(rewriteOn = UnexpectedResultException.class)
518518
double doDL(VirtualFrame frame, long left, double right, PNone none,
519-
@Shared("powCall") @Cached("create(__POW__)") LookupAndCallTernaryNode callPow,
519+
@Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow,
520520
@Shared("negativeRaise") @Cached BranchProfile negativeRaise) throws UnexpectedResultException {
521521
return doDD(frame, left, right, none, callPow, negativeRaise);
522522
}
523523

524524
@Specialization(replaces = "doDL")
525525
Object doDLComplex(VirtualFrame frame, long left, double right, PNone none,
526-
@Shared("powCall") @Cached("create(__POW__)") LookupAndCallTernaryNode callPow,
526+
@Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow,
527527
@Shared("negativeRaise") @Cached BranchProfile negativeRaise) {
528528
return doDDToComplex(frame, left, right, none, callPow, negativeRaise);
529529
}
530530

531531
@Specialization(rewriteOn = UnexpectedResultException.class)
532532
double doDPi(VirtualFrame frame, PInt left, double right, @SuppressWarnings("unused") PNone none,
533-
@Shared("powCall") @Cached("create(__POW__)") LookupAndCallTernaryNode callPow,
533+
@Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow,
534534
@Shared("negativeRaise") @Cached BranchProfile negativeRaise) throws UnexpectedResultException {
535535
return doDD(frame, left.doubleValueWithOverflow(getRaiseNode()), right, none, callPow, negativeRaise);
536536
}
537537

538538
@Specialization(replaces = "doDPi")
539539
Object doDPiToComplex(VirtualFrame frame, PInt left, double right, @SuppressWarnings("unused") PNone none,
540-
@Shared("powCall") @Cached("create(__POW__)") LookupAndCallTernaryNode callPow,
540+
@Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow,
541541
@Shared("negativeRaise") @Cached BranchProfile negativeRaise) {
542542
return doDDToComplex(frame, left.doubleValueWithOverflow(getRaiseNode()), right, none, callPow, negativeRaise);
543543
}
@@ -546,7 +546,7 @@ Object doDPiToComplex(VirtualFrame frame, PInt left, double right, @SuppressWarn
546546
Object doGeneric(VirtualFrame frame, Object left, Object right, Object mod,
547547
@Cached CanBeDoubleNode canBeDoubleNode,
548548
@Cached PyFloatAsDoubleNode asDoubleNode,
549-
@Shared("powCall") @Cached("create(__POW__)") LookupAndCallTernaryNode callPow,
549+
@Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow,
550550
@Shared("negativeRaise") @Cached BranchProfile negativeRaise) {
551551
if (!(mod instanceof PNone)) {
552552
throw raise(PythonBuiltinClassType.TypeError, "pow() 3rd argument not allowed unless all arguments are integers");

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Object next(VirtualFrame frame, PSequenceIterator self,
243243

244244
@Specialization(guards = {"!self.isExhausted()", "!self.isPSequence()"})
245245
Object next(VirtualFrame frame, PSequenceIterator self,
246-
@Cached("create(__GETITEM__)") LookupAndCallBinaryNode callGetItem,
246+
@Cached("create(GetItem)") LookupAndCallBinaryNode callGetItem,
247247
@Cached IsBuiltinClassProfile profile) {
248248
try {
249249
return callGetItem.executeObject(frame, self.getObject(), self.index++);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/BufferBuiltins.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,25 @@ public abstract static class GetItemNode extends PythonBinaryBuiltinNode {
110110

111111
@Specialization
112112
public static Object iter(VirtualFrame frame, PBuffer self, boolean key,
113-
@Cached("create(__GETITEM__)") LookupAndCallBinaryNode callGetItemNode) {
113+
@Cached("create(GetItem)") LookupAndCallBinaryNode callGetItemNode) {
114114
return callGetItemNode.executeObject(frame, self.getDelegate(), key);
115115
}
116116

117117
@Specialization
118118
public static Object iter(VirtualFrame frame, PBuffer self, int key,
119-
@Cached("create(__GETITEM__)") LookupAndCallBinaryNode callGetItemNode) {
119+
@Cached("create(GetItem)") LookupAndCallBinaryNode callGetItemNode) {
120120
return callGetItemNode.executeObject(frame, self.getDelegate(), key);
121121
}
122122

123123
@Specialization
124124
public static Object iter(VirtualFrame frame, PBuffer self, long key,
125-
@Cached("create(__GETITEM__)") LookupAndCallBinaryNode callGetItemNode) {
125+
@Cached("create(GetItem)") LookupAndCallBinaryNode callGetItemNode) {
126126
return callGetItemNode.executeObject(frame, self.getDelegate(), key);
127127
}
128128

129129
@Specialization
130130
public static Object iter(VirtualFrame frame, PBuffer self, PInt key,
131-
@Cached("create(__GETITEM__)") LookupAndCallBinaryNode callGetItemNode) {
131+
@Cached("create(GetItem)") LookupAndCallBinaryNode callGetItemNode) {
132132
return callGetItemNode.executeObject(frame, self.getDelegate(), key);
133133
}
134134

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected Object doIt(PMethod self) {
9393
public abstract static class CodeNode extends PythonBuiltinNode {
9494
@Specialization
9595
protected Object doIt(VirtualFrame frame, PMethod self,
96-
@Cached("create(__GETATTRIBUTE__)") LookupAndCallBinaryNode getCode) {
96+
@Cached("create(GetAttribute)") LookupAndCallBinaryNode getCode) {
9797
return getCode.executeObject(frame, self.getFunction(), __CODE__);
9898
}
9999
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static boolean ne(PythonAbstractNativeObject self, PythonAbstractNativeObject ot
315315
Object ne(VirtualFrame frame, Object self, Object other) {
316316
if (eqNode == null) {
317317
CompilerDirectives.transferToInterpreterAndInvalidate();
318-
eqNode = insert(LookupAndCallBinaryNode.create(__EQ__));
318+
eqNode = insert(LookupAndCallBinaryNode.create(SpecialMethodSlot.Eq));
319319
}
320320
Object result = eqNode.executeObject(frame, self, other);
321321
if (result == PNotImplemented.NOT_IMPLEMENTED) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public Object exhausted(@SuppressWarnings("unused") PBuiltinIterator self) {
8585

8686
@Specialization(guards = "!self.isExhausted()")
8787
Object next(VirtualFrame frame, PSequenceReverseIterator self,
88-
@Cached("create(__GETITEM__)") LookupAndCallBinaryNode callGetItem,
88+
@Cached("create(GetItem)") LookupAndCallBinaryNode callGetItem,
8989
@Cached IsBuiltinClassProfile profile) {
9090
if (self.index >= 0) {
9191
try {

0 commit comments

Comments
 (0)