comparison src/share/vm/classfile/classLoaderData.hpp @ 10408:836a62f43af9

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 19 Jun 2013 10:45:56 +0200
parents f2110083203d
children e64f1fe9756b
comparison
equal deleted inserted replaced
10086:e0fb8a213650 10408:836a62f43af9
29 #include "memory/memRegion.hpp" 29 #include "memory/memRegion.hpp"
30 #include "memory/metaspace.hpp" 30 #include "memory/metaspace.hpp"
31 #include "memory/metaspaceCounters.hpp" 31 #include "memory/metaspaceCounters.hpp"
32 #include "runtime/mutex.hpp" 32 #include "runtime/mutex.hpp"
33 #include "utilities/growableArray.hpp" 33 #include "utilities/growableArray.hpp"
34
35 #if INCLUDE_TRACE
36 # include "trace/traceTime.hpp"
37 #endif
34 38
35 // 39 //
36 // A class loader represents a linkset. Conceptually, a linkset identifies 40 // A class loader represents a linkset. Conceptually, a linkset identifies
37 // the complete transitive closure of resolved links that a dynamic linker can 41 // the complete transitive closure of resolved links that a dynamic linker can
38 // produce. 42 // produce.
47 51
48 class ClassLoaderData; 52 class ClassLoaderData;
49 class JNIMethodBlock; 53 class JNIMethodBlock;
50 class JNIHandleBlock; 54 class JNIHandleBlock;
51 class Metadebug; 55 class Metadebug;
56
52 // GC root for walking class loader data created 57 // GC root for walking class loader data created
53 58
54 class ClassLoaderDataGraph : public AllStatic { 59 class ClassLoaderDataGraph : public AllStatic {
55 friend class ClassLoaderData; 60 friend class ClassLoaderData;
56 friend class ClassLoaderDataGraphMetaspaceIterator; 61 friend class ClassLoaderDataGraphMetaspaceIterator;
60 static ClassLoaderData* _head; 65 static ClassLoaderData* _head;
61 static ClassLoaderData* _unloading; 66 static ClassLoaderData* _unloading;
62 // CMS support. 67 // CMS support.
63 static ClassLoaderData* _saved_head; 68 static ClassLoaderData* _saved_head;
64 69
65 static ClassLoaderData* add(ClassLoaderData** loader_data_addr, Handle class_loader, TRAPS); 70 static ClassLoaderData* add(Handle class_loader, bool anonymous, TRAPS);
71 static void post_class_unload_events(void);
66 public: 72 public:
67 static ClassLoaderData* find_or_create(Handle class_loader, TRAPS); 73 static ClassLoaderData* find_or_create(Handle class_loader, TRAPS);
68 static void purge(); 74 static void purge();
69 static void clear_claimed_marks(); 75 static void clear_claimed_marks();
70 static void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim); 76 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); 77 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); 78 static void keep_alive_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim);
73 static void classes_do(KlassClosure* klass_closure); 79 static void classes_do(KlassClosure* klass_closure);
80 static void classes_do(void f(Klass* const));
81 static void classes_unloading_do(void f(Klass* const));
74 static bool do_unloading(BoolObjectClosure* is_alive); 82 static bool do_unloading(BoolObjectClosure* is_alive);
75 83
76 // CMS support. 84 // CMS support.
77 static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); } 85 static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); }
78 static GrowableArray<ClassLoaderData*>* new_clds(); 86 static GrowableArray<ClassLoaderData*>* new_clds();
83 91
84 #ifndef PRODUCT 92 #ifndef PRODUCT
85 // expensive test for pointer in metaspace for debugging 93 // expensive test for pointer in metaspace for debugging
86 static bool contains(address x); 94 static bool contains(address x);
87 static bool contains_loader_data(ClassLoaderData* loader_data); 95 static bool contains_loader_data(ClassLoaderData* loader_data);
96 #endif
97
98 #if INCLUDE_TRACE
99 private:
100 static TracingTime _class_unload_time;
101 static void class_unload_event(Klass* const k);
88 #endif 102 #endif
89 }; 103 };
90 104
91 // ClassLoaderData class 105 // ClassLoaderData class
92 106
98 void locked_add(objArrayHandle last, 112 void locked_add(objArrayHandle last,
99 objArrayHandle new_dependency, 113 objArrayHandle new_dependency,
100 Thread* THREAD); 114 Thread* THREAD);
101 public: 115 public:
102 Dependencies() : _list_head(NULL) {} 116 Dependencies() : _list_head(NULL) {}
117 Dependencies(TRAPS) : _list_head(NULL) {
118 init(CHECK);
119 }
103 void add(Handle dependency, TRAPS); 120 void add(Handle dependency, TRAPS);
104 void init(TRAPS); 121 void init(TRAPS);
105 void oops_do(OopClosure* f); 122 void oops_do(OopClosure* f);
106 }; 123 };
107 124
148 static Metaspace* _rw_metaspace; 165 static Metaspace* _rw_metaspace;
149 166
150 void set_next(ClassLoaderData* next) { _next = next; } 167 void set_next(ClassLoaderData* next) { _next = next; }
151 ClassLoaderData* next() const { return _next; } 168 ClassLoaderData* next() const { return _next; }
152 169
153 ClassLoaderData(Handle h_class_loader, bool is_anonymous); 170 ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies);
154 ~ClassLoaderData(); 171 ~ClassLoaderData();
155 172
156 void set_metaspace(Metaspace* m) { _metaspace = m; } 173 void set_metaspace(Metaspace* m) { _metaspace = m; }
157 174
158 JNIHandleBlock* handles() const; 175 JNIHandleBlock* handles() const;
166 bool claim(); 183 bool claim();
167 184
168 void unload(); 185 void unload();
169 bool keep_alive() const { return _keep_alive; } 186 bool keep_alive() const { return _keep_alive; }
170 bool is_alive(BoolObjectClosure* is_alive_closure) const; 187 bool is_alive(BoolObjectClosure* is_alive_closure) const;
171 188 void classes_do(void f(Klass*));
172 void classes_do(void f(InstanceKlass*)); 189 void classes_do(void f(InstanceKlass*));
173 190
174 // Deallocate free list during class unloading. 191 // Deallocate free list during class unloading.
175 void free_deallocate_list(); 192 void free_deallocate_list();
176 193
188 bool is_anonymous() const { return _is_anonymous; } 205 bool is_anonymous() const { return _is_anonymous; }
189 206
190 static void init_null_class_loader_data() { 207 static void init_null_class_loader_data() {
191 assert(_the_null_class_loader_data == NULL, "cannot initialize twice"); 208 assert(_the_null_class_loader_data == NULL, "cannot initialize twice");
192 assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice"); 209 assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice");
193 _the_null_class_loader_data = new ClassLoaderData((oop)NULL, false); 210
211 // We explicitly initialize the Dependencies object at a later phase in the initialization
212 _the_null_class_loader_data = new ClassLoaderData((oop)NULL, false, Dependencies());
194 ClassLoaderDataGraph::_head = _the_null_class_loader_data; 213 ClassLoaderDataGraph::_head = _the_null_class_loader_data;
195 assert(_the_null_class_loader_data->is_the_null_class_loader_data(), "Must be"); 214 assert(_the_null_class_loader_data->is_the_null_class_loader_data(), "Must be");
196 if (DumpSharedSpaces) { 215 if (DumpSharedSpaces) {
197 _the_null_class_loader_data->initialize_shared_metaspaces(); 216 _the_null_class_loader_data->initialize_shared_metaspaces();
198 } 217 }