1
1
/*
2
- * Copyright (c) 2013, 2021 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2013, 2023 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
44
44
45
45
public class CompressedClassPointers {
46
46
47
- static final String logging_option = "-Xlog:gc+metaspace=trace,cds=trace" ;
47
+ static final String logging_option = "-Xlog:gc+metaspace=trace,metaspace=info,cds=trace" ;
48
+ static final String reserveCCSAnywhere = "Reserving compressed class space anywhere" ;
48
49
49
50
// Returns true if we are to test the narrow klass base; we only do this on
50
51
// platforms where we can be reasonably shure that we get reproducable placement).
@@ -56,6 +57,15 @@ static boolean testNarrowKlassBase() {
56
57
57
58
}
58
59
60
+ // Returns true if the output indicates that the ccs is reserved anywhere.
61
+ static boolean isCCSReservedAnywhere (OutputAnalyzer output ) {
62
+ if (output .getOutput ().contains (reserveCCSAnywhere )) {
63
+ return true ;
64
+ } else {
65
+ return false ;
66
+ }
67
+ }
68
+
59
69
// CDS off, small heap, ccs size default (1G)
60
70
// A small heap should allow us to place the ccs within the lower 32G and thus allow zero based encoding.
61
71
public static void smallHeapTest () throws Exception {
@@ -67,7 +77,7 @@ public static void smallHeapTest() throws Exception {
67
77
"-Xshare:off" ,
68
78
"-XX:+VerifyBeforeGC" , "-version" );
69
79
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
70
- if (testNarrowKlassBase ()) {
80
+ if (testNarrowKlassBase () && ! isCCSReservedAnywhere ( output ) ) {
71
81
output .shouldContain ("Narrow klass base: 0x0000000000000000" );
72
82
}
73
83
output .shouldHaveExitValue (0 );
@@ -84,7 +94,7 @@ public static void smallHeapTestWith1G() throws Exception {
84
94
"-Xshare:off" ,
85
95
"-XX:+VerifyBeforeGC" , "-version" );
86
96
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
87
- if (testNarrowKlassBase ()) {
97
+ if (testNarrowKlassBase () && ! isCCSReservedAnywhere ( output ) ) {
88
98
output .shouldContain ("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3" );
89
99
}
90
100
output .shouldHaveExitValue (0 );
@@ -102,7 +112,7 @@ public static void largeHeapTest() throws Exception {
102
112
"-Xshare:off" ,
103
113
"-XX:+VerifyBeforeGC" , "-version" );
104
114
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
105
- if (testNarrowKlassBase () && !Platform .isPPC () && !Platform .isOSX ()) {
115
+ if (testNarrowKlassBase () && !Platform .isPPC () && !Platform .isOSX () && ! isCCSReservedAnywhere ( output ) ) {
106
116
// PPC: in most cases the heap cannot be placed below 32g so there
107
117
// is room for ccs and narrow klass base will be 0x0. Exception:
108
118
// Linux 4.1.42 or earlier (see ELF_ET_DYN_BASE in JDK-8244847).
@@ -128,7 +138,7 @@ public static void largeHeapAbove32GTest() throws Exception {
128
138
"-XX:+VerifyBeforeGC" , "-version" );
129
139
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
130
140
if (testNarrowKlassBase ()) {
131
- if (!(Platform .isAArch64 () && Platform .isOSX ())) { // see JDK-8262895
141
+ if (!(Platform .isAArch64 () && Platform .isOSX ()) && ! isCCSReservedAnywhere ( output ) ) { // see JDK-8262895
132
142
output .shouldContain ("Narrow klass base: 0x0000000000000000" );
133
143
if (!Platform .isAArch64 () && !Platform .isPPC () && !Platform .isOSX ()) {
134
144
output .shouldContain ("Narrow klass shift: 0" );
@@ -211,7 +221,9 @@ public static void smallHeapTestNoCoop() throws Exception {
211
221
"-Xlog:cds=trace" ,
212
222
"-XX:+VerifyBeforeGC" , "-version" );
213
223
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
214
- output .shouldContain ("Narrow klass base: 0x0000000000000000" );
224
+ if (!isCCSReservedAnywhere (output )) {
225
+ output .shouldContain ("Narrow klass base: 0x0000000000000000" );
226
+ }
215
227
output .shouldHaveExitValue (0 );
216
228
}
217
229
@@ -227,7 +239,9 @@ public static void smallHeapTestWith1GNoCoop() throws Exception {
227
239
"-Xlog:cds=trace" ,
228
240
"-XX:+VerifyBeforeGC" , "-version" );
229
241
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
230
- output .shouldContain ("Narrow klass base: 0x0000000000000000" );
242
+ if (!isCCSReservedAnywhere (output )) {
243
+ output .shouldContain ("Narrow klass base: 0x0000000000000000" );
244
+ }
231
245
if (!Platform .isAArch64 () && !Platform .isPPC ()) {
232
246
// Currently relax this test for Aarch64 and ppc.
233
247
output .shouldContain ("Narrow klass shift: 0" );
@@ -247,7 +261,9 @@ public static void largeHeapTestNoCoop() throws Exception {
247
261
"-Xlog:cds=trace" ,
248
262
"-XX:+VerifyBeforeGC" , "-version" );
249
263
OutputAnalyzer output = new OutputAnalyzer (pb .start ());
250
- output .shouldContain ("Narrow klass base: 0x0000000000000000" );
264
+ if (!isCCSReservedAnywhere (output )) {
265
+ output .shouldContain ("Narrow klass base: 0x0000000000000000" );
266
+ }
251
267
if (!Platform .isAArch64 () && !Platform .isPPC ()) {
252
268
// Currently relax this test for Aarch64 and ppc.
253
269
output .shouldContain ("Narrow klass shift: 0" );
0 commit comments