changeset 23394:7743f81f8c4a

clean up and minimize JVMCI (JDK-8156835) - part 2
author Doug Simon <doug.simon@oracle.com>
date Fri, 13 May 2016 10:44:29 +0200
parents 1d4ce2d19e52
children 19432ed40848
files jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestResult.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompilationRequestResult.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java src/share/vm/jvmci/jvmciCompiler.cpp src/share/vm/jvmci/jvmciJavaClasses.hpp src/share/vm/jvmci/systemDictionary_jvmci.hpp src/share/vm/jvmci/vmSymbols_jvmci.hpp
diffstat 7 files changed, 129 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestResult.java	Thu May 12 20:57:31 2016 +0200
+++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestResult.java	Fri May 13 10:44:29 2016 +0200
@@ -23,49 +23,15 @@
 package jdk.vm.ci.code;
 
 /**
- * Simple class to provide information about the result of a compile request.
+ * Provides information about the result of a {@link CompilationRequest}.
  */
-public final class CompilationRequestResult {
-
-    /**
-     * A user readable description of the failure.
-     */
-    private final String failureMessage;
-
-    /**
-     * Whether this is a transient failure where retrying would help.
-     */
-    private final boolean retry;
+public interface CompilationRequestResult {
 
     /**
-     * Number of bytecodes inlined into the compilation, exclusive of the bytecodes in the root
-     * method.
+     * Determines if the compilation was successful.
+     *
+     * @return a non-null object whose {@link Object#toString()} describes the failure or null if
+     *         compilation was successful
      */
-    private final int inlinedBytecodes;
-
-    private CompilationRequestResult(String failureMessage, boolean retry, int inlinedBytecodes) {
-        this.failureMessage = failureMessage;
-        this.retry = retry;
-        this.inlinedBytecodes = inlinedBytecodes;
-    }
-
-    public static CompilationRequestResult success(int inlinedBytecodes) {
-        return new CompilationRequestResult(null, true, inlinedBytecodes);
-    }
-
-    public static CompilationRequestResult failure(String failureMessage, boolean retry) {
-        return new CompilationRequestResult(failureMessage, retry, 0);
-    }
-
-    public String getFailureMessage() {
-        return failureMessage;
-    }
-
-    public boolean getRetry() {
-        return retry;
-    }
-
-    public int getInlinedBytecodes() {
-        return inlinedBytecodes;
-    }
+    Object getFailure();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompilationRequestResult.java	Fri May 13 10:44:29 2016 +0200
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.code.CompilationRequest;
+import jdk.vm.ci.code.CompilationRequestResult;
+
+/**
+ * HotSpot specific information about the result of a {@link CompilationRequest}.
+ */
+public final class HotSpotCompilationRequestResult implements CompilationRequestResult {
+
+    /**
+     * A user readable description of the failure.
+     *
+     * This field is read by the VM.
+     */
+    private final String failureMessage;
+
+    /**
+     * Whether this is a transient failure where retrying would help.
+     *
+     * This field is read by the VM.
+     */
+    private final boolean retry;
+
+    /**
+     * Number of bytecodes inlined into the compilation, exclusive of the bytecodes in the root
+     * method.
+     *
+     * This field is read by the VM.
+     */
+    private final int inlinedBytecodes;
+
+    private HotSpotCompilationRequestResult(String failureMessage, boolean retry, int inlinedBytecodes) {
+        this.failureMessage = failureMessage;
+        this.retry = retry;
+        this.inlinedBytecodes = inlinedBytecodes;
+    }
+
+    public Object getFailure() {
+        return failureMessage;
+    }
+
+    /**
+     * Creates a result representing a successful compilation.
+     *
+     * @param inlinedBytecodes number of bytecodes inlined into the compilation, exclusive of the
+     *            bytecodes in the root method
+     */
+    public static HotSpotCompilationRequestResult success(int inlinedBytecodes) {
+        return new HotSpotCompilationRequestResult(null, true, inlinedBytecodes);
+    }
+
+    /**
+     * Creates a result representing a failed compilation.
+     *
+     * @param failureMessage a description of the failure
+     * @param retry whether this is a transient failure where retrying may succeed
+     */
+    public static HotSpotCompilationRequestResult failure(String failureMessage, boolean retry) {
+        return new HotSpotCompilationRequestResult(failureMessage, retry, 0);
+    }
+
+    public String getFailureMessage() {
+        return failureMessage;
+    }
+
+    public boolean getRetry() {
+        return retry;
+    }
+
+    public int getInlinedBytecodes() {
+        return inlinedBytecodes;
+    }
+}
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Thu May 12 20:57:31 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Fri May 13 10:44:29 2016 +0200
@@ -343,10 +343,24 @@
      * Called from the VM.
      */
     @SuppressWarnings({"unused"})
-    private CompilationRequestResult compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) {
+    private HotSpotCompilationRequestResult compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) {
         CompilationRequestResult result = getCompiler().compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id));
         assert result != null : "compileMethod must always return something";
-        return result;
+        HotSpotCompilationRequestResult hsResult;
+        if (result instanceof HotSpotCompilationRequestResult) {
+            hsResult = (HotSpotCompilationRequestResult) result;
+        } else {
+            Object failure = result.getFailure();
+            if (failure != null) {
+                boolean retry = false; // Be conservative with unknown compiler
+                hsResult = HotSpotCompilationRequestResult.failure(failure.toString(), retry);
+            } else {
+                int inlinedBytecodes = -1;
+                hsResult = HotSpotCompilationRequestResult.success(inlinedBytecodes);
+            }
+        }
+
+        return hsResult;
     }
 
     /**
--- a/src/share/vm/jvmci/jvmciCompiler.cpp	Thu May 12 20:57:31 2016 +0200
+++ b/src/share/vm/jvmci/jvmciCompiler.cpp	Fri May 13 10:44:29 2016 +0200
@@ -164,15 +164,15 @@
   } else {
     oop result_object = (oop) result.get_jobject();
     if (result_object != NULL) {
-      oop failure_message = CompilationRequestResult::failureMessage(result_object);
+      oop failure_message = HotSpotCompilationRequestResult::failureMessage(result_object);
       if (failure_message != NULL) {
         const char* failure_reason = java_lang_String::as_utf8_string(failure_message);
-        env->set_failure(failure_reason, CompilationRequestResult::retry(result_object));
+        env->set_failure(failure_reason, HotSpotCompilationRequestResult::retry(result_object));
       } else {
         if (env->task()->code() == NULL) {
           env->set_failure("no nmethod produced", true);
         } else {
-          env->task()->set_num_inlined_bytecodes(CompilationRequestResult::inlinedBytecodes(result_object));
+          env->task()->set_num_inlined_bytecodes(HotSpotCompilationRequestResult::inlinedBytecodes(result_object));
           Atomic::inc(&_methods_compiled);
         }
       }
--- a/src/share/vm/jvmci/jvmciJavaClasses.hpp	Thu May 12 20:57:31 2016 +0200
+++ b/src/share/vm/jvmci/jvmciJavaClasses.hpp	Fri May 13 10:44:29 2016 +0200
@@ -160,10 +160,10 @@
   start_class(site_Mark)                                                                                                                                       \
     oop_field(site_Mark, id, "Ljava/lang/Object;")                                                                                                             \
   end_class                                                                                                                                                    \
-  start_class(CompilationRequestResult)                                                                                                                        \
-    oop_field(CompilationRequestResult, failureMessage, "Ljava/lang/String;")                                                                                  \
-    boolean_field(CompilationRequestResult, retry)                                                                                                             \
-    int_field(CompilationRequestResult, inlinedBytecodes)                                                                                                      \
+  start_class(HotSpotCompilationRequestResult)                                                                                                                 \
+    oop_field(HotSpotCompilationRequestResult, failureMessage, "Ljava/lang/String;")                                                                           \
+    boolean_field(HotSpotCompilationRequestResult, retry)                                                                                                      \
+    int_field(HotSpotCompilationRequestResult, inlinedBytecodes)                                                                                               \
   end_class                                                                                                                                                    \
   start_class(DebugInfo)                                                                                                                                       \
     oop_field(DebugInfo, bytecodePosition, "Ljdk/vm/ci/code/BytecodePosition;")                                                                                \
--- a/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Thu May 12 20:57:31 2016 +0200
+++ b/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Fri May 13 10:44:29 2016 +0200
@@ -46,6 +46,7 @@
   do_klass(HotSpotJVMCIMetaAccessContext_klass,          jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext,       Jvmci) \
   do_klass(HotSpotJVMCIRuntime_klass,                    jdk_vm_ci_hotspot_HotSpotJVMCIRuntime,                 Jvmci) \
   do_klass(HotSpotSpeculationLog_klass,                  jdk_vm_ci_hotspot_HotSpotSpeculationLog,               Jvmci) \
+  do_klass(HotSpotCompilationRequestResult_klass,        jdk_vm_ci_hotspot_HotSpotCompilationRequestResult,     Jvmci) \
   do_klass(Assumptions_ConcreteMethod_klass,             jdk_vm_ci_meta_Assumptions_ConcreteMethod,             Jvmci) \
   do_klass(Assumptions_NoFinalizableSubclass_klass,      jdk_vm_ci_meta_Assumptions_NoFinalizableSubclass,      Jvmci) \
   do_klass(Assumptions_ConcreteSubtype_klass,            jdk_vm_ci_meta_Assumptions_ConcreteSubtype,            Jvmci) \
@@ -57,7 +58,6 @@
   do_klass(DebugInfo_klass,                              jdk_vm_ci_code_DebugInfo,                              Jvmci) \
   do_klass(RegisterSaveLayout_klass,                     jdk_vm_ci_code_RegisterSaveLayout,                     Jvmci) \
   do_klass(BytecodeFrame_klass,                          jdk_vm_ci_code_BytecodeFrame,                          Jvmci) \
-  do_klass(CompilationRequestResult_klass,               jdk_vm_ci_code_CompilationRequestResult,               Jvmci) \
   do_klass(InstalledCode_klass,                          jdk_vm_ci_code_InstalledCode,                          Jvmci) \
   do_klass(code_Location_klass,                          jdk_vm_ci_code_Location,                               Jvmci) \
   do_klass(code_Register_klass,                          jdk_vm_ci_code_Register,                               Jvmci) \
--- a/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Thu May 12 20:57:31 2016 +0200
+++ b/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Fri May 13 10:44:29 2016 +0200
@@ -47,6 +47,7 @@
   template(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext,       "jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext")                      \
   template(jdk_vm_ci_hotspot_HotSpotJVMCIRuntime,                 "jdk/vm/ci/hotspot/HotSpotJVMCIRuntime")                                \
   template(jdk_vm_ci_hotspot_HotSpotSpeculationLog,               "jdk/vm/ci/hotspot/HotSpotSpeculationLog")                              \
+  template(jdk_vm_ci_hotspot_HotSpotCompilationRequestResult,     "jdk/vm/ci/hotspot/HotSpotCompilationRequestResult")                    \
   template(jdk_vm_ci_meta_JavaConstant,                           "jdk/vm/ci/meta/JavaConstant")                                          \
   template(jdk_vm_ci_meta_PrimitiveConstant,                      "jdk/vm/ci/meta/PrimitiveConstant")                                     \
   template(jdk_vm_ci_meta_RawConstant,                            "jdk/vm/ci/meta/RawConstant")                                           \
@@ -63,7 +64,6 @@
   template(jdk_vm_ci_code_Architecture,                           "jdk/vm/ci/code/Architecture")                                          \
   template(jdk_vm_ci_code_BytecodeFrame,                          "jdk/vm/ci/code/BytecodeFrame")                                         \
   template(jdk_vm_ci_code_BytecodePosition,                       "jdk/vm/ci/code/BytecodePosition")                                      \
-  template(jdk_vm_ci_code_CompilationRequestResult,               "jdk/vm/ci/code/CompilationRequestResult")                              \
   template(jdk_vm_ci_code_DebugInfo,                              "jdk/vm/ci/code/DebugInfo")                                             \
   template(jdk_vm_ci_code_InstalledCode,                          "jdk/vm/ci/code/InstalledCode")                                         \
   template(jdk_vm_ci_code_Location,                               "jdk/vm/ci/code/Location")                                              \
@@ -88,7 +88,7 @@
   template(adjustCompilationLevel_name,                           "adjustCompilationLevel")                                               \
   template(adjustCompilationLevel_signature,                      "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;ZI)I")           \
   template(compileMethod_name,                                    "compileMethod")                                                        \
-  template(compileMethod_signature,                               "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)Ljdk/vm/ci/code/CompilationRequestResult;") \
+  template(compileMethod_signature,                               "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)Ljdk/vm/ci/hotspot/HotSpotCompilationRequestResult;") \
   template(fromMetaspace_name,                                    "fromMetaspace")                                                        \
   template(method_fromMetaspace_signature,                        "(J)Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;")                     \
   template(constantPool_fromMetaspace_signature,                  "(J)Ljdk/vm/ci/hotspot/HotSpotConstantPool;")                           \