use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class TruffleDirectCallNodeTest method testCanBeClonedWithoutParent.
@Test
public void testCanBeClonedWithoutParent() {
final RootNode rootNode = new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
return 42;
}
@Override
public boolean isCloningAllowed() {
return true;
}
};
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final DirectCallNode callNode = Truffle.getRuntime().createDirectCallNode(callTarget);
assertTrue(callNode.isCallTargetCloningAllowed());
assertTrue(callNode.cloneCallTarget());
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class OptimizedOSRLoopNodeTest method testTwoLoopsSilblings.
/*
* Test that two silbling loops are compiled independently.
*/
@Theory
public void testTwoLoopsSilblings(OSRLoopFactory factory) {
TwoSilblingLoopNodesTest rootNode = new TwoSilblingLoopNodesTest(factory, new TestRepeatingNode(), new TestRepeatingNode());
CallTarget target = runtime.createCallTarget(rootNode);
target.call(OSR_THRESHOLD + 1, 1);
assertCompiled(rootNode.getOSRTarget());
assertNotCompiled(rootNode.getOSRTarget2());
target.call(1, OSR_THRESHOLD + 1);
assertCompiled(rootNode.getOSRTarget());
assertCompiled(rootNode.getOSRTarget2());
Assert.assertTrue(rootNode.getOSRTarget() != rootNode.getOSRTarget2());
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class OptimizedOSRLoopNodeTest method testTransferToInterpreter.
/*
* Test that calling CompilerDirectives.transferToInterpreter does not invalidate the target.
*/
@Test
public void testTransferToInterpreter() {
OSRLoopFactory factory = CONFIGURED;
class TransferToInterpreterTestRepeatingNode extends TestRepeatingNode {
@Override
public boolean executeRepeating(VirtualFrame frame) {
try {
if (CompilerDirectives.inCompiledCode()) {
CompilerDirectives.transferToInterpreter();
}
int counter = frame.getInt(param1);
frame.setInt(param1, counter - 1);
return counter != 0;
} catch (FrameSlotTypeException e) {
return false;
}
}
}
TestRootNode rootNode = new TestRootNode(factory, new TransferToInterpreterTestRepeatingNode());
CallTarget target = runtime.createCallTarget(rootNode);
target.call(OSR_THRESHOLD + 1);
try {
// Invalidation is asynchronous.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
Assert.assertNotNull(rootNode.getOSRTarget());
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class PartialEvaluationTest method assertPartialEvalNoInvokes.
protected void assertPartialEvalNoInvokes(RootNode root, Object[] arguments) {
CallTarget callTarget = Truffle.getRuntime().createCallTarget(root);
assertPartialEvalNoInvokes(callTarget, arguments);
}
use of com.oracle.truffle.api.CallTarget in project sulong by graalvm.
the class InteropTestBase method loadTestBitcodeInternal.
protected static TruffleObject loadTestBitcodeInternal(String name) {
File dir = new File(testBase, name);
File file = new File(dir, "O0_MEM2REG.bc");
Source source;
try {
source = Source.newBuilder(file).language("llvm").build();
} catch (IOException ex) {
throw new AssertionError(ex);
}
CallTarget target = runWithPolyglot.getTruffleTestEnv().parse(source);
return (TruffleObject) target.call();
}
Aggregations