Skip to content

Commit

Permalink
Improve Truffle compilation listener output.
Browse files Browse the repository at this point in the history
  • Loading branch information
chumer committed Nov 13, 2019
1 parent 1fd2c0b commit 7f694a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void onSuccess(CompilableTruffleAST compilable, TruffleInliningPlan inlin
public void onFailure(CompilableTruffleAST compilable, String reason, boolean bailout, boolean permanentBailout) {
if (isPermanentFailure(bailout, permanentBailout) || bailoutActionIsPrintOrGreater()) {
Map<String, Object> properties = new LinkedHashMap<>();
properties.put("ASTSize", compilable.getNonTrivialNodeCount());
properties.put("Reason", reason);
TruffleCompilerRuntime.getRuntime().logEvent(0, "opt fail", compilable.toString(), properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,21 @@ public static void install(GraalTruffleRuntime runtime) {

@Override
public void onCompilationQueued(OptimizedCallTarget target) {
if (target.engine.traceCompilation) {
runtime.logEvent(0, "opt queued", target.toString(), target.getDebugProperties(null));
if (target.engine.traceCompilationDetails) {
Map<String, Object> properties = new LinkedHashMap<>();
properties.putAll(target.getDebugProperties(null));
properties.put("Source", formatSourceSection(target.getRootNode().getSourceSection()));
runtime.logEvent(0, "opt queued", target.toString(), properties);
}
}

@Override
public void onCompilationDequeued(OptimizedCallTarget target, Object source, CharSequence reason) {
if (target.engine.traceCompilationDetails) {
Map<String, Object> properties = new LinkedHashMap<>();
addSourceInfo(properties, source);
properties.putAll(target.getDebugProperties(null));
properties.put("Reason", reason);
properties.put("Source", formatSourceSection(target.getRootNode().getSourceSection()));
runtime.logEvent(0, "opt unqueued", target.toString(), properties);
}
}
Expand Down Expand Up @@ -100,7 +104,10 @@ public void onCompilationStarted(OptimizedCallTarget target) {
@Override
public void onCompilationDeoptimized(OptimizedCallTarget target, Frame frame) {
if (target.engine.traceCompilation || target.engine.traceCompilationDetails) {
runtime.logEvent(0, "opt deopt", target.toString(), target.getDebugProperties(null));
Map<String, Object> properties = new LinkedHashMap<>();
properties.putAll(target.getDebugProperties(null));
properties.put("Source", formatSourceSection(target.getRootNode().getSourceSection()));
runtime.logEvent(0, "opt deopt", target.toString(), properties);
}
}

Expand Down Expand Up @@ -168,19 +175,13 @@ private static String formatSourceSection(SourceSection sourceSection) {
public void onCompilationInvalidated(OptimizedCallTarget target, Object source, CharSequence reason) {
if (target.getOptionValue(TraceCompilation) || target.getOptionValue(TraceCompilationDetails)) {
Map<String, Object> properties = new LinkedHashMap<>();
addSourceInfo(properties, source);
properties.putAll(target.getDebugProperties(null));
properties.put("Reason", reason);
properties.put("Source", formatSourceSection(target.getRootNode().getSourceSection()));
runtime.logEvent(0, "opt invalidated", target.toString(), properties);
}
}

private static void addSourceInfo(Map<String, Object> properties, Object source) {
if (source != null) {
properties.put("SourceClass", source.getClass().getSimpleName());
properties.put("Source", source);
}
}

/**
* Determines if a failure is permanent.
*
Expand Down

0 comments on commit 7f694a6

Please sign in to comment.