Skip to content

Commit f677494

Browse files
committed
[GR-21590] Update imports.
PullRequest: graalpython/1943
2 parents f7f7ff5 + 133c7df commit f677494

File tree

18 files changed

+120
-78
lines changed

18 files changed

+120
-78
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "244bde9b3ec269919dfcd2776ac4cb767ec2b468" }
1+
{ "overlay": "61fd7e543d7aec3ee0f034e1405fe587056ee001" }

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_calendar.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*graalpython.lib-python.3.test.test_calendar.CommandLineTestCase.test_option_spacing
2222
*graalpython.lib-python.3.test.test_calendar.CommandLineTestCase.test_option_type
2323
*graalpython.lib-python.3.test.test_calendar.CommandLineTestCase.test_option_width
24+
*graalpython.lib-python.3.test.test_calendar.CommandLineTestCase.test_output_current_year
25+
*graalpython.lib-python.3.test.test_calendar.CommandLineTestCase.test_output_month
26+
*graalpython.lib-python.3.test.test_calendar.CommandLineTestCase.test_output_year
2427
*graalpython.lib-python.3.test.test_calendar.LeapdaysTestCase.test_no_leapdays
2528
*graalpython.lib-python.3.test.test_calendar.LeapdaysTestCase.test_no_leapdays_upper_boundary
2629
*graalpython.lib-python.3.test.test_calendar.LeapdaysTestCase.test_no_range

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_pickletools.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
*graalpython.lib-python.3.test.test_pickletools.OptimizedPickleTests.test_structseq
9090
*graalpython.lib-python.3.test.test_pickletools.OptimizedPickleTests.test_unicode
9191
*graalpython.lib-python.3.test.test_pickletools.OptimizedPickleTests.test_unicode_high_plane
92+
*graalpython.lib-python.3.test.test_pickletools.TestMain.test_main
9293
*test.pickletester.AbstractPickleTests.test_attribute_name_interning
9394
*test.pickletester.AbstractPickleTests.test_buffer_callback_error
9495
*test.pickletester.AbstractPickleTests.test_buffers_error

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_smtplib.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
*graalpython.lib-python.3.test.test_smtplib.NonConnectingTests.testNotConnected
2424
*graalpython.lib-python.3.test.test_smtplib.NonConnectingTests.testSockAttributeExists
2525
*graalpython.lib-python.3.test.test_smtplib.SMTPAUTHInitialResponseSimTests.testAUTH_PLAIN_initial_response_auth
26+
*graalpython.lib-python.3.test.test_smtplib.SMTPSimTests.testBasic
27+
*graalpython.lib-python.3.test.test_smtplib.SMTPSimTests.testEXPN
2628
*graalpython.lib-python.3.test.test_smtplib.TooLongLineTests.testLineTooLong

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
import com.oracle.graal.python.nodes.ErrorMessages;
9090
import com.oracle.graal.python.nodes.argument.ReadIndexedArgumentNode;
9191
import com.oracle.graal.python.nodes.argument.ReadVarArgsNode;
92+
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode;
9293
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetSignatureNode;
9394
import com.oracle.graal.python.nodes.call.CallNode;
9495
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
@@ -479,15 +480,13 @@ public abstract static class DumpTruffleAstNode extends PythonUnaryBuiltinNode {
479480
@Specialization
480481
@TruffleBoundary
481482
public String doIt(PFunction func) {
482-
return NodeUtil.printTreeToString(func.getCallTargetUncached().getRootNode());
483+
return NodeUtil.printTreeToString(GetCallTargetNode.getUncached().execute(func).getRootNode());
483484
}
484485

485486
@Specialization(guards = "isFunction(method.getFunction())")
486487
@TruffleBoundary
487488
public String doIt(PMethod method) {
488-
// cast ensured by guard
489-
PFunction fun = (PFunction) method.getFunction();
490-
return NodeUtil.printTreeToString(fun.getCallTargetUncached().getRootNode());
489+
return NodeUtil.printTreeToString(GetCallTargetNode.getUncached().execute(method).getRootNode());
491490
}
492491

493492
@Specialization

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
import com.oracle.graal.python.nodes.attributes.WriteAttributeToDynamicObjectNode;
230230
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
231231
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetSignatureNode;
232+
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode;
232233
import com.oracle.graal.python.nodes.call.CallNode;
233234
import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
234235
import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
@@ -1875,7 +1876,7 @@ abstract static class MakeMayRaiseWrapperNode extends PythonBuiltinNode {
18751876
@Specialization
18761877
@TruffleBoundary
18771878
Object make(PFunction func, Object errorResultObj) {
1878-
RootCallTarget originalCallTarget = func.getCallTargetUncached();
1879+
RootCallTarget originalCallTarget = GetCallTargetNode.getUncached().execute(func);
18791880

18801881
// Replace the first expression node with the MayRaiseNode
18811882
RootCallTarget wrapperCallTarget = getLanguage().createCachedCallTarget(

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PFunction.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
3636
import com.oracle.graal.python.nodes.PRootNode;
3737
import com.oracle.graal.python.nodes.argument.positional.PositionalArgumentsNode;
38+
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode;
3839
import com.oracle.graal.python.nodes.call.CallNode;
3940
import com.oracle.graal.python.nodes.generator.GeneratorFunctionRootNode;
4041
import com.oracle.graal.python.runtime.GilNode;
@@ -43,7 +44,6 @@
4344
import com.oracle.truffle.api.CompilerAsserts;
4445
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
4546
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
46-
import com.oracle.truffle.api.RootCallTarget;
4747
import com.oracle.truffle.api.Truffle;
4848
import com.oracle.truffle.api.dsl.Cached;
4949
import com.oracle.truffle.api.dsl.Cached.Shared;
@@ -95,13 +95,6 @@ public PFunction(PythonLanguage lang, String name, String qualname, String enclo
9595
this.defaultsStableAssumption = defaultsStableAssumption;
9696
}
9797

98-
/**
99-
* Prefer to use a cached CodeNodes.GetCodeCallTargetNode on the fast path.
100-
*/
101-
public RootCallTarget getCallTargetUncached() {
102-
return GetCodeCallTargetNode.getUncached().execute(code);
103-
}
104-
10598
public Assumption getCodeStableAssumption() {
10699
return codeStableAssumption;
107100
}
@@ -177,7 +170,7 @@ public void setKwDefaults(PKeyword[] defaults) {
177170

178171
@TruffleBoundary
179172
String getSourceCode() {
180-
RootNode rootNode = getCallTargetUncached().getRootNode();
173+
RootNode rootNode = GetCallTargetNode.getUncached().execute(this).getRootNode();
181174
if (rootNode instanceof GeneratorFunctionRootNode) {
182175
rootNode = ((GeneratorFunctionRootNode) rootNode).getFunctionRootNode();
183176
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/CreateArgumentsNode.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.FindKwDefaultNodeGen;
6969
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.HandleTooManyArgumentsNodeGen;
7070
import com.oracle.graal.python.nodes.argument.CreateArgumentsNodeGen.ApplyKeywordsNodeGen.SearchNamedParameterNodeGen;
71+
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode;
7172
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetDefaultsNode;
7273
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetKeywordDefaultsNode;
7374
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetSignatureNode;
@@ -172,9 +173,10 @@ Object[] doFunctionCached(PythonObject callable, Object[] userArguments, PKeywor
172173
return createAndCheckArgumentsNode.execute(callable, userArguments, keywords, signature, null, defaults, kwdefaults, false);
173174
}
174175

175-
@Specialization(guards = {"getCallTarget(callable) == cachedCallTarget", "cachedCallTarget != null"}, limit = "getVariableArgumentInlineCacheLimit()", replaces = {"doMethodFunctionCached",
176+
@Specialization(guards = {"getCt.execute(callable) == cachedCallTarget", "cachedCallTarget != null"}, limit = "getVariableArgumentInlineCacheLimit()", replaces = {"doMethodFunctionCached",
176177
"doFunctionCached"})
177178
Object[] doCallTargetCached(PythonObject callable, Object[] userArguments, PKeyword[] keywords,
179+
@SuppressWarnings("unused") @Cached GetCallTargetNode getCt,
178180
@Cached CreateAndCheckArgumentsNode createAndCheckArgumentsNode,
179181
@SuppressWarnings("unused") @Cached GetSignatureNode getSignatureNode,
180182
@Cached("getSignatureNode.execute(callable)") Signature signature, // signatures
@@ -185,7 +187,7 @@ Object[] doCallTargetCached(PythonObject callable, Object[] userArguments, PKeyw
185187
@Cached ConditionProfile gotMethod,
186188
@Cached GetDefaultsNode getDefaultsNode,
187189
@Cached GetKeywordDefaultsNode getKwDefaultsNode,
188-
@Cached("getCallTarget(callable)") @SuppressWarnings("unused") RootCallTarget cachedCallTarget) {
190+
@Cached("getCt.execute(callable)") @SuppressWarnings("unused") RootCallTarget cachedCallTarget) {
189191
Object[] defaults = getDefaultsNode.execute(callable);
190192
PKeyword[] kwdefaults = getKwDefaultsNode.execute(callable);
191193
Object self = null;
@@ -944,24 +946,6 @@ protected static Object getFunction(Object callable) {
944946
return null;
945947
}
946948

947-
protected static RootCallTarget getCallTarget(Object callable) {
948-
if (callable instanceof PBuiltinMethod) {
949-
return ((PBuiltinMethod) callable).getFunction().getCallTarget();
950-
} else if (callable instanceof PMethod) {
951-
Object function = ((PMethod) callable).getFunction();
952-
if (function instanceof PBuiltinFunction) {
953-
return ((PBuiltinFunction) function).getCallTarget();
954-
} else if (function instanceof PFunction) {
955-
return ((PFunction) function).getCallTargetUncached();
956-
}
957-
} else if (callable instanceof PBuiltinFunction) {
958-
return ((PBuiltinFunction) callable).getCallTarget();
959-
} else if (callable instanceof PFunction) {
960-
return ((PFunction) callable).getCallTargetUncached();
961-
}
962-
return null;
963-
}
964-
965949
protected static boolean isMethodCall(Object self) {
966950
return !(self instanceof PythonModule);
967951
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/FunctionNodes.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@
5353
import com.oracle.graal.python.nodes.builtins.FunctionNodesFactory.GetDefaultsNodeGen;
5454
import com.oracle.graal.python.nodes.builtins.FunctionNodesFactory.GetKeywordDefaultsNodeGen;
5555
import com.oracle.graal.python.nodes.builtins.FunctionNodesFactory.GetSignatureNodeGen;
56+
import com.oracle.graal.python.nodes.builtins.FunctionNodesFactory.GetCallTargetNodeGen;
5657
import com.oracle.truffle.api.Assumption;
58+
import com.oracle.truffle.api.RootCallTarget;
5759
import com.oracle.truffle.api.dsl.Bind;
5860
import com.oracle.truffle.api.dsl.Cached;
5961
import com.oracle.truffle.api.dsl.Cached.Shared;
62+
import com.oracle.truffle.api.dsl.Fallback;
6063
import com.oracle.truffle.api.dsl.GenerateUncached;
6164
import com.oracle.truffle.api.dsl.ImportStatic;
6265
import com.oracle.truffle.api.dsl.Specialization;
@@ -244,4 +247,51 @@ public static GetSignatureNode getUncached() {
244247
return GetSignatureNodeGen.getUncached();
245248
}
246249
}
250+
251+
@ImportStatic(PGuards.class)
252+
@GenerateUncached
253+
public abstract static class GetCallTargetNode extends PNodeWithContext {
254+
255+
public abstract RootCallTarget execute(Object function);
256+
257+
@Specialization
258+
static RootCallTarget doFunction(PFunction function,
259+
@Shared("getCode") @Cached GetFunctionCodeNode getFunctionCodeNode,
260+
@Shared("getCt") @Cached CodeNodes.GetCodeCallTargetNode getCt) {
261+
return getCt.execute(getFunctionCodeNode.execute(function));
262+
}
263+
264+
@Specialization
265+
static RootCallTarget doBuiltinFunction(PBuiltinFunction builtinFunction) {
266+
return builtinFunction.getCallTarget();
267+
}
268+
269+
@Specialization(guards = "isPFunction(function)")
270+
static RootCallTarget doMethod(@SuppressWarnings("unused") PMethod method,
271+
@Bind("method.getFunction()") Object function,
272+
@Shared("getCode") @Cached GetFunctionCodeNode getFunctionCodeNode,
273+
@Shared("getCt") @Cached CodeNodes.GetCodeCallTargetNode getCt) {
274+
return getCt.execute(getFunctionCodeNode.execute((PFunction) function));
275+
}
276+
277+
@Specialization(guards = "isPBuiltinFunction(method.getFunction())")
278+
static RootCallTarget doMethod(@SuppressWarnings("unused") PMethod method,
279+
@Bind("method.getFunction()") Object function) {
280+
return ((PBuiltinFunction) function).getCallTarget();
281+
}
282+
283+
@Specialization
284+
static RootCallTarget doBuiltinMethod(PBuiltinMethod builtinMethod) {
285+
return builtinMethod.getFunction().getCallTarget();
286+
}
287+
288+
@Fallback
289+
static RootCallTarget fallback(@SuppressWarnings("unused") Object callable) {
290+
return null;
291+
}
292+
293+
public static GetCallTargetNode getUncached() {
294+
return GetCallTargetNodeGen.getUncached();
295+
}
296+
}
247297
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallDispatchNode.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
3232
import com.oracle.graal.python.builtins.objects.function.PFunction;
3333
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetFunctionCodeNode;
34+
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode;
3435
import com.oracle.graal.python.runtime.PythonOptions;
3536
import com.oracle.truffle.api.Assumption;
37+
import com.oracle.truffle.api.CompilerAsserts;
3638
import com.oracle.truffle.api.RootCallTarget;
3739
import com.oracle.truffle.api.dsl.Cached;
3840
import com.oracle.truffle.api.dsl.GenerateUncached;
@@ -110,10 +112,15 @@ protected Object callFunctionCachedCode(VirtualFrame frame, @SuppressWarnings("u
110112
return invoke.execute(frame, arguments);
111113
}
112114

115+
protected static RootCallTarget getCallTargetUncached(PFunction callee) {
116+
CompilerAsserts.neverPartOfCompilation();
117+
return GetCallTargetNode.getUncached().execute(callee);
118+
}
119+
113120
// We have multiple contexts, don't cache the objects so that contexts can be cleaned up
114121
@Specialization(guards = {"getCt.execute(callee.getCode()) == ct"}, limit = "getCallSiteInlineCacheMaxDepth()", replaces = "callFunctionCachedCode")
115122
protected Object callFunctionCachedCt(VirtualFrame frame, PFunction callee, Object[] arguments,
116-
@SuppressWarnings("unused") @Cached("callee.getCallTargetUncached()") RootCallTarget ct,
123+
@SuppressWarnings("unused") @Cached("getCallTargetUncached(callee)") RootCallTarget ct,
117124
@SuppressWarnings("unused") @Cached GetCodeCallTargetNode getCt,
118125
@Cached("createCtInvokeNode(callee)") CallTargetInvokeNode invoke) {
119126
return invoke.execute(frame, callee, callee.getGlobals(), callee.getClosure(), arguments);

0 commit comments

Comments
 (0)