changeset 38674:eacc567feae8

8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap Reviewed-by: twisti Contributed-by: josef.eisl@jku.at
author never
date Thu, 12 May 2016 04:17:00 +0000
parents e8a403dd5a7d
children 066fcb1eb80a
files hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java hotspot/src/share/vm/classfile/vmSymbols.hpp hotspot/src/share/vm/jvmci/jvmciCompiler.cpp hotspot/src/share/vm/jvmci/jvmciCompiler.hpp hotspot/src/share/vm/jvmci/jvmciRuntime.cpp hotspot/src/share/vm/jvmci/jvmciRuntime.hpp hotspot/src/share/vm/prims/jni.cpp hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.HotSpotVMEventListener hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.JVMCICompilerFactory
diffstat 10 files changed, 48 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Thu May 12 04:17:00 2016 +0000
@@ -382,6 +382,18 @@
     }
 
     /**
+     * Notify on completion of a bootstrap.
+     *
+     * Called from the VM.
+     */
+    @SuppressWarnings({"unused"})
+    private void bootstrapFinished() throws Exception {
+        for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
+            vmEventListener.notifyBootstrapFinished();
+        }
+    }
+
+    /**
      * Notify on successful install into the CodeCache.
      *
      * @param hotSpotCodeCacheProvider
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java	Thu May 12 04:17:00 2016 +0000
@@ -75,6 +75,12 @@
     }
 
     /**
+     * Notify on completion of a bootstrap.
+     */
+    public void notifyBootstrapFinished() {
+    }
+
+    /**
      * Create a custom {@link JVMCIMetaAccessContext} to be used for managing the lifetime of loaded
      * metadata. It a custom one isn't created then the default implementation will be a single
      * context with globally shared instances of {@link ResolvedJavaType} that are never released.
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu May 12 04:17:00 2016 +0000
@@ -358,6 +358,7 @@
   template(nthreads_name,                             "nthreads")                                 \
   template(ngroups_name,                              "ngroups")                                  \
   template(shutdown_method_name,                      "shutdown")                                 \
+  template(bootstrapFinished_method_name,             "bootstrapFinished")                        \
   template(finalize_method_name,                      "finalize")                                 \
   template(reference_lock_name,                       "lock")                                     \
   template(reference_discovered_name,                 "discovered")                               \
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Thu May 12 04:17:00 2016 +0000
@@ -39,6 +39,7 @@
 
 JVMCICompiler::JVMCICompiler() : AbstractCompiler(jvmci) {
   _bootstrapping = false;
+  _bootstrap_compilation_request_handled = false;
   _methods_compiled = 0;
   assert(_instance == NULL, "only one instance allowed");
   _instance = this;
@@ -57,7 +58,7 @@
   CompilationPolicy::completed_vm_startup();
 }
 
-void JVMCICompiler::bootstrap() {
+void JVMCICompiler::bootstrap(TRAPS) {
   if (Arguments::mode() == Arguments::_int) {
     // Nothing to do in -Xint mode
     return;
@@ -68,7 +69,6 @@
   FlagSetting ctwOff(CompileTheWorld, false);
 #endif
 
-  JavaThread* THREAD = JavaThread::current();
   _bootstrapping = true;
   ResourceMark rm;
   HandleMark hm;
@@ -97,7 +97,7 @@
     do {
       os::sleep(THREAD, 100, true);
       qsize = CompileBroker::queue_size(CompLevel_full_optimization);
-    } while (first_round && qsize == 0);
+    } while (!_bootstrap_compilation_request_handled && first_round && qsize == 0);
     first_round = false;
     if (PrintBootstrap) {
       while (z < (_methods_compiled / 100)) {
@@ -111,6 +111,7 @@
     tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methods_compiled);
   }
   _bootstrapping = false;
+  JVMCIRuntime::bootstrap_finished(CHECK);
 }
 
 #define CHECK_ABORT THREAD); \
@@ -187,6 +188,9 @@
       assert(false, "JVMCICompiler.compileMethod should always return non-null");
     }
   }
+  if (_bootstrapping) {
+    _bootstrap_compilation_request_handled = true;
+  }
 }
 
 CompLevel JVMCIRuntime::adjust_comp_level(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread) {
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.hpp	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.hpp	Thu May 12 04:17:00 2016 +0000
@@ -33,6 +33,11 @@
   bool _bootstrapping;
 
   /**
+   * True if we have seen a bootstrap compilation request.
+   */
+  volatile bool _bootstrap_compilation_request_handled;
+
+  /**
    * Number of methods successfully compiled by a call to
    * JVMCICompiler::compile_method().
    */
@@ -72,7 +77,7 @@
    * Initialize the compile queue with the methods in java.lang.Object and
    * then wait until the queue is empty.
    */
-  void bootstrap();
+  void bootstrap(TRAPS);
 
   bool is_bootstrapping() const { return _bootstrapping; }
 
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Thu May 12 04:17:00 2016 +0000
@@ -867,6 +867,15 @@
 #undef CHECK_RETURN
 }
 
+void JVMCIRuntime::bootstrap_finished(TRAPS) {
+  HandleMark hm(THREAD);
+  Handle receiver = get_HotSpotJVMCIRuntime(CHECK);
+  JavaValue result(T_VOID);
+  JavaCallArguments args;
+  args.push_oop(receiver);
+  JavaCalls::call_special(&result, receiver->klass(), vmSymbols::bootstrapFinished_method_name(), vmSymbols::void_method_signature(), &args, CHECK);
+}
+
 bool JVMCIRuntime::treat_as_trivial(Method* method) {
   if (_HotSpotJVMCIRuntime_initialized) {
     for (int i = 0; i < _trivial_prefixes_count; i++) {
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Thu May 12 04:17:00 2016 +0000
@@ -127,6 +127,8 @@
 
   static void shutdown(TRAPS);
 
+  static void bootstrap_finished(TRAPS);
+
   static bool shutdown_called() {
     return _shutdown_called;
   }
--- a/hotspot/src/share/vm/prims/jni.cpp	Wed May 11 17:43:23 2016 -0700
+++ b/hotspot/src/share/vm/prims/jni.cpp	Thu May 12 04:17:00 2016 +0000
@@ -3988,7 +3988,11 @@
         if (BootstrapJVMCI) {
           JavaThread* THREAD = thread;
           JVMCICompiler* compiler = JVMCICompiler::instance(CATCH);
-          compiler->bootstrap();
+          compiler->bootstrap(THREAD);
+          if (HAS_PENDING_EXCEPTION) {
+            HandleMark hm;
+            vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
+          }
         }
       }
     }
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.HotSpotVMEventListener	Wed May 11 17:43:23 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.JVMCICompilerFactory	Wed May 11 17:43:23 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory