@@ -652,6 +652,8 @@ char* VM_PopulateDumpSharedSpace::dump_read_only_tables(AOTClassLocationConfig*&
652652}
653653
654654void VM_PopulateDumpSharedSpace::doit () {
655+ CDSConfig::set_is_at_aot_safepoint (true );
656+
655657 if (!CDSConfig::is_dumping_final_static_archive ()) {
656658 guarantee (!CDSConfig::is_using_archive (), " We should not be using an archive when we dump" );
657659 }
@@ -717,6 +719,8 @@ void VM_PopulateDumpSharedSpace::doit() {
717719 _map_info->set_serialized_data (serialized_data);
718720 _map_info->set_cloned_vtables (CppVtables::vtables_serialized_base ());
719721 _map_info->header ()->set_class_location_config (cl_config);
722+
723+ CDSConfig::set_is_at_aot_safepoint (false );
720724}
721725
722726class CollectClassesForLinking : public KlassClosure {
@@ -773,20 +777,17 @@ bool AOTMetaspace::may_be_eagerly_linked(InstanceKlass* ik) {
773777 return true ;
774778}
775779
776- void AOTMetaspace::link_shared_classes (TRAPS) {
777- AOTClassLinker::initialize ();
778- AOTClassInitializer::init_test_class (CHECK);
779-
780+ void AOTMetaspace::link_all_loaded_classes (JavaThread* current) {
780781 while (true ) {
781- ResourceMark rm (THREAD );
782+ ResourceMark rm (current );
782783 CollectClassesForLinking collect_classes;
783784 bool has_linked = false ;
784785 const GrowableArray<OopHandle>* mirrors = collect_classes.mirrors ();
785786 for (int i = 0 ; i < mirrors->length (); i++) {
786787 OopHandle mirror = mirrors->at (i);
787788 InstanceKlass* ik = InstanceKlass::cast (java_lang_Class::as_Klass (mirror.resolve ()));
788789 if (may_be_eagerly_linked (ik)) {
789- has_linked |= try_link_class (THREAD , ik);
790+ has_linked |= try_link_class (current , ik);
790791 }
791792 }
792793
@@ -796,6 +797,13 @@ void AOTMetaspace::link_shared_classes(TRAPS) {
796797 // Class linking includes verification which may load more classes.
797798 // Keep scanning until we have linked no more classes.
798799 }
800+ }
801+
802+ void AOTMetaspace::link_shared_classes (TRAPS) {
803+ AOTClassLinker::initialize ();
804+ AOTClassInitializer::init_test_class (CHECK);
805+
806+ link_all_loaded_classes (THREAD);
799807
800808 // Eargerly resolve all string constants in constant pools
801809 {
0 commit comments