changeset 22760:82f29fdcb1ce

Avoid truffle compiler initialization in createCallTarget and cancelInstalledTask.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 06 Oct 2015 15:16:00 +0200
parents f31918d83b75
children f46cada70621
files graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Tue Oct 06 14:27:55 2015 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Tue Oct 06 15:16:00 2015 +0200
@@ -116,6 +116,8 @@
  */
 public final class HotSpotTruffleRuntime extends GraalTruffleRuntime {
 
+    private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>());
+
     public static TruffleRuntime makeInstance() {
         return new HotSpotTruffleRuntime();
     }
@@ -124,7 +126,6 @@
         private Map<OptimizedCallTarget, Future<?>> compilations = Collections.synchronizedMap(new IdentityHashMap<>());
         private final ExecutorService compileQueue;
         private StackIntrospection stackIntrospection;
-        private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>());
 
         public Lazy(HotSpotTruffleRuntime runtime) {
             runtime.installDefaultListeners();
@@ -209,7 +210,7 @@
         }
         OptimizedCallTarget target = new OptimizedCallTarget(source, rootNode, this, compilationPolicy, new HotSpotSpeculationLog());
         rootNode.setCallTarget(target);
-        lazy().callTargets.put(target, null);
+        callTargets.put(target, null);
 
         return target;
     }
@@ -337,6 +338,11 @@
 
     @Override
     public boolean cancelInstalledTask(OptimizedCallTarget optimizedCallTarget, Object source, CharSequence reason) {
+        if (lazy == null) {
+            // if truffle wasn't initialized yet, this is a noop
+            return false;
+        }
+
         Lazy l = lazy();
         Future<?> codeTask = l.compilations.get(optimizedCallTarget);
         if (codeTask != null && isCompiling(optimizedCallTarget)) {
@@ -411,7 +417,7 @@
 
     @Override
     public Collection<RootCallTarget> getCallTargets() {
-        return Collections.unmodifiableSet(lazy().callTargets.keySet());
+        return Collections.unmodifiableSet(callTargets.keySet());
     }
 
     @Override