diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java @ 6721:98d691bc23da

make osr compilations asynchronous
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 16 Nov 2012 17:21:10 +0100
parents 28a158024338
children dd0dd0321e2a
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Thu Nov 15 17:18:16 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Fri Nov 16 17:21:10 2012 +0100
@@ -42,15 +42,8 @@
         }
     };
 
-    public static final ThreadLocal<Long> withinCompilation = new ThreadLocal<Long>() {
-        @Override
-        protected Long initialValue() {
-            return 0L;
-        }
-    };
-
-
     private volatile boolean cancelled;
+    private volatile boolean inProgress;
 
     private final HotSpotGraalRuntime graalRuntime;
     private final PhasePlan plan;
@@ -59,13 +52,12 @@
     private final int entryBCI;
     private final int id;
     private final int priority;
-    private final Runnable callback;
 
-    public static CompilationTask create(HotSpotGraalRuntime graalRuntime, PhasePlan plan, OptimisticOptimizations optimisticOpts, HotSpotResolvedJavaMethod method, int entryBCI, int id, int priority, Runnable callback) {
-        return new CompilationTask(graalRuntime, plan, optimisticOpts, method, entryBCI, id, priority, callback);
+    public static CompilationTask create(HotSpotGraalRuntime graalRuntime, PhasePlan plan, OptimisticOptimizations optimisticOpts, HotSpotResolvedJavaMethod method, int entryBCI, int id, int priority) {
+        return new CompilationTask(graalRuntime, plan, optimisticOpts, method, entryBCI, id, priority);
     }
 
-    private CompilationTask(HotSpotGraalRuntime graalRuntime, PhasePlan plan, OptimisticOptimizations optimisticOpts, HotSpotResolvedJavaMethod method, int entryBCI, int id, int priority, Runnable callback) {
+    private CompilationTask(HotSpotGraalRuntime graalRuntime, PhasePlan plan, OptimisticOptimizations optimisticOpts, HotSpotResolvedJavaMethod method, int entryBCI, int id, int priority) {
         this.graalRuntime = graalRuntime;
         this.plan = plan;
         this.method = method;
@@ -73,14 +65,13 @@
         this.entryBCI = entryBCI;
         this.id = id;
         this.priority = priority;
-        this.callback = callback;
     }
 
-    public ResolvedJavaMethod method() {
+    public ResolvedJavaMethod getMethod() {
         return method;
     }
 
-    public int priority() {
+    public int getPriority() {
         return priority;
     }
 
@@ -88,12 +79,21 @@
         cancelled = true;
     }
 
+    public boolean isInProgress() {
+        return inProgress;
+    }
+
+    public int getEntryBCI() {
+        return entryBCI;
+    }
+
     public void run() {
         withinEnqueue.set(Boolean.FALSE);
         try {
             if (cancelled) {
                 return;
             }
+            inProgress = true;
             if (GraalOptions.DynamicCompilePriority) {
                 int threadPriority = priority < GraalOptions.SlowQueueCutoff ? Thread.NORM_PRIORITY : Thread.MIN_PRIORITY;
                 if (Thread.currentThread().getPriority() != threadPriority) {
@@ -105,12 +105,12 @@
                 method.setCurrentTask(null);
             }
         } finally {
+            inProgress = false;
             withinEnqueue.set(Boolean.TRUE);
         }
     }
 
     public void runCompilation() {
-        withinCompilation.set(withinCompilation.get() + 1);
         CompilationStatistics stats = CompilationStatistics.create(method);
         try {
             final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed();
@@ -156,10 +156,6 @@
             }
         }
         stats.finish(method);
-        if (callback != null) {
-            callback.run();
-        }
-        withinCompilation.set(withinCompilation.get() - 1);
     }
 
     private void installMethod(final CompilationResult tm) {