66 friend class ClassLoaderData;
67 friend class ClassLoaderDataGraphMetaspaceIterator;
68 friend class ClassLoaderDataGraphKlassIteratorAtomic;
69 friend class ClassLoaderDataGraphKlassIteratorStatic;
70 friend class VMStructs;
71 private:
72 // All CLDs (except the null CLD) can be reached by walking _head->_next->...
73 static ClassLoaderData* _head;
74 static ClassLoaderData* _unloading;
75 // CMS support.
76 static ClassLoaderData* _saved_head;
77 static ClassLoaderData* _saved_unloading;
78 static bool _should_purge;
79 // OOM has been seen in metaspace allocation. Used to prevent some
80 // allocations until class unloading
81 static bool _metaspace_oom;
82
83 static volatile size_t _num_instance_classes;
84 static volatile size_t _num_array_classes;
85
86 static ClassLoaderData* add(Handle class_loader, bool anonymous, TRAPS);
87 static void post_class_unload_events();
88 public:
89 static ClassLoaderData* find_or_create(Handle class_loader, TRAPS);
90 static void purge();
91 static void clear_claimed_marks();
92 // oops do
93 static void oops_do(OopClosure* f, bool must_claim);
94 static void keep_alive_oops_do(OopClosure* blk, bool must_claim);
95 static void always_strong_oops_do(OopClosure* blk, bool must_claim);
96 // cld do
97 static void cld_do(CLDClosure* cl);
98 static void cld_unloading_do(CLDClosure* cl);
99 static void roots_cld_do(CLDClosure* strong, CLDClosure* weak);
100 static void keep_alive_cld_do(CLDClosure* cl);
101 static void always_strong_cld_do(CLDClosure* cl);
102 // klass do
103 // Walking classes through the ClassLoaderDataGraph include array classes. It also includes
104 // classes that are allocated but not loaded, classes that have errors, and scratch classes
105 // for redefinition. These classes are removed during the next class unloading.
106 // Walking the ClassLoaderDataGraph also includes anonymous classes.
107 static void classes_do(KlassClosure* klass_closure);
108 static void classes_do(void f(Klass* const));
109 static void methods_do(void f(Method*));
134
135 // CMS support.
136 static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); }
137 static GrowableArray<ClassLoaderData*>* new_clds();
138
139 static void set_should_purge(bool b) { _should_purge = b; }
140 static void purge_if_needed() {
141 // Only purge the CLDG for CMS if concurrent sweep is complete.
142 if (_should_purge) {
143 purge();
144 // reset for next time.
145 set_should_purge(false);
146 }
147 }
148
149 static int resize_if_needed();
150
151 static bool has_metaspace_oom() { return _metaspace_oom; }
152 static void set_metaspace_oom(bool value) { _metaspace_oom = value; }
153
154 static void dump_on(outputStream * const out) PRODUCT_RETURN;
155 static void dump() { dump_on(tty); }
156 static void verify();
157 static void print_creation(outputStream* out, Handle loader, ClassLoaderData* cld, TRAPS);
158
159 static bool unload_list_contains(const void* x);
160
161 // instance and array class counters
162 static inline size_t num_instance_classes();
163 static inline size_t num_array_classes();
164 static inline void inc_instance_classes(size_t count);
165 static inline void dec_instance_classes(size_t count);
166 static inline void inc_array_classes(size_t count);
167 static inline void dec_array_classes(size_t count);
168
169 #ifndef PRODUCT
170 static bool contains_loader_data(ClassLoaderData* loader_data);
171 #endif
172
173 #if INCLUDE_TRACE
174 private:
175 static Ticks _class_unload_time;
176 static void class_unload_event(Klass* const k);
177 #endif
178 };
179
180 // ClassLoaderData class
181
182 class ClassLoaderData : public CHeapObj<mtClass> {
183 friend class VMStructs;
184 private:
185 class Dependencies VALUE_OBJ_CLASS_SPEC {
186 objArrayOop _list_head;
187 void locked_add(objArrayHandle last,
188 objArrayHandle new_dependency,
189 Thread* THREAD);
190 public:
191 Dependencies() : _list_head(NULL) {}
192 Dependencies(TRAPS) : _list_head(NULL) {
193 init(CHECK);
194 }
195 void add(Handle dependency, TRAPS);
196 void init(TRAPS);
197 void oops_do(OopClosure* f);
198 };
199
200 class ChunkedHandleList VALUE_OBJ_CLASS_SPEC {
201 struct Chunk : public CHeapObj<mtClass> {
202 static const size_t CAPACITY = 32;
203
204 oop _data[CAPACITY];
205 volatile juint _size;
206 Chunk* _next;
207
208 Chunk(Chunk* c) : _next(c), _size(0) { }
209 };
210
211 Chunk* volatile _head;
212
213 void oops_do_chunk(OopClosure* f, Chunk* c, const juint size);
214
215 public:
216 ChunkedHandleList() : _head(NULL) {}
217 ~ChunkedHandleList();
218
219 // Only one thread at a time can add, guarded by ClassLoaderData::metaspace_lock().
220 // However, multiple threads can execute oops_do concurrently with add.
221 oop* add(oop o);
222 #ifdef ASSERT
223 bool contains(oop* p);
224 #endif
225 void oops_do(OopClosure* f);
226 };
227
228 friend class ClassLoaderDataGraph;
229 friend class ClassLoaderDataGraphKlassIteratorAtomic;
230 friend class ClassLoaderDataGraphKlassIteratorStatic;
231 friend class ClassLoaderDataGraphMetaspaceIterator;
232 friend class InstanceKlass;
233 friend class MetaDataFactory;
234 friend class Method;
235
236 static ClassLoaderData * _the_null_class_loader_data;
237
238 oop _class_loader; // oop used to uniquely identify a class loader
239 // class loader or a canonical class path
240 Dependencies _dependencies; // holds dependencies from this class loader
241 // data to others.
242
243 Metaspace * volatile _metaspace; // Meta-space where meta-data defined by the
244 // classes in the class loader are allocated.
245 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup.
246 bool _unloading; // true if this class loader goes away
247 bool _is_anonymous; // if this CLD is for an anonymous class
248
249 // Remembered sets support for the oops in the class loader data.
250 bool _modified_oops; // Card Table Equivalent (YC/CMS support)
251 bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
252
253 s2 _keep_alive; // if this CLD is kept alive without a keep_alive_object().
254 // Used for anonymous classes and the boot class
255 // loader. _keep_alive does not need to be volatile or
256 // atomic since there is one unique CLD per anonymous class.
257
258 volatile int _claimed; // true if claimed, for example during GC traces.
259 // To avoid applying oop closure more than once.
260 // Has to be an int because we cas it.
261 ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which
262 // have the same life cycle of the corresponding ClassLoader.
263
264 Klass* volatile _klasses; // The classes defined by the class loader.
265 PackageEntryTable* volatile _packages; // The packages defined by the class loader.
266 ModuleEntryTable* volatile _modules; // The modules defined by the class loader.
267 ModuleEntry* _unnamed_module; // This class loader's unnamed module.
268 Dictionary* _dictionary; // The loaded InstanceKlasses, including initiated by this class loader
269
270 // These method IDs are created for the class loader and set to NULL when the
271 // class loader is unloaded. They are rarely freed, only for redefine classes
272 // and if they lose a data race in InstanceKlass.
273 JNIMethodBlock* _jmethod_ids;
274
275 // Metadata to be deallocated when it's safe at class unloading, when
276 // this class loader isn't unloaded itself.
277 GrowableArray<Metadata*>* _deallocate_list;
278
279 // Support for walking class loader data objects
280 ClassLoaderData* _next; /// Next loader_datas created
281
282 // ReadOnly and ReadWrite metaspaces (static because only on the null
283 // class loader for now).
284 static Metaspace* _ro_metaspace;
285 static Metaspace* _rw_metaspace;
286
287 TRACE_DEFINE_TRACE_ID_FIELD;
288
289 void set_next(ClassLoaderData* next) { _next = next; }
290 ClassLoaderData* next() const { return _next; }
291
292 ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies);
293 ~ClassLoaderData();
294
295 // The CLD are not placed in the Heap, so the Card Table or
296 // the Mod Union Table can't be used to mark when CLD have modified oops.
297 // The CT and MUT bits saves this information for the whole class loader data.
298 void clear_modified_oops() { _modified_oops = false; }
299 public:
300 void record_modified_oops() { _modified_oops = true; }
301 bool has_modified_oops() { return _modified_oops; }
302
303 void accumulate_modified_oops() { if (has_modified_oops()) _accumulated_modified_oops = true; }
304 void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
305 bool has_accumulated_modified_oops() { return _accumulated_modified_oops; }
306 private:
307
308 void unload();
309 bool keep_alive() const { return _keep_alive > 0; }
310 void classes_do(void f(Klass*));
311 void loaded_classes_do(KlassClosure* klass_closure);
312 void classes_do(void f(InstanceKlass*));
324 Dictionary* create_dictionary();
325 public:
326 // GC interface.
327 void clear_claimed() { _claimed = 0; }
328 bool claimed() const { return _claimed == 1; }
329 bool claim();
330
331 bool is_alive(BoolObjectClosure* is_alive_closure) const;
332
333 // Accessors
334 Metaspace* metaspace_or_null() const { return _metaspace; }
335
336 static ClassLoaderData* the_null_class_loader_data() {
337 return _the_null_class_loader_data;
338 }
339
340 Mutex* metaspace_lock() const { return _metaspace_lock; }
341
342 bool is_anonymous() const { return _is_anonymous; }
343
344 static void init_null_class_loader_data() {
345 assert(_the_null_class_loader_data == NULL, "cannot initialize twice");
346 assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice");
347
348 // We explicitly initialize the Dependencies object at a later phase in the initialization
349 _the_null_class_loader_data = new ClassLoaderData(Handle(), false, Dependencies());
350 ClassLoaderDataGraph::_head = _the_null_class_loader_data;
351 assert(_the_null_class_loader_data->is_the_null_class_loader_data(), "Must be");
352 }
353
354 bool is_the_null_class_loader_data() const {
355 return this == _the_null_class_loader_data;
356 }
357 bool is_system_class_loader_data() const;
358 bool is_platform_class_loader_data() const;
359
360 // Returns true if this class loader data is for the boot class loader.
361 // (Note that the class loader data may be anonymous.)
362 bool is_boot_class_loader_data() const {
363 return class_loader() == NULL;
364 }
365
366 bool is_builtin_class_loader_data() const;
367 bool is_permanent_class_loader_data() const;
368
369 // The Metaspace is created lazily so may be NULL. This
370 // method will allocate a Metaspace if needed.
371 Metaspace* metaspace_non_null();
372
380 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
381 return _unloading;
382 }
383
384 // Used to refcount an anonymous class's CLD in order to
385 // indicate their aliveness without a keep_alive_object().
386 void inc_keep_alive();
387 void dec_keep_alive();
388
389 inline unsigned int identity_hash() const { return (unsigned int)(((intptr_t)this) >> 3); }
390
391 void oops_do(OopClosure* f, bool must_claim, bool clear_modified_oops = false);
392
393 void classes_do(KlassClosure* klass_closure);
394 Klass* klasses() { return _klasses; }
395
396 JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; }
397 void set_jmethod_ids(JNIMethodBlock* new_block) { _jmethod_ids = new_block; }
398
399 void print() { print_on(tty); }
400 void print_on(outputStream* out) const;
401 void print_value() { print_value_on(tty); }
402 void print_value_on(outputStream* out) const;
403 void dump(outputStream * const out) PRODUCT_RETURN;
404 void verify();
405 const char* loader_name();
406
407 OopHandle add_handle(Handle h);
408 void remove_handle(OopHandle h);
409 void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field
410 void add_class(Klass* k, bool publicize = true);
411 void remove_class(Klass* k);
412 bool contains_klass(Klass* k);
413 void record_dependency(const Klass* to, TRAPS);
414 void init_dependencies(TRAPS);
415 PackageEntryTable* packages() { return _packages; }
416 ModuleEntry* unnamed_module() { return _unnamed_module; }
417 ModuleEntryTable* modules();
418 bool modules_defined() { return (_modules != NULL); }
419
420 // Loaded class dictionary
421 Dictionary* dictionary() const { return _dictionary; }
422
423 void add_to_deallocate_list(Metadata* m);
424
425 static ClassLoaderData* class_loader_data(oop loader);
426 static ClassLoaderData* class_loader_data_or_null(oop loader);
427 static ClassLoaderData* anonymous_class_loader_data(oop loader, TRAPS);
428 static void print_loader(ClassLoaderData *loader_data, outputStream *out);
429
430 TRACE_DEFINE_TRACE_ID_METHODS;
431 };
432
433 // An iterator that distributes Klasses to parallel worker threads.
434 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
435 Klass* volatile _next_klass;
436 public:
437 ClassLoaderDataGraphKlassIteratorAtomic();
438 Klass* next_klass();
439 private:
440 static Klass* next_klass_in_cldg(Klass* klass);
441 };
442
443 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
444 ClassLoaderData* _data;
445 public:
446 ClassLoaderDataGraphMetaspaceIterator();
447 ~ClassLoaderDataGraphMetaspaceIterator();
448 bool repeat() { return _data != NULL; }
|
66 friend class ClassLoaderData;
67 friend class ClassLoaderDataGraphMetaspaceIterator;
68 friend class ClassLoaderDataGraphKlassIteratorAtomic;
69 friend class ClassLoaderDataGraphKlassIteratorStatic;
70 friend class VMStructs;
71 private:
72 // All CLDs (except the null CLD) can be reached by walking _head->_next->...
73 static ClassLoaderData* _head;
74 static ClassLoaderData* _unloading;
75 // CMS support.
76 static ClassLoaderData* _saved_head;
77 static ClassLoaderData* _saved_unloading;
78 static bool _should_purge;
79 // OOM has been seen in metaspace allocation. Used to prevent some
80 // allocations until class unloading
81 static bool _metaspace_oom;
82
83 static volatile size_t _num_instance_classes;
84 static volatile size_t _num_array_classes;
85
86 static ClassLoaderData* add(Handle class_loader, bool anonymous);
87 static void post_class_unload_events();
88 public:
89 static ClassLoaderData* find_or_create(Handle class_loader);
90 static void purge();
91 static void clear_claimed_marks();
92 // oops do
93 static void oops_do(OopClosure* f, bool must_claim);
94 static void keep_alive_oops_do(OopClosure* blk, bool must_claim);
95 static void always_strong_oops_do(OopClosure* blk, bool must_claim);
96 // cld do
97 static void cld_do(CLDClosure* cl);
98 static void cld_unloading_do(CLDClosure* cl);
99 static void roots_cld_do(CLDClosure* strong, CLDClosure* weak);
100 static void keep_alive_cld_do(CLDClosure* cl);
101 static void always_strong_cld_do(CLDClosure* cl);
102 // klass do
103 // Walking classes through the ClassLoaderDataGraph include array classes. It also includes
104 // classes that are allocated but not loaded, classes that have errors, and scratch classes
105 // for redefinition. These classes are removed during the next class unloading.
106 // Walking the ClassLoaderDataGraph also includes anonymous classes.
107 static void classes_do(KlassClosure* klass_closure);
108 static void classes_do(void f(Klass* const));
109 static void methods_do(void f(Method*));
134
135 // CMS support.
136 static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); }
137 static GrowableArray<ClassLoaderData*>* new_clds();
138
139 static void set_should_purge(bool b) { _should_purge = b; }
140 static void purge_if_needed() {
141 // Only purge the CLDG for CMS if concurrent sweep is complete.
142 if (_should_purge) {
143 purge();
144 // reset for next time.
145 set_should_purge(false);
146 }
147 }
148
149 static int resize_if_needed();
150
151 static bool has_metaspace_oom() { return _metaspace_oom; }
152 static void set_metaspace_oom(bool value) { _metaspace_oom = value; }
153
154 static void print_on(outputStream * const out) PRODUCT_RETURN;
155 static void print() { print_on(tty); }
156 static void verify();
157
158 static bool unload_list_contains(const void* x);
159
160 // instance and array class counters
161 static inline size_t num_instance_classes();
162 static inline size_t num_array_classes();
163 static inline void inc_instance_classes(size_t count);
164 static inline void dec_instance_classes(size_t count);
165 static inline void inc_array_classes(size_t count);
166 static inline void dec_array_classes(size_t count);
167
168 #ifndef PRODUCT
169 static bool contains_loader_data(ClassLoaderData* loader_data);
170 #endif
171
172 #if INCLUDE_TRACE
173 private:
174 static Ticks _class_unload_time;
175 static void class_unload_event(Klass* const k);
176 #endif
177 };
178
179 // ClassLoaderData class
180
181 class ClassLoaderData : public CHeapObj<mtClass> {
182 friend class VMStructs;
183
184 private:
185 class ChunkedHandleList VALUE_OBJ_CLASS_SPEC {
186 struct Chunk : public CHeapObj<mtClass> {
187 static const size_t CAPACITY = 32;
188
189 oop _data[CAPACITY];
190 volatile juint _size;
191 Chunk* _next;
192
193 Chunk(Chunk* c) : _next(c), _size(0) { }
194 };
195
196 Chunk* volatile _head;
197
198 void oops_do_chunk(OopClosure* f, Chunk* c, const juint size);
199
200 public:
201 ChunkedHandleList() : _head(NULL) {}
202 ~ChunkedHandleList();
203
204 // Only one thread at a time can add, guarded by ClassLoaderData::metaspace_lock().
205 // However, multiple threads can execute oops_do concurrently with add.
206 oop* add(oop o);
207 bool contains(oop p);
208 void oops_do(OopClosure* f);
209
210 int count() const;
211 };
212
213 friend class ClassLoaderDataGraph;
214 friend class ClassLoaderDataGraphKlassIteratorAtomic;
215 friend class ClassLoaderDataGraphKlassIteratorStatic;
216 friend class ClassLoaderDataGraphMetaspaceIterator;
217 friend class InstanceKlass;
218 friend class MetaDataFactory;
219 friend class Method;
220
221 static ClassLoaderData * _the_null_class_loader_data;
222
223 oop _class_loader; // oop used to uniquely identify a class loader
224 // class loader or a canonical class path
225
226 Metaspace * volatile _metaspace; // Meta-space where meta-data defined by the
227 // classes in the class loader are allocated.
228 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup.
229 bool _unloading; // true if this class loader goes away
230 bool _is_anonymous; // if this CLD is for an anonymous class
231
232 // Remembered sets support for the oops in the class loader data.
233 bool _modified_oops; // Card Table Equivalent (YC/CMS support)
234 bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
235
236 s2 _keep_alive; // if this CLD is kept alive without a keep_alive_object().
237 // Used for anonymous classes and the boot class
238 // loader. _keep_alive does not need to be volatile or
239 // atomic since there is one unique CLD per anonymous class.
240
241 volatile int _claimed; // true if claimed, for example during GC traces.
242 // To avoid applying oop closure more than once.
243 // Has to be an int because we cas it.
244 ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which
245 // have the same life cycle of the corresponding ClassLoader.
246
247 NOT_PRODUCT(volatile int _dependency_count;) // number of class loader dependencies
248
249 Klass* volatile _klasses; // The classes defined by the class loader.
250 PackageEntryTable* volatile _packages; // The packages defined by the class loader.
251 ModuleEntryTable* volatile _modules; // The modules defined by the class loader.
252 ModuleEntry* _unnamed_module; // This class loader's unnamed module.
253 Dictionary* _dictionary; // The loaded InstanceKlasses, including initiated by this class loader
254
255 // These method IDs are created for the class loader and set to NULL when the
256 // class loader is unloaded. They are rarely freed, only for redefine classes
257 // and if they lose a data race in InstanceKlass.
258 JNIMethodBlock* _jmethod_ids;
259
260 // Metadata to be deallocated when it's safe at class unloading, when
261 // this class loader isn't unloaded itself.
262 GrowableArray<Metadata*>* _deallocate_list;
263
264 // Support for walking class loader data objects
265 ClassLoaderData* _next; /// Next loader_datas created
266
267 // ReadOnly and ReadWrite metaspaces (static because only on the null
268 // class loader for now).
269 static Metaspace* _ro_metaspace;
270 static Metaspace* _rw_metaspace;
271
272 TRACE_DEFINE_TRACE_ID_FIELD;
273
274 void set_next(ClassLoaderData* next) { _next = next; }
275 ClassLoaderData* next() const { return _next; }
276
277 ClassLoaderData(Handle h_class_loader, bool is_anonymous);
278 ~ClassLoaderData();
279
280 // The CLD are not placed in the Heap, so the Card Table or
281 // the Mod Union Table can't be used to mark when CLD have modified oops.
282 // The CT and MUT bits saves this information for the whole class loader data.
283 void clear_modified_oops() { _modified_oops = false; }
284 public:
285 void record_modified_oops() { _modified_oops = true; }
286 bool has_modified_oops() { return _modified_oops; }
287
288 void accumulate_modified_oops() { if (has_modified_oops()) _accumulated_modified_oops = true; }
289 void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
290 bool has_accumulated_modified_oops() { return _accumulated_modified_oops; }
291 private:
292
293 void unload();
294 bool keep_alive() const { return _keep_alive > 0; }
295 void classes_do(void f(Klass*));
296 void loaded_classes_do(KlassClosure* klass_closure);
297 void classes_do(void f(InstanceKlass*));
309 Dictionary* create_dictionary();
310 public:
311 // GC interface.
312 void clear_claimed() { _claimed = 0; }
313 bool claimed() const { return _claimed == 1; }
314 bool claim();
315
316 bool is_alive(BoolObjectClosure* is_alive_closure) const;
317
318 // Accessors
319 Metaspace* metaspace_or_null() const { return _metaspace; }
320
321 static ClassLoaderData* the_null_class_loader_data() {
322 return _the_null_class_loader_data;
323 }
324
325 Mutex* metaspace_lock() const { return _metaspace_lock; }
326
327 bool is_anonymous() const { return _is_anonymous; }
328
329 static void init_null_class_loader_data();
330
331 bool is_the_null_class_loader_data() const {
332 return this == _the_null_class_loader_data;
333 }
334 bool is_system_class_loader_data() const;
335 bool is_platform_class_loader_data() const;
336
337 // Returns true if this class loader data is for the boot class loader.
338 // (Note that the class loader data may be anonymous.)
339 bool is_boot_class_loader_data() const {
340 return class_loader() == NULL;
341 }
342
343 bool is_builtin_class_loader_data() const;
344 bool is_permanent_class_loader_data() const;
345
346 // The Metaspace is created lazily so may be NULL. This
347 // method will allocate a Metaspace if needed.
348 Metaspace* metaspace_non_null();
349
357 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
358 return _unloading;
359 }
360
361 // Used to refcount an anonymous class's CLD in order to
362 // indicate their aliveness without a keep_alive_object().
363 void inc_keep_alive();
364 void dec_keep_alive();
365
366 inline unsigned int identity_hash() const { return (unsigned int)(((intptr_t)this) >> 3); }
367
368 void oops_do(OopClosure* f, bool must_claim, bool clear_modified_oops = false);
369
370 void classes_do(KlassClosure* klass_closure);
371 Klass* klasses() { return _klasses; }
372
373 JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; }
374 void set_jmethod_ids(JNIMethodBlock* new_block) { _jmethod_ids = new_block; }
375
376 void print() { print_on(tty); }
377 void print_on(outputStream* out) const PRODUCT_RETURN;
378 void print_value() { print_value_on(tty); }
379 void print_value_on(outputStream* out) const;
380 void verify();
381 const char* loader_name() const;
382
383 OopHandle add_handle(Handle h);
384 void remove_handle(OopHandle h);
385 void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field
386 void add_class(Klass* k, bool publicize = true);
387 void remove_class(Klass* k);
388 bool contains_klass(Klass* k);
389 void record_dependency(const Klass* to);
390 PackageEntryTable* packages() { return _packages; }
391 ModuleEntry* unnamed_module() { return _unnamed_module; }
392 ModuleEntryTable* modules();
393 bool modules_defined() { return (_modules != NULL); }
394
395 // Loaded class dictionary
396 Dictionary* dictionary() const { return _dictionary; }
397
398 void add_to_deallocate_list(Metadata* m);
399
400 static ClassLoaderData* class_loader_data(oop loader);
401 static ClassLoaderData* class_loader_data_or_null(oop loader);
402 static ClassLoaderData* anonymous_class_loader_data(Handle loader);
403
404 TRACE_DEFINE_TRACE_ID_METHODS;
405 };
406
407 // An iterator that distributes Klasses to parallel worker threads.
408 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
409 Klass* volatile _next_klass;
410 public:
411 ClassLoaderDataGraphKlassIteratorAtomic();
412 Klass* next_klass();
413 private:
414 static Klass* next_klass_in_cldg(Klass* klass);
415 };
416
417 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
418 ClassLoaderData* _data;
419 public:
420 ClassLoaderDataGraphMetaspaceIterator();
421 ~ClassLoaderDataGraphMetaspaceIterator();
422 bool repeat() { return _data != NULL; }
|