changeset 22685:3039e5bb94cb

initialize JVMCI eagerly if either the PrintFlags or ShowFlags JVMCI option is present
author Doug Simon <doug.simon@oracle.com>
date Thu, 15 Oct 2015 17:32:19 +0200
parents ceca35d52380
children 2408f05d0ae7
files jvmci/jdk.vm.ci.options/src/jdk/vm/ci/options/OptionsParser.java src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/jvmci/jvmciRuntime.hpp src/share/vm/runtime/thread.cpp
diffstat 4 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.options/src/jdk/vm/ci/options/OptionsParser.java	Thu Oct 15 17:30:42 2015 +0200
+++ b/jvmci/jdk.vm.ci.options/src/jdk/vm/ci/options/OptionsParser.java	Thu Oct 15 17:32:19 2015 +0200
@@ -47,6 +47,7 @@
 public class OptionsParser {
 
     private static final OptionValue<Boolean> PrintFlags = new OptionValue<>(false);
+    private static final OptionValue<Boolean> ShowFlags = new OptionValue<>(false);
 
     /**
      * A service for looking up {@link OptionDescriptor}s.
@@ -153,8 +154,12 @@
     public static void parseOption(String name, String valueString, OptionConsumer setter, OptionDescriptorsProvider odp, SortedMap<String, OptionDescriptor> options) {
 
         OptionDescriptor desc = odp != null ? odp.get(name) : resolveOptions(options).get(name);
-        if (desc == null && name.equals("PrintFlags")) {
-            desc = OptionDescriptor.create("PrintFlags", Boolean.class, "Prints all JVMCI flags and exits", OptionsParser.class, "PrintFlags", PrintFlags);
+        if (desc == null) {
+            if (name.equals("PrintFlags")) {
+                desc = OptionDescriptor.create("PrintFlags", Boolean.class, "Prints all JVMCI flags and exits", OptionsParser.class, "PrintFlags", PrintFlags);
+            } else if (name.equals("ShowFlags")) {
+                desc = OptionDescriptor.create("ShowFlags", Boolean.class, "Prints all JVMCI flags and continues", OptionsParser.class, "ShowFlags", ShowFlags);
+            }
         }
         if (desc == null) {
             List<OptionDescriptor> matches = fuzzyMatch(resolveOptions(options), name);
@@ -198,9 +203,11 @@
             setter.set(desc, value);
         }
 
-        if (PrintFlags.getValue()) {
+        if (PrintFlags.getValue() || ShowFlags.getValue()) {
             printFlags(resolveOptions(options), "JVMCI", System.out);
-            System.exit(0);
+            if (PrintFlags.getValue()) {
+                System.exit(0);
+            }
         }
     }
 
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Oct 15 17:30:42 2015 +0200
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Oct 15 17:32:19 2015 +0200
@@ -940,6 +940,23 @@
   _compiler = compiler;
 }
 
+void JVMCIRuntime::maybe_print_flags(TRAPS) {
+  if (_options != NULL) {
+    for (int i = 0; i < _options_count; i++) {
+      SystemProperty* p = _options[i];
+      const char* name = p->key() + OPTION_PREFIX_LEN;
+      if (strcmp(name, "PrintFlags") == 0 || strcmp(name, "ShowFlags") == 0) {
+        JVMCIRuntime::ensure_jvmci_class_loader_is_initialized();
+        jvmci_compute_offsets();
+        HandleMark hm;
+        ResourceMark rm;
+        JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
+        return;
+      }
+    }
+  }
+}
+
 void JVMCIRuntime::save_options(SystemProperty* props) {
   int count = 0;
   SystemProperty* first = NULL;
--- a/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Oct 15 17:30:42 2015 +0200
+++ b/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Oct 15 17:32:19 2015 +0200
@@ -96,6 +96,12 @@
   static void save_options(SystemProperty* props);
 
   /**
+   * If either the PrintFlags or ShowFlags JVMCI option is present,
+   * then JVMCI is initialized to show the help message.
+   */
+  static void maybe_print_flags(TRAPS);
+
+  /**
    * Ensures that the JVMCI class loader is initialized and the well known JVMCI classes are loaded.
    */
   static void ensure_jvmci_class_loader_is_initialized();
--- a/src/share/vm/runtime/thread.cpp	Thu Oct 15 17:30:42 2015 +0200
+++ b/src/share/vm/runtime/thread.cpp	Thu Oct 15 17:32:19 2015 +0200
@@ -3706,6 +3706,10 @@
   if (jvmciCompiler != NULL) {
     JVMCIRuntime::save_compiler(jvmciCompiler);
   }
+  JVMCIRuntime::maybe_print_flags(THREAD);
+  if (HAS_PENDING_EXCEPTION) {
+    vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
+  }
 #endif
 
   // initialize compiler(s)