Mercurial > hg > truffle
annotate src/share/vm/classfile/classLoader.hpp @ 1294:7de45b5044c3
6932270: Allow Java's ELF symtab reader to use separate debuginfo files
Reviewed-by: never
Contributed-by: Andrew Haley <aph@redhat.com>
author | never |
---|---|
date | Tue, 09 Mar 2010 11:02:39 -0800 |
parents | 89e0543e1737 |
children | c18cbe5936b8 |
rev | line source |
---|---|
0 | 1 /* |
948 | 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // The VM class loader. | |
26 #include <sys/stat.h> | |
27 | |
28 | |
29 // Meta-index (optional, to be able to skip opening boot classpath jar files) | |
30 class MetaIndex: public CHeapObj { | |
31 private: | |
32 char** _meta_package_names; | |
33 int _num_meta_package_names; | |
34 public: | |
35 MetaIndex(char** meta_package_names, int num_meta_package_names); | |
36 ~MetaIndex(); | |
37 bool may_contain(const char* class_name); | |
38 }; | |
39 | |
40 | |
41 // Class path entry (directory or zip file) | |
42 | |
43 class ClassPathEntry: public CHeapObj { | |
44 private: | |
45 ClassPathEntry* _next; | |
46 public: | |
47 // Next entry in class path | |
48 ClassPathEntry* next() { return _next; } | |
49 void set_next(ClassPathEntry* next) { | |
50 // may have unlocked readers, so write atomically. | |
51 OrderAccess::release_store_ptr(&_next, next); | |
52 } | |
53 virtual bool is_jar_file() = 0; | |
54 virtual const char* name() = 0; | |
55 virtual bool is_lazy(); | |
56 // Constructor | |
57 ClassPathEntry(); | |
58 // Attempt to locate file_name through this class path entry. | |
59 // Returns a class file parsing stream if successfull. | |
60 virtual ClassFileStream* open_stream(const char* name) = 0; | |
61 // Debugging | |
62 NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;) | |
63 NOT_PRODUCT(virtual bool is_rt_jar() = 0;) | |
64 }; | |
65 | |
66 | |
67 class ClassPathDirEntry: public ClassPathEntry { | |
68 private: | |
69 char* _dir; // Name of directory | |
70 public: | |
71 bool is_jar_file() { return false; } | |
72 const char* name() { return _dir; } | |
73 ClassPathDirEntry(char* dir); | |
74 ClassFileStream* open_stream(const char* name); | |
75 // Debugging | |
76 NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) | |
77 NOT_PRODUCT(bool is_rt_jar();) | |
78 }; | |
79 | |
80 | |
81 // Type definitions for zip file and zip file entry | |
82 typedef void* jzfile; | |
83 typedef struct { | |
84 char *name; /* entry name */ | |
85 jlong time; /* modification time */ | |
86 jlong size; /* size of uncompressed data */ | |
87 jlong csize; /* size of compressed data (zero if uncompressed) */ | |
88 jint crc; /* crc of uncompressed data */ | |
89 char *comment; /* optional zip file comment */ | |
90 jbyte *extra; /* optional extra data */ | |
91 jlong pos; /* position of LOC header (if negative) or data */ | |
92 } jzentry; | |
93 | |
94 | |
95 class ClassPathZipEntry: public ClassPathEntry { | |
96 private: | |
97 jzfile* _zip; // The zip archive | |
98 char* _zip_name; // Name of zip archive | |
99 public: | |
100 bool is_jar_file() { return true; } | |
101 const char* name() { return _zip_name; } | |
102 ClassPathZipEntry(jzfile* zip, const char* zip_name); | |
103 ~ClassPathZipEntry(); | |
104 ClassFileStream* open_stream(const char* name); | |
105 void contents_do(void f(const char* name, void* context), void* context); | |
106 // Debugging | |
107 NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) | |
108 NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version | |
109 NOT_PRODUCT(void compile_the_world13(Handle loader, TRAPS);) // JDK 1.3 version | |
110 NOT_PRODUCT(bool is_rt_jar();) | |
111 NOT_PRODUCT(bool is_rt_jar12();) | |
112 NOT_PRODUCT(bool is_rt_jar13();) | |
113 }; | |
114 | |
115 | |
116 // For lazier loading of boot class path entries | |
117 class LazyClassPathEntry: public ClassPathEntry { | |
118 private: | |
119 char* _path; // dir or file | |
120 struct stat _st; | |
121 MetaIndex* _meta_index; | |
122 volatile ClassPathEntry* _resolved_entry; | |
123 ClassPathEntry* resolve_entry(); | |
124 public: | |
125 bool is_jar_file(); | |
126 const char* name() { return _path; } | |
127 LazyClassPathEntry(char* path, struct stat st); | |
128 ClassFileStream* open_stream(const char* name); | |
129 void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; } | |
130 virtual bool is_lazy(); | |
131 // Debugging | |
132 NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) | |
133 NOT_PRODUCT(bool is_rt_jar();) | |
134 }; | |
135 | |
136 class PackageHashtable; | |
137 class PackageInfo; | |
138 class HashtableBucket; | |
139 | |
140 class ClassLoader: AllStatic { | |
141 public: | |
142 enum SomeConstants { | |
143 package_hash_table_size = 31 // Number of buckets | |
144 }; | |
145 private: | |
146 friend class LazyClassPathEntry; | |
147 | |
148 // Performance counters | |
149 static PerfCounter* _perf_accumulated_time; | |
150 static PerfCounter* _perf_classes_inited; | |
151 static PerfCounter* _perf_class_init_time; | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
152 static PerfCounter* _perf_class_init_selftime; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
153 static PerfCounter* _perf_classes_verified; |
0 | 154 static PerfCounter* _perf_class_verify_time; |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
155 static PerfCounter* _perf_class_verify_selftime; |
0 | 156 static PerfCounter* _perf_classes_linked; |
157 static PerfCounter* _perf_class_link_time; | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
158 static PerfCounter* _perf_class_link_selftime; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
159 static PerfCounter* _perf_class_parse_time; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
160 static PerfCounter* _perf_class_parse_selftime; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
161 static PerfCounter* _perf_sys_class_lookup_time; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
162 static PerfCounter* _perf_shared_classload_time; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
163 static PerfCounter* _perf_sys_classload_time; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
164 static PerfCounter* _perf_app_classload_time; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
165 static PerfCounter* _perf_app_classload_selftime; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
166 static PerfCounter* _perf_app_classload_count; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
167 static PerfCounter* _perf_define_appclasses; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
168 static PerfCounter* _perf_define_appclass_time; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
169 static PerfCounter* _perf_define_appclass_selftime; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
170 static PerfCounter* _perf_app_classfile_bytes_read; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
171 static PerfCounter* _perf_sys_classfile_bytes_read; |
0 | 172 |
173 static PerfCounter* _sync_systemLoaderLockContentionRate; | |
174 static PerfCounter* _sync_nonSystemLoaderLockContentionRate; | |
175 static PerfCounter* _sync_JVMFindLoadedClassLockFreeCounter; | |
176 static PerfCounter* _sync_JVMDefineClassLockFreeCounter; | |
177 static PerfCounter* _sync_JNIDefineClassLockFreeCounter; | |
178 | |
179 static PerfCounter* _unsafe_defineClassCallCounter; | |
180 static PerfCounter* _isUnsyncloadClass; | |
181 static PerfCounter* _load_instance_class_failCounter; | |
182 | |
183 // First entry in linked list of ClassPathEntry instances | |
184 static ClassPathEntry* _first_entry; | |
185 // Last entry in linked list of ClassPathEntry instances | |
186 static ClassPathEntry* _last_entry; | |
187 // Hash table used to keep track of loaded packages | |
188 static PackageHashtable* _package_hash_table; | |
189 static const char* _shared_archive; | |
190 | |
191 // Hash function | |
192 static unsigned int hash(const char *s, int n); | |
193 // Returns the package file name corresponding to the specified package | |
194 // or class name, or null if not found. | |
195 static PackageInfo* lookup_package(const char *pkgname); | |
196 // Adds a new package entry for the specified class or package name and | |
197 // corresponding directory or jar file name. | |
198 static bool add_package(const char *pkgname, int classpath_index, TRAPS); | |
199 | |
200 // Initialization | |
201 static void setup_meta_index(); | |
202 static void setup_bootstrap_search_path(); | |
203 static void load_zip_library(); | |
204 static void create_class_path_entry(char *path, struct stat st, ClassPathEntry **new_entry, bool lazy); | |
205 | |
206 // Canonicalizes path names, so strcmp will work properly. This is mainly | |
207 // to avoid confusing the zip library | |
208 static bool get_canonical_path(char* orig, char* out, int len); | |
209 public: | |
210 // Used by the kernel jvm. | |
211 static void update_class_path_entry_list(const char *path, | |
212 bool check_for_duplicates); | |
213 static void print_bootclasspath(); | |
214 | |
215 // Timing | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
216 static PerfCounter* perf_accumulated_time() { return _perf_accumulated_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
217 static PerfCounter* perf_classes_inited() { return _perf_classes_inited; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
218 static PerfCounter* perf_class_init_time() { return _perf_class_init_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
219 static PerfCounter* perf_class_init_selftime() { return _perf_class_init_selftime; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
220 static PerfCounter* perf_classes_verified() { return _perf_classes_verified; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
221 static PerfCounter* perf_class_verify_time() { return _perf_class_verify_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
222 static PerfCounter* perf_class_verify_selftime() { return _perf_class_verify_selftime; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
223 static PerfCounter* perf_classes_linked() { return _perf_classes_linked; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
224 static PerfCounter* perf_class_link_time() { return _perf_class_link_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
225 static PerfCounter* perf_class_link_selftime() { return _perf_class_link_selftime; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
226 static PerfCounter* perf_class_parse_time() { return _perf_class_parse_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
227 static PerfCounter* perf_class_parse_selftime() { return _perf_class_parse_selftime; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
228 static PerfCounter* perf_sys_class_lookup_time() { return _perf_sys_class_lookup_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
229 static PerfCounter* perf_shared_classload_time() { return _perf_shared_classload_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
230 static PerfCounter* perf_sys_classload_time() { return _perf_sys_classload_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
231 static PerfCounter* perf_app_classload_time() { return _perf_app_classload_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
232 static PerfCounter* perf_app_classload_selftime() { return _perf_app_classload_selftime; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
233 static PerfCounter* perf_app_classload_count() { return _perf_app_classload_count; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
234 static PerfCounter* perf_define_appclasses() { return _perf_define_appclasses; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
235 static PerfCounter* perf_define_appclass_time() { return _perf_define_appclass_time; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
236 static PerfCounter* perf_define_appclass_selftime() { return _perf_define_appclass_selftime; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
237 static PerfCounter* perf_app_classfile_bytes_read() { return _perf_app_classfile_bytes_read; } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
238 static PerfCounter* perf_sys_classfile_bytes_read() { return _perf_sys_classfile_bytes_read; } |
0 | 239 |
240 // Record how often system loader lock object is contended | |
241 static PerfCounter* sync_systemLoaderLockContentionRate() { | |
242 return _sync_systemLoaderLockContentionRate; | |
243 } | |
244 | |
245 // Record how often non system loader lock object is contended | |
246 static PerfCounter* sync_nonSystemLoaderLockContentionRate() { | |
247 return _sync_nonSystemLoaderLockContentionRate; | |
248 } | |
249 | |
250 // Record how many calls to JVM_FindLoadedClass w/o holding a lock | |
251 static PerfCounter* sync_JVMFindLoadedClassLockFreeCounter() { | |
252 return _sync_JVMFindLoadedClassLockFreeCounter; | |
253 } | |
254 | |
255 // Record how many calls to JVM_DefineClass w/o holding a lock | |
256 static PerfCounter* sync_JVMDefineClassLockFreeCounter() { | |
257 return _sync_JVMDefineClassLockFreeCounter; | |
258 } | |
259 | |
260 // Record how many calls to jni_DefineClass w/o holding a lock | |
261 static PerfCounter* sync_JNIDefineClassLockFreeCounter() { | |
262 return _sync_JNIDefineClassLockFreeCounter; | |
263 } | |
264 | |
265 // Record how many calls to Unsafe_DefineClass | |
266 static PerfCounter* unsafe_defineClassCallCounter() { | |
267 return _unsafe_defineClassCallCounter; | |
268 } | |
269 | |
270 // Record how many times SystemDictionary::load_instance_class call | |
271 // fails with linkageError when Unsyncloadclass flag is set. | |
272 static PerfCounter* load_instance_class_failCounter() { | |
273 return _load_instance_class_failCounter; | |
274 } | |
275 | |
276 // Load individual .class file | |
277 static instanceKlassHandle load_classfile(symbolHandle h_name, TRAPS); | |
278 | |
279 // If the specified package has been loaded by the system, then returns | |
280 // the name of the directory or ZIP file that the package was loaded from. | |
281 // Returns null if the package was not loaded. | |
282 // Note: The specified name can either be the name of a class or package. | |
283 // If a package name is specified, then it must be "/"-separator and also | |
284 // end with a trailing "/". | |
285 static oop get_system_package(const char* name, TRAPS); | |
286 | |
287 // Returns an array of Java strings representing all of the currently | |
288 // loaded system packages. | |
289 // Note: The package names returned are "/"-separated and end with a | |
290 // trailing "/". | |
291 static objArrayOop get_system_packages(TRAPS); | |
292 | |
293 // Initialization | |
294 static void initialize(); | |
295 static void create_package_info_table(); | |
296 static void create_package_info_table(HashtableBucket *t, int length, | |
297 int number_of_entries); | |
298 static int compute_Object_vtable(); | |
299 | |
300 static ClassPathEntry* classpath_entry(int n) { | |
301 ClassPathEntry* e = ClassLoader::_first_entry; | |
302 while (--n >= 0) { | |
303 assert(e != NULL, "Not that many classpath entries."); | |
304 e = e->next(); | |
305 } | |
306 return e; | |
307 } | |
308 | |
309 // Sharing dump and restore | |
310 static void copy_package_info_buckets(char** top, char* end); | |
311 static void copy_package_info_table(char** top, char* end); | |
312 | |
313 // VM monitoring and management support | |
314 static jlong classloader_time_ms(); | |
315 static jlong class_method_total_size(); | |
316 static jlong class_init_count(); | |
317 static jlong class_init_time_ms(); | |
318 static jlong class_verify_time_ms(); | |
319 static jlong class_link_count(); | |
320 static jlong class_link_time_ms(); | |
321 | |
322 // indicates if class path already contains a entry (exact match by name) | |
323 static bool contains_entry(ClassPathEntry* entry); | |
324 | |
325 // adds a class path list | |
326 static void add_to_list(ClassPathEntry* new_entry); | |
327 | |
328 // creates a class path zip entry (returns NULL if JAR file cannot be opened) | |
329 static ClassPathZipEntry* create_class_path_zip_entry(const char *apath); | |
330 | |
331 // Debugging | |
332 static void verify() PRODUCT_RETURN; | |
333 | |
334 // Force compilation of all methods in all classes in bootstrap class path (stress test) | |
335 #ifndef PRODUCT | |
336 private: | |
337 static int _compile_the_world_counter; | |
338 public: | |
339 static void compile_the_world(); | |
340 static void compile_the_world_in(char* name, Handle loader, TRAPS); | |
341 static int compile_the_world_counter() { return _compile_the_world_counter; } | |
342 #endif //PRODUCT | |
343 }; | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
344 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
345 // PerfClassTraceTime is used to measure time for class loading related events. |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
346 // This class tracks cumulative time and exclusive time for specific event types. |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
347 // During the execution of one event, other event types (e.g. class loading and |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
348 // resolution) as well as recursive calls of the same event type could happen. |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
349 // Only one elapsed timer (cumulative) and one thread-local self timer (exclusive) |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
350 // (i.e. only one event type) are active at a time even multiple PerfClassTraceTime |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
351 // instances have been created as multiple events are happening. |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
352 class PerfClassTraceTime { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
353 public: |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
354 enum { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
355 CLASS_LOAD = 0, |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
356 PARSE_CLASS = 1, |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
357 CLASS_LINK = 2, |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
358 CLASS_VERIFY = 3, |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
359 CLASS_CLINIT = 4, |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
360 DEFINE_CLASS = 5, |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
361 EVENT_TYPE_COUNT = 6 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
362 }; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
363 protected: |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
364 // _t tracks time from initialization to destruction of this timer instance |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
365 // including time for all other event types, and recursive calls of this type. |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
366 // When a timer is called recursively, the elapsedTimer _t would not be used. |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
367 elapsedTimer _t; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
368 PerfLongCounter* _timep; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
369 PerfLongCounter* _selftimep; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
370 PerfLongCounter* _eventp; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
371 // pointer to thread-local recursion counter and timer array |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
372 // The thread_local timers track cumulative time for specific event types |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
373 // exclusive of time for other event types, but including recursive calls |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
374 // of the same type. |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
375 int* _recursion_counters; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
376 elapsedTimer* _timers; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
377 int _event_type; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
378 int _prev_active_event; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
379 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
380 public: |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
381 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
382 inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */ |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
383 PerfLongCounter* selftimep, /* counter incremented with exclusive time */ |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
384 PerfLongCounter* eventp, /* event counter */ |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
385 int* recursion_counters, /* thread-local recursion counter array */ |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
386 elapsedTimer* timers, /* thread-local timer array */ |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
387 int type /* event type */ ) : |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
388 _timep(timep), _selftimep(selftimep), _eventp(eventp), _recursion_counters(recursion_counters), _timers(timers), _event_type(type) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
389 initialize(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
390 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
391 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
392 inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */ |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
393 elapsedTimer* timers, /* thread-local timer array */ |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
394 int type /* event type */ ) : |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
395 _timep(timep), _selftimep(NULL), _eventp(NULL), _recursion_counters(NULL), _timers(timers), _event_type(type) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
396 initialize(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
397 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
398 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
399 void initialize() { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
400 if (!UsePerfData) return; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
401 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
402 if (_eventp != NULL) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
403 // increment the event counter |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
404 _eventp->inc(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
405 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
406 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
407 // stop the current active thread-local timer to measure inclusive time |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
408 _prev_active_event = -1; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
409 for (int i=0; i < EVENT_TYPE_COUNT; i++) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
410 if (_timers[i].is_active()) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
411 assert(_prev_active_event == -1, "should have only one active timer"); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
412 _prev_active_event = i; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
413 _timers[i].stop(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
414 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
415 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
416 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
417 if (_recursion_counters == NULL || (_recursion_counters[_event_type])++ == 0) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
418 // start the inclusive timer if not recursively called |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
419 _t.start(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
420 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
421 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
422 // start thread-local timer of the given event type |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
423 if (!_timers[_event_type].is_active()) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
424 _timers[_event_type].start(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
425 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
426 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
427 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
428 inline void suspend() { _t.stop(); _timers[_event_type].stop(); } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
429 inline void resume() { _t.start(); _timers[_event_type].start(); } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
430 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
431 ~PerfClassTraceTime() { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
432 if (!UsePerfData) return; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
433 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
434 // stop the thread-local timer as the event completes |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
435 // and resume the thread-local timer of the event next on the stack |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
436 _timers[_event_type].stop(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
437 jlong selftime = _timers[_event_type].ticks(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
438 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
439 if (_prev_active_event >= 0) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
440 _timers[_prev_active_event].start(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
441 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
442 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
443 if (_recursion_counters != NULL && --(_recursion_counters[_event_type]) > 0) return; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
444 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
445 // increment the counters only on the leaf call |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
446 _t.stop(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
447 _timep->inc(_t.ticks()); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
448 if (_selftimep != NULL) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
449 _selftimep->inc(selftime); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
450 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
451 // add all class loading related event selftime to the accumulated time counter |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
452 ClassLoader::perf_accumulated_time()->inc(selftime); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
453 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
454 // reset the timer |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
455 _timers[_event_type].reset(); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
456 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
457 }; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
0
diff
changeset
|
458 |