diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java @ 14706:579a2a124c95

add HotSpotMethodDataAccessor.Tag enum and dummy entries to PROFILE_DATA_ACCESSORS for new profile types
author twisti
date Thu, 20 Mar 2014 13:41:32 -0700
parents 12eaf1a47a90
children 4ca6dc0799b6
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Thu Mar 20 12:35:15 2014 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Thu Mar 20 13:41:32 2014 -0700
@@ -33,6 +33,7 @@
 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
 import com.oracle.graal.api.meta.ProfilingInfo.TriState;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.HotSpotMethodDataAccessor.Tag;
 
 /**
  * Access to a HotSpot MethodData structure (defined in methodData.hpp).
@@ -57,7 +58,11 @@
         new RetData(),
         new BranchData(),
         new MultiBranchData(),
-        new ArgInfoData()
+        new ArgInfoData(),
+        null, // call_type_data_tag
+        null, // virtual_call_type_data_tag
+        null, // parameters_type_data_tag
+        null  // speculative_trap_data_tag
     };
     // @formatter:on
 
@@ -146,9 +151,10 @@
 
     private HotSpotMethodDataAccessor getData(int position) {
         assert position >= 0 : "out of bounds";
-        int tag = AbstractMethodData.readTag(this, position);
-        assert tag >= 0 && tag < PROFILE_DATA_ACCESSORS.length : "illegal tag " + tag;
-        return PROFILE_DATA_ACCESSORS[tag];
+        final Tag tag = AbstractMethodData.readTag(this, position);
+        HotSpotMethodDataAccessor accessor = PROFILE_DATA_ACCESSORS[tag.getValue()];
+        assert accessor == null || accessor.getTag() == tag : "wrong data accessor " + accessor + " for tag " + tag;
+        return accessor;
     }
 
     private int readUnsignedByte(int position, int offsetInBytes) {
@@ -258,20 +264,21 @@
          */
         private static final int EXCEPTIONS_MASK = 0x2;
 
-        private final int tag;
+        private final Tag tag;
         private final int staticSize;
 
-        protected AbstractMethodData(int tag, int staticSize) {
+        protected AbstractMethodData(Tag tag, int staticSize) {
             this.tag = tag;
             this.staticSize = staticSize;
         }
 
-        public int getTag() {
+        public Tag getTag() {
             return tag;
         }
 
-        public static int readTag(HotSpotMethodData data, int position) {
-            return data.readUnsignedByte(position, config.dataLayoutTagOffset);
+        public static Tag readTag(HotSpotMethodData data, int position) {
+            final int tag = data.readUnsignedByte(position, config.dataLayoutTagOffset);
+            return Tag.getEnum(tag);
         }
 
         @Override
@@ -337,7 +344,7 @@
         private final TriState exceptionSeen;
 
         protected NoMethodData(TriState exceptionSeen) {
-            super(runtime().getConfig().dataLayoutNoTag, NO_DATA_SIZE);
+            super(Tag.No, NO_DATA_SIZE);
             this.exceptionSeen = exceptionSeen;
         }
 
@@ -363,10 +370,10 @@
         private static final int BIT_DATA_NULL_SEEN_FLAG = 0x01;
 
         private BitData() {
-            super(runtime().getConfig().dataLayoutBitDataTag, BIT_DATA_SIZE);
+            super(Tag.BitData, BIT_DATA_SIZE);
         }
 
-        protected BitData(int tag, int staticSize) {
+        protected BitData(Tag tag, int staticSize) {
             super(tag, staticSize);
         }
 
@@ -387,10 +394,10 @@
         private static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(0);
 
         public CounterData() {
-            super(runtime().getConfig().dataLayoutCounterDataTag, COUNTER_DATA_SIZE);
+            super(Tag.CounterData, COUNTER_DATA_SIZE);
         }
 
-        protected CounterData(int tag, int staticSize) {
+        protected CounterData(Tag tag, int staticSize) {
             super(tag, staticSize);
         }
 
@@ -416,10 +423,10 @@
         protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(1);
 
         public JumpData() {
-            super(runtime().getConfig().dataLayoutJumpDataTag, JUMP_DATA_SIZE);
+            super(Tag.JumpData, JUMP_DATA_SIZE);
         }
 
-        protected JumpData(int tag, int staticSize) {
+        protected JumpData(Tag tag, int staticSize) {
             super(tag, staticSize);
         }
 
@@ -465,7 +472,7 @@
         protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(2);
         protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(3);
 
-        protected AbstractTypeData(int tag, int staticSize) {
+        protected AbstractTypeData(Tag tag, int staticSize) {
             super(tag, staticSize);
         }
 
@@ -548,7 +555,7 @@
         private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
 
         public TypeCheckData() {
-            super(runtime().getConfig().dataLayoutReceiverTypeDataTag, TYPE_CHECK_DATA_SIZE);
+            super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE);
         }
 
         @Override
@@ -569,12 +576,12 @@
         private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET = TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
 
         public VirtualCallData() {
-            super(runtime().getConfig().dataLayoutVirtualCallDataTag, VIRTUAL_CALL_DATA_SIZE);
+            super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE);
         }
 
         @Override
         public int getExecutionCount(HotSpotMethodData data, int position) {
-            int typeProfileWidth = config.typeProfileWidth;
+            final int typeProfileWidth = config.typeProfileWidth;
 
             long total = 0;
             for (int i = 0; i < typeProfileWidth; i++) {
@@ -670,7 +677,7 @@
         private static final int RET_DATA_SIZE = cellIndexToOffset(1) + RET_DATA_ROW_SIZE * config.bciProfileWidth;
 
         public RetData() {
-            super(runtime().getConfig().dataLayoutRetDataTag, RET_DATA_SIZE);
+            super(Tag.RetData, RET_DATA_SIZE);
         }
     }
 
@@ -680,7 +687,7 @@
         private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(2);
 
         public BranchData() {
-            super(runtime().getConfig().dataLayoutBranchDataTag, BRANCH_DATA_SIZE);
+            super(Tag.BranchData, BRANCH_DATA_SIZE);
         }
 
         @Override
@@ -712,7 +719,7 @@
         private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(0);
         protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(1);
 
-        public ArrayData(int tag, int staticSize) {
+        public ArrayData(Tag tag, int staticSize) {
             super(tag, staticSize);
         }
 
@@ -740,7 +747,7 @@
         private static final int MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(1);
 
         public MultiBranchData() {
-            super(runtime().getConfig().dataLayoutMultiBranchDataTag, MULTI_BRANCH_DATA_SIZE);
+            super(Tag.MultiBranchData, MULTI_BRANCH_DATA_SIZE);
         }
 
         @Override
@@ -822,7 +829,7 @@
         private static final int ARG_INFO_DATA_SIZE = cellIndexToOffset(1);
 
         public ArgInfoData() {
-            super(runtime().getConfig().dataLayoutArgInfoDataTag, ARG_INFO_DATA_SIZE);
+            super(Tag.ArgInfoData, ARG_INFO_DATA_SIZE);
         }
     }