Skip to content

Commit 4bf9a65

Browse files
committed
Use current aligned chunk size in TestObjectAllocationInNewTLABEvent.
1 parent 5cdee29 commit 4bf9a65

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestObjectAllocationInNewTLABEvent.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131
import org.junit.Test;
3232

3333
import com.oracle.svm.core.NeverInline;
34+
import com.oracle.svm.core.genscavenge.HeapParameters;
3435
import com.oracle.svm.core.jfr.JfrEvent;
36+
import com.oracle.svm.core.util.UnsignedUtils;
3537

3638
import jdk.jfr.consumer.RecordedClass;
3739
import jdk.jfr.consumer.RecordedEvent;
3840
import jdk.jfr.consumer.RecordedThread;
3941

4042
public class TestObjectAllocationInNewTLABEvent extends JfrTest {
4143
private static final int K = 1024;
42-
private static final int DEFAULT_ALIGNED_HEAP_CHUNK_SIZE = 1024 * K;
4344

4445
@Override
4546
public String[] getTestedEvents() {
@@ -48,6 +49,8 @@ public String[] getTestedEvents() {
4849

4950
@Override
5051
public void validateEvents() throws Throwable {
52+
final int alignedHeapChunkSize = UnsignedUtils.safeToInt(HeapParameters.getAlignedHeapChunkSize());
53+
5154
boolean foundBigByteArray = false;
5255
boolean foundSmallByteArray = false;
5356
boolean foundBigCharArray = false;
@@ -64,16 +67,16 @@ public void validateEvents() throws Throwable {
6467
String className = event.<RecordedClass> getValue("objectClass").getName();
6568

6669
// >= To account for size of reference
67-
if (allocationSize >= 2 * DEFAULT_ALIGNED_HEAP_CHUNK_SIZE && tlabSize >= 2 * DEFAULT_ALIGNED_HEAP_CHUNK_SIZE) {
70+
if (allocationSize >= 2 * alignedHeapChunkSize && tlabSize >= 2 * alignedHeapChunkSize) {
6871
// verify previous owner
6972
if (className.equals(char[].class.getName())) {
7073
foundBigCharArray = true;
7174
} else if (className.equals(byte[].class.getName())) {
7275
foundBigByteArray = true;
7376
}
74-
} else if (allocationSize >= K && tlabSize == DEFAULT_ALIGNED_HEAP_CHUNK_SIZE && className.equals(byte[].class.getName())) {
77+
} else if (allocationSize >= K && tlabSize == alignedHeapChunkSize && className.equals(byte[].class.getName())) {
7578
foundSmallByteArray = true;
76-
} else if (tlabSize == DEFAULT_ALIGNED_HEAP_CHUNK_SIZE && className.equals(Helper.class.getName())) {
79+
} else if (tlabSize == alignedHeapChunkSize && className.equals(Helper.class.getName())) {
7780
foundInstance = true;
7881
}
7982
}
@@ -86,17 +89,19 @@ public void validateEvents() throws Throwable {
8689

8790
@Test
8891
public void test() throws Exception {
92+
final int alignedHeapChunkSize = UnsignedUtils.safeToInt(HeapParameters.getAlignedHeapChunkSize());
93+
8994
// Allocate large arrays (always need a new TLAB).
90-
allocateByteArray(2 * DEFAULT_ALIGNED_HEAP_CHUNK_SIZE);
91-
allocateCharArray(DEFAULT_ALIGNED_HEAP_CHUNK_SIZE);
95+
allocateByteArray(2 * alignedHeapChunkSize);
96+
allocateCharArray(alignedHeapChunkSize);
9297

9398
// Exhaust TLAB with small arrays.
94-
for (int i = 0; i < DEFAULT_ALIGNED_HEAP_CHUNK_SIZE / K; i++) {
99+
for (int i = 0; i < alignedHeapChunkSize / K; i++) {
95100
allocateByteArray(K);
96101
}
97102

98103
// Exhaust TLAB with instances.
99-
for (int i = 0; i < DEFAULT_ALIGNED_HEAP_CHUNK_SIZE; i++) {
104+
for (int i = 0; i < alignedHeapChunkSize; i++) {
100105
allocateInstance();
101106
}
102107
}

0 commit comments

Comments
 (0)