Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8244540: Print more information with -XX:+PrintSharedArchiveAndExit #3187

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/hotspot/share/classfile/systemDictionaryShared.cpp
Expand Up @@ -2249,23 +2249,24 @@ class SharedDictionaryPrinter : StackObj {

void do_value(const RunTimeSharedClassInfo* record) {
ResourceMark rm;
_st->print_cr("%4d: %s loaded by: %s", (_index++), record->_klass->external_name(),
_st->print_cr("%4d: %s %s", (_index++), record->_klass->external_name(),
class_loader_name_for_shared(record->_klass));
yminqi marked this conversation as resolved.
Show resolved Hide resolved
}
int index() const { return _index; }
};

class SharedLambdaDictionaryPrinter : StackObj {
outputStream* _st;
int _index;
public:
SharedLambdaDictionaryPrinter(outputStream* st) : _st(st), _index(0) {}
SharedLambdaDictionaryPrinter(outputStream* st, int idx) : _st(st), _index(idx) {}

void do_value(const RunTimeLambdaProxyClassInfo* record) {
if (record->proxy_klass_head()->lambda_proxy_is_available()) {
ResourceMark rm;
Klass* k = record->proxy_klass_head();
while (k != nullptr) {
_st->print_cr("%4d: %s loaded by: %s", (++_index), k->external_name(),
_st->print_cr("%4d: %s %s", (++_index), k->external_name(),
class_loader_name_for_shared(k));
k = k->next_link();
}
Expand All @@ -2286,11 +2287,24 @@ void SystemDictionaryShared::print_on(const char* prefix,
unregistered_dictionary->iterate(&p);
if (!lambda_dictionary->empty()) {
st->print_cr("%sShared Lambda Dictionary", prefix);
SharedLambdaDictionaryPrinter ldp(st);
SharedLambdaDictionaryPrinter ldp(st, p.index());
lambda_dictionary->iterate(&ldp);
}
}

void SystemDictionaryShared::print_shared_archive(outputStream* st, bool is_static) {
if (UseSharedSpaces) {
if (is_static) {
print_on("", &_builtin_dictionary, &_unregistered_dictionary, &_lambda_proxy_class_dictionary, st);
} else {
if (DynamicArchive::is_mapped()) {
print_on("", &_dynamic_builtin_dictionary, &_dynamic_unregistered_dictionary,
&_dynamic_lambda_proxy_class_dictionary, st);
}
}
}
}

void SystemDictionaryShared::print_on(outputStream* st) {
if (UseSharedSpaces) {
print_on("", &_builtin_dictionary, &_unregistered_dictionary, &_lambda_proxy_class_dictionary, st);
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/classfile/systemDictionaryShared.hpp
Expand Up @@ -316,6 +316,7 @@ class SystemDictionaryShared: public SystemDictionary {
static void serialize_vm_classes(class SerializeClosure* soc);
static void print() { return print_on(tty); }
static void print_on(outputStream* st) NOT_CDS_RETURN;
static void print_shared_archive(outputStream* st, bool is_static = true) NOT_CDS_RETURN;
static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;
static bool empty_dumptime_table() NOT_CDS_RETURN_(true);
static void start_dumping() NOT_CDS_RETURN;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/memory/metaspaceShared.cpp
Expand Up @@ -1403,13 +1403,13 @@ void MetaspaceShared::initialize_shared_spaces() {
tty->print_cr("Static archive version %d", static_mapinfo->version());
}

SystemDictionaryShared::print_shared_archive(tty);
if (dynamic_mapinfo != nullptr) {
tty->print_cr("\n\nDynamic archive name: %s", dynamic_mapinfo->full_path());
tty->print_cr("Dynamic archive version %d", dynamic_mapinfo->version());
SystemDictionaryShared::print_shared_archive(tty, false/*dynamic*/);
}

SystemDictionaryShared::print_on(tty);

// collect shared symbols and strings
CountSharedSymbols cl;
SymbolTable::shared_symbols_do(&cl);
Expand Down
Expand Up @@ -76,9 +76,9 @@ public static void run(String... extra_runtime_args) throws Exception {
"-XX:+PrintSharedArchiveAndExit",
"HelloUnload", customJarPath, "true", "true"));
output.shouldMatch(".* archive version \\d+")
.shouldContain("java.lang.Object loaded by: boot_loader")
.shouldContain("HelloUnload loaded by: app_loader")
.shouldContain("CustomLoadee loaded by: unregistered_loader")
.shouldContain("java.lang.Object boot_loader")
.shouldContain("HelloUnload app_loader")
.shouldContain("CustomLoadee unregistered_loader")
.shouldContain("Shared Builtin Dictionary")
.shouldContain("Shared Unregistered Dictionary")
.shouldMatch("Number of shared symbols: \\d+")
Expand Down
Expand Up @@ -86,9 +86,9 @@ public static void testPrtNExit() throws Exception {
.shouldMatch("Base archive name: .*.jsa") // given name ends with .jsa, maynot default name.
.shouldMatch("Dynamic archive name: .*" + ARCHIVE_NAME)
.shouldMatch("Base archive version \\d+")
.shouldContain("java.lang.Object loaded by: boot_loader")
.shouldContain("HelloUnload loaded by: app_loader")
.shouldContain("CustomLoadee loaded by: unregistered_loader")
.shouldContain("java.lang.Object boot_loader")
.shouldContain("HelloUnload app_loader")
.shouldContain("CustomLoadee unregistered_loader")
.shouldContain("Shared Builtin Dictionary")
.shouldContain("Shared Unregistered Dictionary")
.shouldMatch("Number of shared symbols: \\d+")
Expand Down