< prev index next >

src/hotspot/share/classfile/classLoaderData.hpp

Print this page




 243   Klass* volatile _klasses;              // The classes defined by the class loader.
 244   PackageEntryTable* volatile _packages; // The packages defined by the class loader.
 245   ModuleEntryTable*  volatile _modules;  // The modules defined by the class loader.
 246   ModuleEntry* _unnamed_module;          // This class loader's unnamed module.
 247   Dictionary*  _dictionary;              // The loaded InstanceKlasses, including initiated by this class loader
 248 
 249   // These method IDs are created for the class loader and set to NULL when the
 250   // class loader is unloaded.  They are rarely freed, only for redefine classes
 251   // and if they lose a data race in InstanceKlass.
 252   JNIMethodBlock*                  _jmethod_ids;
 253 
 254   // Metadata to be deallocated when it's safe at class unloading, when
 255   // this class loader isn't unloaded itself.
 256   GrowableArray<Metadata*>*      _deallocate_list;
 257 
 258   // Support for walking class loader data objects
 259   ClassLoaderData* _next; /// Next loader_datas created
 260 
 261   // JFR support
 262   Klass*  _class_loader_klass;
 263   Symbol* _class_loader_name;
 264   JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
 265 
 266   void set_next(ClassLoaderData* next) { _next = next; }
 267   ClassLoaderData* next() const        { return _next; }
 268 
 269   ClassLoaderData(Handle h_class_loader, bool is_anonymous);
 270   ~ClassLoaderData();
 271 
 272   // The CLD are not placed in the Heap, so the Card Table or
 273   // the Mod Union Table can't be used to mark when CLD have modified oops.
 274   // The CT and MUT bits saves this information for the whole class loader data.
 275   void clear_modified_oops()             { _modified_oops = false; }
 276  public:
 277   void record_modified_oops()            { _modified_oops = true; }
 278   bool has_modified_oops()               { return _modified_oops; }
 279 
 280   void accumulate_modified_oops()        { if (has_modified_oops()) _accumulated_modified_oops = true; }
 281   void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
 282   bool has_accumulated_modified_oops()   { return _accumulated_modified_oops; }
 283  private:


 345 
 346   // The Metaspace is created lazily so may be NULL.  This
 347   // method will allocate a Metaspace if needed.
 348   ClassLoaderMetaspace* metaspace_non_null();
 349 
 350   inline oop class_loader() const;
 351 
 352   // Returns true if this class loader data is for a loader going away.
 353   bool is_unloading() const     {
 354     assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
 355     return _unloading;
 356   }
 357 
 358   // Used to refcount an anonymous class's CLD in order to
 359   // indicate their aliveness.
 360   void inc_keep_alive();
 361   void dec_keep_alive();
 362 
 363   void initialize_holder(Handle holder);
 364 
 365   inline unsigned int identity_hash() const { return (unsigned int)(((intptr_t)this) >> 3); }
 366 
 367   void oops_do(OopClosure* f, bool must_claim, bool clear_modified_oops = false);
 368 
 369   void classes_do(KlassClosure* klass_closure);
 370   Klass* klasses() { return _klasses; }
 371 
 372   JNIMethodBlock* jmethod_ids() const              { return _jmethod_ids; }
 373   void set_jmethod_ids(JNIMethodBlock* new_block)  { _jmethod_ids = new_block; }
 374 
 375   void print()                                     { print_on(tty); }
 376   void print_on(outputStream* out) const PRODUCT_RETURN;
 377   void print_value()                               { print_value_on(tty); }
 378   void print_value_on(outputStream* out) const;
 379   void verify();
 380   const char* loader_name() const;
 381 
 382   OopHandle add_handle(Handle h);
 383   void remove_handle(OopHandle h);
 384   void init_handle_locked(OopHandle& pd, Handle h);  // used for concurrent access to ModuleEntry::_pd field
 385   void add_class(Klass* k, bool publicize = true);
 386   void remove_class(Klass* k);
 387   bool contains_klass(Klass* k);
 388   void record_dependency(const Klass* to);
 389   PackageEntryTable* packages() { return _packages; }
 390   ModuleEntry* unnamed_module() { return _unnamed_module; }
 391   ModuleEntryTable* modules();
 392   bool modules_defined() { return (_modules != NULL); }
 393 
 394   // Loaded class dictionary
 395   Dictionary* dictionary() const { return _dictionary; }
 396 
 397   void add_to_deallocate_list(Metadata* m);
 398 
 399   static ClassLoaderData* class_loader_data(oop loader);
 400   static ClassLoaderData* class_loader_data_or_null(oop loader);
 401   static ClassLoaderData* anonymous_class_loader_data(Handle loader);
 402 
 403   // Returns Klass* of associated class loader, or NULL if associated loader is <bootstrap>.
 404   // Also works if unloading.
 405   Klass* class_loader_klass() const { return _class_loader_klass; }
 406 
 407   // Returns Name of associated class loader.
 408   // Returns NULL if associated class loader is <bootstrap> or if no name has been set for
 409   //   this loader.
 410   // Also works if unloading.
 411   Symbol* class_loader_name() const { return _class_loader_name; }
 412 
 413   JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
 414 };
 415 
 416 // An iterator that distributes Klasses to parallel worker threads.
 417 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
 418  Klass* volatile _next_klass;
 419  public:
 420   ClassLoaderDataGraphKlassIteratorAtomic();
 421   Klass* next_klass();
 422  private:
 423   static Klass* next_klass_in_cldg(Klass* klass);
 424 };
 425 
 426 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
 427   ClassLoaderData* _data;
 428  public:
 429   ClassLoaderDataGraphMetaspaceIterator();
 430   ~ClassLoaderDataGraphMetaspaceIterator();
 431   bool repeat() { return _data != NULL; }


 243   Klass* volatile _klasses;              // The classes defined by the class loader.
 244   PackageEntryTable* volatile _packages; // The packages defined by the class loader.
 245   ModuleEntryTable*  volatile _modules;  // The modules defined by the class loader.
 246   ModuleEntry* _unnamed_module;          // This class loader's unnamed module.
 247   Dictionary*  _dictionary;              // The loaded InstanceKlasses, including initiated by this class loader
 248 
 249   // These method IDs are created for the class loader and set to NULL when the
 250   // class loader is unloaded.  They are rarely freed, only for redefine classes
 251   // and if they lose a data race in InstanceKlass.
 252   JNIMethodBlock*                  _jmethod_ids;
 253 
 254   // Metadata to be deallocated when it's safe at class unloading, when
 255   // this class loader isn't unloaded itself.
 256   GrowableArray<Metadata*>*      _deallocate_list;
 257 
 258   // Support for walking class loader data objects
 259   ClassLoaderData* _next; /// Next loader_datas created
 260 
 261   // JFR support
 262   Klass*  _class_loader_klass;
 263   Symbol* _class_loader_name_id;
 264   JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
 265 
 266   void set_next(ClassLoaderData* next) { _next = next; }
 267   ClassLoaderData* next() const        { return _next; }
 268 
 269   ClassLoaderData(Handle h_class_loader, bool is_anonymous);
 270   ~ClassLoaderData();
 271 
 272   // The CLD are not placed in the Heap, so the Card Table or
 273   // the Mod Union Table can't be used to mark when CLD have modified oops.
 274   // The CT and MUT bits saves this information for the whole class loader data.
 275   void clear_modified_oops()             { _modified_oops = false; }
 276  public:
 277   void record_modified_oops()            { _modified_oops = true; }
 278   bool has_modified_oops()               { return _modified_oops; }
 279 
 280   void accumulate_modified_oops()        { if (has_modified_oops()) _accumulated_modified_oops = true; }
 281   void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
 282   bool has_accumulated_modified_oops()   { return _accumulated_modified_oops; }
 283  private:


 345 
 346   // The Metaspace is created lazily so may be NULL.  This
 347   // method will allocate a Metaspace if needed.
 348   ClassLoaderMetaspace* metaspace_non_null();
 349 
 350   inline oop class_loader() const;
 351 
 352   // Returns true if this class loader data is for a loader going away.
 353   bool is_unloading() const     {
 354     assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
 355     return _unloading;
 356   }
 357 
 358   // Used to refcount an anonymous class's CLD in order to
 359   // indicate their aliveness.
 360   void inc_keep_alive();
 361   void dec_keep_alive();
 362 
 363   void initialize_holder(Handle holder);
 364 


 365   void oops_do(OopClosure* f, bool must_claim, bool clear_modified_oops = false);
 366 
 367   void classes_do(KlassClosure* klass_closure);
 368   Klass* klasses() { return _klasses; }
 369 
 370   JNIMethodBlock* jmethod_ids() const              { return _jmethod_ids; }
 371   void set_jmethod_ids(JNIMethodBlock* new_block)  { _jmethod_ids = new_block; }
 372 
 373   void print()                                     { print_on(tty); }
 374   void print_on(outputStream* out) const PRODUCT_RETURN;
 375   void print_value()                               { print_value_on(tty); }
 376   void print_value_on(outputStream* out) const;
 377   void verify();

 378 
 379   OopHandle add_handle(Handle h);
 380   void remove_handle(OopHandle h);
 381   void init_handle_locked(OopHandle& pd, Handle h);  // used for concurrent access to ModuleEntry::_pd field
 382   void add_class(Klass* k, bool publicize = true);
 383   void remove_class(Klass* k);
 384   bool contains_klass(Klass* k);
 385   void record_dependency(const Klass* to);
 386   PackageEntryTable* packages() { return _packages; }
 387   ModuleEntry* unnamed_module() { return _unnamed_module; }
 388   ModuleEntryTable* modules();
 389   bool modules_defined() { return (_modules != NULL); }
 390 
 391   // Loaded class dictionary
 392   Dictionary* dictionary() const { return _dictionary; }
 393 
 394   void add_to_deallocate_list(Metadata* m);
 395 
 396   static ClassLoaderData* class_loader_data(oop loader);
 397   static ClassLoaderData* class_loader_data_or_null(oop loader);
 398   static ClassLoaderData* anonymous_class_loader_data(Handle loader);
 399 
 400   // Returns Klass* of associated class loader, or NULL if associated loader is <bootstrap>.
 401   // Also works if unloading.
 402   Klass* class_loader_klass() const { return _class_loader_klass; }
 403 
 404   // Both methods return the class loader's nameAndId in char* or Symbol* format.
 405   // Both methods work during unloading.
 406   const char* loader_name() const;
 407   Symbol* class_loader_name() const { return _class_loader_name_id; }

 408 
 409   JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
 410 };
 411 
 412 // An iterator that distributes Klasses to parallel worker threads.
 413 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
 414  Klass* volatile _next_klass;
 415  public:
 416   ClassLoaderDataGraphKlassIteratorAtomic();
 417   Klass* next_klass();
 418  private:
 419   static Klass* next_klass_in_cldg(Klass* klass);
 420 };
 421 
 422 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
 423   ClassLoaderData* _data;
 424  public:
 425   ClassLoaderDataGraphMetaspaceIterator();
 426   ~ClassLoaderDataGraphMetaspaceIterator();
 427   bool repeat() { return _data != NULL; }
< prev index next >