# HG changeset patch # User Tom Rodriguez # Date 1445964264 25200 # Node ID 6bcd82f2b070412fa2c13195631709861479a7c6 # Parent afcdf04309464db18484a9a1cc18dbfafc8346cb Factor out compilation exception handling logic diff -r afcdf0430946 -r 6bcd82f2b070 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue Oct 27 14:09:17 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue Oct 27 09:44:24 2015 -0700 @@ -232,10 +232,6 @@ bailout.printStackTrace(TTY.out); } } catch (Throwable t) { - if (PrintStackTraceOnException.getValue() || ExitVMOnException.getValue()) { - t.printStackTrace(TTY.out); - } - // Log a failure event. CompilerFailureEvent event = eventProvider.newCompilerFailureEvent(); if (event.shouldWrite()) { @@ -244,9 +240,7 @@ event.commit(); } - if (ExitVMOnException.getValue()) { - System.exit(-1); - } + handleException(t); } finally { try { int compiledBytecodes = 0; @@ -284,17 +278,25 @@ codeCache.notifyCompilationStatistics(getId(), method, entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI, compiledBytecodes, compilationTime, timeUnitsPerSecond, installedCode); } } catch (Throwable t) { - // Don't allow exceptions during recording of statistics to leak out - if (PrintStackTraceOnException.getValue() || ExitVMOnException.getValue()) { - t.printStackTrace(TTY.out); - } - if (ExitVMOnException.getValue()) { - System.exit(-1); - } + handleException(t); } } } + protected void handleException(Throwable t) { + if (PrintStackTraceOnException.getValue() || ExitVMOnException.getValue()) { + try { + t.printStackTrace(TTY.out); + } catch (Throwable throwable) { + // Don't let an exception here change the other control flow + } + } + + if (ExitVMOnException.getValue()) { + System.exit(-1); + } + } + private String getMethodDescription() { HotSpotResolvedJavaMethod method = getMethod(); return String.format("%-6d JVMCI %-70s %-45s %-50s %s", getId(), method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(),