Skip to content

Commit 119cfff

Browse files
committed
don't cache the concrete import function in a shared AST
1 parent 64f0182 commit 119cfff

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,18 @@
4545
import static com.oracle.graal.python.nodes.BuiltinNames.__IMPORT__;
4646

4747
import com.oracle.graal.python.builtins.objects.PNone;
48-
import com.oracle.graal.python.builtins.objects.function.PArguments;
4948
import com.oracle.graal.python.builtins.objects.function.PKeyword;
50-
import com.oracle.graal.python.builtins.objects.function.PythonCallable;
5149
import com.oracle.graal.python.builtins.objects.method.PMethod;
5250
import com.oracle.graal.python.builtins.objects.module.PythonModule;
53-
import com.oracle.graal.python.nodes.call.InvokeNode;
51+
import com.oracle.graal.python.nodes.call.CallNode;
5452
import com.oracle.graal.python.nodes.object.GetDictNode;
5553
import com.oracle.truffle.api.CompilerDirectives;
5654
import com.oracle.truffle.api.instrumentation.StandardTags;
5755
import com.oracle.truffle.api.instrumentation.Tag;
5856

5957
public abstract class AbstractImportNode extends StatementNode {
6058

61-
@Child private InvokeNode invokeNode;
59+
@Child private CallNode callNode;
6260
@Child private GetDictNode getDictNode;
6361

6462
public AbstractImportNode() {
@@ -69,12 +67,12 @@ protected Object importModule(String name) {
6967
return importModule(name, PNone.NONE, new String[0], 0);
7068
}
7169

72-
InvokeNode getInvokeNode(PythonCallable callable) {
73-
if (invokeNode == null) {
70+
CallNode getCallNode() {
71+
if (callNode == null) {
7472
CompilerDirectives.transferToInterpreterAndInvalidate();
75-
invokeNode = insert(InvokeNode.create(callable));
73+
callNode = insert(CallNode.create());
7674
}
77-
return invokeNode;
75+
return callNode;
7876
}
7977

8078
private GetDictNode getGetDictNode() {
@@ -98,11 +96,9 @@ protected Object importModule(String name, Object globals, String[] fromList, in
9896

9997
Object __import__(String name, Object globals, String[] fromList, int level) {
10098
PMethod builtinImport = (PMethod) getContext().getBuiltins().getAttribute(__IMPORT__);
101-
Object[] importArguments = PArguments.create(2);
102-
PArguments.setArgument(importArguments, 1, name);
10399
assert fromList != null;
104100
assert globals != null;
105-
return getInvokeNode(builtinImport).invoke(importArguments, new PKeyword[]{
101+
return getCallNode().execute(builtinImport, new Object[]{name}, new PKeyword[]{
106102
new PKeyword(GLOBALS, getGetDictNode().execute(globals)),
107103
new PKeyword(LOCALS, PNone.NONE), // the locals argument is ignored so it
108104
// can always be None

0 commit comments

Comments
 (0)