use of org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class ConditionalEliminationTestBase method prepareGraph.
protected void prepareGraph(StructuredGraph graph, CanonicalizerPhase canonicalizer, CoreProviders context, boolean applyLowering) {
if (applyLowering) {
new ConvertDeoptimizeToGuardPhase().apply(graph, context);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
}
canonicalizer.apply(graph, context);
new ConvertDeoptimizeToGuardPhase().apply(graph, context);
}
use of org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class GuardPrioritiesTest method prepareGraph.
private StructuredGraph prepareGraph(String method) {
StructuredGraph graph = parseEager(method, StructuredGraph.AllowAssumptions.YES);
HighTierContext highTierContext = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
new ConvertDeoptimizeToGuardPhase().apply(graph, highTierContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highTierContext);
new FloatingReadPhase().apply(graph);
return graph;
}
use of org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class IfNodeCanonicalizationTest method test.
public void test(String name, Class<? extends Node> expectedClass, int expectedCount) {
StructuredGraph graph = parseEager(name, AllowAssumptions.YES);
CoreProviders context = getProviders();
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
new ConvertDeoptimizeToGuardPhase().apply(graph, context);
graph.clearAllStateAfterForTestingOnly();
graph.setGuardsStage(StructuredGraph.GuardsStage.AFTER_FSA);
canonicalizer.apply(graph, context);
new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
canonicalizer.apply(graph, context);
canonicalizer.apply(graph, context);
Assert.assertEquals(expectedCount, graph.getNodes().filter(expectedClass).count());
}
use of org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class CachingPEGraphDecoder method createGraph.
@SuppressWarnings("try")
private EncodedGraph createGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider, boolean isSubstitution) {
StructuredGraph graphToEncode;
if (isSubstitution && IS_IN_NATIVE_IMAGE) {
throw GraalError.shouldNotReachHere("dead path");
} else {
graphToEncode = buildGraph(method, intrinsicBytecodeProvider, isSubstitution);
}
/*
* ConvertDeoptimizeToGuardPhase reduces the number of merges in the graph, so that fewer
* frame states will be created. This significantly reduces the number of nodes in the
* initial graph.
*/
try (DebugContext.Scope scope = debug.scope("createGraph", graphToEncode)) {
new ConvertDeoptimizeToGuardPhase().apply(graphToEncode, providers);
} catch (Throwable t) {
throw debug.handle(t);
}
EncodedGraph encodedGraph = GraphEncoder.encodeSingleGraph(graphToEncode, architecture);
graphCache.put(method, encodedGraph);
return encodedGraph;
}
use of org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase in project graal by oracle.
the class GraphPrepareMetaAccessExtensionProvider method beforeCompilation.
@Override
@SuppressWarnings("try")
public void beforeCompilation(BeforeCompilationAccess c) {
CompilationAccessImpl config = (CompilationAccessImpl) c;
if (Options.PrintRuntimeCompileMethods.getValue()) {
printCallTree();
}
if (Options.PrintStaticTruffleBoundaries.getValue()) {
printStaticTruffleBoundaries();
}
int maxMethods = 0;
for (String value : Options.MaxRuntimeCompileMethods.getValue().values()) {
String numberStr = null;
try {
/* Strip optional comment string from MaxRuntimeCompileMethods value */
numberStr = value.split("#")[0];
maxMethods += Long.parseLong(numberStr);
} catch (NumberFormatException ex) {
throw UserError.abort("Invalid value for option 'MaxRuntimeCompileMethods': '%s' is not a valid number", numberStr);
}
}
if (Options.EnforceMaxRuntimeCompileMethods.getValue() && maxMethods != 0 && methods.size() > maxMethods) {
printDeepestLevelPath();
throw VMError.shouldNotReachHere("Number of methods for runtime compilation exceeds the allowed limit: " + methods.size() + " > " + maxMethods);
}
HostedMetaAccess hMetaAccess = config.getMetaAccess();
runtimeConfigBuilder.updateLazyState(hMetaAccess);
/*
* Start fresh with a new GraphEncoder, since we are going to optimize all graphs now that
* the static analysis results are available.
*/
graphEncoder = new GraphEncoder(ConfigurationValues.getTarget().arch);
StrengthenStampsPhase strengthenStamps = new RuntimeStrengthenStampsPhase(config.getUniverse(), objectReplacer);
CanonicalizerPhase canonicalizer = CanonicalizerPhase.create();
IterativeConditionalEliminationPhase conditionalElimination = new IterativeConditionalEliminationPhase(canonicalizer, true);
ConvertDeoptimizeToGuardPhase convertDeoptimizeToGuard = new ConvertDeoptimizeToGuardPhase();
for (CallTreeNode node : methods.values()) {
StructuredGraph graph = node.graph;
if (graph != null) {
DebugContext debug = graph.getDebug();
try (DebugContext.Scope scope = debug.scope("RuntimeOptimize", graph)) {
removeUnreachableInvokes(node);
strengthenStamps.apply(graph);
canonicalizer.apply(graph, hostedProviders);
conditionalElimination.apply(graph, hostedProviders);
/*
* ConvertDeoptimizeToGuardPhase was already executed after parsing, but
* optimizations applied in between can provide new potential.
*/
convertDeoptimizeToGuard.apply(graph, hostedProviders);
graphEncoder.prepare(graph);
} catch (Throwable ex) {
debug.handle(ex);
}
}
}
graphEncoder.finishPrepare();
for (CallTreeNode node : methods.values()) {
if (node.graph != null) {
registerDeoptEntries(node);
long startOffset = graphEncoder.encode(node.graph);
objectReplacer.createMethod(node.implementationMethod).setEncodedGraphStartOffset(startOffset);
/* We do not need the graph anymore, let the GC do it's work. */
node.graph = null;
}
}
ProgressReporter.singleton().setGraphEncodingByteLength(graphEncoder.getEncoding().length);
GraalSupport.setGraphEncoding(config, graphEncoder.getEncoding(), graphEncoder.getObjects(), graphEncoder.getNodeClasses());
objectReplacer.updateDataDuringAnalysis();
}
Aggregations