Esempio n. 1
0
 @Override
 public int getExecutionCount(HotSpotMethodData data, int position) {
   long count =
       data.readUnsignedInt(position, TAKEN_COUNT_OFFSET)
           + data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET);
   return truncateLongToInt(count);
 }
Esempio n. 2
0
    @Override
    public double getBranchTakenProbability(HotSpotMethodData data, int position) {
      long takenCount = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET);
      long notTakenCount = data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET);
      long total = takenCount + notTakenCount;

      return total <= 0 ? -1 : takenCount / (double) total;
    }
Esempio n. 3
0
 @Override
 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) {
   long taken = data.readUnsignedInt(pos, TAKEN_COUNT_OFFSET);
   long notTaken = data.readUnsignedInt(pos, NOT_TAKEN_COUNT_OFFSET);
   double takenProbability = getBranchTakenProbability(data, pos);
   return sb.append(
       format(
           "taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)",
           taken,
           takenProbability,
           notTaken,
           1.0D - takenProbability,
           getTakenDisplacement(data, pos)));
 }
Esempio n. 4
0
 @Override
 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) {
   int entries = getLength(data, pos) / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS;
   sb.append(format("entries(%d)", entries));
   for (int i = 0; i < entries; i++) {
     sb.append(
         format(
             "%n  %d: count(%d) displacement(%d)",
             i,
             data.readUnsignedInt(pos, getCountOffset(i)),
             data.readUnsignedInt(pos, getDisplacementOffset(i))));
   }
   return sb;
 }
Esempio n. 5
0
 private static long readCount(HotSpotMethodData data, int position, int i) {
   int offset;
   long count;
   offset = getCountOffset(i);
   count = data.readUnsignedInt(position, offset);
   return count;
 }
Esempio n. 6
0
    @Override
    public int getExecutionCount(HotSpotMethodData data, int position) {
      final int typeProfileWidth = config.typeProfileWidth;

      long total = 0;
      for (int i = 0; i < typeProfileWidth; i++) {
        total += data.readUnsignedInt(position, getTypeCountOffset(i));
      }

      total += getCounterValue(data, position);
      return truncateLongToInt(total);
    }
Esempio n. 7
0
    private RawItemProfile<ResolvedJavaType> getRawTypeProfile(
        HotSpotMethodData data, int position) {
      int typeProfileWidth = config.typeProfileWidth;

      ResolvedJavaType[] types = new ResolvedJavaType[typeProfileWidth];
      long[] counts = new long[typeProfileWidth];
      long totalCount = 0;
      int entries = 0;

      outer:
      for (int i = 0; i < typeProfileWidth; i++) {
        long receiverKlass = data.readWord(position, getTypeOffset(i));
        if (receiverKlass != 0) {
          ResolvedJavaType klass = HotSpotResolvedObjectType.fromMetaspaceKlass(receiverKlass);
          long count = data.readUnsignedInt(position, getTypeCountOffset(i));
          /*
           * Because of races in the profile collection machinery it's possible for a
           * class to appear multiple times so merge them to make the profile look
           * rational.
           */
          for (int j = 0; j < entries; j++) {
            if (types[j].equals(klass)) {
              totalCount += count;
              counts[j] += count;
              continue outer;
            }
          }
          types[entries] = klass;
          totalCount += count;
          counts[entries] = count;
          entries++;
        }
      }

      totalCount += getTypesNotRecordedExecutionCount(data, position);
      return new RawItemProfile<>(entries, types, counts, totalCount);
    }
Esempio n. 8
0
    private static RawItemProfile<ResolvedJavaMethod> getRawMethodProfile(
        HotSpotMethodData data, int position) {
      int profileWidth = config.methodProfileWidth;

      ResolvedJavaMethod[] methods = new ResolvedJavaMethod[profileWidth];
      long[] counts = new long[profileWidth];
      long totalCount = 0;
      int entries = 0;

      for (int i = 0; i < profileWidth; i++) {
        long method = data.readWord(position, getMethodOffset(i));
        if (method != 0) {
          methods[entries] = HotSpotResolvedJavaMethod.fromMetaspace(method);
          long count = data.readUnsignedInt(position, getMethodCountOffset(i));
          totalCount += count;
          counts[entries] = count;

          entries++;
        }
      }

      totalCount += getMethodsNotRecordedExecutionCount(data, position);
      return new RawItemProfile<>(entries, methods, counts, totalCount);
    }
Esempio n. 9
0
    @Override
    public int getExecutionCount(HotSpotMethodData data, int position) {
      int arrayLength = getLength(data, position);
      assert arrayLength > 0 : "switch must have at least the default case";
      assert arrayLength % MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS == 0 : "array must have full rows";

      int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS;
      long totalCount = 0;
      for (int i = 0; i < length; i++) {
        int offset = getCountOffset(i);
        totalCount += data.readUnsignedInt(position, offset);
      }

      return truncateLongToInt(totalCount);
    }
Esempio n. 10
0
 protected static int getLength(HotSpotMethodData data, int position) {
   return data.readInt(position, ARRAY_DATA_LENGTH_OFFSET);
 }
Esempio n. 11
0
 @Override
 public int getBCI(HotSpotMethodData data, int position) {
   return data.readUnsignedShort(position, config.dataLayoutBCIOffset);
 }
Esempio n. 12
0
 @Override
 protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
   return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET);
 }
Esempio n. 13
0
 public int getTakenDisplacement(HotSpotMethodData data, int position) {
   return data.readInt(position, TAKEN_DISPLACEMENT_OFFSET);
 }
Esempio n. 14
0
 @Override
 public int getExecutionCount(HotSpotMethodData data, int position) {
   return data.readUnsignedIntAsSignedInt(position, TAKEN_COUNT_OFFSET);
 }
Esempio n. 15
0
 protected int getCounterValue(HotSpotMethodData data, int position) {
   return data.readUnsignedIntAsSignedInt(position, COUNTER_DATA_COUNT_OFFSET);
 }
Esempio n. 16
0
 protected int getFlags(HotSpotMethodData data, int position) {
   return data.readUnsignedByte(position, config.dataLayoutFlagsOffset);
 }
Esempio n. 17
0
 private static long getMethodsNotRecordedExecutionCount(HotSpotMethodData data, int position) {
   return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET);
 }
Esempio n. 18
0
 public static Tag readTag(HotSpotMethodData data, int position) {
   final int tag = data.readUnsignedByte(position, config.dataLayoutTagOffset);
   return Tag.getEnum(tag);
 }