diff jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java @ 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 9273bb6ba33e
children 5d06abd6d35b
line wrap: on
line diff
--- 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;
     }
 }