--- old/src/share/vm/memory/metaspaceShared.cpp 2016-02-10 16:34:40.641920190 -0500 +++ new/src/share/vm/memory/metaspaceShared.cpp 2016-02-10 16:34:40.470833234 -0500 @@ -771,88 +771,92 @@ // Preload classes from a list, populate the shared spaces and dump to a // file. void MetaspaceShared::preload_and_dump(TRAPS) { - TraceTime timer("Dump Shared Spaces", TraceStartupTime); - ResourceMark rm; - char class_list_path_str[JVM_MAXPATHLEN]; - - tty->print_cr("Allocated shared space: " SIZE_FORMAT " bytes at " PTR_FORMAT, - MetaspaceShared::shared_rs()->size(), - p2i(MetaspaceShared::shared_rs()->base())); - - // Preload classes to be shared. - // Should use some os:: method rather than fopen() here. aB. - const char* class_list_path; - if (SharedClassListFile == NULL) { - // Construct the path to the class list (in jre/lib) - // Walk up two directories from the location of the VM and - // optionally tack on "lib" (depending on platform) - os::jvm_path(class_list_path_str, sizeof(class_list_path_str)); - for (int i = 0; i < 3; i++) { - char *end = strrchr(class_list_path_str, *os::file_separator()); - if (end != NULL) *end = '\0'; - } - int class_list_path_len = (int)strlen(class_list_path_str); - if (class_list_path_len >= 3) { - if (strcmp(class_list_path_str + class_list_path_len - 3, "lib") != 0) { - if (class_list_path_len < JVM_MAXPATHLEN - 4) { - jio_snprintf(class_list_path_str + class_list_path_len, - sizeof(class_list_path_str) - class_list_path_len, - "%slib", os::file_separator()); - class_list_path_len += 4; + { ResourceMark rm; + TraceTime timer("Dump Shared Spaces", + log_is_enabled(Info, startuptime), + LogTag::_startuptime); + + char class_list_path_str[JVM_MAXPATHLEN]; + + tty->print_cr("Allocated shared space: " SIZE_FORMAT " bytes at " PTR_FORMAT, + MetaspaceShared::shared_rs()->size(), + p2i(MetaspaceShared::shared_rs()->base())); + + // Preload classes to be shared. + // Should use some os:: method rather than fopen() here. aB. + const char* class_list_path; + if (SharedClassListFile == NULL) { + // Construct the path to the class list (in jre/lib) + // Walk up two directories from the location of the VM and + // optionally tack on "lib" (depending on platform) + os::jvm_path(class_list_path_str, sizeof(class_list_path_str)); + for (int i = 0; i < 3; i++) { + char *end = strrchr(class_list_path_str, *os::file_separator()); + if (end != NULL) *end = '\0'; + } + int class_list_path_len = (int)strlen(class_list_path_str); + if (class_list_path_len >= 3) { + if (strcmp(class_list_path_str + class_list_path_len - 3, "lib") != 0) { + if (class_list_path_len < JVM_MAXPATHLEN - 4) { + jio_snprintf(class_list_path_str + class_list_path_len, + sizeof(class_list_path_str) - class_list_path_len, + "%slib", os::file_separator()); + class_list_path_len += 4; + } } } + if (class_list_path_len < JVM_MAXPATHLEN - 10) { + jio_snprintf(class_list_path_str + class_list_path_len, + sizeof(class_list_path_str) - class_list_path_len, + "%sclasslist", os::file_separator()); + } + class_list_path = class_list_path_str; + } else { + class_list_path = SharedClassListFile; } - if (class_list_path_len < JVM_MAXPATHLEN - 10) { - jio_snprintf(class_list_path_str + class_list_path_len, - sizeof(class_list_path_str) - class_list_path_len, - "%sclasslist", os::file_separator()); - } - class_list_path = class_list_path_str; - } else { - class_list_path = SharedClassListFile; - } - int class_count = 0; - GrowableArray* class_promote_order = new GrowableArray(); + int class_count = 0; + GrowableArray* class_promote_order = new GrowableArray(); - // sun.io.Converters - static const char obj_array_sig[] = "[[Ljava/lang/Object;"; - SymbolTable::new_permanent_symbol(obj_array_sig, THREAD); - - // java.util.HashMap - static const char map_entry_array_sig[] = "[Ljava/util/Map$Entry;"; - SymbolTable::new_permanent_symbol(map_entry_array_sig, THREAD); - - // Need to allocate the op here: - // op.misc_data_space_alloc() will be called during preload_and_dump(). - ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); - VM_PopulateDumpSharedSpace op(loader_data, class_promote_order); - - tty->print_cr("Loading classes to share ..."); - _has_error_classes = false; - class_count += preload_and_dump(class_list_path, class_promote_order, - THREAD); - if (ExtraSharedClassListFile) { - class_count += preload_and_dump(ExtraSharedClassListFile, class_promote_order, + // sun.io.Converters + static const char obj_array_sig[] = "[[Ljava/lang/Object;"; + SymbolTable::new_permanent_symbol(obj_array_sig, THREAD); + + // java.util.HashMap + static const char map_entry_array_sig[] = "[Ljava/util/Map$Entry;"; + SymbolTable::new_permanent_symbol(map_entry_array_sig, THREAD); + + // Need to allocate the op here: + // op.misc_data_space_alloc() will be called during preload_and_dump(). + ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); + VM_PopulateDumpSharedSpace op(loader_data, class_promote_order); + + tty->print_cr("Loading classes to share ..."); + _has_error_classes = false; + class_count += preload_and_dump(class_list_path, class_promote_order, THREAD); - } - tty->print_cr("Loading classes to share: done."); + if (ExtraSharedClassListFile) { + class_count += preload_and_dump(ExtraSharedClassListFile, class_promote_order, + THREAD); + } + tty->print_cr("Loading classes to share: done."); - if (PrintSharedSpaces) { - tty->print_cr("Shared spaces: preloaded %d classes", class_count); - } + if (PrintSharedSpaces) { + tty->print_cr("Shared spaces: preloaded %d classes", class_count); + } - // Rewrite and link classes - tty->print_cr("Rewriting and linking classes ..."); + // Rewrite and link classes + tty->print_cr("Rewriting and linking classes ..."); - // Link any classes which got missed. This would happen if we have loaded classes that - // were not explicitly specified in the classlist. E.g., if an interface implemented by class K - // fails verification, all other interfaces that were not specified in the classlist but - // are implemented by K are not verified. - link_and_cleanup_shared_classes(CATCH); - tty->print_cr("Rewriting and linking classes: done"); + // Link any classes which got missed. This would happen if we have loaded classes that + // were not explicitly specified in the classlist. E.g., if an interface implemented by class K + // fails verification, all other interfaces that were not specified in the classlist but + // are implemented by K are not verified. + link_and_cleanup_shared_classes(CATCH); + tty->print_cr("Rewriting and linking classes: done"); - VMThread::execute(&op); + VMThread::execute(&op); + } // Since various initialization steps have been undone by this process, // it is not reasonable to continue running a java process. exit(0);