|
29 | 29 | import java.lang.management.GarbageCollectorMXBean;
|
30 | 30 | import java.lang.management.ManagementFactory;
|
31 | 31 | import java.lang.management.OperatingSystemMXBean;
|
| 32 | +import java.lang.reflect.Field; |
32 | 33 | import java.nio.file.Path;
|
33 | 34 | import java.util.ArrayList;
|
34 | 35 | import java.util.Collection;
|
|
66 | 67 | import com.oracle.svm.core.annotate.AutomaticFeature;
|
67 | 68 | import com.oracle.svm.core.option.HostedOptionValues;
|
68 | 69 | import com.oracle.svm.core.reflect.MethodMetadataDecoder;
|
| 70 | +import com.oracle.svm.core.util.VMError; |
69 | 71 | import com.oracle.svm.hosted.code.CompileQueue.CompileTask;
|
70 | 72 | import com.oracle.svm.hosted.image.NativeImageHeap.ObjectInfo;
|
71 | 73 | import com.oracle.svm.util.ImageBuildStatistics;
|
| 74 | +import com.oracle.svm.util.ReflectionUtil; |
72 | 75 |
|
73 | 76 | public class ProgressReporter {
|
74 | 77 | private static final int CHARACTERS_PER_LINE;
|
@@ -441,14 +444,24 @@ private static Map<String, Long> calculateCodeBreakdown(Collection<CompileTask>
|
441 | 444 | return classNameToCodeSize;
|
442 | 445 | }
|
443 | 446 |
|
| 447 | + private static final Field STRING_VALUE = ReflectionUtil.lookupField(String.class, "value"); |
| 448 | + |
| 449 | + private static int getInternalByteArrayLength(String string) { |
| 450 | + try { |
| 451 | + return ((byte[]) STRING_VALUE.get(string)).length; |
| 452 | + } catch (ReflectiveOperationException ex) { |
| 453 | + throw VMError.shouldNotReachHere(ex); |
| 454 | + } |
| 455 | + } |
| 456 | + |
444 | 457 | private Map<String, Long> calculateHeapBreakdown(Collection<ObjectInfo> heapObjects) {
|
445 | 458 | Map<String, Long> classNameToSize = new HashMap<>();
|
446 | 459 | long stringByteLength = 0;
|
447 | 460 | for (ObjectInfo o : heapObjects) {
|
448 | 461 | classNameToSize.merge(o.getClazz().toJavaName(true), o.getSize(), Long::sum);
|
449 | 462 | Object javaObject = o.getObject();
|
450 | 463 | if (javaObject instanceof String) {
|
451 |
| - stringByteLength += StringAccess.getInternalByteArrayLength((String) javaObject); |
| 464 | + stringByteLength += getInternalByteArrayLength((String) javaObject); |
452 | 465 | }
|
453 | 466 | }
|
454 | 467 |
|
|
0 commit comments