changeset 5266:c9dd4054c23b

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 20 Apr 2012 13:44:06 +0200
parents b8661be84cfd (current diff) d87155082c4d (diff)
children 8191f71d7f51
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java
diffstat 2 files changed, 39 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- 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()) {
--- 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 {
   }
 }