< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page

        

*** 1686,1715 **** } return k; } class LinkSharedClassesClosure : public KlassClosure { Thread* THREAD; bool _made_progress; public: ! LinkSharedClassesClosure(Thread* thread) : THREAD(thread), _made_progress(false) {} void reset() { _made_progress = false; } bool made_progress() const { return _made_progress; } void do_klass(Klass* k) { if (k->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(k); // Link the class to cause the bytecodes to be rewritten and the // cpcache to be created. Class verification is done according // to -Xverify setting. _made_progress |= MetaspaceShared::try_link_class(ik, THREAD); guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class"); ik->constants()->resolve_class_constants(THREAD); } } }; class CheckSharedClassesClosure : public KlassClosure { bool _made_progress; public: --- 1686,1720 ---- } return k; } class LinkSharedClassesClosure : public KlassClosure { + bool _is_static; Thread* THREAD; bool _made_progress; public: ! LinkSharedClassesClosure(bool is_static, Thread* thread) : _is_static(is_static), THREAD(thread), _made_progress(false) {} void reset() { _made_progress = false; } bool made_progress() const { return _made_progress; } void do_klass(Klass* k) { if (k->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(k); + // For dynamic CDS dump, only link classes loaded by the builtin class loaders. + bool do_linking = _is_static ? true : ik->loader_type() != 0; + if (do_linking) { // Link the class to cause the bytecodes to be rewritten and the // cpcache to be created. Class verification is done according // to -Xverify setting. _made_progress |= MetaspaceShared::try_link_class(ik, THREAD); guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class"); ik->constants()->resolve_class_constants(THREAD); } } + } }; class CheckSharedClassesClosure : public KlassClosure { bool _made_progress; public:
*** 1722,1735 **** _made_progress = true; } } }; ! void MetaspaceShared::link_and_cleanup_shared_classes(TRAPS) { // We need to iterate because verification may cause additional classes // to be loaded. ! LinkSharedClassesClosure link_closure(THREAD); do { link_closure.reset(); ClassLoaderDataGraph::unlocked_loaded_classes_do(&link_closure); guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class"); } while (link_closure.made_progress()); --- 1727,1740 ---- _made_progress = true; } } }; ! void MetaspaceShared::link_and_cleanup_shared_classes(bool is_static, Thread* THREAD) { // We need to iterate because verification may cause additional classes // to be loaded. ! LinkSharedClassesClosure link_closure(is_static, THREAD); do { link_closure.reset(); ClassLoaderDataGraph::unlocked_loaded_classes_do(&link_closure); guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class"); } while (link_closure.made_progress());
*** 1813,1823 **** // 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); log_info(cds)("Rewriting and linking classes: done"); if (HeapShared::is_heap_object_archiving_allowed()) { // Avoid fragmentation while archiving heap objects. Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true); --- 1818,1828 ---- // 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(true, CATCH); log_info(cds)("Rewriting and linking classes: done"); if (HeapShared::is_heap_object_archiving_allowed()) { // Avoid fragmentation while archiving heap objects. Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
*** 1869,1879 **** return class_count; } // Returns true if the class's status has changed bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) { ! assert(DumpSharedSpaces, "should only be called during dumping"); if (ik->init_state() < InstanceKlass::linked) { bool saved = BytecodeVerificationLocal; if (ik->loader_type() == 0 && ik->class_loader() == NULL) { // The verification decision is based on BytecodeVerificationRemote // for non-system classes. Since we are using the NULL classloader --- 1874,1884 ---- return class_count; } // Returns true if the class's status has changed bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) { ! Arguments::assert_is_dumping_archive(); if (ik->init_state() < InstanceKlass::linked) { bool saved = BytecodeVerificationLocal; if (ik->loader_type() == 0 && ik->class_loader() == NULL) { // The verification decision is based on BytecodeVerificationRemote // for non-system classes. Since we are using the NULL classloader
< prev index next >