use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod in project graal by oracle.
the class TruffleGraphBuilderPlugins method logPerformanceWarningLocationNotConstant.
@SuppressWarnings("try")
static void logPerformanceWarningLocationNotConstant(ValueNode location, ResolvedJavaMethod targetMethod, UnsafeAccessNode access) {
if (!PartialEvaluator.PerformanceInformationHandler.isEnabled()) {
return;
}
StructuredGraph graph = location.graph();
DebugContext debug = access.getDebug();
try (DebugContext.Scope s = debug.scope("TrufflePerformanceWarnings", graph)) {
TruffleDebugJavaMethod truffleMethod = debug.contextLookup(TruffleDebugJavaMethod.class);
String callTargetName = truffleMethod != null ? truffleMethod.getName() : "";
Map<String, Object> properties = new LinkedHashMap<>();
properties.put("location", location);
properties.put("method", targetMethod.format("%h.%n"));
PartialEvaluator.PerformanceInformationHandler.logPerformanceWarning(callTargetName, Collections.singletonList(access), "location argument not PE-constant", properties);
debug.dump(DebugContext.VERBOSE_LEVEL, graph, "perf warn: location argument not PE-constant: %s", location);
} catch (Throwable t) {
debug.handle(t);
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod 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 org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod 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 org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod 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;
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod in project graal by oracle.
the class GraalTestTVMCI method finishWarmup.
@SuppressWarnings("try")
@Override
public void finishWarmup(OptimizedCallTarget callTarget, String testName) {
OptionValues options = TruffleCompilerOptions.getOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
TruffleCompiler compiler = truffleRuntime.getTruffleCompiler();
TruffleInlining inliningDecision = new TruffleInlining(callTarget, new DefaultInliningPolicy());
try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(callTarget))) {
compiler.doCompile(debug, null, options, callTarget, inliningDecision, null, null);
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations