Skip to content

Commit 8444007

Browse files
committed
Use slots (more) in LookupAndCallUnaryNode
1 parent 6d14d4c commit 8444007

27 files changed

+64
-48
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@
8585
import static com.oracle.graal.python.nodes.SpecialMethodNames.__COMPLEX__;
8686
import static com.oracle.graal.python.nodes.SpecialMethodNames.__EQ__;
8787
import static com.oracle.graal.python.nodes.SpecialMethodNames.__HASH__;
88-
import static com.oracle.graal.python.nodes.SpecialMethodNames.__INDEX__;
8988
import static com.oracle.graal.python.nodes.SpecialMethodNames.__INT__;
90-
import static com.oracle.graal.python.nodes.SpecialMethodNames.__REPR__;
9189
import static com.oracle.graal.python.nodes.SpecialMethodNames.__TRUNC__;
9290
import static com.oracle.graal.python.runtime.exception.PythonErrorType.NotImplementedError;
9391
import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError;
@@ -641,7 +639,7 @@ private PComplex convertStringToComplex(VirtualFrame frame, String src, Object c
641639
if (str == null) {
642640
if (callReprNode == null) {
643641
CompilerDirectives.transferToInterpreterAndInvalidate();
644-
callReprNode = insert(LookupAndCallUnaryNode.create(__REPR__));
642+
callReprNode = insert(LookupAndCallUnaryNode.create(SpecialMethodSlot.Repr));
645643
}
646644
Object strStr = callReprNode.executeObject(frame, origObj);
647645
if (PGuards.isString(strStr)) {
@@ -856,7 +854,7 @@ public Object reversed(VirtualFrame frame, Object cls, Object sequence,
856854
@Cached GetClassNode getClassNode,
857855
@Cached("create(Reversed)") LookupSpecialMethodSlotNode lookupReversed,
858856
@Cached CallUnaryMethodNode callReversed,
859-
@Cached("create(__LEN__)") LookupAndCallUnaryNode lookupLen,
857+
@Cached("create(Len)") LookupAndCallUnaryNode lookupLen,
860858
@Cached("create(GetItem)") LookupSpecialMethodSlotNode getItemNode,
861859
@Cached ConditionProfile noReversedProfile,
862860
@Cached ConditionProfile noGetItemProfile) {
@@ -1053,7 +1051,7 @@ private Object stringToInt(VirtualFrame frame, Object cls, String number, int ba
10531051
invalidValueProfile.enter();
10541052
if (callReprNode == null) {
10551053
CompilerDirectives.transferToInterpreterAndInvalidate();
1056-
callReprNode = insert(LookupAndCallUnaryNode.create(__REPR__));
1054+
callReprNode = insert(LookupAndCallUnaryNode.create(SpecialMethodSlot.Repr));
10571055
}
10581056
Object str = callReprNode.executeObject(frame, origObj);
10591057
if (PGuards.isString(str)) {
@@ -1449,7 +1447,7 @@ protected static FloatBuiltins.IntNode createFloatInt() {
14491447
private Object callIndex(VirtualFrame frame, Object obj) {
14501448
if (callIndexNode == null) {
14511449
CompilerDirectives.transferToInterpreterAndInvalidate();
1452-
callIndexNode = insert(LookupAndCallUnaryNode.create(__INDEX__));
1450+
callIndexNode = insert(LookupAndCallUnaryNode.create(SpecialMethodSlot.Index));
14531451
}
14541452
Object result = callIndexNode.executeObject(frame, obj);
14551453
// the case when the result is NO_VALUE (i.e. the object does not provide __index__)
@@ -1471,7 +1469,7 @@ private Object callTrunc(VirtualFrame frame, Object obj) {
14711469
private Object callInt(VirtualFrame frame, Object object) {
14721470
if (callIntNode == null) {
14731471
CompilerDirectives.transferToInterpreterAndInvalidate();
1474-
callIntNode = insert(LookupAndCallUnaryNode.create(__INT__));
1472+
callIntNode = insert(LookupAndCallUnaryNode.create(SpecialMethodSlot.Int));
14751473
}
14761474
Object result = callIntNode.executeObject(frame, object);
14771475
if (result != PNone.NO_VALUE && !isIntegerType(result)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ Object ternary(VirtualFrame frame, Object x, Object y, Object z,
20382038
@GenerateNodeFactory
20392039
public abstract static class SumFunctionNode extends PythonBuiltinNode {
20402040

2041-
@Child private LookupAndCallUnaryNode next = LookupAndCallUnaryNode.create(__NEXT__);
2041+
@Child private LookupAndCallUnaryNode next = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next);
20422042
@Child private AddNode add = AddNode.create();
20432043

20442044
@Child private IsBuiltinClassProfile errorProfile1 = IsBuiltinClassProfile.create();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626
package com.oracle.graal.python.builtins.modules;
2727

28-
import static com.oracle.graal.python.nodes.SpecialMethodNames.__NEXT__;
2928
import static com.oracle.graal.python.runtime.exception.PythonErrorType.NotImplementedError;
3029
import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError;
3130
import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError;
@@ -49,6 +48,7 @@
4948
import com.oracle.graal.python.builtins.objects.function.PKeyword;
5049
import com.oracle.graal.python.builtins.objects.ints.PInt;
5150
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
51+
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
5252
import com.oracle.graal.python.lib.PyFloatAsDoubleNode;
5353
import com.oracle.graal.python.lib.PyNumberIndexNode;
5454
import com.oracle.graal.python.lib.PyObjectGetIter;
@@ -948,7 +948,7 @@ public abstract static class FsumNode extends PythonUnaryBuiltinNode {
948948
@Specialization
949949
double doIt(VirtualFrame frame, Object iterable,
950950
@Cached PyObjectGetIter getIter,
951-
@Cached("create(__NEXT__)") LookupAndCallUnaryNode callNextNode,
951+
@Cached("create(Next)") LookupAndCallUnaryNode callNextNode,
952952
@Cached PyFloatAsDoubleNode asDoubleNode,
953953
@Cached IsBuiltinClassProfile stopProfile) {
954954
Object iterator = getIter.execute(frame, iterable);
@@ -2259,7 +2259,7 @@ private void raiseIfNegative(boolean condition) {
22592259
@GenerateNodeFactory
22602260
public abstract static class ProdNode extends PythonBuiltinNode {
22612261

2262-
@Child private LookupAndCallUnaryNode callNextNode = LookupAndCallUnaryNode.create(__NEXT__);
2262+
@Child private LookupAndCallUnaryNode callNextNode = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next);
22632263
@Child private BinaryOpNode mul = BinaryArithmetic.Mul.create();
22642264
@Child private IsBuiltinClassProfile errorProfile = IsBuiltinClassProfile.create();
22652265

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,7 +3378,7 @@ abstract static class PyTruffle_OS_DoubleToString extends NativeBuiltin {
33783378
@Specialization(guards = "isReprFormatCode(formatCode)")
33793379
@SuppressWarnings("unused")
33803380
PTuple doRepr(VirtualFrame frame, Object module, double val, int formatCode, int precision, int flags,
3381-
@Cached("create(__REPR__)") LookupAndCallUnaryNode callReprNode,
3381+
@Cached("create(Repr)") LookupAndCallUnaryNode callReprNode,
33823382
@Cached CastToJavaStringNode castToStringNode,
33833383
@Cached GetNativeNullNode getNativeNullNode) {
33843384
Object reprString = callReprNode.executeObject(frame, val);
@@ -3476,7 +3476,7 @@ static int doMapping(PHashingCollection container,
34763476

34773477
@Specialization(guards = "!isMappingOrSequence(obj)")
34783478
static Object doGenericUnboxed(VirtualFrame frame, Object obj,
3479-
@Cached("create(__LEN__)") LookupAndCallUnaryNode callLenNode,
3479+
@Cached("create(Len)") LookupAndCallUnaryNode callLenNode,
34803480
@Cached ConditionProfile noLenProfile,
34813481
@Cached CastToNativeLongNode castToLongNode,
34823482
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ protected abstract static class UnpickleNode extends PythonBinaryBuiltinNode {
500500
@Specialization
501501
Object unpickle(VirtualFrame frame, Object typ, PTuple state,
502502
@Cached CallNode callNode,
503-
@Cached("create(__NEW__)") LookupAndCallUnaryNode lookupAndCallUnaryNode,
503+
@Cached("create(New)") LookupAndCallUnaryNode lookupAndCallUnaryNode,
504504
@Cached("create(__SETSTATE__)") GetAttributeNode setStateAttr) {
505505
Object obj = lookupAndCallUnaryNode.executeObject(frame, typ);
506506
Object meth = setStateAttr.executeObject(frame, obj);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ static Object doit(@SuppressWarnings("unused") PFileIO self) {
11201120
@Specialization(guards = "!self.isClosed()")
11211121
Object doit(VirtualFrame frame, PFileIO self,
11221122
@Cached PyObjectLookupAttr lookupName,
1123-
@Cached("create(__REPR__)") LookupAndCallUnaryNode repr) {
1123+
@Cached("create(Repr)") LookupAndCallUnaryNode repr) {
11241124
String mode = ModeNode.modeString(self);
11251125
String closefd = self.isCloseFD() ? "True" : "False";
11261126
Object nameobj = lookupName.execute(frame, self, "name");

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ abstract static class ReprNode extends InitCheckPythonUnaryBuiltinNode {
11591159
@Specialization(guards = "self.isOK()")
11601160
Object doit(VirtualFrame frame, PTextIO self,
11611161
@Cached PyObjectLookupAttr lookup,
1162-
@Cached("create(__REPR__)") LookupAndCallUnaryNode repr,
1162+
@Cached("create(Repr)") LookupAndCallUnaryNode repr,
11631163
@Cached IONodes.ToStringNode toString,
11641164
@Cached IsBuiltinClassProfile isValueError) {
11651165
if (!getContext().reprEnter(self)) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.oracle.graal.python.builtins.objects.list.PList;
3434
import com.oracle.graal.python.builtins.objects.str.PString;
3535
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
36+
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
3637
import com.oracle.graal.python.nodes.PGuards;
3738
import com.oracle.graal.python.nodes.PRaiseNode;
3839
import com.oracle.graal.python.nodes.SpecialMethodNames;
@@ -73,12 +74,12 @@ public abstract static class CallEncoderNode extends PythonTernaryClinicBuiltinN
7374
@Child private CallUnaryMethodNode callDefaultFn = CallUnaryMethodNode.create();
7475
@Child private CastToJavaStringNode castEncodeResult = CastToJavaStringNode.create();
7576
@Child private LookupAndCallUnaryNode callGetItems = LookupAndCallUnaryNode.create(SpecialMethodNames.ITEMS);
76-
@Child private LookupAndCallUnaryNode callGetDictIter = LookupAndCallUnaryNode.create(SpecialMethodNames.__ITER__);
77+
@Child private LookupAndCallUnaryNode callGetDictIter = LookupAndCallUnaryNode.create(SpecialMethodSlot.Iter);
7778
@Child private GetNextNode callDictNext = GetNextNode.create();
7879
@Child private IsBuiltinClassProfile stopDictIterationProfile = IsBuiltinClassProfile.create();
7980
@Child private HashingStorageLibrary dictLib = HashingStorageLibrary.getFactory().createDispatched(6);
8081
@Child private ListSortNode sortList = ListSortNode.create();
81-
@Child private LookupAndCallUnaryNode callGetListIter = LookupAndCallUnaryNode.create(SpecialMethodNames.__ITER__);
82+
@Child private LookupAndCallUnaryNode callGetListIter = LookupAndCallUnaryNode.create(SpecialMethodSlot.Iter);
8283
@Child private GetNextNode callListNext = GetNextNode.create();
8384
@Child private IsBuiltinClassProfile stopListIterationProfile = IsBuiltinClassProfile.create();
8485
@Child private GetClassNode getDictClass = GetClassNode.create();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static boolean contains(VirtualFrame frame, PArray self, Object value,
437437
abstract static class ReprNode extends PythonUnaryBuiltinNode {
438438
@Specialization
439439
static String repr(VirtualFrame frame, PArray self,
440-
@Cached("create(__REPR__)") LookupAndCallUnaryNode reprNode,
440+
@Cached("create(Repr)") LookupAndCallUnaryNode reprNode,
441441
@Cached ConditionProfile isEmptyProfile,
442442
@Cached ConditionProfile isUnicodeProfile,
443443
@Cached CastToJavaStringNode cast,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/FormatNodeBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
5959
// applies to all types: empty format string => use __str__
6060
@Specialization(guards = "formatString.isEmpty()")
6161
public static Object formatEmptyString(VirtualFrame frame, Object self, @SuppressWarnings("unused") String formatString,
62-
@Cached("create(__STR__)") LookupAndCallUnaryNode lookupAndCallNode) {
62+
@Cached("create(Str)") LookupAndCallUnaryNode lookupAndCallNode) {
6363
return lookupAndCallNode.executeObject(frame, self);
6464
}
6565
}

0 commit comments

Comments
 (0)