Skip to content

Commit 82dbbf0

Browse files
committed
GH-520 oopSize computation - make sure it returns 4 or 8 only
1 parent 37ec888 commit 82dbbf0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

visualvm/libs.profiler/lib.profiler.heap/src/org/graalvm/visualvm/lib/jfluid/heap/ObjectSizeSettings.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ int getOopSize() {
7676
LOG.log(Level.CONFIG, "OopSize uses idSize {0}", idSize); // NOI18N
7777
if (idSize == 8) { // can be compressed oops
7878
if (hprofHeap.getClassDumpSegment().newSize) {
79-
oopSize = getMinimumInstanceSize() - idSize;
80-
LOG.log(Level.CONFIG, "OopSize computed as {0}", oopSize); // NOI18N
79+
oopSize = guessNewOopSize(idSize);
8180
} else {
8281
oopSize = guessOopSize(idSize);
8382
}
@@ -89,6 +88,17 @@ int getOopSize() {
8988
return oopSize;
9089
}
9190

91+
private int guessNewOopSize(int idSize) {
92+
int size = getMinimumInstanceSize() - idSize;
93+
LOG.log(Level.CONFIG, "OopSize computed as {0}", size); // NOI18N
94+
if (size == 4 || size == 8) {
95+
return size;
96+
}
97+
size = (size < 8) ? 4 : 8;
98+
LOG.log(Level.CONFIG, "OopSize set to {0}", size); // NOI18N
99+
return size;
100+
}
101+
92102
private int guessOopSize(int idSize) {
93103
// detect compressed oops
94104
int size = getFieldsDiff("java.lang.Class$Atomic", "annotationDataOffset", "annotationTypeOffset"); // NOI18N

0 commit comments

Comments
 (0)