Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
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);
    }