author | acorn |
Tue, 01 Oct 2013 08:10:42 -0400 | |
changeset 20284 | 595a25ab9474 |
parent 19685 | 3df9b00b5d5f |
child 25057 | f38210f84f8c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3795
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3795
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3795
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CLASSFILE_CLASSLOADER_HPP |
26 |
#define SHARE_VM_CLASSFILE_CLASSLOADER_HPP |
|
27 |
||
28 |
#include "classfile/classFileParser.hpp" |
|
29 |
#include "runtime/perfData.hpp" |
|
30 |
||
1 | 31 |
// The VM class loader. |
32 |
#include <sys/stat.h> |
|
33 |
||
34 |
||
35 |
// Meta-index (optional, to be able to skip opening boot classpath jar files) |
|
13195 | 36 |
class MetaIndex: public CHeapObj<mtClass> { |
1 | 37 |
private: |
38 |
char** _meta_package_names; |
|
39 |
int _num_meta_package_names; |
|
40 |
public: |
|
41 |
MetaIndex(char** meta_package_names, int num_meta_package_names); |
|
42 |
~MetaIndex(); |
|
43 |
bool may_contain(const char* class_name); |
|
44 |
}; |
|
45 |
||
46 |
||
47 |
// Class path entry (directory or zip file) |
|
48 |
||
13195 | 49 |
class ClassPathEntry: public CHeapObj<mtClass> { |
1 | 50 |
private: |
51 |
ClassPathEntry* _next; |
|
52 |
public: |
|
53 |
// Next entry in class path |
|
54 |
ClassPathEntry* next() { return _next; } |
|
55 |
void set_next(ClassPathEntry* next) { |
|
56 |
// may have unlocked readers, so write atomically. |
|
57 |
OrderAccess::release_store_ptr(&_next, next); |
|
58 |
} |
|
59 |
virtual bool is_jar_file() = 0; |
|
60 |
virtual const char* name() = 0; |
|
61 |
virtual bool is_lazy(); |
|
62 |
// Constructor |
|
63 |
ClassPathEntry(); |
|
64 |
// Attempt to locate file_name through this class path entry. |
|
65 |
// Returns a class file parsing stream if successfull. |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
66 |
virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0; |
1 | 67 |
// Debugging |
68 |
NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;) |
|
69 |
NOT_PRODUCT(virtual bool is_rt_jar() = 0;) |
|
70 |
}; |
|
71 |
||
72 |
||
73 |
class ClassPathDirEntry: public ClassPathEntry { |
|
74 |
private: |
|
75 |
char* _dir; // Name of directory |
|
76 |
public: |
|
77 |
bool is_jar_file() { return false; } |
|
78 |
const char* name() { return _dir; } |
|
79 |
ClassPathDirEntry(char* dir); |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
80 |
ClassFileStream* open_stream(const char* name, TRAPS); |
1 | 81 |
// Debugging |
82 |
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
|
83 |
NOT_PRODUCT(bool is_rt_jar();) |
|
84 |
}; |
|
85 |
||
86 |
||
87 |
// Type definitions for zip file and zip file entry |
|
88 |
typedef void* jzfile; |
|
89 |
typedef struct { |
|
90 |
char *name; /* entry name */ |
|
91 |
jlong time; /* modification time */ |
|
92 |
jlong size; /* size of uncompressed data */ |
|
93 |
jlong csize; /* size of compressed data (zero if uncompressed) */ |
|
94 |
jint crc; /* crc of uncompressed data */ |
|
95 |
char *comment; /* optional zip file comment */ |
|
96 |
jbyte *extra; /* optional extra data */ |
|
97 |
jlong pos; /* position of LOC header (if negative) or data */ |
|
98 |
} jzentry; |
|
99 |
||
100 |
||
101 |
class ClassPathZipEntry: public ClassPathEntry { |
|
102 |
private: |
|
103 |
jzfile* _zip; // The zip archive |
|
104 |
char* _zip_name; // Name of zip archive |
|
105 |
public: |
|
106 |
bool is_jar_file() { return true; } |
|
107 |
const char* name() { return _zip_name; } |
|
108 |
ClassPathZipEntry(jzfile* zip, const char* zip_name); |
|
109 |
~ClassPathZipEntry(); |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
110 |
ClassFileStream* open_stream(const char* name, TRAPS); |
1 | 111 |
void contents_do(void f(const char* name, void* context), void* context); |
112 |
// Debugging |
|
113 |
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
|
114 |
NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version |
|
115 |
NOT_PRODUCT(void compile_the_world13(Handle loader, TRAPS);) // JDK 1.3 version |
|
116 |
NOT_PRODUCT(bool is_rt_jar();) |
|
117 |
NOT_PRODUCT(bool is_rt_jar12();) |
|
118 |
NOT_PRODUCT(bool is_rt_jar13();) |
|
119 |
}; |
|
120 |
||
121 |
||
122 |
// For lazier loading of boot class path entries |
|
123 |
class LazyClassPathEntry: public ClassPathEntry { |
|
124 |
private: |
|
125 |
char* _path; // dir or file |
|
126 |
struct stat _st; |
|
127 |
MetaIndex* _meta_index; |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
128 |
bool _has_error; |
1 | 129 |
volatile ClassPathEntry* _resolved_entry; |
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
130 |
ClassPathEntry* resolve_entry(TRAPS); |
1 | 131 |
public: |
132 |
bool is_jar_file(); |
|
133 |
const char* name() { return _path; } |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
134 |
LazyClassPathEntry(char* path, const struct stat* st); |
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
135 |
ClassFileStream* open_stream(const char* name, TRAPS); |
1 | 136 |
void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; } |
137 |
virtual bool is_lazy(); |
|
138 |
// Debugging |
|
139 |
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
|
140 |
NOT_PRODUCT(bool is_rt_jar();) |
|
141 |
}; |
|
142 |
||
143 |
class PackageHashtable; |
|
144 |
class PackageInfo; |
|
13195 | 145 |
template <MEMFLAGS F> class HashtableBucket; |
1 | 146 |
|
147 |
class ClassLoader: AllStatic { |
|
148 |
public: |
|
149 |
enum SomeConstants { |
|
150 |
package_hash_table_size = 31 // Number of buckets |
|
151 |
}; |
|
152 |
private: |
|
153 |
friend class LazyClassPathEntry; |
|
154 |
||
155 |
// Performance counters |
|
156 |
static PerfCounter* _perf_accumulated_time; |
|
157 |
static PerfCounter* _perf_classes_inited; |
|
158 |
static PerfCounter* _perf_class_init_time; |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
159 |
static PerfCounter* _perf_class_init_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
160 |
static PerfCounter* _perf_classes_verified; |
1 | 161 |
static PerfCounter* _perf_class_verify_time; |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
162 |
static PerfCounter* _perf_class_verify_selftime; |
1 | 163 |
static PerfCounter* _perf_classes_linked; |
164 |
static PerfCounter* _perf_class_link_time; |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
165 |
static PerfCounter* _perf_class_link_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
166 |
static PerfCounter* _perf_class_parse_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
167 |
static PerfCounter* _perf_class_parse_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
168 |
static PerfCounter* _perf_sys_class_lookup_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
169 |
static PerfCounter* _perf_shared_classload_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
170 |
static PerfCounter* _perf_sys_classload_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
171 |
static PerfCounter* _perf_app_classload_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
172 |
static PerfCounter* _perf_app_classload_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
173 |
static PerfCounter* _perf_app_classload_count; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
174 |
static PerfCounter* _perf_define_appclasses; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
175 |
static PerfCounter* _perf_define_appclass_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
176 |
static PerfCounter* _perf_define_appclass_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
177 |
static PerfCounter* _perf_app_classfile_bytes_read; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
178 |
static PerfCounter* _perf_sys_classfile_bytes_read; |
1 | 179 |
|
180 |
static PerfCounter* _sync_systemLoaderLockContentionRate; |
|
181 |
static PerfCounter* _sync_nonSystemLoaderLockContentionRate; |
|
182 |
static PerfCounter* _sync_JVMFindLoadedClassLockFreeCounter; |
|
183 |
static PerfCounter* _sync_JVMDefineClassLockFreeCounter; |
|
184 |
static PerfCounter* _sync_JNIDefineClassLockFreeCounter; |
|
185 |
||
186 |
static PerfCounter* _unsafe_defineClassCallCounter; |
|
187 |
static PerfCounter* _isUnsyncloadClass; |
|
188 |
static PerfCounter* _load_instance_class_failCounter; |
|
189 |
||
190 |
// First entry in linked list of ClassPathEntry instances |
|
191 |
static ClassPathEntry* _first_entry; |
|
192 |
// Last entry in linked list of ClassPathEntry instances |
|
193 |
static ClassPathEntry* _last_entry; |
|
194 |
// Hash table used to keep track of loaded packages |
|
195 |
static PackageHashtable* _package_hash_table; |
|
196 |
static const char* _shared_archive; |
|
197 |
||
198 |
// Hash function |
|
199 |
static unsigned int hash(const char *s, int n); |
|
200 |
// Returns the package file name corresponding to the specified package |
|
201 |
// or class name, or null if not found. |
|
202 |
static PackageInfo* lookup_package(const char *pkgname); |
|
203 |
// Adds a new package entry for the specified class or package name and |
|
204 |
// corresponding directory or jar file name. |
|
205 |
static bool add_package(const char *pkgname, int classpath_index, TRAPS); |
|
206 |
||
207 |
// Initialization |
|
208 |
static void setup_meta_index(); |
|
209 |
static void setup_bootstrap_search_path(); |
|
210 |
static void load_zip_library(); |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
211 |
static ClassPathEntry* create_class_path_entry(char *path, const struct stat* st, |
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
212 |
bool lazy, TRAPS); |
1 | 213 |
|
214 |
// Canonicalizes path names, so strcmp will work properly. This is mainly |
|
215 |
// to avoid confusing the zip library |
|
216 |
static bool get_canonical_path(char* orig, char* out, int len); |
|
217 |
public: |
|
218 |
// Used by the kernel jvm. |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
219 |
static void update_class_path_entry_list(char *path, |
1 | 220 |
bool check_for_duplicates); |
221 |
static void print_bootclasspath(); |
|
222 |
||
223 |
// Timing |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
224 |
static PerfCounter* perf_accumulated_time() { return _perf_accumulated_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
225 |
static PerfCounter* perf_classes_inited() { return _perf_classes_inited; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
226 |
static PerfCounter* perf_class_init_time() { return _perf_class_init_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
227 |
static PerfCounter* perf_class_init_selftime() { return _perf_class_init_selftime; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
228 |
static PerfCounter* perf_classes_verified() { return _perf_classes_verified; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
229 |
static PerfCounter* perf_class_verify_time() { return _perf_class_verify_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
230 |
static PerfCounter* perf_class_verify_selftime() { return _perf_class_verify_selftime; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
231 |
static PerfCounter* perf_classes_linked() { return _perf_classes_linked; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
232 |
static PerfCounter* perf_class_link_time() { return _perf_class_link_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
233 |
static PerfCounter* perf_class_link_selftime() { return _perf_class_link_selftime; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
234 |
static PerfCounter* perf_class_parse_time() { return _perf_class_parse_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
235 |
static PerfCounter* perf_class_parse_selftime() { return _perf_class_parse_selftime; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
236 |
static PerfCounter* perf_sys_class_lookup_time() { return _perf_sys_class_lookup_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
237 |
static PerfCounter* perf_shared_classload_time() { return _perf_shared_classload_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
238 |
static PerfCounter* perf_sys_classload_time() { return _perf_sys_classload_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
239 |
static PerfCounter* perf_app_classload_time() { return _perf_app_classload_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
240 |
static PerfCounter* perf_app_classload_selftime() { return _perf_app_classload_selftime; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
241 |
static PerfCounter* perf_app_classload_count() { return _perf_app_classload_count; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
242 |
static PerfCounter* perf_define_appclasses() { return _perf_define_appclasses; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
243 |
static PerfCounter* perf_define_appclass_time() { return _perf_define_appclass_time; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
244 |
static PerfCounter* perf_define_appclass_selftime() { return _perf_define_appclass_selftime; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
245 |
static PerfCounter* perf_app_classfile_bytes_read() { return _perf_app_classfile_bytes_read; } |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
246 |
static PerfCounter* perf_sys_classfile_bytes_read() { return _perf_sys_classfile_bytes_read; } |
1 | 247 |
|
248 |
// Record how often system loader lock object is contended |
|
249 |
static PerfCounter* sync_systemLoaderLockContentionRate() { |
|
250 |
return _sync_systemLoaderLockContentionRate; |
|
251 |
} |
|
252 |
||
253 |
// Record how often non system loader lock object is contended |
|
254 |
static PerfCounter* sync_nonSystemLoaderLockContentionRate() { |
|
255 |
return _sync_nonSystemLoaderLockContentionRate; |
|
256 |
} |
|
257 |
||
258 |
// Record how many calls to JVM_FindLoadedClass w/o holding a lock |
|
259 |
static PerfCounter* sync_JVMFindLoadedClassLockFreeCounter() { |
|
260 |
return _sync_JVMFindLoadedClassLockFreeCounter; |
|
261 |
} |
|
262 |
||
263 |
// Record how many calls to JVM_DefineClass w/o holding a lock |
|
264 |
static PerfCounter* sync_JVMDefineClassLockFreeCounter() { |
|
265 |
return _sync_JVMDefineClassLockFreeCounter; |
|
266 |
} |
|
267 |
||
268 |
// Record how many calls to jni_DefineClass w/o holding a lock |
|
269 |
static PerfCounter* sync_JNIDefineClassLockFreeCounter() { |
|
270 |
return _sync_JNIDefineClassLockFreeCounter; |
|
271 |
} |
|
272 |
||
273 |
// Record how many calls to Unsafe_DefineClass |
|
274 |
static PerfCounter* unsafe_defineClassCallCounter() { |
|
275 |
return _unsafe_defineClassCallCounter; |
|
276 |
} |
|
277 |
||
278 |
// Record how many times SystemDictionary::load_instance_class call |
|
279 |
// fails with linkageError when Unsyncloadclass flag is set. |
|
280 |
static PerfCounter* load_instance_class_failCounter() { |
|
281 |
return _load_instance_class_failCounter; |
|
282 |
} |
|
283 |
||
284 |
// Load individual .class file |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7910
diff
changeset
|
285 |
static instanceKlassHandle load_classfile(Symbol* h_name, TRAPS); |
1 | 286 |
|
287 |
// If the specified package has been loaded by the system, then returns |
|
288 |
// the name of the directory or ZIP file that the package was loaded from. |
|
289 |
// Returns null if the package was not loaded. |
|
290 |
// Note: The specified name can either be the name of a class or package. |
|
291 |
// If a package name is specified, then it must be "/"-separator and also |
|
292 |
// end with a trailing "/". |
|
293 |
static oop get_system_package(const char* name, TRAPS); |
|
294 |
||
295 |
// Returns an array of Java strings representing all of the currently |
|
296 |
// loaded system packages. |
|
297 |
// Note: The package names returned are "/"-separated and end with a |
|
298 |
// trailing "/". |
|
299 |
static objArrayOop get_system_packages(TRAPS); |
|
300 |
||
301 |
// Initialization |
|
302 |
static void initialize(); |
|
303 |
static void create_package_info_table(); |
|
13195 | 304 |
static void create_package_info_table(HashtableBucket<mtClass> *t, int length, |
1 | 305 |
int number_of_entries); |
306 |
static int compute_Object_vtable(); |
|
307 |
||
308 |
static ClassPathEntry* classpath_entry(int n) { |
|
309 |
ClassPathEntry* e = ClassLoader::_first_entry; |
|
310 |
while (--n >= 0) { |
|
311 |
assert(e != NULL, "Not that many classpath entries."); |
|
312 |
e = e->next(); |
|
313 |
} |
|
314 |
return e; |
|
315 |
} |
|
316 |
||
317 |
// Sharing dump and restore |
|
318 |
static void copy_package_info_buckets(char** top, char* end); |
|
319 |
static void copy_package_info_table(char** top, char* end); |
|
320 |
||
321 |
// VM monitoring and management support |
|
322 |
static jlong classloader_time_ms(); |
|
323 |
static jlong class_method_total_size(); |
|
324 |
static jlong class_init_count(); |
|
325 |
static jlong class_init_time_ms(); |
|
326 |
static jlong class_verify_time_ms(); |
|
327 |
static jlong class_link_count(); |
|
328 |
static jlong class_link_time_ms(); |
|
329 |
||
330 |
// indicates if class path already contains a entry (exact match by name) |
|
331 |
static bool contains_entry(ClassPathEntry* entry); |
|
332 |
||
333 |
// adds a class path list |
|
334 |
static void add_to_list(ClassPathEntry* new_entry); |
|
335 |
||
336 |
// creates a class path zip entry (returns NULL if JAR file cannot be opened) |
|
337 |
static ClassPathZipEntry* create_class_path_zip_entry(const char *apath); |
|
338 |
||
339 |
// Debugging |
|
340 |
static void verify() PRODUCT_RETURN; |
|
341 |
||
342 |
// Force compilation of all methods in all classes in bootstrap class path (stress test) |
|
343 |
#ifndef PRODUCT |
|
344 |
private: |
|
17004
4d2371d76a19
8011933: add number of classes, methods and time spent to CompileTheWorld
twisti
parents:
13963
diff
changeset
|
345 |
static int _compile_the_world_class_counter; |
4d2371d76a19
8011933: add number of classes, methods and time spent to CompileTheWorld
twisti
parents:
13963
diff
changeset
|
346 |
static int _compile_the_world_method_counter; |
1 | 347 |
public: |
348 |
static void compile_the_world(); |
|
349 |
static void compile_the_world_in(char* name, Handle loader, TRAPS); |
|
17004
4d2371d76a19
8011933: add number of classes, methods and time spent to CompileTheWorld
twisti
parents:
13963
diff
changeset
|
350 |
static int compile_the_world_counter() { return _compile_the_world_class_counter; } |
1 | 351 |
#endif //PRODUCT |
352 |
}; |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
353 |
|
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
354 |
// PerfClassTraceTime is used to measure time for class loading related events. |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
355 |
// This class tracks cumulative time and exclusive time for specific event types. |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
356 |
// During the execution of one event, other event types (e.g. class loading and |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
357 |
// resolution) as well as recursive calls of the same event type could happen. |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
358 |
// Only one elapsed timer (cumulative) and one thread-local self timer (exclusive) |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
359 |
// (i.e. only one event type) are active at a time even multiple PerfClassTraceTime |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
360 |
// instances have been created as multiple events are happening. |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
361 |
class PerfClassTraceTime { |
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
362 |
public: |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
363 |
enum { |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
364 |
CLASS_LOAD = 0, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
365 |
PARSE_CLASS = 1, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
366 |
CLASS_LINK = 2, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
367 |
CLASS_VERIFY = 3, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
368 |
CLASS_CLINIT = 4, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
369 |
DEFINE_CLASS = 5, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
370 |
EVENT_TYPE_COUNT = 6 |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
371 |
}; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
372 |
protected: |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
373 |
// _t tracks time from initialization to destruction of this timer instance |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
374 |
// including time for all other event types, and recursive calls of this type. |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
375 |
// When a timer is called recursively, the elapsedTimer _t would not be used. |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
376 |
elapsedTimer _t; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
377 |
PerfLongCounter* _timep; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
378 |
PerfLongCounter* _selftimep; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
379 |
PerfLongCounter* _eventp; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
380 |
// pointer to thread-local recursion counter and timer array |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
381 |
// The thread_local timers track cumulative time for specific event types |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
382 |
// exclusive of time for other event types, but including recursive calls |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
383 |
// of the same type. |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
384 |
int* _recursion_counters; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
385 |
elapsedTimer* _timers; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
386 |
int _event_type; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
387 |
int _prev_active_event; |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
388 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
389 |
public: |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
390 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
391 |
inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
392 |
PerfLongCounter* selftimep, /* counter incremented with exclusive time */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
393 |
PerfLongCounter* eventp, /* event counter */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
394 |
int* recursion_counters, /* thread-local recursion counter array */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
395 |
elapsedTimer* timers, /* thread-local timer array */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
396 |
int type /* event type */ ) : |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
397 |
_timep(timep), _selftimep(selftimep), _eventp(eventp), _recursion_counters(recursion_counters), _timers(timers), _event_type(type) { |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
398 |
initialize(); |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
399 |
} |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
400 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
401 |
inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
402 |
elapsedTimer* timers, /* thread-local timer array */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
403 |
int type /* event type */ ) : |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
404 |
_timep(timep), _selftimep(NULL), _eventp(NULL), _recursion_counters(NULL), _timers(timers), _event_type(type) { |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
405 |
initialize(); |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
406 |
} |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
407 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
408 |
inline void suspend() { _t.stop(); _timers[_event_type].stop(); } |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
409 |
inline void resume() { _t.start(); _timers[_event_type].start(); } |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
410 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
411 |
~PerfClassTraceTime(); |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
412 |
void initialize(); |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
413 |
}; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
414 |
|
7397 | 415 |
#endif // SHARE_VM_CLASSFILE_CLASSLOADER_HPP |