# HG changeset patch # User twisti # Date 1395348092 25200 # Node ID 579a2a124c95f3cc0f4dcf956a0586e6bc5d6a00 # Parent 7986af88b7827c5da7195a0b07115f2d857f592f add HotSpotMethodDataAccessor.Tag enum and dummy entries to PROFILE_DATA_ACCESSORS for new profile types diff -r 7986af88b782 -r 579a2a124c95 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Mar 20 12:35:15 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Mar 20 13:41:32 2014 -0700 @@ -1276,6 +1276,7 @@ @HotSpotVMConstant(name = "DataLayout::call_type_data_tag") @Stable public int dataLayoutCallTypeDataTag; @HotSpotVMConstant(name = "DataLayout::virtual_call_type_data_tag") @Stable public int dataLayoutVirtualCallTypeDataTag; @HotSpotVMConstant(name = "DataLayout::parameters_type_data_tag") @Stable public int dataLayoutParametersTypeDataTag; + @HotSpotVMConstant(name = "DataLayout::speculative_trap_data_tag") @Stable public int dataLayoutSpeculativeTrapDataTag; @HotSpotVMFlag(name = "BciProfileWidth") @Stable public int bciProfileWidth; @HotSpotVMFlag(name = "TypeProfileWidth") @Stable public int typeProfileWidth; diff -r 7986af88b782 -r 579a2a124c95 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java --- 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); } } diff -r 7986af88b782 -r 579a2a124c95 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodDataAccessor.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodDataAccessor.java Thu Mar 20 12:35:15 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodDataAccessor.java Thu Mar 20 13:41:32 2014 -0700 @@ -22,8 +22,12 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.ProfilingInfo.TriState; +import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.*; /** * Interface for accessor objects that encapsulate the logic for accessing the different kinds of @@ -33,11 +37,54 @@ public interface HotSpotMethodDataAccessor { /** - * Returns the tag stored in the LayoutData header. + * {@code DataLayout} tag values. + */ + enum Tag { + No(config().dataLayoutNoTag), + BitData(config().dataLayoutBitDataTag), + CounterData(config().dataLayoutCounterDataTag), + JumpData(config().dataLayoutJumpDataTag), + ReceiverTypeData(config().dataLayoutReceiverTypeDataTag), + VirtualCallData(config().dataLayoutVirtualCallDataTag), + RetData(config().dataLayoutRetDataTag), + BranchData(config().dataLayoutBranchDataTag), + MultiBranchData(config().dataLayoutMultiBranchDataTag), + ArgInfoData(config().dataLayoutArgInfoDataTag), + CallTypeData(config().dataLayoutCallTypeDataTag), + VirtualCallTypeData(config().dataLayoutVirtualCallTypeDataTag), + ParametersTypeData(config().dataLayoutParametersTypeDataTag), + SpeculativeTrapData(config().dataLayoutSpeculativeTrapDataTag); + + private final int value; + + private Tag(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + private static HotSpotVMConfig config() { + return runtime().getConfig(); + } + + public static Tag getEnum(int value) { + for (Tag e : values()) { + if (e.value == value) { + return e; + } + } + throw GraalInternalError.shouldNotReachHere("unknown enum value " + value); + } + } + + /** + * Returns the {@link Tag} stored in the LayoutData header. * - * @return An integer >= 0 or -1 if not supported. + * @return tag stored in the LayoutData header */ - int getTag(); + Tag getTag(); /** * Returns the BCI stored in the LayoutData header. diff -r 7986af88b782 -r 579a2a124c95 src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Thu Mar 20 12:35:15 2014 -0700 +++ b/src/share/vm/runtime/vmStructs.cpp Thu Mar 20 13:41:32 2014 -0700 @@ -2445,6 +2445,7 @@ declare_constant(DataLayout::call_type_data_tag) \ declare_constant(DataLayout::virtual_call_type_data_tag) \ declare_constant(DataLayout::parameters_type_data_tag) \ + declare_constant(DataLayout::speculative_trap_data_tag) \ \ /*************************************/ \ /* InstanceKlass enum */ \