use of jdk.vm.ci.meta.SpeculationLog in project graal by oracle.
the class HotSpotGraalCompiler method createGraph.
public StructuredGraph createGraph(ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
HotSpotBackend backend = graalRuntime.getHostBackend();
HotSpotProviders providers = backend.getProviders();
final boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
StructuredGraph graph = method.isNative() || isOSR ? null : getIntrinsicGraph(method, providers, compilationId, options, debug);
if (graph == null) {
SpeculationLog speculationLog = method.getSpeculationLog();
if (speculationLog != null) {
speculationLog.collectFailedSpeculations();
}
graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.ifTrue(OptAssumptions.getValue(options))).method(method).entryBCI(entryBCI).speculationLog(speculationLog).useProfilingInfo(useProfilingInfo).compilationId(compilationId).build();
}
return graph;
}
use of jdk.vm.ci.meta.SpeculationLog in project graal by oracle.
the class TruffleToTruffleCallExceptionHandlerTest method partialEval.
@SuppressWarnings("try")
private static StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arguments, AllowAssumptions allowAssumptions) {
compilable.call(arguments);
compilable.call(arguments);
compilable.call(arguments);
OptionValues options = TruffleCompilerOptions.getOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable))) {
TruffleInlining inliningDecision = new TruffleInlining(compilable, new DefaultInliningPolicy());
SpeculationLog speculationLog = compilable.getSpeculationLog();
return truffleCompiler.getPartialEvaluator().createGraph(debug, compilable, inliningDecision, allowAssumptions, INVALID_COMPILATION_ID, speculationLog, null);
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of jdk.vm.ci.meta.SpeculationLog in project graal by oracle.
the class PartialEvaluationTest method partialEval.
@SuppressWarnings("try")
protected StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arguments, AllowAssumptions allowAssumptions, CompilationIdentifier compilationId) {
// Executed AST so that all classes are loaded and initialized.
compilable.call(arguments);
compilable.call(arguments);
compilable.call(arguments);
OptionValues options = TruffleCompilerOptions.getOptions();
DebugContext debug = getDebugContext(options);
try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable))) {
TruffleInlining inliningDecision = new TruffleInlining(compilable, new DefaultInliningPolicy());
SpeculationLog speculationLog = compilable.getSpeculationLog();
return truffleCompiler.getPartialEvaluator().createGraph(debug, compilable, inliningDecision, allowAssumptions, compilationId, speculationLog, null);
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of jdk.vm.ci.meta.SpeculationLog in project graal by oracle.
the class TruffleCompilerImpl method compileAST.
/**
* Compiles a Truffle AST. If compilation succeeds, the AST will have compiled code associated
* with it that can be executed instead of interpreting the AST.
*
* @param compilable representation of the AST to be compiled
* @param inliningPlan
* @param compilationId identifier to be used for the compilation
* @param cancellable an object polled during the compilation process to
* {@linkplain CancellationBailoutException abort} early if the thread owning the
* cancellable requests it
* @param listener
*/
@SuppressWarnings("try")
public void compileAST(DebugContext debug, final CompilableTruffleAST compilable, TruffleInliningPlan inliningPlan, CompilationIdentifier compilationId, Cancellable cancellable, TruffleCompilerListener listener) {
final CompilationPrinter printer = CompilationPrinter.begin(TruffleCompilerOptions.getOptions(), compilationId, new TruffleDebugJavaMethod(compilable), INVOCATION_ENTRY_BCI);
StructuredGraph graph = null;
try (CompilationAlarm alarm = CompilationAlarm.trackCompilationPeriod(TruffleCompilerOptions.getOptions())) {
PhaseSuite<HighTierContext> graphBuilderSuite = createGraphBuilderSuite();
// Failed speculations must be collected before any compilation or
// partial evaluation is performed.
SpeculationLog speculationLog = compilable.getSpeculationLog();
if (speculationLog != null) {
speculationLog.collectFailedSpeculations();
}
try (DebugCloseable a = PartialEvaluationTime.start(debug);
DebugCloseable c = PartialEvaluationMemUse.start(debug)) {
graph = partialEvaluator.createGraph(debug, compilable, inliningPlan, AllowAssumptions.YES, compilationId, speculationLog, cancellable);
}
// Check if the task has been cancelled
if (cancellable != null && cancellable.isCancelled()) {
return;
}
if (listener != null) {
listener.onTruffleTierFinished(compilable, inliningPlan, new GraphInfoImpl(graph));
}
CompilationResult compilationResult = compilePEGraph(graph, compilable.toString(), graphBuilderSuite, compilable, asCompilationRequest(compilationId), listener);
if (listener != null) {
listener.onSuccess(compilable, inliningPlan, new GraphInfoImpl(graph), new CompilationResultInfoImpl(compilationResult));
}
// Partial evaluation and installation are included in
// compilation time and memory usage reported by printer
printer.finish(compilationResult);
} catch (Throwable t) {
// graph is null
if (listener != null) {
BailoutException bailout = t instanceof BailoutException ? (BailoutException) t : null;
boolean permanentBailout = bailout != null ? bailout.isPermanent() : false;
listener.onFailure(compilable, t.toString(), bailout != null, permanentBailout);
}
throw t;
}
}
Aggregations