Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/classLoaderData.hpp @ 7185:90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
Summary: Add ClassLoaderData object for each anonymous class with metaspaces to allocate in.
Reviewed-by: twisti, jrose, stefank
author | coleenp |
---|---|
date | Thu, 29 Nov 2012 16:50:29 -0500 |
parents | e861d44e0c9c |
children | 30866cd626b0 79f492f184d0 |
comparison
equal
deleted
inserted
replaced
7181:2fc0334f613a | 7185:90273fc0a981 |
---|---|
60 static ClassLoaderData* _head; | 60 static ClassLoaderData* _head; |
61 static ClassLoaderData* _unloading; | 61 static ClassLoaderData* _unloading; |
62 // CMS support. | 62 // CMS support. |
63 static ClassLoaderData* _saved_head; | 63 static ClassLoaderData* _saved_head; |
64 | 64 |
65 static ClassLoaderData* add(ClassLoaderData** loader_data_addr, Handle class_loader); | 65 static ClassLoaderData* add(ClassLoaderData** loader_data_addr, Handle class_loader, TRAPS); |
66 public: | 66 public: |
67 static ClassLoaderData* find_or_create(Handle class_loader); | 67 static ClassLoaderData* find_or_create(Handle class_loader, TRAPS); |
68 static void purge(); | 68 static void purge(); |
69 static void clear_claimed_marks(); | 69 static void clear_claimed_marks(); |
70 static void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim); | 70 static void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim); |
71 static void always_strong_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); | 71 static void always_strong_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); |
72 static void keep_alive_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); | |
72 static void classes_do(KlassClosure* klass_closure); | 73 static void classes_do(KlassClosure* klass_closure); |
73 static bool do_unloading(BoolObjectClosure* is_alive); | 74 static bool do_unloading(BoolObjectClosure* is_alive); |
74 | 75 |
75 // CMS support. | 76 // CMS support. |
76 static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); } | 77 static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); } |
99 | 100 |
100 static ClassLoaderData * _the_null_class_loader_data; | 101 static ClassLoaderData * _the_null_class_loader_data; |
101 | 102 |
102 oop _class_loader; // oop used to uniquely identify a class loader | 103 oop _class_loader; // oop used to uniquely identify a class loader |
103 // class loader or a canonical class path | 104 // class loader or a canonical class path |
105 oop _dependencies; // oop to hold dependencies from this class loader | |
106 // data to others. | |
104 Metaspace * _metaspace; // Meta-space where meta-data defined by the | 107 Metaspace * _metaspace; // Meta-space where meta-data defined by the |
105 // classes in the class loader are allocated. | 108 // classes in the class loader are allocated. |
106 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. | 109 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. |
107 bool _unloading; // true if this class loader goes away | 110 bool _unloading; // true if this class loader goes away |
111 bool _keep_alive; // if this CLD can be unloaded for anonymous loaders | |
108 volatile int _claimed; // true if claimed, for example during GC traces. | 112 volatile int _claimed; // true if claimed, for example during GC traces. |
109 // To avoid applying oop closure more than once. | 113 // To avoid applying oop closure more than once. |
110 // Has to be an int because we cas it. | 114 // Has to be an int because we cas it. |
111 Klass* _klasses; // The classes defined by the class loader. | 115 Klass* _klasses; // The classes defined by the class loader. |
112 | 116 |
127 // ReadOnly and ReadWrite metaspaces (static because only on the null | 131 // ReadOnly and ReadWrite metaspaces (static because only on the null |
128 // class loader for now). | 132 // class loader for now). |
129 static Metaspace* _ro_metaspace; | 133 static Metaspace* _ro_metaspace; |
130 static Metaspace* _rw_metaspace; | 134 static Metaspace* _rw_metaspace; |
131 | 135 |
132 bool has_dependency(ClassLoaderData* cld); | 136 void add_dependency(Handle dependency, TRAPS); |
133 void add_dependency(ClassLoaderData* to_loader_data, TRAPS); | 137 void locked_add_dependency(objArrayHandle last, objArrayHandle new_dependency); |
134 | 138 |
135 void set_next(ClassLoaderData* next) { _next = next; } | 139 void set_next(ClassLoaderData* next) { _next = next; } |
136 ClassLoaderData* next() const { return _next; } | 140 ClassLoaderData* next() const { return _next; } |
137 | 141 |
138 ClassLoaderData(Handle h_class_loader); | 142 ClassLoaderData(Handle h_class_loader); |
148 // GC interface. | 152 // GC interface. |
149 void clear_claimed() { _claimed = 0; } | 153 void clear_claimed() { _claimed = 0; } |
150 bool claimed() const { return _claimed == 1; } | 154 bool claimed() const { return _claimed == 1; } |
151 bool claim(); | 155 bool claim(); |
152 | 156 |
153 void mark_for_unload() { _unloading = true; } | 157 void unload(); |
158 bool keep_alive() const { return _keep_alive; } | |
159 bool is_alive(BoolObjectClosure* is_alive_closure) const; | |
154 | 160 |
155 void classes_do(void f(InstanceKlass*)); | 161 void classes_do(void f(InstanceKlass*)); |
156 | 162 |
157 // Deallocate free list during class unloading. | 163 // Deallocate free list during class unloading. |
158 void free_deallocate_list(); | 164 void free_deallocate_list(); |
165 Metaspace* metaspace_or_null() const { return _metaspace; } | 171 Metaspace* metaspace_or_null() const { return _metaspace; } |
166 | 172 |
167 static ClassLoaderData* the_null_class_loader_data() { | 173 static ClassLoaderData* the_null_class_loader_data() { |
168 return _the_null_class_loader_data; | 174 return _the_null_class_loader_data; |
169 } | 175 } |
176 | |
177 bool is_anonymous() const; | |
170 | 178 |
171 static void init_null_class_loader_data() { | 179 static void init_null_class_loader_data() { |
172 assert(_the_null_class_loader_data == NULL, "cannot initialize twice"); | 180 assert(_the_null_class_loader_data == NULL, "cannot initialize twice"); |
173 assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice"); | 181 assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice"); |
174 _the_null_class_loader_data = new ClassLoaderData((oop)NULL); | 182 _the_null_class_loader_data = new ClassLoaderData((oop)NULL); |
192 // Returns true if this class loader data is for a loader going away. | 200 // Returns true if this class loader data is for a loader going away. |
193 bool is_unloading() const { | 201 bool is_unloading() const { |
194 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded"); | 202 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded"); |
195 return _unloading; | 203 return _unloading; |
196 } | 204 } |
205 // Anonymous class loader data doesn't have anything to keep them from | |
206 // being unloaded during parsing the anonymous class. | |
207 void set_keep_alive(bool value) { _keep_alive = value; } | |
197 | 208 |
198 unsigned int identity_hash() { | 209 unsigned int identity_hash() { |
199 return _class_loader == NULL ? 0 : _class_loader->identity_hash(); | 210 return _class_loader == NULL ? 0 : _class_loader->identity_hash(); |
200 } | 211 } |
201 | 212 |
209 | 220 |
210 void print_value() { print_value_on(tty); } | 221 void print_value() { print_value_on(tty); } |
211 void print_value_on(outputStream* out) const PRODUCT_RETURN; | 222 void print_value_on(outputStream* out) const PRODUCT_RETURN; |
212 void dump(outputStream * const out) PRODUCT_RETURN; | 223 void dump(outputStream * const out) PRODUCT_RETURN; |
213 void verify(); | 224 void verify(); |
225 const char* loader_name(); | |
214 | 226 |
215 jobject add_handle(Handle h); | 227 jobject add_handle(Handle h); |
216 void add_class(Klass* k); | 228 void add_class(Klass* k); |
217 void remove_class(Klass* k); | 229 void remove_class(Klass* k); |
218 void record_dependency(Klass* to, TRAPS); | 230 void record_dependency(Klass* to, TRAPS); |
231 void init_dependencies(TRAPS); | |
219 | 232 |
220 void add_to_deallocate_list(Metadata* m); | 233 void add_to_deallocate_list(Metadata* m); |
221 | 234 |
222 static ClassLoaderData* class_loader_data(oop loader); | 235 static ClassLoaderData* class_loader_data(oop loader); |
236 static ClassLoaderData* anonymous_class_loader_data(oop loader, TRAPS); | |
223 static void print_loader(ClassLoaderData *loader_data, outputStream *out); | 237 static void print_loader(ClassLoaderData *loader_data, outputStream *out); |
224 | 238 |
225 // CDS support | 239 // CDS support |
226 Metaspace* ro_metaspace(); | 240 Metaspace* ro_metaspace(); |
227 Metaspace* rw_metaspace(); | 241 Metaspace* rw_metaspace(); |