Skip to content

Commit ce7f291

Browse files
committed
replace __len__ call in ImportStarNode
1 parent 6bd361b commit ce7f291

File tree

1 file changed

+6
-17
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement

1 file changed

+6
-17
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/ImportStarNode.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
3535
import com.oracle.graal.python.nodes.PRaiseNode;
3636
import com.oracle.graal.python.nodes.SpecialAttributeNames;
37-
import com.oracle.graal.python.nodes.SpecialMethodNames;
3837
import com.oracle.graal.python.nodes.attributes.GetAttributeNode;
3938
import com.oracle.graal.python.nodes.attributes.GetAttributeNode.GetAnyAttributeNode;
4039
import com.oracle.graal.python.nodes.attributes.SetAttributeNode;
41-
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
4240
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
4341
import com.oracle.graal.python.nodes.subscript.GetItemNode;
4442
import com.oracle.graal.python.nodes.subscript.SetItemNode;
@@ -61,9 +59,8 @@ public class ImportStarNode extends AbstractImportNode {
6159

6260
@Child private SetItemNode dictWriteNode;
6361
@Child private SetAttributeNode.Dynamic setAttributeNode;
64-
@Child private LookupAndCallUnaryNode callLenNode;
6562
@Child private GetItemNode getItemNode;
66-
@Child private PythonObjectLibrary castToIndexNode;
63+
@Child private PythonObjectLibrary pythonLibrary;
6764
@Child private CastToJavaStringNode castToStringNode;
6865
@Child private GetAnyAttributeNode readNode;
6966
@Child private PRaiseNode raiseNode;
@@ -127,7 +124,7 @@ public void executeVoid(VirtualFrame frame) {
127124
} else {
128125
try {
129126
Object attrAll = readAttribute(frame, importedModule, SpecialAttributeNames.__ALL__);
130-
int n = ensureCastToIndexNode().asSizeWithState(ensureCallLenNode().executeObject(frame, attrAll), PArguments.getThreadState(frame));
127+
int n = ensurePythonLibrary().lengthWithState(attrAll, PArguments.getThreadState(frame));
131128
for (int i = 0; i < n; i++) {
132129
Object attrNameObj = ensureGetItemNode().executeWith(frame, attrAll, i);
133130
String attrName = ensureCastToStringNode().execute(attrNameObj);
@@ -155,20 +152,12 @@ public void executeVoid(VirtualFrame frame) {
155152
}
156153
}
157154

158-
private LookupAndCallUnaryNode ensureCallLenNode() {
159-
if (callLenNode == null) {
155+
private PythonObjectLibrary ensurePythonLibrary() {
156+
if (pythonLibrary == null) {
160157
CompilerDirectives.transferToInterpreterAndInvalidate();
161-
callLenNode = insert(LookupAndCallUnaryNode.create(SpecialMethodNames.__LEN__));
158+
pythonLibrary = insert(PythonObjectLibrary.getFactory().createDispatched(PythonOptions.getCallSiteInlineCacheMaxDepth()));
162159
}
163-
return callLenNode;
164-
}
165-
166-
private PythonObjectLibrary ensureCastToIndexNode() {
167-
if (castToIndexNode == null) {
168-
CompilerDirectives.transferToInterpreterAndInvalidate();
169-
castToIndexNode = insert(PythonObjectLibrary.getFactory().createDispatched(PythonOptions.getCallSiteInlineCacheMaxDepth()));
170-
}
171-
return castToIndexNode;
160+
return pythonLibrary;
172161
}
173162

174163
private GetItemNode ensureGetItemNode() {

0 commit comments

Comments
 (0)