use of org.graalvm.compiler.options.OptionValues in project graal by oracle.
the class TypedNodeIteratorTest method iteratorBehaviorTest.
@Test
public void iteratorBehaviorTest() {
OptionValues options = getOptions();
Graph graph = new Graph(options, getDebug(options));
graph.add(new TestNode("a"));
Iterator<TestNode> iterator = graph.getNodes(TestNode.TYPE).iterator();
assertTrue(iterator.hasNext());
assertEquals("a", iterator.next().getName());
assertFalse(iterator.hasNext());
graph.add(new TestNode("b"));
assertTrue(iterator.hasNext());
assertEquals("b", iterator.next().getName());
assertFalse(iterator.hasNext());
TestNode c = new TestNode("c");
graph.add(c);
assertTrue(iterator.hasNext());
c.safeDelete();
assertFalse(iterator.hasNext());
}
use of org.graalvm.compiler.options.OptionValues in project graal by oracle.
the class TypedNodeIteratorTest method deletingNodeTest.
@Test
public void deletingNodeTest() {
TestNode testNode = new TestNode("a");
OptionValues options = getOptions();
Graph graph = new Graph(options, getDebug(options));
graph.add(testNode);
testNode.safeDelete();
assertEquals("", toString(graph.getNodes(TestNode.TYPE)));
}
use of org.graalvm.compiler.options.OptionValues in project graal by oracle.
the class GraalTruffleRuntime method submitForCompilation.
@SuppressWarnings("try")
public CancellableCompileTask submitForCompilation(OptimizedCallTarget optimizedCallTarget) {
BackgroundCompileQueue l = getCompileQueue();
final WeakReference<OptimizedCallTarget> weakCallTarget = new WeakReference<>(optimizedCallTarget);
final OptionValues optionOverrides = TruffleCompilerOptions.getCurrentOptionOverrides();
CancellableCompileTask cancellable = new CancellableCompileTask();
cancellable.setFuture(l.compileQueue.submit(new Runnable() {
@Override
public void run() {
OptimizedCallTarget callTarget = weakCallTarget.get();
if (callTarget != null) {
try (TruffleOptionsOverrideScope scope = optionOverrides != null ? overrideOptions(optionOverrides.getMap()) : null) {
OptionValues options = TruffleCompilerOptions.getOptions();
doCompile(options, callTarget, cancellable);
} finally {
callTarget.resetCompilationTask();
}
}
}
}));
// task and future must never diverge from each other
assert cancellable.future != null;
return cancellable;
}
use of org.graalvm.compiler.options.OptionValues in project graal by oracle.
the class AOTInliningPolicy method isWorthInlining.
@Override
public boolean isWorthInlining(Replacements replacements, MethodInvocation invocation, int inliningDepth, boolean fullyProcessed) {
final InlineInfo info = invocation.callee();
for (int i = 0; i < info.numberOfMethods(); ++i) {
HotSpotResolvedObjectType t = (HotSpotResolvedObjectType) info.methodAt(i).getDeclaringClass();
if (t.getFingerprint() == 0) {
return false;
}
}
final double probability = invocation.probability();
final double relevance = invocation.relevance();
OptionValues options = info.graph().getOptions();
if (InlineEverything.getValue(options)) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "inline everything");
return true;
}
if (isIntrinsic(replacements, info)) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "intrinsic");
return true;
}
if (info.shouldInline()) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "forced inlining");
return true;
}
double inliningBonus = getInliningBonus(info);
int nodes = info.determineNodeCount();
if (nodes < TrivialInliningSize.getValue(options) * inliningBonus) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "trivial (relevance=%f, probability=%f, bonus=%f, nodes=%d)", relevance, probability, inliningBonus, nodes);
return true;
}
double maximumNodes = computeMaximumSize(relevance, (int) (maxInliningSize(inliningDepth, options) * inliningBonus));
if (nodes <= maximumNodes) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d <= %f)", relevance, probability, inliningBonus, nodes, maximumNodes);
return true;
}
InliningUtil.traceNotInlinedMethod(info, inliningDepth, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d > %f)", relevance, probability, inliningBonus, nodes, maximumNodes);
return false;
}
use of org.graalvm.compiler.options.OptionValues in project graal by oracle.
the class GreedyInliningPolicy method isWorthInlining.
@Override
public boolean isWorthInlining(Replacements replacements, MethodInvocation invocation, int inliningDepth, boolean fullyProcessed) {
final InlineInfo info = invocation.callee();
OptionValues options = info.graph().getOptions();
final double probability = invocation.probability();
final double relevance = invocation.relevance();
if (InlineEverything.getValue(options)) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "inline everything");
return true;
}
if (isIntrinsic(replacements, info)) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "intrinsic");
return true;
}
if (info.shouldInline()) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "forced inlining");
return true;
}
double inliningBonus = getInliningBonus(info);
int nodes = info.determineNodeCount();
int lowLevelGraphSize = previousLowLevelGraphSize(info);
if (SmallCompiledLowLevelGraphSize.getValue(options) > 0 && lowLevelGraphSize > SmallCompiledLowLevelGraphSize.getValue(options) * inliningBonus) {
InliningUtil.traceNotInlinedMethod(info, inliningDepth, "too large previous low-level graph (low-level-nodes: %d, relevance=%f, probability=%f, bonus=%f, nodes=%d)", lowLevelGraphSize, relevance, probability, inliningBonus, nodes);
return false;
}
if (nodes < TrivialInliningSize.getValue(options) * inliningBonus) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "trivial (relevance=%f, probability=%f, bonus=%f, nodes=%d)", relevance, probability, inliningBonus, nodes);
return true;
}
/*
* TODO (chaeubl): invoked methods that are on important paths but not yet compiled -> will
* be compiled anyways and it is likely that we are the only caller... might be useful to
* inline those methods but increases bootstrap time (maybe those methods are also getting
* queued in the compilation queue concurrently)
*/
double invokes = determineInvokeProbability(info);
if (LimitInlinedInvokes.getValue(options) > 0 && fullyProcessed && invokes > LimitInlinedInvokes.getValue(options) * inliningBonus) {
InliningUtil.traceNotInlinedMethod(info, inliningDepth, "callee invoke probability is too high (invokeP=%f, relevance=%f, probability=%f, bonus=%f, nodes=%d)", invokes, relevance, probability, inliningBonus, nodes);
return false;
}
double maximumNodes = computeMaximumSize(relevance, (int) (MaximumInliningSize.getValue(options) * inliningBonus));
if (nodes <= maximumNodes) {
InliningUtil.traceInlinedMethod(info, inliningDepth, fullyProcessed, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d <= %f)", relevance, probability, inliningBonus, nodes, maximumNodes);
return true;
}
InliningUtil.traceNotInlinedMethod(info, inliningDepth, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d > %f)", relevance, probability, inliningBonus, nodes, maximumNodes);
return false;
}
Aggregations