changeset 22572:c3b49e9d0f48

HotSpotMethodData shouldn't hardcode constants
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 17 Sep 2015 12:10:17 -0700
parents 8dddd3b5ff37
children be44a5efeaff
files jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfig.java src/share/vm/jvmci/vmStructs_jvmci.hpp src/share/vm/oops/methodData.hpp
diffstat 4 files changed, 58 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java	Thu Sep 17 13:52:48 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java	Thu Sep 17 12:10:17 2015 -0700
@@ -55,7 +55,7 @@
         new BitData(),
         new CounterData(),
         new JumpData(),
-        new TypeCheckData(),
+        new ReceiverTypeData(),
         new VirtualCallData(),
         new RetData(),
         new BranchData(),
@@ -271,7 +271,7 @@
         /**
          * Corresponds to {@code exception_seen_flag}.
          */
-        private static final int EXCEPTIONS_MASK = 0x2;
+        private static final int EXCEPTIONS_MASK = 1 << config.bitDataExceptionSeenFlag;
 
         private final Tag tag;
         private final int staticSize;
@@ -380,7 +380,7 @@
     private static class BitData extends AbstractMethodData {
 
         private static final int BIT_DATA_SIZE = cellIndexToOffset(0);
-        private static final int BIT_DATA_NULL_SEEN_FLAG = 0x01;
+        private static final int BIT_DATA_NULL_SEEN_FLAG = 1 << config.bitDataNullSeenFlag;
 
         private BitData() {
             super(Tag.BitData, BIT_DATA_SIZE);
@@ -404,7 +404,7 @@
     private static class CounterData extends BitData {
 
         private static final int COUNTER_DATA_SIZE = cellIndexToOffset(1);
-        private static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(0);
+        private static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(config.methodDataCountOffset);
 
         public CounterData() {
             super(Tag.CounterData, COUNTER_DATA_SIZE);
@@ -432,8 +432,8 @@
     private static class JumpData extends AbstractMethodData {
 
         private static final int JUMP_DATA_SIZE = cellIndexToOffset(2);
-        protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(0);
-        protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(1);
+        protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(config.jumpDataTakenOffset);
+        protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(config.jumpDataDisplacementOffset);
 
         public JumpData() {
             super(Tag.JumpData, JUMP_DATA_SIZE);
@@ -479,11 +479,11 @@
 
     private abstract static class AbstractTypeData extends CounterData {
 
-        protected static final int TYPE_DATA_ROW_SIZE = cellsToBytes(2);
+        protected static final int TYPE_DATA_ROW_SIZE = cellsToBytes(config.receiverTypeDataReceiverTypeRowCellCount);
 
-        protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(1);
-        protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(2);
-        protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(3);
+        protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataNonprofiledCountOffset);
+        protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(config.receiverTypeDataReceiver0Offset);
+        protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataCount0Offset);
 
         protected AbstractTypeData(Tag tag, int staticSize) {
             super(tag, staticSize);
@@ -576,14 +576,18 @@
         }
     }
 
-    private static class TypeCheckData extends AbstractTypeData {
+    private static class ReceiverTypeData extends AbstractTypeData {
 
         private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
 
-        public TypeCheckData() {
+        public ReceiverTypeData() {
             super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE);
         }
 
+        protected ReceiverTypeData(Tag tag, int staticSize) {
+            super(tag, staticSize);
+        }
+
         @Override
         public int getExecutionCount(HotSpotMethodData data, int position) {
             return -1;
@@ -595,7 +599,7 @@
         }
     }
 
-    private static class VirtualCallData extends AbstractTypeData {
+    private static class VirtualCallData extends ReceiverTypeData {
 
         private static final int VIRTUAL_CALL_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * (config.typeProfileWidth + config.methodProfileWidth);
         private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET = TYPE_DATA_FIRST_TYPE_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
@@ -710,7 +714,7 @@
     private static class BranchData extends JumpData {
 
         private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3);
-        private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(2);
+        private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(config.branchDataNotTakenOffset);
 
         public BranchData() {
             super(Tag.BranchData, BRANCH_DATA_SIZE);
@@ -742,8 +746,8 @@
 
     private static class ArrayData extends AbstractMethodData {
 
-        private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(0);
-        protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(1);
+        private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(config.arrayDataArrayLenOffset);
+        protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(config.arrayDataArrayStartOffset);
 
         public ArrayData(Tag tag, int staticSize) {
             super(tag, staticSize);
@@ -767,7 +771,7 @@
     private static class MultiBranchData extends ArrayData {
 
         private static final int MULTI_BRANCH_DATA_SIZE = cellIndexToOffset(1);
-        private static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = 2;
+        private static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = config.multiBranchDataPerCaseCellCount;
         private static final int MULTI_BRANCH_DATA_ROW_SIZE = cellsToBytes(MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS);
         private static final int MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(0);
         private static final int MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(1);
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfig.java	Thu Sep 17 13:52:48 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfig.java	Thu Sep 17 12:10:17 2015 -0700
@@ -1521,6 +1521,20 @@
     @HotSpotVMConstant(name = "CodeInstaller::CARD_TABLE_ADDRESS") @Stable public int MARKID_CARD_TABLE_ADDRESS;
     @HotSpotVMConstant(name = "CodeInstaller::INVOKE_INVALID") @Stable public int MARKID_INVOKE_INVALID;
 
+    @HotSpotVMConstant(name = "BitData::exception_seen_flag") @Stable public int bitDataExceptionSeenFlag;
+    @HotSpotVMConstant(name = "BitData::null_seen_flag") @Stable public int bitDataNullSeenFlag;
+    @HotSpotVMConstant(name = "CounterData::count_off") @Stable public int methodDataCountOffset;
+    @HotSpotVMConstant(name = "JumpData::taken_off_set") @Stable public int jumpDataTakenOffset;
+    @HotSpotVMConstant(name = "JumpData::displacement_off_set") @Stable public int jumpDataDisplacementOffset;
+    @HotSpotVMConstant(name = "ReceiverTypeData::nonprofiled_count_off_set") @Stable public int receiverTypeDataNonprofiledCountOffset;
+    @HotSpotVMConstant(name = "ReceiverTypeData::receiver_type_row_cell_count") @Stable public int receiverTypeDataReceiverTypeRowCellCount;
+    @HotSpotVMConstant(name = "ReceiverTypeData::receiver0_offset") @Stable public int receiverTypeDataReceiver0Offset;
+    @HotSpotVMConstant(name = "ReceiverTypeData::count0_offset") @Stable public int receiverTypeDataCount0Offset;
+    @HotSpotVMConstant(name = "BranchData::not_taken_off_set") @Stable public int branchDataNotTakenOffset;
+    @HotSpotVMConstant(name = "ArrayData::array_len_off_set") @Stable public int arrayDataArrayLenOffset;
+    @HotSpotVMConstant(name = "ArrayData::array_start_off_set") @Stable public int arrayDataArrayStartOffset;
+    @HotSpotVMConstant(name = "MultiBranchData::per_case_cell_count") @Stable public int multiBranchDataPerCaseCellCount;
+
     // Checkstyle: resume
 
     public boolean check() {
--- a/src/share/vm/jvmci/vmStructs_jvmci.hpp	Thu Sep 17 13:52:48 2015 +0200
+++ b/src/share/vm/jvmci/vmStructs_jvmci.hpp	Thu Sep 17 12:10:17 2015 -0700
@@ -62,6 +62,20 @@
   declare_constant(CompilerToVM::KLASS_TAG)                                                       \
   declare_constant(CompilerToVM::SYMBOL_TAG)                                                      \
                                                                                                   \
+  declare_constant(BitData::exception_seen_flag)                                                  \
+  declare_constant(BitData::null_seen_flag)                                                       \
+  declare_constant(CounterData::count_off)                                                        \
+  declare_constant(JumpData::taken_off_set)                                                       \
+  declare_constant(JumpData::displacement_off_set)                                                \
+  declare_constant(ReceiverTypeData::nonprofiled_count_off_set)                                   \
+  declare_constant(ReceiverTypeData::receiver_type_row_cell_count)                                \
+  declare_constant(ReceiverTypeData::receiver0_offset)                                            \
+  declare_constant(ReceiverTypeData::count0_offset)                                               \
+  declare_constant(BranchData::not_taken_off_set)                                                 \
+  declare_constant(ArrayData::array_len_off_set)                                                  \
+  declare_constant(ArrayData::array_start_off_set)                                                \
+  declare_constant(MultiBranchData::per_case_cell_count)                                          \
+                                                                                                  \
   declare_constant(CodeInstaller::VERIFIED_ENTRY)                                                 \
   declare_constant(CodeInstaller::UNVERIFIED_ENTRY)                                               \
   declare_constant(CodeInstaller::OSR_ENTRY)                                                      \
--- a/src/share/vm/oops/methodData.hpp	Thu Sep 17 13:52:48 2015 +0200
+++ b/src/share/vm/oops/methodData.hpp	Thu Sep 17 12:10:17 2015 -0700
@@ -537,6 +537,7 @@
 //
 // A BitData holds a flag or two in its header.
 class BitData : public ProfileData {
+  friend class VMStructs;
 protected:
   enum {
     // null_seen:
@@ -608,6 +609,7 @@
 //
 // A CounterData corresponds to a simple counter.
 class CounterData : public BitData {
+  friend class VMStructs;
 protected:
   enum {
     count_off,
@@ -674,6 +676,7 @@
 // plus a data displacement, used for realigning the data pointer to
 // the corresponding target bci.
 class JumpData : public ProfileData {
+  friend class VMStructs;
 protected:
   enum {
     taken_off_set,
@@ -1177,6 +1180,7 @@
 // that the check is reached, and a series of (Klass*, count) pairs
 // which are used to store a type profile for the receiver of the check.
 class ReceiverTypeData : public CounterData {
+  friend class VMStructs;
 protected:
   enum {
 #if INCLUDE_JVMCI
@@ -1353,6 +1357,7 @@
 // A VirtualCallData is used to access profiling information about a
 // virtual call.  For now, it has nothing more than a ReceiverTypeData.
 class VirtualCallData : public ReceiverTypeData {
+  friend class VMStructs;
 public:
   VirtualCallData(DataLayout* layout) : ReceiverTypeData(layout) {
     assert(layout->tag() == DataLayout::virtual_call_data_tag ||
@@ -1455,6 +1460,7 @@
 // a virtual call for which we collect type information about
 // arguments and return value.
 class VirtualCallTypeData : public VirtualCallData {
+  friend class VMStructs;
 private:
   // entries for arguments if any
   TypeStackSlotEntries _args;
@@ -1684,6 +1690,7 @@
 // It consists of taken and not_taken counts as well as a data displacement
 // for the taken case.
 class BranchData : public JumpData {
+  friend class VMStructs;
 protected:
   enum {
     not_taken_off_set = jump_cell_count,
@@ -1762,6 +1769,7 @@
 // not have a statically known size.  It consists of an array length
 // and an array start.
 class ArrayData : public ProfileData {
+  friend class VMStructs;
 protected:
   friend class DataLayout;
 
@@ -1839,6 +1847,7 @@
 // of (count, displacement) pairs, which count the number of times each
 // case was taken and specify the data displacment for each branch target.
 class MultiBranchData : public ArrayData {
+  friend class VMStructs;
 protected:
   enum {
     default_count_off_set,