# HG changeset patch # User Tom Rodriguez # Date 1445539974 25200 # Node ID b4f50acabc279f8c678a528f88f0a5aefbb2dd0f # Parent cc788c1189fc404f4e5f83f78ff7872631bfefdc Use try/catch around all the logic in a CompilationTask diff -r cc788c1189fc -r b4f50acabc27 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 Thu Oct 22 16:21:29 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Oct 22 11:52:54 2015 -0700 @@ -248,39 +248,49 @@ System.exit(-1); } } finally { - int compiledBytecodes = 0; - int codeSize = 0; - if (result != null) { - compiledBytecodes = result.getBytecodeSize(); - } - if (installedCode != null) { - codeSize = installedCode.getSize(); - } - CompiledBytecodes.add(compiledBytecodes); + try { + int compiledBytecodes = 0; + int codeSize = 0; + if (result != null) { + compiledBytecodes = result.getBytecodeSize(); + } + if (installedCode != null) { + codeSize = installedCode.getSize(); + } + CompiledBytecodes.add(compiledBytecodes); - // Log a compilation event. - if (compilationEvent.shouldWrite()) { - compilationEvent.setMethod(method.format("%H.%n(%p)")); - compilationEvent.setCompileId(getId()); - compilationEvent.setCompileLevel(config.compilationLevelFullOptimization); - compilationEvent.setSucceeded(result != null && installedCode != null); - compilationEvent.setIsOsr(isOSR); - compilationEvent.setCodeSize(codeSize); - compilationEvent.setInlinedBytes(compiledBytecodes); - compilationEvent.commit(); - } + // Log a compilation event. + if (compilationEvent.shouldWrite()) { + compilationEvent.setMethod(method.format("%H.%n(%p)")); + compilationEvent.setCompileId(getId()); + compilationEvent.setCompileLevel(config.compilationLevelFullOptimization); + compilationEvent.setSucceeded(result != null && installedCode != null); + compilationEvent.setIsOsr(isOSR); + compilationEvent.setCodeSize(codeSize); + compilationEvent.setInlinedBytes(compiledBytecodes); + compilationEvent.commit(); + } - long jvmciEnv = request.getJvmciEnv(); - if (jvmciEnv != 0) { - long ctask = UNSAFE.getAddress(jvmciEnv + config.jvmciEnvTaskOffset); - assert ctask != 0L; - UNSAFE.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, compiledBytecodes); - } - long compilationTime = System.nanoTime() - startCompilationTime; - if ((config.ciTime || config.ciTimeEach) && installedCode != null) { - long timeUnitsPerSecond = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); - final HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmciRuntime.getHostJVMCIBackend().getCodeCache(); - codeCache.notifyCompilationStatistics(getId(), method, entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI, compiledBytecodes, compilationTime, timeUnitsPerSecond, installedCode); + long jvmciEnv = request.getJvmciEnv(); + if (jvmciEnv != 0) { + long ctask = UNSAFE.getAddress(jvmciEnv + config.jvmciEnvTaskOffset); + assert ctask != 0L; + UNSAFE.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, compiledBytecodes); + } + long compilationTime = System.nanoTime() - startCompilationTime; + if ((config.ciTime || config.ciTimeEach) && installedCode != null) { + long timeUnitsPerSecond = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); + final HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmciRuntime.getHostJVMCIBackend().getCodeCache(); + 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); + } } } }