241 WeakHandle<vm_class_loader_data> _holder; // The oop that determines lifetime of this class loader
242 OopHandle _class_loader; // The instance of java/lang/ClassLoader associated with
243 // this ClassLoaderData
244
245 ClassLoaderMetaspace * volatile _metaspace; // Meta-space where meta-data defined by the
246 // classes in the class loader are allocated.
247 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup.
248 bool _unloading; // true if this class loader goes away
249 bool _is_unsafe_anonymous; // CLD is dedicated to one class and that class determines the CLDs lifecycle.
250 // For example, an unsafe anonymous class.
251
252 // Remembered sets support for the oops in the class loader data.
253 bool _modified_oops; // Card Table Equivalent (YC/CMS support)
254 bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
255
256 s2 _keep_alive; // if this CLD is kept alive.
257 // Used for unsafe anonymous classes and the boot class
258 // loader. _keep_alive does not need to be volatile or
259 // atomic since there is one unique CLD per unsafe anonymous class.
260
261 volatile int _claimed; // true if claimed, for example during GC traces.
262 // To avoid applying oop closure more than once.
263 // Has to be an int because we cas it.
264 ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which
265 // have the same life cycle of the corresponding ClassLoader.
266
267 NOT_PRODUCT(volatile int _dependency_count;) // number of class loader dependencies
268
269 Klass* volatile _klasses; // The classes defined by the class loader.
270 PackageEntryTable* volatile _packages; // The packages defined by the class loader.
271 ModuleEntryTable* volatile _modules; // The modules defined by the class loader.
272 ModuleEntry* _unnamed_module; // This class loader's unnamed module.
273 Dictionary* _dictionary; // The loaded InstanceKlasses, including initiated by this class loader
274
275 // These method IDs are created for the class loader and set to NULL when the
276 // class loader is unloaded. They are rarely freed, only for redefine classes
277 // and if they lose a data race in InstanceKlass.
278 JNIMethodBlock* _jmethod_ids;
279
280 // Metadata to be deallocated when it's safe at class unloading, when
281 // this class loader isn't unloaded itself.
282 GrowableArray<Metadata*>* _deallocate_list;
|
241 WeakHandle<vm_class_loader_data> _holder; // The oop that determines lifetime of this class loader
242 OopHandle _class_loader; // The instance of java/lang/ClassLoader associated with
243 // this ClassLoaderData
244
245 ClassLoaderMetaspace * volatile _metaspace; // Meta-space where meta-data defined by the
246 // classes in the class loader are allocated.
247 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup.
248 bool _unloading; // true if this class loader goes away
249 bool _is_unsafe_anonymous; // CLD is dedicated to one class and that class determines the CLDs lifecycle.
250 // For example, an unsafe anonymous class.
251
252 // Remembered sets support for the oops in the class loader data.
253 bool _modified_oops; // Card Table Equivalent (YC/CMS support)
254 bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
255
256 s2 _keep_alive; // if this CLD is kept alive.
257 // Used for unsafe anonymous classes and the boot class
258 // loader. _keep_alive does not need to be volatile or
259 // atomic since there is one unique CLD per unsafe anonymous class.
260
261 volatile int _claim_value; // non-zero if claimed, for example during GC traces.
262 // To avoid applying oop closure more than once.
263 ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which
264 // have the same life cycle of the corresponding ClassLoader.
265
266 NOT_PRODUCT(volatile int _dependency_count;) // number of class loader dependencies
267
268 Klass* volatile _klasses; // The classes defined by the class loader.
269 PackageEntryTable* volatile _packages; // The packages defined by the class loader.
270 ModuleEntryTable* volatile _modules; // The modules defined by the class loader.
271 ModuleEntry* _unnamed_module; // This class loader's unnamed module.
272 Dictionary* _dictionary; // The loaded InstanceKlasses, including initiated by this class loader
273
274 // These method IDs are created for the class loader and set to NULL when the
275 // class loader is unloaded. They are rarely freed, only for redefine classes
276 // and if they lose a data race in InstanceKlass.
277 JNIMethodBlock* _jmethod_ids;
278
279 // Metadata to be deallocated when it's safe at class unloading, when
280 // this class loader isn't unloaded itself.
281 GrowableArray<Metadata*>* _deallocate_list;
|
313 bool keep_alive() const { return _keep_alive > 0; }
314
315 oop holder_phantom() const;
316 void classes_do(void f(Klass*));
317 void loaded_classes_do(KlassClosure* klass_closure);
318 void classes_do(void f(InstanceKlass*));
319 void methods_do(void f(Method*));
320 void modules_do(void f(ModuleEntry*));
321 void packages_do(void f(PackageEntry*));
322
323 // Deallocate free list during class unloading.
324 void free_deallocate_list(); // for the classes that are not unloaded
325 void free_deallocate_list_C_heap_structures(); // for the classes that are unloaded
326
327 // Allocate out of this class loader data
328 MetaWord* allocate(size_t size);
329
330 Dictionary* create_dictionary();
331
332 void initialize_name(Handle class_loader);
333 public:
334 // GC interface.
335 void clear_claimed() { _claimed = 0; }
336 bool claimed() const { return _claimed == 1; }
337 bool claim();
338
339 // Computes if the CLD is alive or not. This is safe to call in concurrent
340 // contexts.
341 bool is_alive() const;
342
343 // Accessors
344 ClassLoaderMetaspace* metaspace_or_null() const { return _metaspace; }
345
346 static ClassLoaderData* the_null_class_loader_data() {
347 return _the_null_class_loader_data;
348 }
349
350 Mutex* metaspace_lock() const { return _metaspace_lock; }
351
352 bool is_unsafe_anonymous() const { return _is_unsafe_anonymous; }
353
354 static void init_null_class_loader_data();
355
356 bool is_the_null_class_loader_data() const {
|
312 bool keep_alive() const { return _keep_alive > 0; }
313
314 oop holder_phantom() const;
315 void classes_do(void f(Klass*));
316 void loaded_classes_do(KlassClosure* klass_closure);
317 void classes_do(void f(InstanceKlass*));
318 void methods_do(void f(Method*));
319 void modules_do(void f(ModuleEntry*));
320 void packages_do(void f(PackageEntry*));
321
322 // Deallocate free list during class unloading.
323 void free_deallocate_list(); // for the classes that are not unloaded
324 void free_deallocate_list_C_heap_structures(); // for the classes that are unloaded
325
326 // Allocate out of this class loader data
327 MetaWord* allocate(size_t size);
328
329 Dictionary* create_dictionary();
330
331 void initialize_name(Handle class_loader);
332
333 public:
334 // GC interface.
335
336 // The "claim_value" is typically used to check if oops_do needs to be applied on
337 // the CLD or not. Most GCs only perform strong marking during the marking phase,
338 // in which case the claim value is
339 enum {
340 _claim_value_none = 0,
341 _claim_value_strong = 1,
342 _claim_value_finalizable = 2
343 };
344 void clear_claimed() { _claim_value = 0; }
345 bool claimed() const { return _claim_value != 0; }
346 bool claim(int claim_value);
347 int claim_value() const { return _claim_value; }
348 void set_claim_value(int claim_value) { _claim_value = claim_value; }
349
350 // Computes if the CLD is alive or not. This is safe to call in concurrent
351 // contexts.
352 bool is_alive() const;
353
354 // Accessors
355 ClassLoaderMetaspace* metaspace_or_null() const { return _metaspace; }
356
357 static ClassLoaderData* the_null_class_loader_data() {
358 return _the_null_class_loader_data;
359 }
360
361 Mutex* metaspace_lock() const { return _metaspace_lock; }
362
363 bool is_unsafe_anonymous() const { return _is_unsafe_anonymous; }
364
365 static void init_null_class_loader_data();
366
367 bool is_the_null_class_loader_data() const {
|
377 ClassLoaderMetaspace* metaspace_non_null();
378
379 inline oop class_loader() const;
380
381 // Returns true if this class loader data is for a loader going away.
382 // Note that this is only safe after the GC has computed if the CLD is
383 // unloaded or not. In concurrent contexts where there are no such
384 // guarantees, is_alive() should be used instead.
385 bool is_unloading() const {
386 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
387 return _unloading;
388 }
389
390 // Used to refcount an unsafe anonymous class's CLD in order to
391 // indicate their aliveness.
392 void inc_keep_alive();
393 void dec_keep_alive();
394
395 void initialize_holder(Handle holder);
396
397 void oops_do(OopClosure* f, bool must_claim, bool clear_modified_oops = false);
398
399 void classes_do(KlassClosure* klass_closure);
400 Klass* klasses() { return _klasses; }
401
402 JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; }
403 void set_jmethod_ids(JNIMethodBlock* new_block) { _jmethod_ids = new_block; }
404
405 void print() { print_on(tty); }
406 void print_on(outputStream* out) const PRODUCT_RETURN;
407 void print_value() { print_value_on(tty); }
408 void print_value_on(outputStream* out) const;
409 void verify();
410
411 OopHandle add_handle(Handle h);
412 void remove_handle(OopHandle h);
413 void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field
414 void add_class(Klass* k, bool publicize = true);
415 void remove_class(Klass* k);
416 bool contains_klass(Klass* k);
|
388 ClassLoaderMetaspace* metaspace_non_null();
389
390 inline oop class_loader() const;
391
392 // Returns true if this class loader data is for a loader going away.
393 // Note that this is only safe after the GC has computed if the CLD is
394 // unloaded or not. In concurrent contexts where there are no such
395 // guarantees, is_alive() should be used instead.
396 bool is_unloading() const {
397 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
398 return _unloading;
399 }
400
401 // Used to refcount an unsafe anonymous class's CLD in order to
402 // indicate their aliveness.
403 void inc_keep_alive();
404 void dec_keep_alive();
405
406 void initialize_holder(Handle holder);
407
408 void oops_do(OopClosure* f, int claim_value, bool clear_modified_oops = false);
409
410 void classes_do(KlassClosure* klass_closure);
411 Klass* klasses() { return _klasses; }
412
413 JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; }
414 void set_jmethod_ids(JNIMethodBlock* new_block) { _jmethod_ids = new_block; }
415
416 void print() { print_on(tty); }
417 void print_on(outputStream* out) const PRODUCT_RETURN;
418 void print_value() { print_value_on(tty); }
419 void print_value_on(outputStream* out) const;
420 void verify();
421
422 OopHandle add_handle(Handle h);
423 void remove_handle(OopHandle h);
424 void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field
425 void add_class(Klass* k, bool publicize = true);
426 void remove_class(Klass* k);
427 bool contains_klass(Klass* k);
|