Skip to content

Commit bf300e8

Browse files
author
Nils Eliasson
committed
8247421: ReturnBlobToWrongHeapTest.java failed allocating blob
Reviewed-by: kvn
1 parent 02cec34 commit bf300e8

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
@@ -63,13 +63,22 @@ private static void free(long address) {
6363

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

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

0 commit comments

Comments
 (0)