use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class SLNodeFactory method startFunction.
public void startFunction(Token nameToken, int bodyStartPos) {
assert functionStartPos == 0;
assert functionName == null;
assert functionBodyStartPos == 0;
assert parameterCount == 0;
assert frameDescriptor == null;
assert lexicalScope == null;
functionStartPos = nameToken.charPos;
functionName = nameToken.val;
functionBodyStartPos = bodyStartPos;
frameDescriptor = new FrameDescriptor();
methodNodes = new ArrayList<>();
startBlock();
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class AssumptionPartialEvaluationTest method constantValue.
@Test
public void constantValue() {
Assumption assumption = Truffle.getRuntime().createAssumption();
AbstractTestNode result = new ConstantWithAssumptionTestNode(assumption, 42);
RootTestNode rootNode = new RootTestNode(new FrameDescriptor(), "constantValue", result);
OptimizedCallTarget callTarget = assertPartialEvalEquals("constant42", rootNode);
Assert.assertTrue(callTarget.isValid());
assertDeepEquals(42, callTarget.call());
Assert.assertTrue(callTarget.isValid());
try {
assumption.check();
} catch (InvalidAssumptionException e) {
Assert.fail("Assumption must not have been invalidated.");
}
assumption.invalidate();
try {
assumption.check();
Assert.fail("Assumption must have been invalidated.");
} catch (InvalidAssumptionException e) {
}
Assert.assertFalse(callTarget.isValid());
assertDeepEquals(43, callTarget.call());
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class DebuggerSessionSnippets method clearFrame.
private static void clearFrame(MaterializedFrame frame) {
FrameDescriptor descriptor = frame.getFrameDescriptor();
Object value = descriptor.getDefaultValue();
for (FrameSlot slot : descriptor.getSlots()) {
frame.setObject(slot, value);
}
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class ImplicitCastTest method testExecuteChildWithImplicitCast1.
@Test
public void testExecuteChildWithImplicitCast1() throws UnexpectedResultException {
ExecuteChildWithImplicitCast1Node node = ExecuteChildWithImplicitCast1NodeGen.create(createArguments(1));
/*
* if executeLong is used for the initial execution of the node and the uninitialized case
* is not checked then this executeLong method might return 0L instead of 2L. This test
* verifies that this particular case does not happen.
*/
Assert.assertEquals(2L, node.executeLong(Truffle.getRuntime().createVirtualFrame(new Object[] { 2L }, new FrameDescriptor())));
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class ReturnTypeSpecializationTest method test.
@Test
public void test() {
TruffleRuntime runtime = Truffle.getRuntime();
FrameDescriptor frameDescriptor = new FrameDescriptor();
FrameSlot slot = frameDescriptor.addFrameSlot("localVar", FrameSlotKind.Int);
TestRootNode rootNode = new TestRootNode(frameDescriptor, new IntAssignLocal(slot, new StringTestChildNode()), new IntReadLocal(slot));
CallTarget target = runtime.createCallTarget(rootNode);
Assert.assertEquals(FrameSlotKind.Int, slot.getKind());
Object result = target.call();
Assert.assertEquals("42", result);
Assert.assertEquals(FrameSlotKind.Object, slot.getKind());
}
Aggregations