Skip to content

Commit

Permalink
[GR-25654] Migrate from createCallTarget() to getCallTarget().
Browse files Browse the repository at this point in the history
PullRequest: graal/9887
  • Loading branch information
fniephaus committed Sep 30, 2021
2 parents d465c58 + ad460e2 commit f49b9d1
Show file tree
Hide file tree
Showing 235 changed files with 971 additions and 1,223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected GraalTestContext createTestContext(String testName) {

@Override
public OptimizedCallTarget createTestCallTarget(GraalTestContext testContext, RootNode testNode) {
OptimizedCallTarget target = (OptimizedCallTarget) truffleRuntime.createCallTarget(testNode);
OptimizedCallTarget target = (OptimizedCallTarget) testNode.getCallTarget();
testContext.init(target);
return target;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public static final class PartialBlocks<T extends Node> {
PartialBlockRootNode<T> partialRootNode = new PartialBlockRootNode<>(new FrameDescriptor(), block, startIndex, endIndex, blockIndex);
GraalRuntimeAccessor.NODES.applyPolyglotEngine(rootNode, partialRootNode);

targets[i] = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(partialRootNode);
targets[i] = (OptimizedCallTarget) partialRootNode.getCallTarget();
targets[i].setNonTrivialNodeCount(blockSizes[i]);
// we know the parameter types for block compilations. No need to check, lets cast
// them unsafely.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.junit.Test;

import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.RootNode;
Expand Down Expand Up @@ -89,7 +88,7 @@ public void byteBufferHandleSet() {
private void testCommon(AbstractTestNode testNode, String testName, Object... args) {
FrameDescriptor fd = new FrameDescriptor();
RootNode rootNode = new RootTestNode(fd, testName, testNode);
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
RootCallTarget callTarget = rootNode.getCallTarget();
Assert.assertEquals(42, callTarget.call(args));
assertPartialEvalNoInvokes(callTarget, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
import org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime;
import org.graalvm.compiler.truffle.runtime.OptimizedCallTarget;
import org.graalvm.polyglot.Context;
import org.junit.Test;
Expand Down Expand Up @@ -115,7 +114,7 @@ private TestRootNode setup(BaseNode node, Object receiver) {
context.initialize(ProxyLanguage.ID);
context.enter();
TestRootNode root = new TestRootNode(TestLanguage.getCurrentLanguage(), node, receiver);
GraalTruffleRuntime.getRuntime().createCallTarget(root);
root.getCallTarget();
context.leave();
return root;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected static void reflectivelySetField(Object o, String fieldName, Object va

protected static void createDummyTargetsToBoostGrowingSplitLimit() {
for (int i = 0; i < 10; i++) {
runtime.createCallTarget(new DummyRootNode());
new DummyRootNode().getCallTarget();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ public boolean hasNextTier() {
return request.graph;
}

protected final OptimizedCallTarget createDummyNode() {
return (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
protected static final OptimizedCallTarget createDummyNode() {
return (OptimizedCallTarget) new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
return null;
}
});
}.getCallTarget();
}

protected class CallsInnerNodeTwice extends RootNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime;
import org.graalvm.compiler.truffle.runtime.OptimizedCallTarget;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.PolyglotAccess;
import org.junit.Test;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrumentation.AllocationEvent;
Expand All @@ -52,8 +50,6 @@
*/
public class AllocationReporterPartialEvaluationTest extends TestWithSynchronousCompiling {

private static final GraalTruffleRuntime runtime = (GraalTruffleRuntime) Truffle.getRuntime();

@Test
public void testConsistentAssertions() {
// Test that onEnter()/onReturnValue() are not broken
Expand All @@ -64,20 +60,20 @@ public void testConsistentAssertions() {
assertNotNull(tester);
final AllocationReporter reporter = (AllocationReporter) context.getPolyglotBindings().getMember(AllocationReporter.class.getSimpleName()).asHostObject();
final Long[] value = new Long[]{1L};
OptimizedCallTarget enterTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
OptimizedCallTarget enterTarget = (OptimizedCallTarget) new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
reporter.onEnter(value[0], 4, 8);
return null;
}
});
OptimizedCallTarget returnTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
}.getCallTarget();
OptimizedCallTarget returnTarget = (OptimizedCallTarget) new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
reporter.onReturnValue(value[0], 4, 8);
return null;
}
});
}.getCallTarget();

// Interpret both:
assertNotCompiled(enterTarget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
*/
package org.graalvm.compiler.truffle.test;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.utilities.AssumedValue;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.truffle.runtime.OptimizedCallTarget;
import org.graalvm.compiler.truffle.test.nodes.AbstractTestNode;
import org.graalvm.compiler.truffle.test.nodes.RootTestNode;
import org.junit.Assert;
import org.junit.Test;

import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.utilities.AssumedValue;

public class AssumedValuePartialEvaluationTest extends PartialEvaluationTest {

public static Object constant42() {
Expand Down Expand Up @@ -73,7 +73,7 @@ public void testDynamic() {
AssumedValue<Integer> value = new AssumedValue<>(42);

RootTestNode root = new RootTestNode(new FrameDescriptor(), "assumedValue", new ReadDynamicAssumedValueNode());
OptimizedCallTarget target = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(root);
OptimizedCallTarget target = (OptimizedCallTarget) root.getCallTarget();

StructuredGraph graph = partialEval(target, new Object[]{value});
compile(target, graph);
Expand All @@ -87,7 +87,7 @@ public void testDynamicNoDeopt() {
AssumedValue<Integer> value = new AssumedValue<>(42);

RootTestNode root = new RootTestNode(new FrameDescriptor(), "assumedValue", new ReadDynamicAssumedValueNode());
OptimizedCallTarget target = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(root);
OptimizedCallTarget target = (OptimizedCallTarget) root.getCallTarget();

StructuredGraph graph = partialEval(target, new Object[]{value});
compile(target, graph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.FrameSlotKind;
Expand Down Expand Up @@ -257,7 +256,7 @@ public static Object constant42() {
}

private static void assertReturns42(RootNode program) {
Object result = Truffle.getRuntime().createCallTarget(program).call();
Object result = program.getCallTarget().call();
Assert.assertEquals(Integer.valueOf(42), result);
}

Expand Down
Loading

0 comments on commit f49b9d1

Please sign in to comment.