Skip to content

Commit

Permalink
improved failure messages for permanentbailouts in runtime compiled m…
Browse files Browse the repository at this point in the history
…ethods.
  • Loading branch information
teshull committed Feb 26, 2024
1 parent 2483c3f commit f646601
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ enum InlineDecision {
private final Set<SubstrateMethod> substrateAnalysisMethods = ConcurrentHashMap.newKeySet();
private final Map<AnalysisMethod, String> invalidForRuntimeCompilation = new ConcurrentHashMap<>();
private final Set<RuntimeCompilationCandidate> runtimeCompilationCandidates = ConcurrentHashMap.newKeySet();
private final Set<AnalysisMethod> runtimeCompilationsFailedDuringParsing = ConcurrentHashMap.newKeySet();
private CallTreeInfo callTreeMetadata = null;
private HostedProviders analysisProviders = null;
private AllowInliningPredicate allowInliningPredicate = (builder, target) -> AllowInliningPredicate.InlineDecision.INLINING_DISALLOWED;
Expand Down Expand Up @@ -513,6 +514,12 @@ private void checkMaxRuntimeCompiledMethods(CallTreeInfo callTreeInfo) {
public void afterAnalysis(Feature.AfterAnalysisAccess access) {
VMError.guarantee(callTreeMetadata == null);
callTreeMetadata = CallTreeInfo.create(((FeatureImpl.AfterAnalysisAccessImpl) access).getUniverse(), invalidForRuntimeCompilation);
if (!runtimeCompilationsFailedDuringParsing.isEmpty()) {
System.out.println("PermanentBailouts seen while parsing runtime compiled methods. One reason for this can be encountering invalid frame states.");
for (AnalysisMethod failedMethod : runtimeCompilationsFailedDuringParsing) {
printFailingRuntimeMethodTrace(callTreeMetadata, failedMethod, failedMethod);
}
}

ProgressReporter.singleton().setNumRuntimeCompiledMethods(callTreeMetadata.runtimeCompilations().size());
// after analysis has completed we must ensure no new SubstrateTypes are introduced
Expand Down Expand Up @@ -596,20 +603,24 @@ public void reportAnalysisError(AnalysisUniverse aUniverse, Throwable t) {
} else if (errorMethod.isDeoptTarget()) {
failingRuntimeMethod = errorMethod.getMultiMethod(RUNTIME_COMPILED_METHOD);
}
System.out.println("Parsing failed on a special method version: " + errorMethod.format("%H.%n"));
System.out.println("Method reachability trace");
if (failingRuntimeMethod != null) {
Arrays.stream(CallTreeInfo.getCallTrace(treeInfo, failingRuntimeMethod, registeredRuntimeCompilations)).forEach(System.out::println);
} else {
System.out.println("trace unavailable");
}
printFailingRuntimeMethodTrace(treeInfo, failingRuntimeMethod, errorMethod);
System.out.println("error: " + e.getMessage());
}
}
}
}
}

private void printFailingRuntimeMethodTrace(CallTreeInfo treeInfo, AnalysisMethod failingRuntimeMethod, AnalysisMethod errorMethod) {
System.out.println("Parsing failed on a special method version: " + errorMethod.format("%H.%n"));
System.out.println("Method reachability trace");
if (failingRuntimeMethod != null) {
Arrays.stream(CallTreeInfo.getCallTrace(treeInfo, failingRuntimeMethod, registeredRuntimeCompilations)).forEach(System.out::println);
} else {
System.out.println("trace unavailable");
}
}

private class RuntimeCompilationParsingSupport implements SVMParsingSupport {
RuntimeCompilationInlineBeforeAnalysisPolicy runtimeInlineBeforeAnalysisPolicy = null;

Expand Down Expand Up @@ -665,6 +676,7 @@ private Object parseRuntimeCompiledMethod(BigBang bb, DebugContext debug, Analys
if (graph == null) {
if (!method.hasBytecodes()) {
recordFailed(method);
runtimeCompilationsFailedDuringParsing.add(method);
return HostVM.PARSING_FAILED;
}

Expand All @@ -684,6 +696,7 @@ private Object parseRuntimeCompiledMethod(BigBang bb, DebugContext debug, Analys
} catch (PermanentBailoutException ex) {
bb.getUnsupportedFeatures().addMessage(method.format("%H.%n(%p)"), method, ex.getLocalizedMessage(), null, ex);
recordFailed(method);
runtimeCompilationsFailedDuringParsing.add(method);
return HostVM.PARSING_FAILED;
}
}
Expand Down

0 comments on commit f646601

Please sign in to comment.