36 #include "classfile/loaderConstraints.hpp"
37 #include "classfile/packageEntry.hpp"
38 #include "classfile/placeholders.hpp"
39 #include "classfile/protectionDomainCache.hpp"
40 #include "classfile/resolutionErrors.hpp"
41 #include "classfile/stringTable.hpp"
42 #include "classfile/systemDictionary.hpp"
43 #include "classfile/vmSymbols.hpp"
44 #include "code/codeCache.hpp"
45 #include "compiler/compileBroker.hpp"
46 #include "gc/shared/gcLocker.hpp"
47 #include "gc/shared/gcTraceTime.inline.hpp"
48 #include "interpreter/bytecodeStream.hpp"
49 #include "interpreter/interpreter.hpp"
50 #include "logging/log.hpp"
51 #include "logging/logStream.hpp"
52 #include "memory/filemap.hpp"
53 #include "memory/metaspaceClosure.hpp"
54 #include "memory/oopFactory.hpp"
55 #include "memory/resourceArea.hpp"
56 #include "oops/instanceKlass.hpp"
57 #include "oops/instanceRefKlass.hpp"
58 #include "oops/klass.inline.hpp"
59 #include "oops/method.inline.hpp"
60 #include "oops/methodData.hpp"
61 #include "oops/objArrayKlass.hpp"
62 #include "oops/objArrayOop.inline.hpp"
63 #include "oops/oop.inline.hpp"
64 #include "oops/symbol.hpp"
65 #include "oops/typeArrayKlass.hpp"
66 #include "prims/jvmtiEnvBase.hpp"
67 #include "prims/resolvedMethodTable.hpp"
68 #include "prims/methodHandles.hpp"
69 #include "runtime/arguments.hpp"
70 #include "runtime/arguments_ext.hpp"
71 #include "runtime/biasedLocking.hpp"
72 #include "runtime/fieldType.hpp"
73 #include "runtime/handles.inline.hpp"
74 #include "runtime/java.hpp"
75 #include "runtime/javaCalls.hpp"
1812 // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1813 // Also, first reinitialize vtable because it may have gotten out of synch
1814 // while the new class wasn't connected to the class hierarchy.
1815 CodeCache::flush_dependents_on(k);
1816 }
1817
1818 // ----------------------------------------------------------------------------
1819 // GC support
1820
1821 void SystemDictionary::always_strong_oops_do(OopClosure* blk) {
1822 roots_oops_do(blk, NULL);
1823 }
1824
1825
1826 #ifdef ASSERT
1827 class VerifySDReachableAndLiveClosure : public OopClosure {
1828 private:
1829 BoolObjectClosure* _is_alive;
1830
1831 template <class T> void do_oop_work(T* p) {
1832 oop obj = oopDesc::load_decode_heap_oop(p);
1833 guarantee(_is_alive->do_object_b(obj), "Oop in protection domain cache table must be live");
1834 }
1835
1836 public:
1837 VerifySDReachableAndLiveClosure(BoolObjectClosure* is_alive) : OopClosure(), _is_alive(is_alive) { }
1838
1839 virtual void do_oop(oop* p) { do_oop_work(p); }
1840 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
1841 };
1842 #endif
1843
1844 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1845 // Note: anonymous classes are not in the SD.
1846 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive,
1847 GCTimer* gc_timer,
1848 bool do_cleaning) {
1849
1850
1851 bool unloading_occurred;
1852 {
2682 objArrayHandle pts = oopFactory::new_objArray_handle(SystemDictionary::Class_klass(), npts, CHECK_(empty));
2683 int arg = 0;
2684 Handle rt; // the return type from the signature
2685 ResourceMark rm(THREAD);
2686 for (SignatureStream ss(signature); !ss.is_done(); ss.next()) {
2687 oop mirror = NULL;
2688 if (can_be_cached) {
2689 // Use neutral class loader to lookup candidate classes to be placed in the cache.
2690 mirror = ss.as_java_mirror(Handle(), Handle(),
2691 SignatureStream::ReturnNull, CHECK_(empty));
2692 if (mirror == NULL || (ss.is_object() && !is_always_visible_class(mirror))) {
2693 // Fall back to accessing_klass context.
2694 can_be_cached = false;
2695 }
2696 }
2697 if (!can_be_cached) {
2698 // Resolve, throwing a real error if it doesn't work.
2699 mirror = ss.as_java_mirror(class_loader, protection_domain,
2700 SignatureStream::NCDFError, CHECK_(empty));
2701 }
2702 assert(!oopDesc::is_null(mirror), "%s", ss.as_symbol(THREAD)->as_C_string());
2703 if (ss.at_return_type())
2704 rt = Handle(THREAD, mirror);
2705 else
2706 pts->obj_at_put(arg++, mirror);
2707
2708 // Check accessibility.
2709 if (!java_lang_Class::is_primitive(mirror) && accessing_klass != NULL) {
2710 Klass* sel_klass = java_lang_Class::as_Klass(mirror);
2711 mirror = NULL; // safety
2712 // Emulate ConstantPool::verify_constant_pool_resolve.
2713 bool fold_type_to_class = true;
2714 LinkResolver::check_klass_accessability(accessing_klass, sel_klass,
2715 fold_type_to_class, CHECK_(empty));
2716 }
2717 }
2718 assert(arg == npts, "");
2719
2720 // call java.lang.invoke.MethodHandleNatives::findMethodHandleType(Class rt, Class[] pts) -> MethodType
2721 JavaCallArguments args(Handle(THREAD, rt()));
2722 args.push_oop(pts);
|
36 #include "classfile/loaderConstraints.hpp"
37 #include "classfile/packageEntry.hpp"
38 #include "classfile/placeholders.hpp"
39 #include "classfile/protectionDomainCache.hpp"
40 #include "classfile/resolutionErrors.hpp"
41 #include "classfile/stringTable.hpp"
42 #include "classfile/systemDictionary.hpp"
43 #include "classfile/vmSymbols.hpp"
44 #include "code/codeCache.hpp"
45 #include "compiler/compileBroker.hpp"
46 #include "gc/shared/gcLocker.hpp"
47 #include "gc/shared/gcTraceTime.inline.hpp"
48 #include "interpreter/bytecodeStream.hpp"
49 #include "interpreter/interpreter.hpp"
50 #include "logging/log.hpp"
51 #include "logging/logStream.hpp"
52 #include "memory/filemap.hpp"
53 #include "memory/metaspaceClosure.hpp"
54 #include "memory/oopFactory.hpp"
55 #include "memory/resourceArea.hpp"
56 #include "oops/access.inline.hpp"
57 #include "oops/instanceKlass.hpp"
58 #include "oops/instanceRefKlass.hpp"
59 #include "oops/klass.inline.hpp"
60 #include "oops/method.inline.hpp"
61 #include "oops/methodData.hpp"
62 #include "oops/objArrayKlass.hpp"
63 #include "oops/objArrayOop.inline.hpp"
64 #include "oops/oop.inline.hpp"
65 #include "oops/symbol.hpp"
66 #include "oops/typeArrayKlass.hpp"
67 #include "prims/jvmtiEnvBase.hpp"
68 #include "prims/resolvedMethodTable.hpp"
69 #include "prims/methodHandles.hpp"
70 #include "runtime/arguments.hpp"
71 #include "runtime/arguments_ext.hpp"
72 #include "runtime/biasedLocking.hpp"
73 #include "runtime/fieldType.hpp"
74 #include "runtime/handles.inline.hpp"
75 #include "runtime/java.hpp"
76 #include "runtime/javaCalls.hpp"
1813 // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1814 // Also, first reinitialize vtable because it may have gotten out of synch
1815 // while the new class wasn't connected to the class hierarchy.
1816 CodeCache::flush_dependents_on(k);
1817 }
1818
1819 // ----------------------------------------------------------------------------
1820 // GC support
1821
1822 void SystemDictionary::always_strong_oops_do(OopClosure* blk) {
1823 roots_oops_do(blk, NULL);
1824 }
1825
1826
1827 #ifdef ASSERT
1828 class VerifySDReachableAndLiveClosure : public OopClosure {
1829 private:
1830 BoolObjectClosure* _is_alive;
1831
1832 template <class T> void do_oop_work(T* p) {
1833 oop obj = RawAccess<>::oop_load(p);
1834 guarantee(_is_alive->do_object_b(obj), "Oop in protection domain cache table must be live");
1835 }
1836
1837 public:
1838 VerifySDReachableAndLiveClosure(BoolObjectClosure* is_alive) : OopClosure(), _is_alive(is_alive) { }
1839
1840 virtual void do_oop(oop* p) { do_oop_work(p); }
1841 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
1842 };
1843 #endif
1844
1845 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1846 // Note: anonymous classes are not in the SD.
1847 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive,
1848 GCTimer* gc_timer,
1849 bool do_cleaning) {
1850
1851
1852 bool unloading_occurred;
1853 {
2683 objArrayHandle pts = oopFactory::new_objArray_handle(SystemDictionary::Class_klass(), npts, CHECK_(empty));
2684 int arg = 0;
2685 Handle rt; // the return type from the signature
2686 ResourceMark rm(THREAD);
2687 for (SignatureStream ss(signature); !ss.is_done(); ss.next()) {
2688 oop mirror = NULL;
2689 if (can_be_cached) {
2690 // Use neutral class loader to lookup candidate classes to be placed in the cache.
2691 mirror = ss.as_java_mirror(Handle(), Handle(),
2692 SignatureStream::ReturnNull, CHECK_(empty));
2693 if (mirror == NULL || (ss.is_object() && !is_always_visible_class(mirror))) {
2694 // Fall back to accessing_klass context.
2695 can_be_cached = false;
2696 }
2697 }
2698 if (!can_be_cached) {
2699 // Resolve, throwing a real error if it doesn't work.
2700 mirror = ss.as_java_mirror(class_loader, protection_domain,
2701 SignatureStream::NCDFError, CHECK_(empty));
2702 }
2703 assert(mirror != NULL, "%s", ss.as_symbol(THREAD)->as_C_string());
2704 if (ss.at_return_type())
2705 rt = Handle(THREAD, mirror);
2706 else
2707 pts->obj_at_put(arg++, mirror);
2708
2709 // Check accessibility.
2710 if (!java_lang_Class::is_primitive(mirror) && accessing_klass != NULL) {
2711 Klass* sel_klass = java_lang_Class::as_Klass(mirror);
2712 mirror = NULL; // safety
2713 // Emulate ConstantPool::verify_constant_pool_resolve.
2714 bool fold_type_to_class = true;
2715 LinkResolver::check_klass_accessability(accessing_klass, sel_klass,
2716 fold_type_to_class, CHECK_(empty));
2717 }
2718 }
2719 assert(arg == npts, "");
2720
2721 // call java.lang.invoke.MethodHandleNatives::findMethodHandleType(Class rt, Class[] pts) -> MethodType
2722 JavaCallArguments args(Handle(THREAD, rt()));
2723 args.push_oop(pts);
|