< prev index next >

test/lib/sun/hotspot/WhiteBox.java

Print this page
rev 1945 : 8150646: Add support for blocking compiles though whitebox API
Reviewed-by: kvn, ppunegov, simonis, neliasso
Contributed-by: nils.eliasson@oracle.com, volker.simonis@gmail.com

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -301,16 +301,35 @@
   public         boolean testSetForceInlineMethod(Executable method, boolean value) {
     Objects.requireNonNull(method);
     return testSetForceInlineMethod0(method, value);
   }
   public        boolean enqueueMethodForCompilation(Executable method, int compLevel) {
-    return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
+    return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/, false);
+  }
+  // This is a convenience method for doing blocking compiles.
+  // It adds a new compiler directive which may shadow previously added directives!
+  public        boolean enqueueMethodForCompilation(Executable method, int compLevel, boolean block) {
+        return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/, block);
   }
   private native boolean enqueueMethodForCompilation0(Executable method, int compLevel, int entry_bci);
   public  boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci) {
-    Objects.requireNonNull(method);
-    return enqueueMethodForCompilation0(method, compLevel, entry_bci);
+    return enqueueMethodForCompilation(method, compLevel, entry_bci, false);
+  }
+  // This is a convenience method for doing blocking compiles.
+  // It adds a new compiler directive which may shadow previously added directives!
+  public  boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci, boolean block) {
+    Objects.requireNonNull(method);
+    if (block) {
+      String comp = (compLevel == 4) ? "c2: {" : "c1: {";
+      addCompilerDirective("[{ match: \"" + method.getDeclaringClass().getName() + "::" + method.getName() + "\", " +
+                           comp + "BackgroundCompilation: false }}]");
+    }
+    boolean ret = enqueueMethodForCompilation0(method, compLevel, entry_bci);
+    if (block) {
+      removeCompilerDirective(1);
+    }
+    return ret;
   }
   private native void    clearMethodState0(Executable method);
   public         void    clearMethodState(Executable method) {
     Objects.requireNonNull(method);
     clearMethodState0(method);

@@ -453,6 +472,10 @@
 
   // Sharing
   public native boolean isSharedClass(Class<?> c);
   public native boolean isShared(Object o);
   public native boolean areSharedStringsIgnored();
+
+  // Compiler Directive
+  public native int addCompilerDirective(String compDirect);
+  public native void removeCompilerDirective(int count);
 }
< prev index next >