package jdk.vm.ci.hotspot;
import jdk.vm.ci.meta.JavaMethodProfile;
import jdk.vm.ci.meta.JavaTypeProfile;
import jdk.vm.ci.meta.ProfilingInfo;
import jdk.vm.ci.meta.TriState;
abstract class HotSpotMethodDataAccessor {
final int tag;
final int staticSize;
final HotSpotVMConfig config;
protected HotSpotMethodDataAccessor(HotSpotVMConfig config, int tag, int staticSize) {
this.config = config;
this.tag = tag;
this.staticSize = staticSize;
}
int getTag() {
return tag;
}
static int readTag(HotSpotVMConfig config, HotSpotMethodData data, int position) {
final int tag = data.readUnsignedByte(position, config.dataLayoutTagOffset);
assert tag >= config.dataLayoutNoTag && tag <= config.dataLayoutSpeculativeTrapDataTag : "profile data tag out of bounds: " + tag;
return tag;
}
int getBCI(HotSpotMethodData data, int position) {
return data.readUnsignedShort(position, config.dataLayoutBCIOffset);
}
final int getSize(HotSpotMethodData data, int position) {
int size = staticSize + getDynamicSize(data, position);
int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position);
assert size == vmSize : size + " != " + vmSize;
return size;
}
TriState getExceptionSeen(HotSpotMethodData data, int position) {
final int EXCEPTIONS_MASK = 1 << config.bitDataExceptionSeenFlag;
return TriState.get((getFlags(data, position) & EXCEPTIONS_MASK) != 0);
}
JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) {
return null;
}
JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) {
return null;
}
double getBranchTakenProbability(HotSpotMethodData data, int position) {
return -1;
}
double[] getSwitchProbabilities(HotSpotMethodData data, int position) {
return null;
}
int getExecutionCount(HotSpotMethodData data, int position) {
return -1;
}
TriState getNullSeen(HotSpotMethodData data, int position) {
return TriState.UNKNOWN;
}
protected int getFlags(HotSpotMethodData data, int position) {
return data.readUnsignedByte(position, config.dataLayoutFlagsOffset);
}
protected int getDynamicSize(HotSpotMethodData data, int position) {
return 0;
}
abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos);
}