Skip to content

Commit 4f2f2c3

Browse files
committed
[GR-25654] [GR-33795] Migrate from createCallTarget() to getCallTarget().
PullRequest: graalpython/1985
2 parents 3e5a318 + 577f6a5 commit 4f2f2c3

File tree

10 files changed

+16
-28
lines changed

10 files changed

+16
-28
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/WithPythonContextRule.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import com.oracle.graal.python.test.PythonTests;
5252
import com.oracle.graal.python.util.Consumer;
5353
import com.oracle.truffle.api.RootCallTarget;
54-
import com.oracle.truffle.api.Truffle;
5554
import com.oracle.truffle.api.frame.VirtualFrame;
5655
import com.oracle.truffle.api.nodes.RootNode;
5756

@@ -90,7 +89,7 @@ public Statement apply(final Statement base, FrameworkMethod method, Object targ
9089
public void evaluate() throws Throwable {
9190
PythonTests.enterContext(getOptions(), new String[0]);
9291

93-
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new RootNode(null) {
92+
RootCallTarget callTarget = new RootNode(null) {
9493
@Override
9594
public Object execute(VirtualFrame frame) {
9695
pythonContext = PythonContext.get(this);
@@ -101,7 +100,7 @@ public Object execute(VirtualFrame frame) {
101100
}
102101
return null;
103102
}
104-
});
103+
}.getCallTarget();
105104
Throwable result = (Throwable) callTarget.call();
106105
PythonTests.closeContext();
107106
if (result != null) {

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/builtins/modules/ClinicTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import com.oracle.graal.python.runtime.exception.PException;
7171
import com.oracle.graal.python.test.PythonTests;
7272
import com.oracle.truffle.api.CallTarget;
73-
import com.oracle.truffle.api.Truffle;
7473
import com.oracle.truffle.api.dsl.Specialization;
7574
import com.oracle.truffle.api.frame.VirtualFrame;
7675
import com.oracle.truffle.api.nodes.RootNode;
@@ -179,7 +178,7 @@ public void testCustomConvertor() {
179178
}
180179

181180
private static CallTarget createCallTarget(PythonBinaryClinicBuiltinNode node) {
182-
return Truffle.getRuntime().createCallTarget(new BinaryBuiltinRoot(node));
181+
return new BinaryBuiltinRoot(node).getCallTarget();
183182
}
184183

185184
private static final class BinaryBuiltinRoot extends RootNode {

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/builtins/modules/ConversionNodeTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import com.oracle.graal.python.runtime.exception.PException;
5959
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
6060
import com.oracle.truffle.api.RootCallTarget;
61-
import com.oracle.truffle.api.Truffle;
6261
import com.oracle.truffle.api.frame.VirtualFrame;
6362

6463
public class ConversionNodeTests {
@@ -69,7 +68,7 @@ protected static Object call(Object arg, ArgumentCastNode castNode) {
6968
PythonLanguage language = PythonLanguage.get(castNode);
7069
final PythonContext pythonContext = PythonContext.get(castNode);
7170

72-
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new PRootNode(language) {
71+
RootCallTarget callTarget = new PRootNode(language) {
7372
@Child private CalleeContext calleeContext = CalleeContext.create();
7473
@Child private ArgumentCastNode node = castNode;
7574

@@ -95,7 +94,7 @@ public Signature getSignature() {
9594
public boolean isPythonInternal() {
9695
return true;
9796
}
98-
});
97+
}.getCallTarget();
9998
try {
10099
Object[] arguments = PArguments.create(1);
101100
PArguments.setGlobals(arguments, PythonObjectFactory.getUncached().createDict());

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNodeTests.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import com.oracle.graal.python.runtime.exception.PException;
4747
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
4848
import com.oracle.graal.python.test.PythonTests;
49-
import com.oracle.truffle.api.Truffle;
5049
import com.oracle.truffle.api.frame.VirtualFrame;
5150
import com.oracle.truffle.api.nodes.RootNode;
5251
import org.junit.After;
@@ -145,35 +144,35 @@ private static void expect(PythonBuiltinClassType errorType, Runnable test) {
145144
}
146145

147146
private static long castInt(int arg) {
148-
return (Long) Truffle.getRuntime().createCallTarget(new RootNode(null) {
147+
return (Long) new RootNode(null) {
149148
@Child private CastToJavaUnsignedLongNode castNode = CastToJavaUnsignedLongNode.create();
150149

151150
@Override
152151
public Object execute(VirtualFrame frame) {
153152
return castNode.execute(arg);
154153
}
155-
}).call();
154+
}.getCallTarget().call();
156155
}
157156

158157
private static long castLong(long arg) {
159-
return (Long) Truffle.getRuntime().createCallTarget(new RootNode(null) {
158+
return (Long) new RootNode(null) {
160159
@Child private CastToJavaUnsignedLongNode castNode = CastToJavaUnsignedLongNode.create();
161160

162161
@Override
163162
public Object execute(VirtualFrame frame) {
164163
return castNode.execute(arg);
165164
}
166-
}).call();
165+
}.getCallTarget().call();
167166
}
168167

169168
private static long castObject(Object arg) {
170-
return (Long) Truffle.getRuntime().createCallTarget(new RootNode(null) {
169+
return (Long) new RootNode(null) {
171170
@Child private CastToJavaUnsignedLongNode castNode = CastToJavaUnsignedLongNode.create();
172171

173172
@Override
174173
public Object execute(VirtualFrame frame) {
175174
return castNode.execute(arg);
176175
}
177-
}).call();
176+
}.getCallTarget().call();
178177
}
179178
}

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/PythonModuleTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import com.oracle.graal.python.nodes.call.CallNode;
4747
import com.oracle.graal.python.runtime.PythonContext;
4848
import com.oracle.graal.python.test.PythonTests;
49-
import com.oracle.truffle.api.Truffle;
5049
import com.oracle.truffle.api.frame.VirtualFrame;
5150
import com.oracle.truffle.api.nodes.RootNode;
5251

@@ -59,7 +58,7 @@ private static class PythonModuleTestRootNode extends RootNode {
5958
public PythonModuleTestRootNode(PythonLanguage language, CallNode body) {
6059
super(language);
6160
this.body = body;
62-
Truffle.getRuntime().createCallTarget(this);
61+
this.getCallTarget(); // Ensure call target is initialized
6362
}
6463

6564
@Override

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
*graalpython.lib-python.3.test.test_cmd_line.CmdLineTest.test_unmached_quote
1515
*graalpython.lib-python.3.test.test_cmd_line.CmdLineTest.test_usage
1616
*graalpython.lib-python.3.test.test_cmd_line.CmdLineTest.test_verbose
17-
*graalpython.lib-python.3.test.test_cmd_line.CmdLineTest.test_version
1817
*graalpython.lib-python.3.test.test_cmd_line.IgnoreEnvironmentTest.test_ignore_PYTHONPATH

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@
132132
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_cpu_count
133133
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_current
134134
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_daemon_argument
135-
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_error_on_stdio_flush_1
136-
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_error_on_stdio_flush_2
137135
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_forkserver_sigint
138136
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_forkserver_sigkill
139137
*graalpython.lib-python.3.test.test_multiprocessing_spawn.WithProcessesTestProcess.test_kill

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102

103103
@TruffleLanguage.Registration(id = PythonLanguage.ID, //
104104
name = PythonLanguage.NAME, //
105+
implementationName = PythonLanguage.IMPLEMENTATION_NAME, //
105106
version = PythonLanguage.VERSION, //
106107
characterMimeTypes = {PythonLanguage.MIME_TYPE,
107108
PythonLanguage.MIME_TYPE_COMPILE0, PythonLanguage.MIME_TYPE_COMPILE1, PythonLanguage.MIME_TYPE_COMPILE2,
@@ -126,6 +127,7 @@
126127
public final class PythonLanguage extends TruffleLanguage<PythonContext> {
127128
public static final String ID = "python";
128129
public static final String NAME = "Python";
130+
public static final String IMPLEMENTATION_NAME = "GraalVM Python";
129131
public static final int MAJOR = 3;
130132
public static final int MINOR = 8;
131133
public static final int MICRO = 5;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SortNodes.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
7272
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7373
import com.oracle.truffle.api.RootCallTarget;
74-
import com.oracle.truffle.api.Truffle;
7574
import com.oracle.truffle.api.TruffleLanguage;
7675
import com.oracle.truffle.api.dsl.Cached;
7776
import com.oracle.truffle.api.dsl.Fallback;
@@ -470,7 +469,7 @@ private RootCallTarget getComparatorCallTarget(PythonLanguage language) {
470469
* Every sort node should get its own copy to be able to optimize sorts of different
471470
* types. Don't put the call targets to the language cache.
472471
*/
473-
comparatorCallTarget = Truffle.getRuntime().createCallTarget(new ObjectComparatorRootNode(language));
472+
comparatorCallTarget = new ObjectComparatorRootNode(language).getCallTarget();
474473
}
475474
return comparatorCallTarget;
476475
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
import com.oracle.truffle.api.CompilerDirectives;
7474
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7575
import com.oracle.truffle.api.RootCallTarget;
76-
import com.oracle.truffle.api.Truffle;
7776
import com.oracle.truffle.api.dsl.NodeFactory;
7877
import com.oracle.truffle.api.memory.ByteArraySupport;
7978
import com.oracle.truffle.api.nodes.RootNode;
@@ -348,11 +347,7 @@ public static void dumpHeap(String path) {
348347
*/
349348
@TruffleBoundary
350349
public static RootCallTarget getOrCreateCallTarget(RootNode rootNode) {
351-
RootCallTarget ct = rootNode.getCallTarget();
352-
if (ct == null) {
353-
ct = Truffle.getRuntime().createCallTarget(rootNode);
354-
}
355-
return ct;
350+
return rootNode.getCallTarget();
356351
}
357352

358353
@TruffleBoundary

0 commit comments

Comments
 (0)