annotate src/share/vm/services/classLoadingService.cpp @ 12322:72b7e96c1922

8024545: make develop and notproduct flag values available in product builds Reviewed-by: dholmes, kvn
author twisti
date Thu, 26 Sep 2013 12:07:53 -0700
parents db9981fd3124
children 268e7a2178d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1147
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1147
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1147
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/universe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "services/classLoadingService.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "services/memoryService.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "utilities/dtrace.hpp"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 6854
diff changeset
34 #include "utilities/macros.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 #ifdef DTRACE_ENABLED
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Only bother with this argument setup if dtrace is available
a61af66fc99e Initial load
duke
parents:
diff changeset
39
4006
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
40 #ifndef USDT2
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
41
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42 HS_DTRACE_PROBE_DECL4(hotspot, class__loaded, char*, int, oop, bool);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 HS_DTRACE_PROBE_DECL4(hotspot, class__unloaded, char*, int, oop, bool);
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 #define DTRACE_CLASSLOAD_PROBE(type, clss, shared) \
a61af66fc99e Initial load
duke
parents:
diff changeset
46 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
47 char* data = NULL; \
a61af66fc99e Initial load
duke
parents:
diff changeset
48 int len = 0; \
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
49 Symbol* name = (clss)->name(); \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (name != NULL) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
51 data = (char*)name->bytes(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
52 len = name->utf8_length(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
53 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
54 HS_DTRACE_PROBE4(hotspot, class__##type, \
a61af66fc99e Initial load
duke
parents:
diff changeset
55 data, len, (clss)->class_loader(), (shared)); \
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
4006
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
58 #else /* USDT2 */
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
59
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
60 #define HOTSPOT_CLASS_unloaded HOTSPOT_CLASS_UNLOADED
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
61 #define HOTSPOT_CLASS_loaded HOTSPOT_CLASS_LOADED
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
62 #define DTRACE_CLASSLOAD_PROBE(type, clss, shared) \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
63 { \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
64 char* data = NULL; \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
65 int len = 0; \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
66 Symbol* name = (clss)->name(); \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
67 if (name != NULL) { \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
68 data = (char*)name->bytes(); \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
69 len = name->utf8_length(); \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
70 } \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
71 HOTSPOT_CLASS_##type( /* type = unloaded, loaded */ \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
72 data, len, (clss)->class_loader(), (shared)); \
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
73 }
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
74
436b4a3231bf 7098194: integrate macosx-port changes
dcubed
parents: 2426
diff changeset
75 #endif /* USDT2 */
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 #else // ndef DTRACE_ENABLED
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 #define DTRACE_CLASSLOAD_PROBE(type, clss, shared)
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
81
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
82 #if INCLUDE_MANAGEMENT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // counters for classes loaded from class files
a61af66fc99e Initial load
duke
parents:
diff changeset
84 PerfCounter* ClassLoadingService::_classes_loaded_count = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 PerfCounter* ClassLoadingService::_classes_unloaded_count = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 PerfCounter* ClassLoadingService::_classbytes_loaded = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 PerfCounter* ClassLoadingService::_classbytes_unloaded = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // counters for classes loaded from shared archive
a61af66fc99e Initial load
duke
parents:
diff changeset
90 PerfCounter* ClassLoadingService::_shared_classes_loaded_count = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 PerfCounter* ClassLoadingService::_shared_classes_unloaded_count = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 PerfCounter* ClassLoadingService::_shared_classbytes_loaded = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 PerfCounter* ClassLoadingService::_shared_classbytes_unloaded = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 PerfVariable* ClassLoadingService::_class_methods_size = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void ClassLoadingService::init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // These counters are for java.lang.management API support.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // They are created even if -XX:-UsePerfData is set and in
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // that case, they will be allocated on C heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _classes_loaded_count =
a61af66fc99e Initial load
duke
parents:
diff changeset
103 PerfDataManager::create_counter(JAVA_CLS, "loadedClasses",
a61af66fc99e Initial load
duke
parents:
diff changeset
104 PerfData::U_Events, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 _classes_unloaded_count =
a61af66fc99e Initial load
duke
parents:
diff changeset
107 PerfDataManager::create_counter(JAVA_CLS, "unloadedClasses",
a61af66fc99e Initial load
duke
parents:
diff changeset
108 PerfData::U_Events, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 _shared_classes_loaded_count =
a61af66fc99e Initial load
duke
parents:
diff changeset
111 PerfDataManager::create_counter(JAVA_CLS, "sharedLoadedClasses",
a61af66fc99e Initial load
duke
parents:
diff changeset
112 PerfData::U_Events, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _shared_classes_unloaded_count =
a61af66fc99e Initial load
duke
parents:
diff changeset
115 PerfDataManager::create_counter(JAVA_CLS, "sharedUnloadedClasses",
a61af66fc99e Initial load
duke
parents:
diff changeset
116 PerfData::U_Events, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 _classbytes_loaded =
a61af66fc99e Initial load
duke
parents:
diff changeset
120 PerfDataManager::create_counter(SUN_CLS, "loadedBytes",
a61af66fc99e Initial load
duke
parents:
diff changeset
121 PerfData::U_Bytes, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 _classbytes_unloaded =
a61af66fc99e Initial load
duke
parents:
diff changeset
124 PerfDataManager::create_counter(SUN_CLS, "unloadedBytes",
a61af66fc99e Initial load
duke
parents:
diff changeset
125 PerfData::U_Bytes, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 _shared_classbytes_loaded =
a61af66fc99e Initial load
duke
parents:
diff changeset
127 PerfDataManager::create_counter(SUN_CLS, "sharedLoadedBytes",
a61af66fc99e Initial load
duke
parents:
diff changeset
128 PerfData::U_Bytes, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _shared_classbytes_unloaded =
a61af66fc99e Initial load
duke
parents:
diff changeset
131 PerfDataManager::create_counter(SUN_CLS, "sharedUnloadedBytes",
a61af66fc99e Initial load
duke
parents:
diff changeset
132 PerfData::U_Bytes, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 _class_methods_size =
a61af66fc99e Initial load
duke
parents:
diff changeset
134 PerfDataManager::create_variable(SUN_CLS, "methodBytes",
a61af66fc99e Initial load
duke
parents:
diff changeset
135 PerfData::U_Bytes, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
139 void ClassLoadingService::notify_class_unloaded(InstanceKlass* k) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140 DTRACE_CLASSLOAD_PROBE(unloaded, k, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Classes that can be unloaded must be non-shared
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _classes_unloaded_count->inc();
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // add the class size
a61af66fc99e Initial load
duke
parents:
diff changeset
146 size_t size = compute_class_size(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 _classbytes_unloaded->inc(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Compute method size & subtract from running total.
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // We are called during phase 1 of mark sweep, so it's
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
151 // still ok to iterate through Method*s here.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
152 Array<Method*>* methods = k->methods();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153 for (int i = 0; i < methods->length(); i++) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
154 _class_methods_size->inc(-methods->at(i)->size());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (TraceClassUnloading) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 ResourceMark rm;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
160 tty->print_cr("[Unloading class %s " INTPTR_FORMAT "]", k->external_name(), k);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
164 void ClassLoadingService::notify_class_loaded(InstanceKlass* k, bool shared_class) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
165 DTRACE_CLASSLOAD_PROBE(loaded, k, shared_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 PerfCounter* classes_counter = (shared_class ? _shared_classes_loaded_count
a61af66fc99e Initial load
duke
parents:
diff changeset
167 : _classes_loaded_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // increment the count
a61af66fc99e Initial load
duke
parents:
diff changeset
169 classes_counter->inc();
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 PerfCounter* classbytes_counter = (shared_class ? _shared_classbytes_loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
173 : _classbytes_loaded);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // add the class size
a61af66fc99e Initial load
duke
parents:
diff changeset
175 size_t size = compute_class_size(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 classbytes_counter->inc(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
180 size_t ClassLoadingService::compute_class_size(InstanceKlass* k) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
181 // lifted from ClassStatistics.do_class(Klass* k)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 size_t class_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
184
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
185 class_size += k->size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 if (k->oop_is_instance()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 class_size += k->methods()->size();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
189 // FIXME: Need to count the contents of methods
0
a61af66fc99e Initial load
duke
parents:
diff changeset
190 class_size += k->constants()->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
191 class_size += k->local_interfaces()->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 class_size += k->transitive_interfaces()->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // We do not have to count implementors, since we only store one!
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
194 // FIXME: How should these be accounted for, now when they have moved.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4006
diff changeset
195 //class_size += k->fields()->size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return class_size * oopSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 bool ClassLoadingService::set_verbose(bool verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 MutexLocker m(Management_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // verbose will be set to the previous value
12322
72b7e96c1922 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 8001
diff changeset
205 bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassLoading", &verbose, Flag::MANAGEMENT);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(succeed, "Setting TraceClassLoading flag fails");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 reset_trace_class_unloading();
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return verbose;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // Caller to this function must own Management_lock
a61af66fc99e Initial load
duke
parents:
diff changeset
213 void ClassLoadingService::reset_trace_class_unloading() {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 assert(Management_lock->owned_by_self(), "Must own the Management_lock");
a61af66fc99e Initial load
duke
parents:
diff changeset
215 bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose();
12322
72b7e96c1922 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 8001
diff changeset
216 bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassUnloading", &value, Flag::MANAGEMENT);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 assert(succeed, "Setting TraceClassUnLoading flag fails");
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 Thread* LoadedClassesEnumerator::_current_thread = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 LoadedClassesEnumerator::LoadedClassesEnumerator(Thread* cur_thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 assert(cur_thread == Thread::current(), "Check current thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 int init_size = ClassLoadingService::loaded_class_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 _klass_handle_array = new GrowableArray<KlassHandle>(init_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // For consistency of the loaded classes, grab the SystemDictionary lock
a61af66fc99e Initial load
duke
parents:
diff changeset
230 MutexLocker sd_mutex(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Set _loaded_classes and _current_thread and begin enumerating all classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // Only one thread will do the enumeration at a time.
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // These static variables are needed and they are used by the static method
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // add_loaded_class called from classes_do().
a61af66fc99e Initial load
duke
parents:
diff changeset
236 _loaded_classes = _klass_handle_array;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 _current_thread = cur_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 SystemDictionary::classes_do(&add_loaded_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // FIXME: Exclude array klasses for now
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Universe::basic_type_classes_do(&add_loaded_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
244
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
245 #endif // INCLUDE_MANAGEMENT