< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page




2400           bad = true;
2401           break;
2402         }
2403       }
2404     }
2405 
2406     if (bad) {
2407       set_in_error_state();
2408     }
2409   }
2410 
2411   return (old_state != is_in_error_state());
2412 }
2413 
2414 #if INCLUDE_JVMTI
2415 static void clear_all_breakpoints(Method* m) {
2416   m->clear_all_breakpoints();
2417 }
2418 #endif
2419 
2420 void InstanceKlass::notify_unload_class(InstanceKlass* ik) {



2421   // notify the debugger
2422   if (JvmtiExport::should_post_class_unload()) {
2423     JvmtiExport::post_class_unload(ik);
2424   }
2425 
2426   // notify ClassLoadingService of class unload
2427   ClassLoadingService::notify_class_unloaded(ik);
2428 
2429 #if INCLUDE_JFR
2430   assert(ik != NULL, "invariant");
2431   EventClassUnload event;
2432   event.set_unloadedClass(ik);
2433   event.set_definingClassLoader(ik->class_loader_data());
2434   event.commit();
2435 #endif
2436 }
2437 
2438 void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) {
2439   // Clean up C heap
2440   ik->release_C_heap_structures();


2445   // Can't release the constant pool here because the constant pool can be
2446   // deallocated separately from the InstanceKlass for default methods and
2447   // redefine classes.
2448 
2449   // Deallocate oop map cache
2450   if (_oop_map_cache != NULL) {
2451     delete _oop_map_cache;
2452     _oop_map_cache = NULL;
2453   }
2454 
2455   // Deallocate JNI identifiers for jfieldIDs
2456   JNIid::deallocate(jni_ids());
2457   set_jni_ids(NULL);
2458 
2459   jmethodID* jmeths = methods_jmethod_ids_acquire();
2460   if (jmeths != (jmethodID*)NULL) {
2461     release_set_methods_jmethod_ids(NULL);
2462     FreeHeap(jmeths);
2463   }
2464 
2465   // Release dependencies.
2466   // It is desirable to use DC::remove_all_dependents() here, but, unfortunately,
2467   // it is not safe (see JDK-8143408). The problem is that the klass dependency
2468   // context can contain live dependencies, since there's a race between nmethod &
2469   // klass unloading. If the klass is dead when nmethod unloading happens, relevant
2470   // dependencies aren't removed from the context associated with the class (see
2471   // nmethod::flush_dependencies). It ends up during klass unloading as seemingly
2472   // live dependencies pointing to unloaded nmethods and causes a crash in
2473   // DC::remove_all_dependents() when it touches unloaded nmethod.
2474   dependencies().wipe();
2475 
2476 #if INCLUDE_JVMTI
2477   // Deallocate breakpoint records
2478   if (breakpoints() != 0x0) {
2479     methods_do(clear_all_breakpoints);
2480     assert(breakpoints() == 0x0, "should have cleared breakpoints");
2481   }
2482 
2483   // deallocate the cached class file
2484   if (_cached_class_file != NULL && !MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {
2485     os::free(_cached_class_file);
2486     _cached_class_file = NULL;
2487   }
2488 #endif
2489 
2490   // Decrement symbol reference counts associated with the unloaded class.
2491   if (_name != NULL) _name->decrement_refcount();
2492   // unreference array name derived from this class name (arrays of an unloaded
2493   // class can't be referenced anymore).
2494   if (_array_name != NULL)  _array_name->decrement_refcount();




2400           bad = true;
2401           break;
2402         }
2403       }
2404     }
2405 
2406     if (bad) {
2407       set_in_error_state();
2408     }
2409   }
2410 
2411   return (old_state != is_in_error_state());
2412 }
2413 
2414 #if INCLUDE_JVMTI
2415 static void clear_all_breakpoints(Method* m) {
2416   m->clear_all_breakpoints();
2417 }
2418 #endif
2419 
2420 void InstanceKlass::unload_class(InstanceKlass* ik) {
2421   // Release dependencies.
2422   ik->dependencies().remove_all_dependents();
2423 
2424   // notify the debugger
2425   if (JvmtiExport::should_post_class_unload()) {
2426     JvmtiExport::post_class_unload(ik);
2427   }
2428 
2429   // notify ClassLoadingService of class unload
2430   ClassLoadingService::notify_class_unloaded(ik);
2431 
2432 #if INCLUDE_JFR
2433   assert(ik != NULL, "invariant");
2434   EventClassUnload event;
2435   event.set_unloadedClass(ik);
2436   event.set_definingClassLoader(ik->class_loader_data());
2437   event.commit();
2438 #endif
2439 }
2440 
2441 void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) {
2442   // Clean up C heap
2443   ik->release_C_heap_structures();


2448   // Can't release the constant pool here because the constant pool can be
2449   // deallocated separately from the InstanceKlass for default methods and
2450   // redefine classes.
2451 
2452   // Deallocate oop map cache
2453   if (_oop_map_cache != NULL) {
2454     delete _oop_map_cache;
2455     _oop_map_cache = NULL;
2456   }
2457 
2458   // Deallocate JNI identifiers for jfieldIDs
2459   JNIid::deallocate(jni_ids());
2460   set_jni_ids(NULL);
2461 
2462   jmethodID* jmeths = methods_jmethod_ids_acquire();
2463   if (jmeths != (jmethodID*)NULL) {
2464     release_set_methods_jmethod_ids(NULL);
2465     FreeHeap(jmeths);
2466   }
2467 
2468   assert(_dep_context == DependencyContext::EMPTY,
2469          "dependencies should already be cleaned");








2470 
2471 #if INCLUDE_JVMTI
2472   // Deallocate breakpoint records
2473   if (breakpoints() != 0x0) {
2474     methods_do(clear_all_breakpoints);
2475     assert(breakpoints() == 0x0, "should have cleared breakpoints");
2476   }
2477 
2478   // deallocate the cached class file
2479   if (_cached_class_file != NULL && !MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {
2480     os::free(_cached_class_file);
2481     _cached_class_file = NULL;
2482   }
2483 #endif
2484 
2485   // Decrement symbol reference counts associated with the unloaded class.
2486   if (_name != NULL) _name->decrement_refcount();
2487   // unreference array name derived from this class name (arrays of an unloaded
2488   // class can't be referenced anymore).
2489   if (_array_name != NULL)  _array_name->decrement_refcount();


< prev index next >