Skip to content

Commit 66d4ee9

Browse files
committed
8247421: [TESTBUG] ReturnBlobToWrongHeapTest.java failed allocating blob
Backport-of: bf300e8
1 parent df587c7 commit 66d4ee9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/hotspot/jtreg/compiler/codecache/stress/ReturnBlobToWrongHeapTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,22 @@ private static void free(long address) {
6464

6565
public static void main(String[] args) {
6666
if (codeCacheMinBlockLength == 1) {
67+
// start with allocating a small block
68+
long firstSegmentSizedAddress = 0;
69+
firstSegmentSizedAddress = allocate(0);
70+
if (firstSegmentSizedAddress == 0) {
71+
throw new RuntimeException("Test failed: Failed allocating first segment-sized blob");
72+
}
73+
6774
// Fill first code heap with large blobs until allocation fails.
6875
long address;
6976
while ((address = allocate((int)largeBlobSize)) != 0) {
7077
}
7178

72-
// Allocate segment-sized blocks in first code heap.
73-
long lastSegmentSizedAddress = 0; // Address of the last segment-sized blob allocated
79+
// Allocate segment-sized blocks in first code heap until it runs out
80+
// Remember the last one
81+
// Use the pre-allocated one as backup if the code cache is already completely full.
82+
long lastSegmentSizedAddress = firstSegmentSizedAddress;
7483
while ((address = allocate(0)) != 0) {
7584
lastSegmentSizedAddress = address;
7685
}

0 commit comments

Comments
 (0)