use of com.oracle.truffle.api.frame.VirtualFrame in project TrufflePascal by Aspect26.
the class PascalState method createUnitFrame.
public VirtualFrame createUnitFrame(String unitIdentifier, FrameDescriptor frameDescriptor) {
VirtualFrame unitFrame = Truffle.getRuntime().createVirtualFrame(new Object[0], frameDescriptor);
this.unitFrames.put(unitIdentifier, unitFrame);
return unitFrame;
}
use of com.oracle.truffle.api.frame.VirtualFrame in project graal by oracle.
the class EnumPartialEvaluationTest method enumValuesConstant.
@Ignore("Currently only works if compiled with ecj")
@Test
public void enumValuesConstant() {
AbstractTestNode result = new AbstractTestNode() {
@Override
public int execute(VirtualFrame frame) {
return TestEnum.values()[0].ordinal();
}
};
assertPartialEvalEquals("constant0", new RootTestNode(new FrameDescriptor(), "enumValuesConstant", result));
}
use of com.oracle.truffle.api.frame.VirtualFrame in project graal by oracle.
the class EnumPartialEvaluationTest method enumOrdinalConstant.
@Test
public void enumOrdinalConstant() {
AbstractTestNode result = new AbstractTestNode() {
@Override
public int execute(VirtualFrame frame) {
return TestEnum.Test0.ordinal();
}
};
assertPartialEvalEquals("constant0", new RootTestNode(new FrameDescriptor(), "enumOrdinalConstant", result));
}
use of com.oracle.truffle.api.frame.VirtualFrame in project graal by oracle.
the class ExperimentalSplittingStrategyTest method testNoSplitsDirectCallsBecauseFirstExecution.
@Test
public void testNoSplitsDirectCallsBecauseFirstExecution() {
final OptimizedCallTarget callTarget = (OptimizedCallTarget) runtime.createCallTarget(new SplittableRootNode() {
@Child
private OptimizedDirectCallNode callNode = (OptimizedDirectCallNode) runtime.createDirectCallNode(runtime.createCallTarget(new SplittingTestRootNode(ExperimentalSplittingStrategyTestFactory.TurnsPolymorphicOnZeroNodeGen.create(new ReturnsArgumentNode()))));
@Override
public Object execute(VirtualFrame frame) {
final Object[] first = { 1 };
callNode.call(first);
callNode.call(first);
// This call turns the node polymorphic
final Object[] second = { 0 };
callNode.call(second);
return null;
}
});
// Multiple call nodes
runtime.createDirectCallNode(callTarget);
runtime.createDirectCallNode(callTarget);
final DirectCallNode directCallNode = runtime.createDirectCallNode(callTarget);
directCallNode.call(new Object[] { 0 });
Assert.assertFalse("Target needs split after first execution", getNeedsSplit(callTarget));
}
use of com.oracle.truffle.api.frame.VirtualFrame in project graal by oracle.
the class OptimizedCallTargetTest method testCompilationHeuristics.
/*
* GR-1328
*/
@Test
@Ignore("Fails non deterministically")
public void testCompilationHeuristics() {
testInvalidationCounterCompiled = 0;
testInvalidationCounterInterpreted = 0;
doInvalidate = false;
OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
if (CompilerDirectives.inInterpreter()) {
testInvalidationCounterInterpreted++;
} else {
testInvalidationCounterCompiled++;
}
// doInvalidate needs to be volatile otherwise it floats up.
if (doInvalidate) {
CompilerDirectives.transferToInterpreterAndInvalidate();
}
return null;
}
});
final int compilationThreshold = TruffleCompilerOptions.getValue(TruffleCompilationThreshold);
final int reprofileCount = TruffleCompilerOptions.getValue(TruffleReplaceReprofileCount);
assertTrue(compilationThreshold >= 2);
int expectedCompiledCount = 0;
int expectedInterpreterCount = 0;
for (int i = 0; i < compilationThreshold; i++) {
assertNotCompiled(target);
target.call();
}
assertCompiled(target);
expectedInterpreterCount += compilationThreshold;
assertEquals(expectedCompiledCount, testInvalidationCounterCompiled);
assertEquals(expectedInterpreterCount, testInvalidationCounterInterpreted);
for (int j = 1; j < 100; j++) {
target.invalidate(this, "test");
for (int i = 0; i < reprofileCount; i++) {
assertNotCompiled(target);
target.call();
}
assertCompiled(target);
expectedInterpreterCount += reprofileCount;
assertEquals(expectedCompiledCount, testInvalidationCounterCompiled);
assertEquals(expectedInterpreterCount, testInvalidationCounterInterpreted);
doInvalidate = true;
expectedCompiledCount++;
target.call();
assertNotCompiled(target);
doInvalidate = false;
assertEquals(expectedCompiledCount, testInvalidationCounterCompiled);
assertEquals(expectedInterpreterCount, testInvalidationCounterInterpreted);
for (int i = 0; i < reprofileCount; i++) {
assertNotCompiled(target);
target.call();
}
assertCompiled(target);
expectedInterpreterCount += reprofileCount;
assertEquals(expectedCompiledCount, testInvalidationCounterCompiled);
assertEquals(expectedInterpreterCount, testInvalidationCounterInterpreted);
for (int i = 0; i < compilationThreshold; i++) {
assertCompiled(target);
target.call();
}
assertCompiled(target);
expectedCompiledCount += compilationThreshold;
assertEquals(expectedCompiledCount, testInvalidationCounterCompiled);
assertEquals(expectedInterpreterCount, testInvalidationCounterInterpreted);
}
}
Aggregations