Skip to content

Commit b9fc7d0

Browse files
committed
[GR-30855] Use slots more (2).
PullRequest: graalpython/2078
2 parents eb070a9 + 3acce7e commit b9fc7d0

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
package com.oracle.graal.python.builtins.objects.type;
4242

4343
import static com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot.Flags.NO_BUILTIN_DESCRIPTORS;
44-
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__CLASS__;
4544
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__DICT__;
4645
import static com.oracle.graal.python.nodes.SpecialMethodNames.__ADD__;
4746
import static com.oracle.graal.python.nodes.SpecialMethodNames.__AND__;
@@ -178,7 +177,6 @@ public enum SpecialMethodSlot {
178177
SetAttr(__SETATTR__),
179178
DelAttr(__DELATTR__),
180179

181-
Class(__CLASS__),
182180
Dict(__DICT__),
183181

184182
Get(__GET__),
@@ -697,8 +695,6 @@ public static SpecialMethodSlot findSpecialSlot(String name) {
697695
return SetAttr;
698696
case __DELATTR__:
699697
return DelAttr;
700-
case __CLASS__:
701-
return Class;
702698
case __DICT__:
703699
return Dict;
704700
case __GET__:

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@
5454
import com.oracle.graal.python.nodes.SpecialMethodNames;
5555
import com.oracle.graal.python.nodes.argument.CreateArgumentsNode;
5656
import com.oracle.graal.python.nodes.argument.positional.PositionalArgumentsNode;
57-
import com.oracle.graal.python.nodes.attributes.LookupInheritedAttributeNode;
57+
import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
5858
import com.oracle.graal.python.nodes.attributes.LookupInheritedSlotNode;
5959
import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
60+
import com.oracle.graal.python.nodes.object.GetClassNode;
6061
import com.oracle.graal.python.nodes.truffle.PythonTypes;
6162
import com.oracle.truffle.api.dsl.Cached;
6263
import com.oracle.truffle.api.dsl.Cached.Shared;
@@ -212,7 +213,8 @@ protected Object doGeneric(VirtualFrame frame, Object callableObject, Object[] a
212213
@Shared("dispatchNode") @Cached CallDispatchNode dispatch,
213214
@Shared("argsNode") @Cached CreateArgumentsNode createArgs,
214215
@Shared("raise") @Cached PRaiseNode raise,
215-
@Cached LookupInheritedAttributeNode.Dynamic callAttrGetterNode,
216+
@Cached(parameters = "Call") LookupCallableSlotInMRONode callAttrGetterNode,
217+
@Cached GetClassNode getClassNode,
216218
@Shared("callVarargs") @Cached CallVarargsMethodNode callCallNode) {
217219
if (callableObject instanceof PFunction) {
218220
return functionCall(frame, (PFunction) callableObject, arguments, keywords, dispatch, createArgs);
@@ -230,6 +232,6 @@ protected Object doGeneric(VirtualFrame frame, Object callableObject, Object[] a
230232
PBuiltinMethod method = (PBuiltinMethod) callableObject;
231233
return builtinMethodCallBuiltinDirect(frame, method, arguments, keywords, dispatch, createArgs);
232234
}
233-
return callCall(frame, callableObject, arguments, keywords, raise, callCallNode, callAttrGetterNode.execute(callableObject, SpecialMethodNames.__CALL__));
235+
return callCall(frame, callableObject, arguments, keywords, raise, callCallNode, callAttrGetterNode.execute(getClassNode.execute(callableObject)));
234236
}
235237
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public static LookupAndCallUnaryNode create(String name, Supplier<NoAttributeHan
8787
return LookupAndCallUnaryNodeGen.create(name, handlerFactory);
8888
}
8989

90+
public static LookupAndCallUnaryNode create(SpecialMethodSlot slot, Supplier<NoAttributeHandler> handlerFactory) {
91+
return LookupAndCallUnaryNodeGen.create(slot, handlerFactory);
92+
}
93+
9094
LookupAndCallUnaryNode(SpecialMethodSlot slot, Supplier<NoAttributeHandler> handlerFactory) {
9195
this.slot = slot;
9296
this.name = slot.getName();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/GetNextNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public Object execute(Object iterator) {
7979
@NodeInfo(cost = NONE)
8080
private static final class GetNextCached extends GetNextNode {
8181

82-
@Child private LookupAndCallUnaryNode nextCall = LookupAndCallUnaryNode.create(__NEXT__, () -> new NoAttributeHandler() {
82+
@Child private LookupAndCallUnaryNode nextCall = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next, () -> new NoAttributeHandler() {
8383
@Child private PRaiseNode raiseNode = PRaiseNode.create();
8484

8585
@Override

0 commit comments

Comments
 (0)