Beispiel #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);
    }