8213250: CDS archive creation aborts due to metaspace object allocation failure

Reviewed-by: jiangli, ccheung
This commit is contained in:
Ioi Lam 2018-11-01 10:59:05 -07:00
parent 836e02e1f1
commit b84cf61b08
4 changed files with 27 additions and 36 deletions

View file

@ -1207,10 +1207,6 @@ private:
public:
static void copy_and_compact() {
// We should no longer allocate anything from the metaspace, so that
// we can have a stable set of MetaspaceObjs to work with.
Metaspace::freeze();
ResourceMark rm;
SortedSymbolClosure the_ssc; // StackObj
_ssc = &the_ssc;
@ -1356,6 +1352,14 @@ char* VM_PopulateDumpSharedSpace::dump_read_only_tables() {
}
void VM_PopulateDumpSharedSpace::doit() {
// We should no longer allocate anything from the metaspace, so that:
//
// (1) Metaspace::allocate might trigger GC if we have run out of
// committed metaspace, but we can't GC because we're running
// in the VM thread.
// (2) ArchiveCompactor needs to work with a stable set of MetaspaceObjs.
Metaspace::freeze();
Thread* THREAD = VMThread::vm_thread();
FileMapInfo::check_nonempty_dir_in_shared_path_table();
@ -1420,8 +1424,6 @@ void VM_PopulateDumpSharedSpace::doit() {
// any dictionaries.
NOT_PRODUCT(assert_no_unsafe_anonymous_classes_in_dictionaries());
SystemDictionaryShared::finalize_verification_constraints();
ArchiveCompactor::initialize();
ArchiveCompactor::copy_and_compact();
@ -1717,6 +1719,8 @@ void MetaspaceShared::preload_and_dump(TRAPS) {
SystemDictionary::clear_invoke_method_table();
SystemDictionaryShared::finalize_verification_constraints();
VM_PopulateDumpSharedSpace op;
VMThread::execute(&op);
}