Skip to content

Commit 56d3ec1

Browse files
committed
Use new lookup and call in lengthWithState
1 parent c86d4b3 commit 56d3ec1

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
import com.oracle.graal.python.nodes.call.CallNode;
116116
import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
117117
import com.oracle.graal.python.nodes.call.special.CallTernaryMethodNode;
118-
import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
119118
import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
120119
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.LookupAndCallUnaryDynamicNode;
121120
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
@@ -642,22 +641,20 @@ public boolean isSequence(@CachedLibrary("this") PythonObjectLibrary plib,
642641

643642
@ExportMessage
644643
public int lengthWithState(ThreadState state,
644+
@CachedLibrary("this") PythonObjectLibrary plib,
645+
@Shared("methodLib") @CachedLibrary(limit = "2") PythonObjectLibrary methodLib,
645646
@Shared("gotState") @Cached ConditionProfile gotState,
646647
@Exclusive @Cached ConditionProfile hasLen,
647648
@Exclusive @Cached ConditionProfile ltZero,
648-
@Exclusive @Cached LookupInheritedAttributeNode.Dynamic getLenNode,
649-
@Exclusive @Cached CallUnaryMethodNode callNode,
650649
@Shared("raise") @Cached PRaiseNode raiseNode,
651650
@Exclusive @CachedLibrary(limit = "1") PythonObjectLibrary lib) {
652-
Object lenFunc = getLenNode.execute(this, __LEN__);
651+
Object lenFunc = plib.lookupAttributeOnType(this, __LEN__);
653652
if (hasLen.profile(lenFunc != PNone.NO_VALUE)) {
654-
Object lenResult;
653+
Object lenResult = methodLib.callUnboundMethodWithState(lenFunc, state, this);
655654
int len;
656655
if (gotState.profile(state == null)) {
657-
lenResult = callNode.executeObject(lenFunc, this);
658656
len = lib.asSize(lenResult);
659657
} else {
660-
lenResult = callNode.executeObject(PArguments.frameForCall(state), lenFunc, this);
661658
len = lib.asSizeWithState(lenResult, state);
662659
}
663660
if (ltZero.profile(len < 0)) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/PString.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.oracle.graal.python.nodes.PRaiseNode;
3737
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
3838
import com.oracle.graal.python.nodes.attributes.LookupInheritedAttributeNode;
39-
import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
4039
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
4140
import com.oracle.graal.python.nodes.util.CannotCastException;
4241
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
@@ -166,15 +165,15 @@ static int nativeStringMat(PString self, @SuppressWarnings("unused") ThreadState
166165

167166
@Specialization(replaces = {"string", "lazyString", "nativeString", "nativeStringMat"})
168167
static int subclassedString(PString self, ThreadState state,
169-
@Exclusive @Cached("createBinaryProfile()") ConditionProfile gotState,
170-
@Exclusive @Cached("createBinaryProfile()") ConditionProfile hasLen,
171-
@Exclusive @Cached("createBinaryProfile()") ConditionProfile ltZero,
172-
@Exclusive @Cached LookupInheritedAttributeNode.Dynamic getLenNode,
173-
@Exclusive @Cached CallUnaryMethodNode callNode,
174-
@Exclusive @Cached PRaiseNode raiseNode,
168+
@CachedLibrary("self") PythonObjectLibrary plib,
169+
@Shared("methodLib") @CachedLibrary(limit = "2") PythonObjectLibrary methodLib,
170+
@Shared("gotState") @Cached ConditionProfile gotState,
171+
@Exclusive @Cached ConditionProfile hasLen,
172+
@Exclusive @Cached ConditionProfile ltZero,
173+
@Shared("raise") @Cached PRaiseNode raiseNode,
175174
@Exclusive @CachedLibrary(limit = "1") PythonObjectLibrary lib) {
176175
// call the generic implementation in the superclass
177-
return self.lengthWithState(state, gotState, hasLen, ltZero, getLenNode, callNode, raiseNode, lib);
176+
return self.lengthWithState(state, plib, methodLib, gotState, hasLen, ltZero, raiseNode, lib);
178177
}
179178
}
180179

0 commit comments

Comments
 (0)