Exemplo 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);
 }
Exemplo 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;
    }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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)));
 }
Exemplo 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;
 }
Exemplo 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);
    }
Exemplo n.º 7
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);
    }
Exemplo n.º 8
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);
    }
Exemplo n.º 9
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);
    }