Skip to content

Commit 7041530

Browse files
committed
Remove lookup base nodes
1 parent 784bc28 commit 7041530

File tree

6 files changed

+16
-118
lines changed

6 files changed

+16
-118
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/LookupAttributeInMRONode.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -84,7 +84,10 @@
8484
import com.oracle.truffle.api.strings.TruffleString;
8585

8686
@ImportStatic(PythonOptions.class)
87-
public abstract class LookupAttributeInMRONode extends LookupInMROBaseNode {
87+
public abstract class LookupAttributeInMRONode extends PNodeWithContext {
88+
89+
public abstract Object execute(Object klass);
90+
8891
@GenerateUncached
8992
@GenerateInline(false) // footprint reduction 36 -> 17
9093
public abstract static class Dynamic extends PNodeWithContext {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/LookupInMROBaseNode.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Object callObjectGeneric(VirtualFrame frame, Object left, Object right,
127127
@SuppressWarnings("unused") @Cached("left.getClass()") Class<?> cachedLeftClass,
128128
@SuppressWarnings("unused") @Cached("right.getClass()") Class<?> cachedRightClass,
129129
@Exclusive @Cached GetClassNode getClassNode,
130-
@Exclusive @Cached("createLookup()") LookupSpecialBaseNode getattr) {
130+
@Exclusive @Cached("create(name)") LookupSpecialMethodNode getattr) {
131131
return doCallObject(frame, inliningTarget, left, right, getClassNode, getattr);
132132
}
133133

@@ -137,21 +137,16 @@ Object callObjectGeneric(VirtualFrame frame, Object left, Object right,
137137
Object callObjectMegamorphic(VirtualFrame frame, Object left, Object right,
138138
@Bind("this") Node inliningTarget,
139139
@Exclusive @Cached GetClassNode getClassNode,
140-
@Exclusive @Cached("createLookup()") LookupSpecialBaseNode getattr) {
140+
@Exclusive @Cached("create(name)") LookupSpecialMethodNode getattr) {
141141
return doCallObject(frame, inliningTarget, left, right, getClassNode, getattr);
142142
}
143143

144-
private Object doCallObject(VirtualFrame frame, Node inliningTarget, Object left, Object right, GetClassNode getClassNode, LookupSpecialBaseNode getattr) {
144+
private Object doCallObject(VirtualFrame frame, Node inliningTarget, Object left, Object right, GetClassNode getClassNode, LookupSpecialMethodNode getattr) {
145145
Object leftClass = getClassNode.execute(inliningTarget, left);
146146
Object leftCallable = getattr.execute(frame, leftClass, left);
147147
if (PGuards.isNoValue(leftCallable)) {
148148
throw SpecialMethodNotFound.INSTANCE;
149149
}
150150
return ensureDispatch().executeObject(frame, leftCallable, left, right);
151151
}
152-
153-
@NeverDefault
154-
protected final LookupSpecialBaseNode createLookup() {
155-
return LookupSpecialMethodNode.create(name);
156-
}
157152
}

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Object callObjectGeneric(VirtualFrame frame, Object receiver,
137137
@Bind("this") Node inliningTarget,
138138
@SuppressWarnings("unused") @Cached("receiver.getClass()") Class<?> cachedClass,
139139
@Shared @Cached GetClassNode getClassNode,
140-
@Shared @Cached("createLookup()") LookupSpecialBaseNode getattr,
140+
@Shared @Cached("create(name)") LookupSpecialMethodNode getattr,
141141
@Shared @Cached CallUnaryMethodNode dispatchNode) {
142142
return doCallObject(frame, inliningTarget, receiver, getClassNode, getattr, dispatchNode);
143143
}
@@ -148,7 +148,7 @@ Object callObjectGeneric(VirtualFrame frame, Object receiver,
148148
Object callObjectMegamorphic(VirtualFrame frame, Object receiver,
149149
@Bind("this") Node inliningTarget,
150150
@Shared @Cached GetClassNode getClassNode,
151-
@Shared @Cached("createLookup()") LookupSpecialBaseNode getattr,
151+
@Shared @Cached("create(name)") LookupSpecialMethodNode getattr,
152152
@Shared @Cached CallUnaryMethodNode dispatchNode) {
153153
return doCallObject(frame, inliningTarget, receiver, getClassNode, getattr, dispatchNode);
154154
}
@@ -157,7 +157,7 @@ protected Class<?> getObjectClass(Object object) {
157157
return object.getClass();
158158
}
159159

160-
private Object doCallObject(VirtualFrame frame, Node inliningTarget, Object receiver, GetClassNode getClassNode, LookupSpecialBaseNode getattr, CallUnaryMethodNode dispatchNode) {
160+
private Object doCallObject(VirtualFrame frame, Node inliningTarget, Object receiver, GetClassNode getClassNode, LookupSpecialMethodNode getattr, CallUnaryMethodNode dispatchNode) {
161161
Object attr = getattr.execute(frame, getClassNode.execute(inliningTarget, receiver), receiver);
162162
if (attr == PNone.NO_VALUE) {
163163
if (handlerFactory != null) {
@@ -173,11 +173,6 @@ private Object doCallObject(VirtualFrame frame, Node inliningTarget, Object rece
173173
}
174174
}
175175

176-
@NeverDefault
177-
protected final LookupSpecialBaseNode createLookup() {
178-
return LookupSpecialMethodNode.create(name);
179-
}
180-
181176
@GenerateUncached
182177
@SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 20
183178
public abstract static class LookupAndCallUnaryDynamicNode extends PNodeWithContext {

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

Lines changed: 0 additions & 48 deletions
This file was deleted.

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -40,6 +40,7 @@
4040
*/
4141
package com.oracle.graal.python.nodes.call.special;
4242

43+
import com.oracle.graal.python.nodes.PNodeWithContext;
4344
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
4445
import com.oracle.truffle.api.dsl.Bind;
4546
import com.oracle.truffle.api.dsl.Cached;
@@ -60,13 +61,15 @@
6061
* differentiate it from the unbound case. {@link CallUnaryMethodNode} and other method calling
6162
* nodes handle this wrapper.
6263
*/
63-
public abstract class LookupSpecialMethodNode extends LookupSpecialBaseNode {
64+
public abstract class LookupSpecialMethodNode extends PNodeWithContext {
6465
protected final TruffleString name;
6566

6667
public LookupSpecialMethodNode(TruffleString name) {
6768
this.name = name;
6869
}
6970

71+
public abstract Object execute(Frame frame, Object type, Object receiver);
72+
7073
@NeverDefault
7174
public static LookupSpecialMethodNode create(TruffleString name) {
7275
return LookupSpecialMethodNodeGen.create(name);

0 commit comments

Comments
 (0)