2085 } else {
2086 *id_p = cache[idnum+1]; // fetch jmethodID (if any)
2087 }
2088 }
2089
2090
2091 // Lookup a jmethodID, NULL if not found. Do no blocking, no allocations, no handles
2092 jmethodID InstanceKlass::jmethod_id_or_null(Method* method) {
2093 size_t idnum = (size_t)method->method_idnum();
2094 jmethodID* jmeths = methods_jmethod_ids_acquire();
2095 size_t length; // length assigned as debugging crumb
2096 jmethodID id = NULL;
2097 if (jmeths != NULL && // If there is a cache
2098 (length = (size_t)jmeths[0]) > idnum) { // and if it is long enough,
2099 id = jmeths[idnum+1]; // Look up the id (may be NULL)
2100 }
2101 return id;
2102 }
2103
2104 inline DependencyContext InstanceKlass::dependencies() {
2105 DependencyContext dep_context(&_dep_context);
2106 return dep_context;
2107 }
2108
2109 int InstanceKlass::mark_dependent_nmethods(KlassDepChange& changes) {
2110 return dependencies().mark_dependent_nmethods(changes);
2111 }
2112
2113 void InstanceKlass::add_dependent_nmethod(nmethod* nm) {
2114 dependencies().add_dependent_nmethod(nm);
2115 }
2116
2117 void InstanceKlass::remove_dependent_nmethod(nmethod* nm, bool delete_immediately) {
2118 dependencies().remove_dependent_nmethod(nm, delete_immediately);
2119 }
2120
2121 #ifndef PRODUCT
2122 void InstanceKlass::print_dependent_nmethods(bool verbose) {
2123 dependencies().print_dependent_nmethods(verbose);
2124 }
2125
2126 bool InstanceKlass::is_dependent_nmethod(nmethod* nm) {
2127 return dependencies().is_dependent_nmethod(nm);
2128 }
2129 #endif //PRODUCT
2130
2131 void InstanceKlass::clean_weak_instanceklass_links() {
2132 clean_implementors_list();
2133 clean_method_data();
2134
2135 // Since GC iterates InstanceKlasses sequentially, it is safe to remove stale entries here.
2136 DependencyContext dep_context(&_dep_context);
2137 dep_context.expunge_stale_entries();
2138 }
2139
2140 void InstanceKlass::clean_implementors_list() {
2141 assert(is_loader_alive(), "this klass should be live");
2142 if (is_interface()) {
2143 if (ClassUnloading) {
2144 Klass* impl = implementor();
2145 if (impl != NULL) {
2146 if (!impl->is_loader_alive()) {
2147 // remove this guy
2148 Klass** klass = adr_implementor();
2149 assert(klass != NULL, "null klass");
2150 if (klass != NULL) {
2151 *klass = NULL;
2152 }
2153 }
2154 }
2155 }
2156 }
|
2085 } else {
2086 *id_p = cache[idnum+1]; // fetch jmethodID (if any)
2087 }
2088 }
2089
2090
2091 // Lookup a jmethodID, NULL if not found. Do no blocking, no allocations, no handles
2092 jmethodID InstanceKlass::jmethod_id_or_null(Method* method) {
2093 size_t idnum = (size_t)method->method_idnum();
2094 jmethodID* jmeths = methods_jmethod_ids_acquire();
2095 size_t length; // length assigned as debugging crumb
2096 jmethodID id = NULL;
2097 if (jmeths != NULL && // If there is a cache
2098 (length = (size_t)jmeths[0]) > idnum) { // and if it is long enough,
2099 id = jmeths[idnum+1]; // Look up the id (may be NULL)
2100 }
2101 return id;
2102 }
2103
2104 inline DependencyContext InstanceKlass::dependencies() {
2105 DependencyContext dep_context(&_dep_context, &_dep_context_last_cleaned);
2106 return dep_context;
2107 }
2108
2109 int InstanceKlass::mark_dependent_nmethods(KlassDepChange& changes) {
2110 return dependencies().mark_dependent_nmethods(changes);
2111 }
2112
2113 void InstanceKlass::add_dependent_nmethod(nmethod* nm) {
2114 dependencies().add_dependent_nmethod(nm);
2115 }
2116
2117 void InstanceKlass::remove_dependent_nmethod(nmethod* nm) {
2118 dependencies().remove_dependent_nmethod(nm);
2119 }
2120
2121 void InstanceKlass::clean_dependency_context() {
2122 dependencies().clean_unloading_dependents();
2123 }
2124
2125 #ifndef PRODUCT
2126 void InstanceKlass::print_dependent_nmethods(bool verbose) {
2127 dependencies().print_dependent_nmethods(verbose);
2128 }
2129
2130 bool InstanceKlass::is_dependent_nmethod(nmethod* nm) {
2131 return dependencies().is_dependent_nmethod(nm);
2132 }
2133 #endif //PRODUCT
2134
2135 void InstanceKlass::clean_weak_instanceklass_links() {
2136 clean_implementors_list();
2137 clean_method_data();
2138 }
2139
2140 void InstanceKlass::clean_implementors_list() {
2141 assert(is_loader_alive(), "this klass should be live");
2142 if (is_interface()) {
2143 if (ClassUnloading) {
2144 Klass* impl = implementor();
2145 if (impl != NULL) {
2146 if (!impl->is_loader_alive()) {
2147 // remove this guy
2148 Klass** klass = adr_implementor();
2149 assert(klass != NULL, "null klass");
2150 if (klass != NULL) {
2151 *klass = NULL;
2152 }
2153 }
2154 }
2155 }
2156 }
|
2302 {
2303 MutexLocker ml(Compile_lock);
2304 init_implementor();
2305 }
2306
2307 constants()->remove_unshareable_info();
2308
2309 for (int i = 0; i < methods()->length(); i++) {
2310 Method* m = methods()->at(i);
2311 m->remove_unshareable_info();
2312 }
2313
2314 // do array classes also.
2315 if (array_klasses() != NULL) {
2316 array_klasses()->remove_unshareable_info();
2317 }
2318
2319 // These are not allocated from metaspace, but they should should all be empty
2320 // during dump time, so we don't need to worry about them in InstanceKlass::iterate().
2321 guarantee(_source_debug_extension == NULL, "must be");
2322 guarantee(_dep_context == DependencyContext::EMPTY, "must be");
2323 guarantee(_osr_nmethods_head == NULL, "must be");
2324
2325 #if INCLUDE_JVMTI
2326 guarantee(_breakpoints == NULL, "must be");
2327 guarantee(_previous_versions == NULL, "must be");
2328 #endif
2329
2330 _init_thread = NULL;
2331 _methods_jmethod_ids = NULL;
2332 _jni_ids = NULL;
2333 _oop_map_cache = NULL;
2334 // clear _nest_host to ensure re-load at runtime
2335 _nest_host = NULL;
2336 }
2337
2338 void InstanceKlass::remove_java_mirror() {
2339 Klass::remove_java_mirror();
2340
2341 // do array classes also.
|
2302 {
2303 MutexLocker ml(Compile_lock);
2304 init_implementor();
2305 }
2306
2307 constants()->remove_unshareable_info();
2308
2309 for (int i = 0; i < methods()->length(); i++) {
2310 Method* m = methods()->at(i);
2311 m->remove_unshareable_info();
2312 }
2313
2314 // do array classes also.
2315 if (array_klasses() != NULL) {
2316 array_klasses()->remove_unshareable_info();
2317 }
2318
2319 // These are not allocated from metaspace, but they should should all be empty
2320 // during dump time, so we don't need to worry about them in InstanceKlass::iterate().
2321 guarantee(_source_debug_extension == NULL, "must be");
2322 guarantee(_dep_context == NULL, "must be");
2323 guarantee(_osr_nmethods_head == NULL, "must be");
2324
2325 #if INCLUDE_JVMTI
2326 guarantee(_breakpoints == NULL, "must be");
2327 guarantee(_previous_versions == NULL, "must be");
2328 #endif
2329
2330 _init_thread = NULL;
2331 _methods_jmethod_ids = NULL;
2332 _jni_ids = NULL;
2333 _oop_map_cache = NULL;
2334 // clear _nest_host to ensure re-load at runtime
2335 _nest_host = NULL;
2336 }
2337
2338 void InstanceKlass::remove_java_mirror() {
2339 Klass::remove_java_mirror();
2340
2341 // do array classes also.
|
2447 // Can't release the constant pool here because the constant pool can be
2448 // deallocated separately from the InstanceKlass for default methods and
2449 // redefine classes.
2450
2451 // Deallocate oop map cache
2452 if (_oop_map_cache != NULL) {
2453 delete _oop_map_cache;
2454 _oop_map_cache = NULL;
2455 }
2456
2457 // Deallocate JNI identifiers for jfieldIDs
2458 JNIid::deallocate(jni_ids());
2459 set_jni_ids(NULL);
2460
2461 jmethodID* jmeths = methods_jmethod_ids_acquire();
2462 if (jmeths != (jmethodID*)NULL) {
2463 release_set_methods_jmethod_ids(NULL);
2464 FreeHeap(jmeths);
2465 }
2466
2467 assert(_dep_context == DependencyContext::EMPTY,
2468 "dependencies should already be cleaned");
2469
2470 #if INCLUDE_JVMTI
2471 // Deallocate breakpoint records
2472 if (breakpoints() != 0x0) {
2473 methods_do(clear_all_breakpoints);
2474 assert(breakpoints() == 0x0, "should have cleared breakpoints");
2475 }
2476
2477 // deallocate the cached class file
2478 if (_cached_class_file != NULL && !MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {
2479 os::free(_cached_class_file);
2480 _cached_class_file = NULL;
2481 }
2482 #endif
2483
2484 // Decrement symbol reference counts associated with the unloaded class.
2485 if (_name != NULL) _name->decrement_refcount();
2486 // unreference array name derived from this class name (arrays of an unloaded
|
2447 // Can't release the constant pool here because the constant pool can be
2448 // deallocated separately from the InstanceKlass for default methods and
2449 // redefine classes.
2450
2451 // Deallocate oop map cache
2452 if (_oop_map_cache != NULL) {
2453 delete _oop_map_cache;
2454 _oop_map_cache = NULL;
2455 }
2456
2457 // Deallocate JNI identifiers for jfieldIDs
2458 JNIid::deallocate(jni_ids());
2459 set_jni_ids(NULL);
2460
2461 jmethodID* jmeths = methods_jmethod_ids_acquire();
2462 if (jmeths != (jmethodID*)NULL) {
2463 release_set_methods_jmethod_ids(NULL);
2464 FreeHeap(jmeths);
2465 }
2466
2467 assert(_dep_context == NULL,
2468 "dependencies should already be cleaned");
2469
2470 #if INCLUDE_JVMTI
2471 // Deallocate breakpoint records
2472 if (breakpoints() != 0x0) {
2473 methods_do(clear_all_breakpoints);
2474 assert(breakpoints() == 0x0, "should have cleared breakpoints");
2475 }
2476
2477 // deallocate the cached class file
2478 if (_cached_class_file != NULL && !MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {
2479 os::free(_cached_class_file);
2480 _cached_class_file = NULL;
2481 }
2482 #endif
2483
2484 // Decrement symbol reference counts associated with the unloaded class.
2485 if (_name != NULL) _name->decrement_refcount();
2486 // unreference array name derived from this class name (arrays of an unloaded
|