changeset 22780:b4ff1a18d19c

Move data fields from CompiledCode to HotSpotCompiledCode
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 19 Jan 2016 17:36:21 -0800
parents b41377216cf9
children 5d06abd6d35b
files jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java src/share/vm/jvmci/jvmciCodeInstaller.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, 87 insertions(+), 97 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java	Tue Jan 19 13:32:31 2016 -0800
+++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java	Tue Jan 19 17:36:21 2016 -0800
@@ -22,82 +22,8 @@
  */
 package jdk.vm.ci.code;
 
-import jdk.vm.ci.code.site.Infopoint;
-import jdk.vm.ci.code.site.Site;
-import jdk.vm.ci.meta.Assumptions.Assumption;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
-
 /**
- * Abstract base class that represents the output from compiling a method.
+ * The output from compiling a method.
  */
-public abstract class CompiledCode {
-
-    /**
-     * The name of this compilation unit.
-     */
-    protected final String name;
-
-    /**
-     * The buffer containing the emitted machine code.
-     */
-    protected final byte[] targetCode;
-
-    /**
-     * The leading number of bytes in {@link #targetCode} containing the emitted machine code.
-     */
-    protected final int targetCodeSize;
-
-    /**
-     * A list of code annotations describing special sites in {@link #targetCode}.
-     */
-    protected final Site[] sites;
-
-    /**
-     * A list of {@link Assumption} this code relies on.
-     */
-    protected final Assumption[] assumptions;
-
-    /**
-     * The list of the methods whose bytecodes were used as input to the compilation. If
-     * {@code null}, then the compilation did not record method dependencies. Otherwise, the first
-     * element of this array is the root method of the compilation.
-     */
-    protected final ResolvedJavaMethod[] methods;
-
-    public CompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods) {
-        this.name = name;
-        this.targetCode = targetCode;
-        this.targetCodeSize = targetCodeSize;
-        this.sites = sites;
-        this.assumptions = assumptions;
-        this.methods = methods;
-
-        assert validateFrames();
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public String toString() {
-        return name;
-    }
-
-    /**
-     * Ensure that all the frames passed into the VM are properly formatted with an empty or illegal
-     * slot following double word slots.
-     */
-    private boolean validateFrames() {
-        for (Site site : sites) {
-            if (site instanceof Infopoint) {
-                Infopoint info = (Infopoint) site;
-                if (info.debugInfo != null) {
-                    BytecodeFrame frame = info.debugInfo.frame();
-                    assert frame == null || frame.validateFormat();
-                }
-            }
-        }
-        return true;
-    }
+public interface CompiledCode {
 }
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Tue Jan 19 13:32:31 2016 -0800
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Tue Jan 19 17:36:21 2016 -0800
@@ -111,9 +111,9 @@
         if (installedCode == null) {
             if (method == null) {
                 // Must be a stub
-                resultInstalledCode = new HotSpotRuntimeStub(compiledCode.getName());
+                resultInstalledCode = new HotSpotRuntimeStub(((HotSpotCompiledCode) compiledCode).getName());
             } else {
-                resultInstalledCode = new HotSpotNmethod((HotSpotResolvedJavaMethod) method, compiledCode.getName(), isDefault);
+                resultInstalledCode = new HotSpotNmethod((HotSpotResolvedJavaMethod) method, ((HotSpotCompiledCode) compiledCode).getName(), isDefault);
             }
         } else {
             resultInstalledCode = installedCode;
@@ -135,7 +135,7 @@
                 }
                 throw new BailoutException(result != config.codeInstallResultDependenciesFailed, msg);
             } else {
-                throw new BailoutException("Error installing %s: %s", compiledCode.getName(), resultDesc);
+                throw new BailoutException("Error installing %s: %s", ((HotSpotCompiledCode) compiledCode).getName(), resultDesc);
             }
         }
         return logOrDump(resultInstalledCode, compiledCode);
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java	Tue Jan 19 13:32:31 2016 -0800
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java	Tue Jan 19 17:36:21 2016 -0800
@@ -22,8 +22,10 @@
  */
 package jdk.vm.ci.hotspot;
 
+import jdk.vm.ci.code.BytecodeFrame;
 import jdk.vm.ci.code.CompiledCode;
 import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Infopoint;
 import jdk.vm.ci.code.site.Site;
 import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -32,7 +34,39 @@
  * A {@link CompiledCode} with additional HotSpot-specific information required for installing the
  * code in HotSpot's code cache.
  */
-public class HotSpotCompiledCode extends CompiledCode {
+public class HotSpotCompiledCode implements CompiledCode {
+
+    /**
+     * The name of this compilation unit.
+     */
+    protected final String name;
+
+    /**
+     * The buffer containing the emitted machine code.
+     */
+    protected final byte[] targetCode;
+
+    /**
+     * The leading number of bytes in {@link #targetCode} containing the emitted machine code.
+     */
+    protected final int targetCodeSize;
+
+    /**
+     * A list of code annotations describing special sites in {@link #targetCode}.
+     */
+    protected final Site[] sites;
+
+    /**
+     * A list of {@link Assumption} this code relies on.
+     */
+    protected final Assumption[] assumptions;
+
+    /**
+     * The list of the methods whose bytecodes were used as input to the compilation. If
+     * {@code null}, then the compilation did not record method dependencies. Otherwise, the first
+     * element of this array is the root method of the compilation.
+     */
+    protected final ResolvedJavaMethod[] methods;
 
     protected final Comment[] comments;
 
@@ -56,12 +90,46 @@
 
     public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
                     int dataSectionAlignment, DataPatch[] dataSectionPatches, int totalFrameSize, int customStackAreaOffset) {
-        super(name, targetCode, targetCodeSize, sites, assumptions, methods);
+        this.name = name;
+        this.targetCode = targetCode;
+        this.targetCodeSize = targetCodeSize;
+        this.sites = sites;
+        this.assumptions = assumptions;
+        this.methods = methods;
+
         this.comments = comments;
         this.dataSection = dataSection;
         this.dataSectionAlignment = dataSectionAlignment;
         this.dataSectionPatches = dataSectionPatches;
         this.totalFrameSize = totalFrameSize;
         this.customStackAreaOffset = customStackAreaOffset;
+
+        assert validateFrames();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    /**
+     * Ensure that all the frames passed into the VM are properly formatted with an empty or illegal
+     * slot following double word slots.
+     */
+    private boolean validateFrames() {
+        for (Site site : sites) {
+            if (site instanceof Infopoint) {
+                Infopoint info = (Infopoint) site;
+                if (info.debugInfo != null) {
+                    BytecodeFrame frame = info.debugInfo.frame();
+                    assert frame == null || frame.validateFormat();
+                }
+            }
+        }
+        return true;
     }
 }
--- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Tue Jan 19 13:32:31 2016 -0800
+++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Tue Jan 19 17:36:21 2016 -0800
@@ -390,7 +390,7 @@
   CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL;
   _oop_recorder = new OopRecorder(&_arena, true);
   _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL);
-  objArrayHandle assumptions = CompiledCode::assumptions(compiled_code);
+  objArrayHandle assumptions = HotSpotCompiledCode::assumptions(compiled_code);
   if (!assumptions.is_null()) {
     int length = assumptions->length();
     for (int i = 0; i < length; ++i) {
@@ -413,7 +413,7 @@
     }
   }
   if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
-    objArrayHandle methods = CompiledCode::methods(compiled_code);
+    objArrayHandle methods = HotSpotCompiledCode::methods(compiled_code);
     if (!methods.is_null()) {
       int length = methods->length();
       for (int i = 0; i < length; ++i) {
@@ -444,7 +444,7 @@
   int stack_slots = _total_frame_size / HeapWordSize; // conversion to words
 
   if (!compiled_code->is_a(HotSpotCompiledNmethod::klass())) {
-    oop stubName = CompiledCode::name(compiled_code_obj);
+    oop stubName = HotSpotCompiledCode::name(compiled_code_obj);
     char* name = strdup(java_lang_String::as_utf8_string(stubName));
     cb = RuntimeStub::new_runtime_stub(name,
                                        &buffer,
@@ -489,10 +489,10 @@
     // Only used in OopMap constructor for non-product builds
     _parameter_count = 0;
   }
-  _sites_handle = JNIHandles::make_local(CompiledCode::sites(compiled_code));
+  _sites_handle = JNIHandles::make_local(HotSpotCompiledCode::sites(compiled_code));
 
-  _code_handle = JNIHandles::make_local(CompiledCode::targetCode(compiled_code));
-  _code_size = CompiledCode::targetCodeSize(compiled_code);
+  _code_handle = JNIHandles::make_local(HotSpotCompiledCode::targetCode(compiled_code));
+  _code_size = HotSpotCompiledCode::targetCodeSize(compiled_code);
   _total_frame_size = HotSpotCompiledCode::totalFrameSize(compiled_code);
   _custom_stack_area_offset = HotSpotCompiledCode::customStackAreaOffset(compiled_code);
 
--- a/src/share/vm/jvmci/jvmciJavaClasses.hpp	Tue Jan 19 13:32:31 2016 -0800
+++ b/src/share/vm/jvmci/jvmciJavaClasses.hpp	Tue Jan 19 17:36:21 2016 -0800
@@ -77,15 +77,13 @@
   start_class(HotSpotNmethod)                                                                                                                                  \
     boolean_field(HotSpotNmethod, isDefault)                                                                                                                   \
   end_class                                                                                                                                                    \
-  start_class(CompiledCode)                                                                                                                                    \
-    oop_field(CompiledCode, name, "Ljava/lang/String;")                                                                                                        \
-    typeArrayOop_field(CompiledCode, targetCode, "[B")                                                                                                         \
-    int_field(CompiledCode, targetCodeSize)                                                                                                                    \
-    objArrayOop_field(CompiledCode, sites, "[Ljdk/vm/ci/code/site/Site;")                                                                                      \
-    objArrayOop_field(CompiledCode, assumptions, "[Ljdk/vm/ci/meta/Assumptions$Assumption;")                                                                   \
-    objArrayOop_field(CompiledCode, methods, "[Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                           \
-  end_class                                                                                                                                                    \
   start_class(HotSpotCompiledCode)                                                                                                                             \
+    oop_field(HotSpotCompiledCode, name, "Ljava/lang/String;")                                                                                                        \
+    typeArrayOop_field(HotSpotCompiledCode, targetCode, "[B")                                                                                                         \
+    int_field(HotSpotCompiledCode, targetCodeSize)                                                                                                                    \
+    objArrayOop_field(HotSpotCompiledCode, sites, "[Ljdk/vm/ci/code/site/Site;")                                                                                      \
+    objArrayOop_field(HotSpotCompiledCode, assumptions, "[Ljdk/vm/ci/meta/Assumptions$Assumption;")                                                                   \
+    objArrayOop_field(HotSpotCompiledCode, methods, "[Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                           \
     objArrayOop_field(HotSpotCompiledCode, comments, "[Ljdk/vm/ci/hotspot/HotSpotCompiledCode$Comment;")                                                       \
     typeArrayOop_field(HotSpotCompiledCode, dataSection, "[B")                                                                                                 \
     int_field(HotSpotCompiledCode, dataSectionAlignment)                                                                                                       \
--- a/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Tue Jan 19 13:32:31 2016 -0800
+++ b/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Tue Jan 19 17:36:21 2016 -0800
@@ -54,7 +54,6 @@
   do_klass(Architecture_klass,                           jdk_vm_ci_code_Architecture,                           Jvmci) \
   do_klass(TargetDescription_klass,                      jdk_vm_ci_code_TargetDescription,                      Jvmci) \
   do_klass(BytecodePosition_klass,                       jdk_vm_ci_code_BytecodePosition,                       Jvmci) \
-  do_klass(CompiledCode_klass,                           jdk_vm_ci_code_CompiledCode,                           Jvmci) \
   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) \
--- a/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Tue Jan 19 13:32:31 2016 -0800
+++ b/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Tue Jan 19 17:36:21 2016 -0800
@@ -64,7 +64,6 @@
   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_CompiledCode,                           "jdk/vm/ci/code/CompiledCode")                                          \
   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")                                              \