use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class CompilationFinalWeakReferencePartialEvaluationTest method compilationFinalWeakReferenceTestGC.
/**
* {@link WeakReference} constant-folded and embedded in compiled code.
*/
@Test
public void compilationFinalWeakReferenceTestGC() {
String name = "compilationFinalWeakReferenceTestGC";
FrameDescriptor fd = new FrameDescriptor();
IntSupplier data = generateTestData();
AbstractTestNode result = new CompilationFinalWeakReferenceTestGCNode(data);
RootTestNode rootNode = new RootTestNode(fd, name, result);
OptimizedCallTarget callTarget = compileHelper(name, rootNode, new Object[] { data });
Assert.assertEquals(42, (int) callTarget.call(new Object[] { data }));
Assert.assertEquals(-1, (int) callTarget.call(new Object[] { null }));
callTarget = compileHelper(name, rootNode, new Object[] { data });
assertTrue(callTarget.isValid());
assert data != null;
clearDebugScopeTL();
WeakReference<IntSupplier> witness = new WeakReference<>(data);
data = null;
boolean cleared = false;
for (int i = 1; i <= 5 && !cleared; i++) {
System.gc();
cleared = witness.get() == null;
}
assertTrue("Test data should have been garbage collected at this point", cleared);
// Compiled code had the collected reference embedded so it had to be invalidated
assertFalse(callTarget.isValid());
Assert.assertEquals(0xdead, (int) callTarget.call(new Object[] { null }));
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class SLCallUntilOptimizedBuiltin method callUntilCompiled.
@Specialization
public SLFunction callUntilCompiled(SLFunction function, boolean checkTarget) {
OptimizedCallTarget target = ((OptimizedCallTarget) function.getCallTarget());
for (int i = 0; i < MAX_CALLS; i++) {
if (isCompiling(target)) {
break;
} else {
indirectCall.call(target, EMPTY_ARGS);
}
}
// call one more in compiled
indirectCall.call(target, EMPTY_ARGS);
if (checkTarget) {
checkTarget(target);
}
return function;
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class SLCallWithOptionOverrideBuiltin method callWithOptionOverride.
@Specialization
public SLFunction callWithOptionOverride(SLFunction function, String name, Object value) {
TruffleOptionsOverrideScope scope = override(name, value);
OptimizedCallTarget target = ((OptimizedCallTarget) function.getCallTarget());
indirectCall.call(target, EMPTY_ARGS);
close(scope);
return function;
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class SLWaitForOptimizationBuiltin method waitForOptimization.
@Specialization
public SLFunction waitForOptimization(SLFunction function, long timeout) {
OptimizedCallTarget target = (OptimizedCallTarget) function.getCallTarget();
GraalTruffleRuntime runtime = ((GraalTruffleRuntime) Truffle.getRuntime());
try {
runtime.waitForCompilation(target, timeout);
} catch (ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
return function;
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class TraceSplittingListener method onCompilationSplit.
@Override
public void onCompilationSplit(OptimizedDirectCallNode callNode) {
OptimizedCallTarget callTarget = callNode.getCallTarget();
String label = String.format("split %3s-%-4s-%-4s ", splitCount++, Integer.toHexString(callNode.getCurrentCallTarget().hashCode()), callNode.getCallCount());
final Map<String, Object> debugProperties = callTarget.getDebugProperties(null);
debugProperties.put("SourceSection", extractSourceSection(callNode));
TruffleCompilerRuntime.getRuntime().logEvent(0, label, callTarget.toString(), debugProperties);
}
Aggregations