Skip to content

Commit 508cc21

Browse files
author
Christian Wimmer
committed
Remove StringAccess
1 parent c329e42 commit 508cc21

File tree

2 files changed

+14
-47
lines changed

2 files changed

+14
-47
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.lang.management.GarbageCollectorMXBean;
3030
import java.lang.management.ManagementFactory;
3131
import java.lang.management.OperatingSystemMXBean;
32+
import java.lang.reflect.Field;
3233
import java.nio.file.Path;
3334
import java.util.ArrayList;
3435
import java.util.Collection;
@@ -66,9 +67,11 @@
6667
import com.oracle.svm.core.annotate.AutomaticFeature;
6768
import com.oracle.svm.core.option.HostedOptionValues;
6869
import com.oracle.svm.core.reflect.MethodMetadataDecoder;
70+
import com.oracle.svm.core.util.VMError;
6971
import com.oracle.svm.hosted.code.CompileQueue.CompileTask;
7072
import com.oracle.svm.hosted.image.NativeImageHeap.ObjectInfo;
7173
import com.oracle.svm.util.ImageBuildStatistics;
74+
import com.oracle.svm.util.ReflectionUtil;
7275

7376
public class ProgressReporter {
7477
private static final int CHARACTERS_PER_LINE;
@@ -441,14 +444,24 @@ private static Map<String, Long> calculateCodeBreakdown(Collection<CompileTask>
441444
return classNameToCodeSize;
442445
}
443446

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+
444457
private Map<String, Long> calculateHeapBreakdown(Collection<ObjectInfo> heapObjects) {
445458
Map<String, Long> classNameToSize = new HashMap<>();
446459
long stringByteLength = 0;
447460
for (ObjectInfo o : heapObjects) {
448461
classNameToSize.merge(o.getClazz().toJavaName(true), o.getSize(), Long::sum);
449462
Object javaObject = o.getObject();
450463
if (javaObject instanceof String) {
451-
stringByteLength += StringAccess.getInternalByteArrayLength((String) javaObject);
464+
stringByteLength += getInternalByteArrayLength((String) javaObject);
452465
}
453466
}
454467

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/StringAccess.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)