# HG changeset patch # User Doug Simon # Date 1400188368 -7200 # Node ID e563b7668db578b2003037b5741a4361fbf7cb55 # Parent 5f1373b3527ddced1ac1cf22accf455e9441908e# Parent 5ec52f033e588f6f198d5e8bbc8de953b24025af Merge. diff -r 5ec52f033e58 -r e563b7668db5 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 May 15 22:25:34 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu May 15 23:12:48 2014 +0200 @@ -107,6 +107,13 @@ private final int id; private final AtomicReference status; + /** + * The executor processing the Graal compilation queue this task was placed on. This will be + * null for blocking compilations or if compilations are scheduled as native HotSpot + * {@linkplain #ctask CompileTask}s. + */ + private final ExecutorService executor; + private StructuredGraph graph; /** @@ -120,7 +127,7 @@ * A {@link com.sun.management.ThreadMXBean} to be able to query some information about the * current compiler thread, e.g. total allocated bytes. */ - private final com.sun.management.ThreadMXBean threadMXBean = (com.sun.management.ThreadMXBean) ManagementFactory.getThreadMXBean(); + private static final com.sun.management.ThreadMXBean threadMXBean = (com.sun.management.ThreadMXBean) ManagementFactory.getThreadMXBean(); /** * The address of the native CompileTask associated with this compilation. If 0L, then this @@ -129,7 +136,8 @@ */ private final long ctask; - public CompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long ctask, boolean blocking) { + public CompilationTask(ExecutorService executor, HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long ctask, boolean blocking) { + this.executor = executor; this.backend = backend; this.method = method; this.entryBCI = entryBCI; @@ -165,7 +173,7 @@ public void run() { withinEnqueue.set(Boolean.FALSE); try { - runCompilation(true); + runCompilation(); } finally { withinEnqueue.set(Boolean.TRUE); status.set(CompilationStatus.Finished); @@ -235,7 +243,14 @@ return method.getCompilationProfilingInfo(osrCompilation); } - public void runCompilation(boolean clearFromCompilationQueue) { + public void runCompilation() { + if (executor != null && executor.isShutdown()) { + // We don't want to do any unnecessary compilation is the Graal compilation + // queue has been shutdown. Note that we leave the JVM_ACC_QUEUED bit set + // for the method so that it won't be re-scheduled for compilation. + return; + } + /* * no code must be outside this try/finally because it could happen otherwise that * clearQueuedForCompilation() is not executed @@ -402,7 +417,7 @@ c2vm.notifyCompilationStatistics(id, method, entryBCI != INVOCATION_ENTRY_BCI, processedBytes, time, timeUnitsPerSecond, installedCode); } - if (clearFromCompilationQueue) { + if (executor != null) { assert method.isQueuedForCompilation(); method.clearQueuedForCompilation(); } diff -r 5ec52f033e58 -r e563b7668db5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Thu May 15 22:25:34 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Thu May 15 23:12:48 2014 +0200 @@ -317,7 +317,7 @@ class CTWCompilationTask extends CompilationTask { CTWCompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method) { - super(backend, method, INVOCATION_ENTRY_BCI, 0L, false); + super(null, backend, method, INVOCATION_ENTRY_BCI, 0L, false); } /** @@ -349,7 +349,7 @@ HotSpotBackend backend = runtime.getHostBackend(); CompilationTask task = new CTWCompilationTask(backend, method); - task.runCompilation(false); + task.runCompilation(); compileTime += (System.currentTimeMillis() - start); compiledMethodsCounter++; diff -r 5ec52f033e58 -r e563b7668db5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu May 15 22:25:34 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu May 15 23:12:48 2014 +0200 @@ -91,7 +91,7 @@ * is in the proper state. */ static class Queue { - private ThreadPoolExecutor executor; + private final ThreadPoolExecutor executor; Queue(CompilerThreadFactory factory) { executor = new ThreadPoolExecutor(Threads.getValue(), Threads.getValue(), 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), factory); @@ -117,11 +117,19 @@ executor.execute(task); } + /** + * @see ExecutorService#isShutdown() + */ + public boolean isShutdown() { + return executor.isShutdown(); + } + public void shutdown() throws InterruptedException { assert CompilationTask.isWithinEnqueue(); - executor.shutdown(); - if (Debug.isEnabled() && Dump.getValue() != null) { - // Wait 2 seconds to flush out all graph dumps that may be of interest + executor.shutdownNow(); + if (Debug.isEnabled() && (Dump.getValue() != null || areMetricsOrTimersEnabled())) { + // Wait up to 2 seconds to flush out all graph dumps and stop metrics/timers + // being updated. executor.awaitTermination(2, TimeUnit.SECONDS); } } @@ -472,19 +480,7 @@ printMap(new DebugValueScope(null, result), debugValues); } - static long collectTotal(DebugValue value) { - List maps = DebugValueMap.getTopLevelMaps(); - long total = 0; - for (int i = 0; i < maps.size(); i++) { - DebugValueMap map = maps.get(i); - int index = value.getIndex(); - total += map.getCurrentValue(index); - total += collectTotal(map.getChildren(), index); - } - return total; - } - - private static long collectTotal(List maps, int index) { + public static long collectTotal(List maps, int index) { long total = 0; for (int i = 0; i < maps.size(); i++) { DebugValueMap map = maps.get(i); @@ -570,8 +566,8 @@ void compileMethod(final HotSpotResolvedJavaMethod method, final int entryBCI, long ctask, final boolean blocking) { if (ctask != 0L) { HotSpotBackend backend = runtime.getHostBackend(); - CompilationTask task = new CompilationTask(backend, method, entryBCI, ctask, false); - task.runCompilation(false); + CompilationTask task = new CompilationTask(null, backend, method, entryBCI, ctask, false); + task.runCompilation(); return; } @@ -596,13 +592,14 @@ if (method.tryToQueueForCompilation()) { assert method.isQueuedForCompilation(); - HotSpotBackend backend = runtime.getHostBackend(); - CompilationTask task = new CompilationTask(backend, method, entryBCI, ctask, block); - try { - compileQueue.execute(task); - if (block) { - task.block(); + if (!compileQueue.executor.isShutdown()) { + HotSpotBackend backend = runtime.getHostBackend(); + CompilationTask task = new CompilationTask(compileQueue.executor, backend, method, entryBCI, ctask, block); + compileQueue.execute(task); + if (block) { + task.block(); + } } } catch (RejectedExecutionException e) { // The compile queue was already shut down. diff -r 5ec52f033e58 -r e563b7668db5 mxtool/mx.py --- a/mxtool/mx.py Thu May 15 22:25:34 2014 +0200 +++ b/mxtool/mx.py Thu May 15 23:12:48 2014 +0200 @@ -2994,7 +2994,7 @@ elif dep.isProject(): memento = XMLDoc().element('javaProject', {'name' : dep.name}).xml(standalone='no') slm.element('container', {'memento' : memento, 'typeId':'org.eclipse.jdt.launching.sourceContainer.javaProject'}) - if javaCompliance is None or dep.javaCompliance < javaCompliance: + if javaCompliance is None or dep.javaCompliance > javaCompliance: javaCompliance = dep.javaCompliance if javaCompliance: diff -r 5ec52f033e58 -r e563b7668db5 src/share/vm/runtime/java.cpp --- a/src/share/vm/runtime/java.cpp Thu May 15 22:25:34 2014 +0200 +++ b/src/share/vm/runtime/java.cpp Thu May 15 23:12:48 2014 +0200 @@ -462,15 +462,6 @@ #define BEFORE_EXIT_DONE 2 static jint volatile _before_exit_status = BEFORE_EXIT_NOT_RUN; -#ifdef GRAAL -#ifdef COMPILERGRAAL - if (GraalCompiler::instance() != NULL) { - GraalCompiler::instance()->shutdown(); - } -#endif - VMToCompiler::shutdownRuntime(); -#endif - // Note: don't use a Mutex to guard the entire before_exit(), as // JVMTI post_thread_end_event and post_vm_death_event will run native code. // A CAS or OSMutex would work just fine but then we need to manipulate @@ -492,6 +483,15 @@ } } +#ifdef GRAAL +#ifdef COMPILERGRAAL + if (GraalCompiler::instance() != NULL) { + GraalCompiler::instance()->shutdown(); + } +#endif + VMToCompiler::shutdownRuntime(); +#endif + // The only difference between this and Win32's _onexit procs is that // this version is invoked before any threads get killed. ExitProc* current = exit_procs;