use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.
the class AnalysisParsedGraph method parseBytecode.
@SuppressWarnings("try")
public static AnalysisParsedGraph parseBytecode(BigBang bb, AnalysisMethod method) {
if (bb == null) {
throw AnalysisError.shouldNotReachHere("BigBang object required for parsing method " + method.format("%H.%p(%n)"));
}
OptionValues options = bb.getOptions();
Description description = new Description(method, ClassUtil.getUnqualifiedName(method.getClass()) + ":" + method.getId());
DebugContext debug = new Builder(options, new GraalDebugHandlersFactory(bb.getProviders().getSnippetReflection())).description(description).build();
try (Indent indent = debug.logAndIndent("parse graph %s", method)) {
StructuredGraph graph = method.buildGraph(debug, method, bb.getProviders(), Purpose.ANALYSIS);
if (graph != null) {
return optimizeAndEncode(bb, method, graph, false);
}
InvocationPlugin plugin = bb.getProviders().getGraphBuilderPlugins().getInvocationPlugins().lookupInvocation(method, options);
if (plugin != null && !plugin.inlineOnly()) {
Bytecode code = new ResolvedJavaMethodBytecode(method);
graph = new SubstrateIntrinsicGraphBuilder(options, debug, bb.getProviders(), code).buildGraph(plugin);
if (graph != null) {
return optimizeAndEncode(bb, method, graph, true);
}
}
if (method.getCode() == null) {
return EMPTY;
}
graph = new StructuredGraph.Builder(options, debug).method(method).build();
try (DebugContext.Scope s = debug.scope("ClosedWorldAnalysis", graph, method)) {
// enable this logging to get log output in compilation passes
try (Indent indent2 = debug.logAndIndent("parse graph phases")) {
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(bb.getProviders().getGraphBuilderPlugins()).withEagerResolving(true).withUnresolvedIsError(PointstoOptions.UnresolvedIsError.getValue(bb.getOptions())).withNodeSourcePosition(true).withBytecodeExceptionMode(BytecodeExceptionMode.CheckAll).withRetainLocalVariables(true);
config = bb.getHostVM().updateGraphBuilderConfiguration(config, method);
bb.getHostVM().createGraphBuilderPhase(bb.getProviders(), config, OptimisticOptimizations.NONE, null).apply(graph);
} catch (PermanentBailoutException ex) {
bb.getUnsupportedFeatures().addMessage(method.format("%H.%n(%p)"), method, ex.getLocalizedMessage(), null, ex);
return EMPTY;
}
} catch (Throwable e) {
throw debug.handle(e);
}
return optimizeAndEncode(bb, method, graph, false);
}
}
Aggregations