changeset 22575:569c82ebb96e

Replace JVMCICompileWithC1Only with package based controls
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 17 Sep 2015 18:25:08 -0700
parents 5a706439be63
children b4abfaab2ba9
files jvmci/jdk.internal.jvmci.compiler/src/jdk/internal/jvmci/compiler/CompilerFactory.java jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java src/share/vm/compiler/abstractCompiler.hpp src/share/vm/jvmci/jvmciCompiler.cpp src/share/vm/jvmci/jvmciCompiler.hpp src/share/vm/jvmci/jvmciJavaClasses.hpp src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/jvmci/jvmciRuntime.hpp src/share/vm/jvmci/jvmci_globals.hpp src/share/vm/jvmci/systemDictionary_jvmci.hpp src/share/vm/jvmci/vmSymbols_jvmci.hpp src/share/vm/runtime/advancedThresholdPolicy.cpp src/share/vm/runtime/simpleThresholdPolicy.inline.hpp
diffstat 13 files changed, 64 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.compiler/src/jdk/internal/jvmci/compiler/CompilerFactory.java	Thu Sep 17 12:58:40 2015 -0700
+++ b/jvmci/jdk.internal.jvmci.compiler/src/jdk/internal/jvmci/compiler/CompilerFactory.java	Thu Sep 17 18:25:08 2015 -0700
@@ -46,4 +46,17 @@
      * Create a new instance of the {@link Compiler}.
      */
     Compiler createCompiler(JVMCIRuntime runtime);
+
+    /**
+     * In a tiered system it might be advantageous for startup to keep the JVMCI compiler from
+     * compiling itself so provide a hook to request that certain packages are compiled only by an
+     * optimizing first tier. The prefixes should class or package names using / as the separator,
+     * i.e. jdk/internal/jvmci for instance.
+     *
+     * @return 0 or more Strings identifying packages that should by compiled by the first tier
+     *         only.
+     */
+    default String[] getTrivialPrefixes() {
+        return null;
+    }
 }
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java	Thu Sep 17 12:58:40 2015 -0700
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java	Thu Sep 17 18:25:08 2015 -0700
@@ -110,6 +110,7 @@
      */
     public void completeInitialization() {
         compiler = HotSpotJVMCICompilerConfig.getCompilerFactory().createCompiler(this);
+        trivialPrefixes = HotSpotJVMCICompilerConfig.getCompilerFactory().getTrivialPrefixes();
     }
 
     public static HotSpotJVMCIBackendFactory findFactory(String architecture) {
@@ -141,6 +142,8 @@
 
     private final Iterable<HotSpotVMEventListener> vmEventListeners;
 
+    @SuppressWarnings("unused") private String[] trivialPrefixes;
+
     @SuppressWarnings("try")
     private HotSpotJVMCIRuntime() {
         compilerToVm = new CompilerToVM();
--- a/src/share/vm/compiler/abstractCompiler.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/compiler/abstractCompiler.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -114,6 +114,9 @@
   bool is_shark()                                { return _type == shark; }
   bool is_jvmci()                                { return _type == jvmci; }
 
+  // Extra tests to identity trivial methods for the tiered compilation policy.
+  virtual bool is_trivial(Method* method) { return false; }
+
   // Customization
   virtual void initialize () = 0;
 
--- a/src/share/vm/jvmci/jvmciCompiler.cpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/jvmciCompiler.cpp	Thu Sep 17 18:25:08 2015 -0700
@@ -69,8 +69,6 @@
   JavaThread* THREAD = JavaThread::current();
   _bootstrapping = true;
   // Allow bootstrap to perform JVMCI compilations of itself
-  bool c1only = JVMCICompileWithC1Only;
-  JVMCICompileWithC1Only = false;
   ResourceMark rm;
   HandleMark hm;
   if (PrintBootstrap) {
@@ -111,7 +109,6 @@
   if (PrintBootstrap) {
     tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled);
   }
-  JVMCICompileWithC1Only = c1only;
   _bootstrapping = false;
 }
 
@@ -156,6 +153,13 @@
   ShouldNotReachHere();
 }
 
+bool JVMCICompiler::is_trivial(Method* method) {
+  if (_bootstrapping) {
+    return false;
+  }
+  return JVMCIRuntime::treat_as_trivial(method);
+}
+
 // Print compilation timers and statistics
 void JVMCICompiler::print_timers() {
   print_compilation_timers();
--- a/src/share/vm/jvmci/jvmciCompiler.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/jvmciCompiler.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -75,6 +75,8 @@
 
   void compile_method(methodHandle target, int entry_bci, JVMCIEnv* env);
 
+  virtual bool is_trivial(Method* method);
+
   // Print compilation timers and statistics
   virtual void print_timers();
 
--- a/src/share/vm/jvmci/jvmciJavaClasses.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/jvmciJavaClasses.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -272,6 +272,9 @@
   start_class(HotSpotConstantPool)                                                                                                                             \
     long_field(HotSpotConstantPool, metaspaceConstantPool)                                                                                                     \
   end_class                                                                                                                                                    \
+  start_class(HotSpotJVMCIRuntime)                                                                                                                             \
+  objArrayOop_field(HotSpotJVMCIRuntime, trivialPrefixes, "[Ljava/lang/String;")                                                                               \
+  end_class                                                                                                                                                    \
   /* end*/
 
 #define START_CLASS(name)                                                                                                                                      \
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Sep 17 18:25:08 2015 -0700
@@ -49,6 +49,8 @@
 bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
 const char* JVMCIRuntime::_compiler = NULL;
 const char* JVMCIRuntime::_options = NULL;
+int JVMCIRuntime::_trivial_prefixes_count = 0;
+char** JVMCIRuntime::_trivial_prefixes = NULL;
 bool JVMCIRuntime::_shutdown_called = false;
 
 void JVMCIRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) {
@@ -706,6 +708,19 @@
     Handle result = callStatic("jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime",
                                "runtime",
                                "()Ljdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
+    objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
+    if (trivial_prefixes != NULL) {
+      _trivial_prefixes_count = trivial_prefixes->length();
+      _trivial_prefixes = NEW_C_HEAP_ARRAY(char*, _trivial_prefixes_count, mtCompiler);
+      for (int i = 0; i < trivial_prefixes->length(); i++) {
+        oop str = trivial_prefixes->obj_at(i);
+        if (str == NULL) {
+          THROW(vmSymbols::java_lang_NullPointerException());
+        } else {
+          _trivial_prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
+        }
+      }
+    }
     _HotSpotJVMCIRuntime_initialized = true;
     _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
   }
@@ -942,6 +957,15 @@
   }
 }
 
+bool JVMCIRuntime::treat_as_trivial(Method* method) {
+  for (int i = 0; i < _trivial_prefixes_count; i++) {
+    if (method->method_holder()->name()->starts_with(_trivial_prefixes[i])) {
+      return true;
+    }
+  }
+  return false;
+}
+
 void JVMCIRuntime::call_printStackTrace(Handle exception, Thread* thread) {
   assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
   JavaValue result(T_VOID);
--- a/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -61,6 +61,9 @@
   static const char* _compiler;
   static const char* _options;
 
+  static int _trivial_prefixes_count;
+  static char** _trivial_prefixes;
+
   static bool _shutdown_called;
 
   /**
@@ -132,6 +135,8 @@
     return _shutdown_called;
   }
 
+  static bool treat_as_trivial(Method* method);
+
   /**
    * Given an interface representing a JVMCI service (i.e. sub-interface of
    * jdk.internal.jvmci.api.service.Service), gets an array of objects, one per
--- a/src/share/vm/jvmci/jvmci_globals.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/jvmci_globals.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -85,12 +85,6 @@
   product(bool, JVMCICountersExcludeCompiler, true,                         \
           "Exclude JVMCI compiler threads from benchmark counters")         \
                                                                             \
-  product(bool, JVMCICompileWithC1Only, true,                               \
-          "Only compile JVMCI classes with C1")                             \
-                                                                            \
-  product(bool, JVMCICompileAppFirst, false,                                \
-          "Prioritize application compilations over JVMCI compilations")    \
-                                                                            \
   develop(bool, JVMCIUseFastLocking, true,                                  \
           "Use fast inlined locking code")                                  \
                                                                             \
--- a/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -44,6 +44,7 @@
   do_klass(HotSpotStackFrameReference_klass,             jdk_internal_jvmci_hotspot_HotSpotStackFrameReference,          Jvmci) \
   do_klass(HotSpotConstantPool_klass,                    jdk_internal_jvmci_hotspot_HotSpotConstantPool,                 Jvmci) \
   do_klass(HotSpotJVMCIMetaAccessContext_klass,          jdk_internal_jvmci_hotspot_HotSpotJVMCIMetaAccessContext,       Jvmci) \
+  do_klass(HotSpotJVMCIRuntime_klass,                    jdk_internal_jvmci_hotspot_HotSpotJVMCIRuntime,                 Jvmci) \
   do_klass(Assumptions_ConcreteMethod_klass,             jdk_internal_jvmci_meta_Assumptions_ConcreteMethod,             Jvmci) \
   do_klass(Assumptions_NoFinalizableSubclass_klass,      jdk_internal_jvmci_meta_Assumptions_NoFinalizableSubclass,      Jvmci) \
   do_klass(Assumptions_ConcreteSubtype_klass,            jdk_internal_jvmci_meta_Assumptions_ConcreteSubtype,            Jvmci) \
--- a/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -45,6 +45,7 @@
   template(jdk_internal_jvmci_hotspot_HotSpotStackFrameReference,      "jdk/internal/jvmci/hotspot/HotSpotStackFrameReference")           \
   template(jdk_internal_jvmci_hotspot_HotSpotConstantPool,             "jdk/internal/jvmci/hotspot/HotSpotConstantPool")                  \
   template(jdk_internal_jvmci_hotspot_HotSpotJVMCIMetaAccessContext,   "jdk/internal/jvmci/hotspot/HotSpotJVMCIMetaAccessContext")        \
+  template(jdk_internal_jvmci_hotspot_HotSpotJVMCIRuntime,             "jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime")                  \
   template(jdk_internal_jvmci_meta_JavaConstant,                       "jdk/internal/jvmci/meta/JavaConstant")                            \
   template(jdk_internal_jvmci_meta_PrimitiveConstant,                  "jdk/internal/jvmci/meta/PrimitiveConstant")                       \
   template(jdk_internal_jvmci_meta_RawConstant,                        "jdk/internal/jvmci/meta/RawConstant")                             \
--- a/src/share/vm/runtime/advancedThresholdPolicy.cpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/runtime/advancedThresholdPolicy.cpp	Thu Sep 17 18:25:08 2015 -0700
@@ -161,9 +161,6 @@
 
 // Called with the queue locked and with at least one element
 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
-#ifdef COMPILERJVMCI
-  CompileTask *max_non_jvmci_task = NULL;
-#endif
   CompileTask *max_task = NULL;
   Method* max_method = NULL;
   jlong t = os::javaTimeMillis();
@@ -194,30 +191,9 @@
         max_method = method;
       }
     }
-#ifdef COMPILERJVMCI
-    if (JVMCICompileAppFirst && (task->comp_level() == CompLevel_full_optimization || !method->has_compiled_code()) &&
-        SystemDictionary::jvmci_loader() != NULL &&
-        method->method_holder()->class_loader() != SystemDictionary::jvmci_loader()) {
-      if (max_non_jvmci_task == NULL) {
-        max_non_jvmci_task = task;
-      } else {
-        // Select a method with a higher rate
-        if (compare_methods(method, max_non_jvmci_task->method())) {
-          max_non_jvmci_task = task;
-        }
-      }
-    }
-#endif
     task = next_task;
   }
 
-#ifdef COMPILERJVMCI
-  if (max_non_jvmci_task != NULL) {
-    max_task = max_non_jvmci_task;
-    max_method = max_task->method();
-  }
-#endif
-
   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
       && is_method_profiled(max_method)) {
     max_task->set_comp_level(CompLevel_limited_profile);
--- a/src/share/vm/runtime/simpleThresholdPolicy.inline.hpp	Thu Sep 17 12:58:40 2015 -0700
+++ b/src/share/vm/runtime/simpleThresholdPolicy.inline.hpp	Thu Sep 17 18:25:08 2015 -0700
@@ -59,9 +59,8 @@
     return true;
   }
 #ifdef COMPILERJVMCI
-  if (TieredCompilation && JVMCICompileWithC1Only &&
-      SystemDictionary::jvmci_loader() != NULL &&
-      method->method_holder()->class_loader() == SystemDictionary::jvmci_loader()) {
+  if (TieredCompilation && CompileBroker::compiler(CompLevel_full_optimization) != NULL &&
+      CompileBroker::compiler(CompLevel_full_optimization)->is_trivial(method)) {
     return true;
   }
 #endif