Skip to content

Commit e2c23ca

Browse files
committed
Use LookupSpecialMethodNode for __init__
1 parent 22218b6 commit e2c23ca

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
import com.oracle.graal.python.nodes.SpecialMethodNames;
161161
import com.oracle.graal.python.nodes.attributes.GetAttributeNode;
162162
import com.oracle.graal.python.nodes.attributes.GetAttributeNode.GetAnyAttributeNode;
163-
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
164163
import com.oracle.graal.python.nodes.attributes.LookupInheritedAttributeNode;
165164
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
166165
import com.oracle.graal.python.nodes.attributes.SetAttributeNode;
@@ -169,6 +168,7 @@
169168
import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
170169
import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode;
171170
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
171+
import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodNode;
172172
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
173173
import com.oracle.graal.python.nodes.control.GetIteratorExpressionNode.GetIteratorNode;
174174
import com.oracle.graal.python.nodes.control.GetNextNode;
@@ -857,16 +857,16 @@ public PythonObject reversed(Object cls, String value) {
857857
@Specialization(guards = {"!isString(sequence)", "!isPRange(sequence)"}, limit = "3")
858858
public Object reversed(VirtualFrame frame, Object cls, Object sequence,
859859
@CachedLibrary("sequence") PythonObjectLibrary lib,
860-
@Cached("create(__REVERSED__)") LookupAttributeInMRONode reversedNode,
860+
@Cached("create(__REVERSED__)") LookupSpecialMethodNode reversedNode,
861861
@Cached("create()") CallUnaryMethodNode callReversedNode,
862862
@Cached("create(__LEN__)") LookupAndCallUnaryNode lenNode,
863-
@Cached("create(__GETITEM__)") LookupAttributeInMRONode getItemNode,
863+
@Cached("create(__GETITEM__)") LookupSpecialMethodNode getItemNode,
864864
@Cached("createBinaryProfile()") ConditionProfile noReversedProfile,
865865
@Cached("createBinaryProfile()") ConditionProfile noGetItemProfile) {
866866
Object sequenceKlass = lib.getLazyPythonClass(sequence);
867-
Object reversed = reversedNode.execute(sequenceKlass);
867+
Object reversed = reversedNode.execute(frame, sequenceKlass, sequence);
868868
if (noReversedProfile.profile(reversed == PNone.NO_VALUE)) {
869-
Object getItem = getItemNode.execute(sequenceKlass);
869+
Object getItem = getItemNode.execute(frame, sequenceKlass, sequence);
870870
if (noGetItemProfile.profile(getItem == PNone.NO_VALUE)) {
871871
throw raise(TypeError, ErrorMessages.OBJ_ISNT_REVERSIBLE, sequence);
872872
} else {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
100100
import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
101101
import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode;
102+
import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodNode;
102103
import com.oracle.graal.python.nodes.classes.AbstractObjectGetBasesNode;
103104
import com.oracle.graal.python.nodes.classes.AbstractObjectIsSubclassNode;
104105
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
@@ -205,7 +206,7 @@ public abstract static class CallNode extends PythonVarargsBuiltinNode {
205206
@Child private LookupAndCallTernaryNode callNewGet = LookupAndCallTernaryNode.create(__GET__);
206207
@Child private LookupAttributeInMRONode lookupNew = LookupAttributeInMRONode.create(__NEW__);
207208
@Child private CallVarargsMethodNode dispatchInit = CallVarargsMethodNode.create();
208-
@Child private LookupAttributeInMRONode lookupInit = LookupAttributeInMRONode.create(__INIT__);
209+
@Child private LookupSpecialMethodNode lookupInit = LookupSpecialMethodNode.create(__INIT__);
209210
@Child private IsSubtypeNode isSubTypeNode;
210211
@Child private TypeNodes.GetNameNode getNameNode;
211212
@Child private IsBuiltinClassProfile isClassClassProfile = IsBuiltinClassProfile.create();
@@ -360,7 +361,7 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
360361
// passing keywords or more than one argument see:
361362
// https://github.com/python/cpython/blob/2102c789035ccacbac4362589402ac68baa2cd29/Objects/typeobject.c#L3538
362363
} else {
363-
Object initMethod = lookupInit.execute(newInstanceKlass);
364+
Object initMethod = lookupInit.execute(frame, newInstanceKlass, newInstance);
364365
if (initMethod != PNone.NO_VALUE) {
365366
Object[] initArgs;
366367
if (doCreateArgs) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ public static LookupSpecialMethodNode create(String name, boolean ignoreDescript
8484
return LookupSpecialMethodNodeGen.create(name, ignoreDescriptorException);
8585
}
8686

87+
public static LookupSpecialMethodNode create(String name) {
88+
return LookupSpecialMethodNodeGen.create(name, false);
89+
}
90+
8791
public static class BoundDescriptor {
8892
public final Object descriptor;
8993

0 commit comments

Comments
 (0)