1602 // we should come here only if there are unverifiable classes, which
1603 // shouldn't happen in normal cases. So better safe than sorry.
1604 check_closure.reset();
1605 ClassLoaderDataGraph::loaded_classes_do(&check_closure);
1606 } while (check_closure.made_progress());
1607
1608 if (IgnoreUnverifiableClassesDuringDump) {
1609 // This is useful when running JCK or SQE tests. You should not
1610 // enable this when running real apps.
1611 SystemDictionary::remove_classes_in_error_state();
1612 } else {
1613 tty->print_cr("Please remove the unverifiable classes from your class list and try again");
1614 exit(1);
1615 }
1616 }
1617 }
1618
1619 void MetaspaceShared::prepare_for_dumping() {
1620 Arguments::check_unsupported_dumping_properties();
1621 ClassLoader::initialize_shared_path();
1622 FileMapInfo::allocate_classpath_entry_table();
1623 }
1624
1625 // Preload classes from a list, populate the shared spaces and dump to a
1626 // file.
1627 void MetaspaceShared::preload_and_dump(TRAPS) {
1628 { TraceTime timer("Dump Shared Spaces", TRACETIME_LOG(Info, startuptime));
1629 ResourceMark rm;
1630 char class_list_path_str[JVM_MAXPATHLEN];
1631 // Preload classes to be shared.
1632 // Should use some os:: method rather than fopen() here. aB.
1633 const char* class_list_path;
1634 if (SharedClassListFile == NULL) {
1635 // Construct the path to the class list (in jre/lib)
1636 // Walk up two directories from the location of the VM and
1637 // optionally tack on "lib" (depending on platform)
1638 os::jvm_path(class_list_path_str, sizeof(class_list_path_str));
1639 for (int i = 0; i < 3; i++) {
1640 char *end = strrchr(class_list_path_str, *os::file_separator());
1641 if (end != NULL) *end = '\0';
1642 }
1984 // mappings of the regions to fail.
1985 ReservedSpace shared_rs = mapinfo->reserve_shared_memory();
1986 if (!shared_rs.is_reserved()) return false;
1987 #endif
1988
1989 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces");
1990
1991 char* ro_base = NULL; char* ro_top;
1992 char* rw_base = NULL; char* rw_top;
1993 char* mc_base = NULL; char* mc_top;
1994 char* md_base = NULL; char* md_top;
1995 char* od_base = NULL; char* od_top;
1996
1997 // Map each shared region
1998 if ((mc_base = mapinfo->map_region(mc, &mc_top)) != NULL &&
1999 (rw_base = mapinfo->map_region(rw, &rw_top)) != NULL &&
2000 (ro_base = mapinfo->map_region(ro, &ro_top)) != NULL &&
2001 (md_base = mapinfo->map_region(md, &md_top)) != NULL &&
2002 (od_base = mapinfo->map_region(od, &od_top)) != NULL &&
2003 (image_alignment == (size_t)os::vm_allocation_granularity()) &&
2004 mapinfo->validate_classpath_entry_table()) {
2005 // Success -- set up MetaspaceObj::_shared_metaspace_{base,top} for
2006 // fast checking in MetaspaceShared::is_in_shared_metaspace() and
2007 // MetaspaceObj::is_shared().
2008 //
2009 // We require that mc->rw->ro->md->od to be laid out consecutively, with no
2010 // gaps between them. That way, we can ensure that the OS won't be able to
2011 // allocate any new memory spaces inside _shared_metaspace_{base,top}, which
2012 // would mess up the simple comparision in MetaspaceShared::is_in_shared_metaspace().
2013 assert(mc_base < ro_base && mc_base < rw_base && mc_base < md_base && mc_base < od_base, "must be");
2014 assert(od_top > ro_top && od_top > rw_top && od_top > md_top && od_top > mc_top , "must be");
2015 assert(mc_top == rw_base, "must be");
2016 assert(rw_top == ro_base, "must be");
2017 assert(ro_top == md_base, "must be");
2018 assert(md_top == od_base, "must be");
2019
2020 MetaspaceObj::_shared_metaspace_base = (void*)mc_base;
2021 MetaspaceObj::_shared_metaspace_top = (void*)od_top;
2022 return true;
2023 } else {
2024 // If there was a failure in mapping any of the spaces, unmap the ones
|
1602 // we should come here only if there are unverifiable classes, which
1603 // shouldn't happen in normal cases. So better safe than sorry.
1604 check_closure.reset();
1605 ClassLoaderDataGraph::loaded_classes_do(&check_closure);
1606 } while (check_closure.made_progress());
1607
1608 if (IgnoreUnverifiableClassesDuringDump) {
1609 // This is useful when running JCK or SQE tests. You should not
1610 // enable this when running real apps.
1611 SystemDictionary::remove_classes_in_error_state();
1612 } else {
1613 tty->print_cr("Please remove the unverifiable classes from your class list and try again");
1614 exit(1);
1615 }
1616 }
1617 }
1618
1619 void MetaspaceShared::prepare_for_dumping() {
1620 Arguments::check_unsupported_dumping_properties();
1621 ClassLoader::initialize_shared_path();
1622 }
1623
1624 // Preload classes from a list, populate the shared spaces and dump to a
1625 // file.
1626 void MetaspaceShared::preload_and_dump(TRAPS) {
1627 { TraceTime timer("Dump Shared Spaces", TRACETIME_LOG(Info, startuptime));
1628 ResourceMark rm;
1629 char class_list_path_str[JVM_MAXPATHLEN];
1630 // Preload classes to be shared.
1631 // Should use some os:: method rather than fopen() here. aB.
1632 const char* class_list_path;
1633 if (SharedClassListFile == NULL) {
1634 // Construct the path to the class list (in jre/lib)
1635 // Walk up two directories from the location of the VM and
1636 // optionally tack on "lib" (depending on platform)
1637 os::jvm_path(class_list_path_str, sizeof(class_list_path_str));
1638 for (int i = 0; i < 3; i++) {
1639 char *end = strrchr(class_list_path_str, *os::file_separator());
1640 if (end != NULL) *end = '\0';
1641 }
1983 // mappings of the regions to fail.
1984 ReservedSpace shared_rs = mapinfo->reserve_shared_memory();
1985 if (!shared_rs.is_reserved()) return false;
1986 #endif
1987
1988 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces");
1989
1990 char* ro_base = NULL; char* ro_top;
1991 char* rw_base = NULL; char* rw_top;
1992 char* mc_base = NULL; char* mc_top;
1993 char* md_base = NULL; char* md_top;
1994 char* od_base = NULL; char* od_top;
1995
1996 // Map each shared region
1997 if ((mc_base = mapinfo->map_region(mc, &mc_top)) != NULL &&
1998 (rw_base = mapinfo->map_region(rw, &rw_top)) != NULL &&
1999 (ro_base = mapinfo->map_region(ro, &ro_top)) != NULL &&
2000 (md_base = mapinfo->map_region(md, &md_top)) != NULL &&
2001 (od_base = mapinfo->map_region(od, &od_top)) != NULL &&
2002 (image_alignment == (size_t)os::vm_allocation_granularity()) &&
2003 mapinfo->validate_shared_path_table()) {
2004 // Success -- set up MetaspaceObj::_shared_metaspace_{base,top} for
2005 // fast checking in MetaspaceShared::is_in_shared_metaspace() and
2006 // MetaspaceObj::is_shared().
2007 //
2008 // We require that mc->rw->ro->md->od to be laid out consecutively, with no
2009 // gaps between them. That way, we can ensure that the OS won't be able to
2010 // allocate any new memory spaces inside _shared_metaspace_{base,top}, which
2011 // would mess up the simple comparision in MetaspaceShared::is_in_shared_metaspace().
2012 assert(mc_base < ro_base && mc_base < rw_base && mc_base < md_base && mc_base < od_base, "must be");
2013 assert(od_top > ro_top && od_top > rw_top && od_top > md_top && od_top > mc_top , "must be");
2014 assert(mc_top == rw_base, "must be");
2015 assert(rw_top == ro_base, "must be");
2016 assert(ro_top == md_base, "must be");
2017 assert(md_top == od_base, "must be");
2018
2019 MetaspaceObj::_shared_metaspace_base = (void*)mc_base;
2020 MetaspaceObj::_shared_metaspace_top = (void*)od_top;
2021 return true;
2022 } else {
2023 // If there was a failure in mapping any of the spaces, unmap the ones
|