Skip to content

Commit cd4b88d

Browse files
Matias Saavedra Silvacalvinccheung
Matias Saavedra Silva
authored andcommitted
8292269: Replace FileMapInfo::fail_continue() with Unified Logging
Reviewed-by: iklam, dholmes, ccheung
1 parent ae29054 commit cd4b88d

9 files changed

+71
-95
lines changed

src/hotspot/share/cds/dynamicArchive.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,14 @@ bool DynamicArchive::validate(FileMapInfo* dynamic_info) {
420420

421421
// Check the header crc
422422
if (dynamic_header->base_header_crc() != base_info->crc()) {
423-
FileMapInfo::fail_continue("Dynamic archive cannot be used: static archive header checksum verification failed.");
423+
log_warning(cds)("Dynamic archive cannot be used: static archive header checksum verification failed.");
424424
return false;
425425
}
426426

427427
// Check each space's crc
428428
for (int i = 0; i < MetaspaceShared::n_regions; i++) {
429429
if (dynamic_header->base_region_crc(i) != base_info->region_crc(i)) {
430-
FileMapInfo::fail_continue("Dynamic archive cannot be used: static archive region #%d checksum verification failed.", i);
430+
log_warning(cds)("Dynamic archive cannot be used: static archive region #%d checksum verification failed.", i);
431431
return false;
432432
}
433433
}

src/hotspot/share/cds/filemap.cpp

+49-84
Large diffs are not rendered by default.

src/hotspot/share/cds/filemap.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,6 @@ class FileMapInfo : public CHeapObj<mtInternal> {
484484

485485
// Errors.
486486
static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
487-
static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
488-
static void fail_continue(LogLevelType level, const char *msg, ...) ATTRIBUTE_PRINTF(2, 3);
489-
static void fail_continue_impl(LogLevelType level, const char *msg, va_list ap) ATTRIBUTE_PRINTF(2, 0);
490487
static bool memory_mapping_failed() {
491488
CDS_ONLY(return _memory_mapping_failed;)
492489
NOT_CDS(return false;)

src/hotspot/share/cds/metaspaceShared.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -947,18 +947,27 @@ void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
947947
// The base archive cannot be mapped. We cannot dump the dynamic shared archive.
948948
AutoCreateSharedArchive = false;
949949
DynamicDumpSharedSpaces = false;
950-
FileMapInfo::fail_continue("Unable to map shared spaces");
950+
log_info(cds)("Unable to map shared spaces");
951951
if (PrintSharedArchiveAndExit) {
952952
vm_exit_during_initialization("Unable to use shared archive.");
953+
} else if (RequireSharedSpaces) {
954+
FileMapInfo::fail_stop("Unable to map shared spaces");
953955
}
954956
}
955957

958+
// If mapping failed and -XShare:on, the vm should exit
959+
bool has_failed = false;
956960
if (static_mapinfo != nullptr && !static_mapinfo->is_mapped()) {
961+
has_failed = true;
957962
delete static_mapinfo;
958963
}
959964
if (dynamic_mapinfo != nullptr && !dynamic_mapinfo->is_mapped()) {
965+
has_failed = true;
960966
delete dynamic_mapinfo;
961967
}
968+
if (RequireSharedSpaces && has_failed) {
969+
FileMapInfo::fail_stop("Unable to map shared spaces");
970+
}
962971
}
963972

964973
FileMapInfo* MetaspaceShared::open_static_archive() {
@@ -984,6 +993,9 @@ FileMapInfo* MetaspaceShared::open_dynamic_archive() {
984993
FileMapInfo* mapinfo = new FileMapInfo(dynamic_archive, false);
985994
if (!mapinfo->initialize()) {
986995
delete(mapinfo);
996+
if (RequireSharedSpaces) {
997+
FileMapInfo::fail_stop("Failed to initialize dynamic archive");
998+
}
987999
return nullptr;
9881000
}
9891001
return mapinfo;

test/hotspot/jtreg/runtime/cds/ArchiveDoesNotExist.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception {
4646
throw new RuntimeException("Test error: cds file already exists");
4747

4848
CDSOptions opts = (new CDSOptions()).setArchiveName(fileName);
49-
49+
opts.addPrefix("-Xlog:cds");
5050
// -Xshare=on
5151
OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
5252
CDSTestUtils.checkMappingFailure(out);

test/hotspot/jtreg/runtime/cds/CdsDifferentCompactStrings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static void createAndLoadSharedArchive(String create, String load)
4848

4949
CDSTestUtils.createArchiveAndCheck(createCompactStringsArgument);
5050

51-
OutputAnalyzer out = CDSTestUtils.runWithArchive(loadCompactStringsArgument);
51+
OutputAnalyzer out = CDSTestUtils.runWithArchive("-Xlog:cds", loadCompactStringsArgument);
5252
CDSTestUtils.checkMappingFailure(out);
5353

5454
out.shouldMatch("The shared archive file's CompactStrings " +

test/hotspot/jtreg/runtime/cds/CdsDifferentObjectAlignment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception {
6363

6464
CDSTestUtils.createArchiveAndCheck(createAlignmentArgument);
6565

66-
OutputAnalyzer out = CDSTestUtils.runWithArchive(loadAlignmentArgument);
66+
OutputAnalyzer out = CDSTestUtils.runWithArchive("-Xlog:cds", loadAlignmentArgument);
6767
CDSTestUtils.checkExecExpectError(out, 1, expectedErrorMsg);
6868
}
6969
}

test/hotspot/jtreg/runtime/cds/appcds/PrintSharedArchiveAndExit.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static void main(String[] args) throws Exception {
114114
TestCommon.run(
115115
"-cp", cp,
116116
"-XX:+PrintSharedArchiveAndExit")
117-
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "[Timestamp mismatch]"));
117+
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "Timestamp mismatch"));
118118

119119
log("Even if hello.jar is out of date, we should still be able to print the dictionary.");
120120
TestCommon.run(
@@ -128,7 +128,7 @@ public static void main(String[] args) throws Exception {
128128
TestCommon.run(
129129
"-cp", cp,
130130
"-XX:+PrintSharedArchiveAndExit")
131-
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "[Required classpath entry does not exist: " + appJar + "]"));
131+
.ifNoMappingFailure(output -> check(output, 1, true, lastCheckMsg, "Required classpath entry does not exist: " + appJar));
132132

133133
log("Execution with major errors -- with 'major' errors like the JSA file\n" +
134134
"is missing, we should stop immediately to avoid crashing the JVM.");

test/hotspot/jtreg/runtime/cds/appcds/VerifierTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static void testset_1(String jar, String[] noAppClasses, String[] appClasses, Te
221221
runtime_arg1 = runtime_arg2 = runtime_arg3 = runtime_setting;
222222
}
223223
TestCommon.run("-cp", jar,
224+
"-Xlog:cds",
224225
runtime_arg1, runtime_arg2, runtime_arg3,
225226
"VerifierTest0")
226227
.ifNoMappingFailure(output -> checkRuntimeOutput(output, expected_output_str));
@@ -301,6 +302,7 @@ static void testset_2(String jarName_greet, String jarName_hi) throws Exception
301302
runtime_arg1 = runtime_arg2 = runtime_arg3 = runtime_setting;
302303
}
303304
TestCommon.run("-cp", jar,
305+
"-Xlog:cds",
304306
runtime_arg1, runtime_arg2, runtime_arg3,
305307
"Hi")
306308
.ifNoMappingFailure(output -> checkRuntimeOutput(output, expected_output_str));

0 commit comments

Comments
 (0)