8224692: runtime/appcds tests crash in "HotSpotJVMCI::compute_offset" when running in Graal as JIT mode

Reviewed-by: ccheung
This commit is contained in:
Ioi Lam 2019-05-31 12:51:36 -07:00
parent 67defd71f2
commit 43e23020f2
3 changed files with 26 additions and 14 deletions

View File

@ -623,13 +623,11 @@ size_t SymbolTable::estimate_size_for_archive() {
}
void SymbolTable::write_to_archive(bool is_static_archive) {
_shared_table.reset();
_dynamic_shared_table.reset();
CompactHashtableWriter writer(int(_items_count),
&MetaspaceShared::stats()->symbol);
copy_shared_symbol_table(&writer);
if (is_static_archive) {
_shared_table.reset();
writer.dump(&_shared_table, "symbol");
// Verify table is correct
@ -639,6 +637,7 @@ void SymbolTable::write_to_archive(bool is_static_archive) {
unsigned int hash = hash_symbol(name, len, _alt_hash);
assert(sym == _shared_table.lookup(name, hash, len), "sanity");
} else {
_dynamic_shared_table.reset();
writer.dump(&_dynamic_shared_table, "symbol");
}
}

View File

@ -756,6 +756,10 @@ size_t DynamicArchiveBuilder::estimate_trampoline_size() {
Array<Method*>* methods = ik->methods();
total += each_method_bytes * methods->length();
}
if (total == 0) {
// We have nothing to archive, but let's avoid having an empty region.
total = SharedRuntime::trampoline_size();
}
return total;
}
@ -774,6 +778,11 @@ void DynamicArchiveBuilder::make_trampolines() {
m->set_adapter_trampoline(to_target(adapter_trampoline));
}
}
if (MetaspaceShared::misc_code_dump_space()->used() == 0) {
// We have nothing to archive, but let's avoid having an empty region.
MetaspaceShared::misc_code_space_alloc(SharedRuntime::trampoline_size());
}
}
void DynamicArchiveBuilder::make_klasses_shareable() {

View File

@ -61,19 +61,21 @@ public class NoClassToArchive extends DynamicArchiveTestBase {
doTestCustomBase(baseArchiveName, topArchiveName);
}
private static void checkWarning(OutputAnalyzer output) throws Exception {
if (output.getStdout().contains("jrt:/") || output.getStdout().contains("unsafe anonymous")) {
System.out.println("test skipped: this platform uses non-archived classes when running -version");
} else {
output.shouldContain(warningMessage);
}
}
private static void doTest(String baseArchiveName, String topArchiveName) throws Exception {
dump2(baseArchiveName, topArchiveName,
"-Xlog:cds",
"-Xlog:cds+dynamic=debug",
"-Xlog:class+load=trace",
"-version")
.assertNormalExit(output -> {
if (output.getStdout().contains("jrt:/")) {
System.out.println("test skipped: this platform uses non-archived classes when running -version");
} else {
output.shouldContain(warningMessage);
}
});
.assertNormalExit(output -> checkWarning(output));
dump2(baseArchiveName, topArchiveName,
"-Xlog:cds",
@ -103,9 +105,11 @@ public class NoClassToArchive extends DynamicArchiveTestBase {
// create a dynamic archive with the custom base archive
// no class should be included in the dynamic archive
dump2(baseArchiveName, topArchiveName, "-version")
.assertNormalExit(out -> {
out.shouldMatch(warningMessage);
});
dump2(baseArchiveName, topArchiveName,
"-Xlog:cds",
"-Xlog:cds+dynamic=debug",
"-Xlog:class+load=trace",
"-version")
.assertNormalExit(out -> checkWarning(out));
}
}