170 bool _is_anonymous; // if this CLD is for an anonymous class
171 volatile int _claimed; // true if claimed, for example during GC traces.
172 // To avoid applying oop closure more than once.
173 // Has to be an int because we cas it.
174 Klass* _klasses; // The classes defined by the class loader.
175
176 JNIHandleBlock* _handles; // Handles to constant pool arrays
177
178 // These method IDs are created for the class loader and set to NULL when the
179 // class loader is unloaded. They are rarely freed, only for redefine classes
180 // and if they lose a data race in InstanceKlass.
181 JNIMethodBlock* _jmethod_ids;
182
183 // Metadata to be deallocated when it's safe at class unloading, when
184 // this class loader isn't unloaded itself.
185 GrowableArray<Metadata*>* _deallocate_list;
186
187 // Support for walking class loader data objects
188 ClassLoaderData* _next; /// Next loader_datas created
189
190 // ReadOnly and ReadWrite metaspaces (static because only on the null
191 // class loader for now).
192 static Metaspace* _ro_metaspace;
193 static Metaspace* _rw_metaspace;
194
195 void set_next(ClassLoaderData* next) { _next = next; }
196 ClassLoaderData* next() const { return _next; }
197
198 ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies);
199 ~ClassLoaderData();
200
201 void set_metaspace(Metaspace* m) { _metaspace = m; }
202
203 JNIHandleBlock* handles() const;
204 void set_handles(JNIHandleBlock* handles);
205
206 // GC interface.
207 void clear_claimed() { _claimed = 0; }
208 bool claimed() const { return _claimed == 1; }
209 bool claim();
291 const char* loader_name();
292
293 jobject add_handle(Handle h);
294 void add_class(Klass* k);
295 void remove_class(Klass* k);
296 bool contains_klass(Klass* k);
297 void record_dependency(Klass* to, TRAPS);
298 void init_dependencies(TRAPS);
299
300 void add_to_deallocate_list(Metadata* m);
301
302 static ClassLoaderData* class_loader_data(oop loader);
303 static ClassLoaderData* class_loader_data_or_null(oop loader);
304 static ClassLoaderData* anonymous_class_loader_data(oop loader, TRAPS);
305 static void print_loader(ClassLoaderData *loader_data, outputStream *out);
306
307 // CDS support
308 Metaspace* ro_metaspace();
309 Metaspace* rw_metaspace();
310 void initialize_shared_metaspaces();
311 };
312
313 // An iterator that distributes Klasses to parallel worker threads.
314 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
315 Klass* volatile _next_klass;
316 public:
317 ClassLoaderDataGraphKlassIteratorAtomic();
318 Klass* next_klass();
319 private:
320 static Klass* next_klass_in_cldg(Klass* klass);
321 };
322
323 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
324 ClassLoaderData* _data;
325 public:
326 ClassLoaderDataGraphMetaspaceIterator();
327 ~ClassLoaderDataGraphMetaspaceIterator();
328 bool repeat() { return _data != NULL; }
329 Metaspace* get_next() {
330 assert(_data != NULL, "Should not be NULL in call to the iterator");
|
170 bool _is_anonymous; // if this CLD is for an anonymous class
171 volatile int _claimed; // true if claimed, for example during GC traces.
172 // To avoid applying oop closure more than once.
173 // Has to be an int because we cas it.
174 Klass* _klasses; // The classes defined by the class loader.
175
176 JNIHandleBlock* _handles; // Handles to constant pool arrays
177
178 // These method IDs are created for the class loader and set to NULL when the
179 // class loader is unloaded. They are rarely freed, only for redefine classes
180 // and if they lose a data race in InstanceKlass.
181 JNIMethodBlock* _jmethod_ids;
182
183 // Metadata to be deallocated when it's safe at class unloading, when
184 // this class loader isn't unloaded itself.
185 GrowableArray<Metadata*>* _deallocate_list;
186
187 // Support for walking class loader data objects
188 ClassLoaderData* _next; /// Next loader_datas created
189
190 // CDS
191 int _shared_class_loader_id;
192
193 // ReadOnly and ReadWrite metaspaces (static because only on the null
194 // class loader for now).
195 static Metaspace* _ro_metaspace;
196 static Metaspace* _rw_metaspace;
197
198 void set_next(ClassLoaderData* next) { _next = next; }
199 ClassLoaderData* next() const { return _next; }
200
201 ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies);
202 ~ClassLoaderData();
203
204 void set_metaspace(Metaspace* m) { _metaspace = m; }
205
206 JNIHandleBlock* handles() const;
207 void set_handles(JNIHandleBlock* handles);
208
209 // GC interface.
210 void clear_claimed() { _claimed = 0; }
211 bool claimed() const { return _claimed == 1; }
212 bool claim();
294 const char* loader_name();
295
296 jobject add_handle(Handle h);
297 void add_class(Klass* k);
298 void remove_class(Klass* k);
299 bool contains_klass(Klass* k);
300 void record_dependency(Klass* to, TRAPS);
301 void init_dependencies(TRAPS);
302
303 void add_to_deallocate_list(Metadata* m);
304
305 static ClassLoaderData* class_loader_data(oop loader);
306 static ClassLoaderData* class_loader_data_or_null(oop loader);
307 static ClassLoaderData* anonymous_class_loader_data(oop loader, TRAPS);
308 static void print_loader(ClassLoaderData *loader_data, outputStream *out);
309
310 // CDS support
311 Metaspace* ro_metaspace();
312 Metaspace* rw_metaspace();
313 void initialize_shared_metaspaces();
314
315 int shared_class_loader_id() {
316 return _shared_class_loader_id;
317 }
318 void set_shared_class_loader_id(int id) {
319 assert(id >= 0, "sanity");
320 assert(_shared_class_loader_id <0, "cannot be assigned more than once");
321 _shared_class_loader_id = id;
322 }
323 };
324
325 // An iterator that distributes Klasses to parallel worker threads.
326 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
327 Klass* volatile _next_klass;
328 public:
329 ClassLoaderDataGraphKlassIteratorAtomic();
330 Klass* next_klass();
331 private:
332 static Klass* next_klass_in_cldg(Klass* klass);
333 };
334
335 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
336 ClassLoaderData* _data;
337 public:
338 ClassLoaderDataGraphMetaspaceIterator();
339 ~ClassLoaderDataGraphMetaspaceIterator();
340 bool repeat() { return _data != NULL; }
341 Metaspace* get_next() {
342 assert(_data != NULL, "Should not be NULL in call to the iterator");
|