# HG changeset patch # User Lukas Stadler # Date 1334922246 -7200 # Node ID c9dd4054c23b0fde0ef302a7b3e1af2d28ef618d # Parent b8661be84cfd3315e333d8b6c0bd655368871e8b# Parent d87155082c4de7e6143eded9b3b2cfe824e7f478 Merge diff -r b8661be84cfd -r c9dd4054c23b 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 Apr 19 14:47:10 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Fri Apr 20 13:44:06 2012 +0200 @@ -178,23 +178,28 @@ // Compile until the queue is empty. int z = 0; - if (slowCompileQueue == null) { - while (compileQueue.getCompletedTaskCount() < Math.max(3, compileQueue.getTaskCount())) { - Thread.sleep(100); - while (z < compileQueue.getCompletedTaskCount() / 100) { - ++z; - TTY.print("."); - TTY.flush(); + while (true) { + try { + assert !CompilationTask.withinEnqueue.get(); + CompilationTask.withinEnqueue.set(Boolean.TRUE); + if (slowCompileQueue == null) { + if (compileQueue.getCompletedTaskCount() >= Math.max(3, compileQueue.getTaskCount())) { + break; + } + } else { + if (compileQueue.getCompletedTaskCount() + slowCompileQueue.getCompletedTaskCount() >= Math.max(3, compileQueue.getTaskCount() + slowCompileQueue.getTaskCount())) { + break; + } } + } finally { + CompilationTask.withinEnqueue.set(Boolean.FALSE); } - } else { - while (compileQueue.getCompletedTaskCount() + slowCompileQueue.getCompletedTaskCount() < Math.max(3, compileQueue.getTaskCount() + slowCompileQueue.getTaskCount())) { - Thread.sleep(100); - while (z < (compileQueue.getCompletedTaskCount() + slowCompileQueue.getCompletedTaskCount()) / 100) { - ++z; - TTY.print("."); - TTY.flush(); - } + + Thread.sleep(100); + while (z < compileQueue.getCompletedTaskCount() / 100) { + ++z; + TTY.print("."); + TTY.flush(); } } } while ((System.currentTimeMillis() - startTime) <= GraalOptions.TimedBootstrap); @@ -216,9 +221,15 @@ } public void shutdownCompiler() throws Throwable { - compileQueue.shutdown(); - if (slowCompileQueue != null) { - slowCompileQueue.shutdown(); + try { + assert !CompilationTask.withinEnqueue.get(); + CompilationTask.withinEnqueue.set(Boolean.TRUE); + compileQueue.shutdown(); + if (slowCompileQueue != null) { + slowCompileQueue.shutdown(); + } + } finally { + CompilationTask.withinEnqueue.set(Boolean.FALSE); } if (Debug.isEnabled()) { diff -r b8661be84cfd -r c9dd4054c23b src/share/vm/runtime/compilationPolicy.cpp --- a/src/share/vm/runtime/compilationPolicy.cpp Thu Apr 19 14:47:10 2012 +0200 +++ b/src/share/vm/runtime/compilationPolicy.cpp Fri Apr 20 13:44:06 2012 +0200 @@ -443,10 +443,16 @@ jlong current_time = os::javaTimeNanos(); int time_per_call = (int) ((current_time - hot_time) / hot_count); m->set_graal_invocation_time(current_time); - if (m->queued_for_compilation()) { - if (time_per_call < (m->graal_priority() / 5)) { - m->set_graal_priority(time_per_call); - m->clear_queued_for_compilation(); + if (UseNewCode) { + if (m->queued_for_compilation()) { + if (time_per_call < (m->graal_priority() / 5)) { + m->set_graal_priority(time_per_call); + m->clear_queued_for_compilation(); + } + } else { + if (time_per_call < m->graal_priority()) { + m->set_graal_priority(time_per_call); + } } } else { if (time_per_call < m->graal_priority()) { @@ -458,7 +464,6 @@ CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier, m, hot_count, "count", thread); } } - } else { } }