author | chegar |
Wed, 03 Dec 2014 17:48:58 +0000 | |
changeset 27711 | 0b952ebd3953 |
parent 27562 | 47f369e3c69c |
parent 27683 | 1d5707553fff |
child 29076 | 4a5f7c1e6ed7 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
25057 | 2 |
* Copyright (c) 1997, 2014, 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" |
|
27683
1d5707553fff
8064580: Move INCLUDE_CDS include section to the end of the include list
stefank
parents:
27025
diff
changeset
|
30 |
#include "utilities/macros.hpp" |
7397 | 31 |
|
1 | 32 |
// The VM class loader. |
33 |
#include <sys/stat.h> |
|
34 |
||
35 |
||
36 |
// Meta-index (optional, to be able to skip opening boot classpath jar files) |
|
13195 | 37 |
class MetaIndex: public CHeapObj<mtClass> { |
1 | 38 |
private: |
39 |
char** _meta_package_names; |
|
40 |
int _num_meta_package_names; |
|
41 |
public: |
|
42 |
MetaIndex(char** meta_package_names, int num_meta_package_names); |
|
43 |
~MetaIndex(); |
|
44 |
bool may_contain(const char* class_name); |
|
45 |
}; |
|
46 |
||
47 |
||
48 |
// Class path entry (directory or zip file) |
|
49 |
||
13195 | 50 |
class ClassPathEntry: public CHeapObj<mtClass> { |
1 | 51 |
private: |
52 |
ClassPathEntry* _next; |
|
53 |
public: |
|
54 |
// Next entry in class path |
|
55 |
ClassPathEntry* next() { return _next; } |
|
56 |
void set_next(ClassPathEntry* next) { |
|
57 |
// may have unlocked readers, so write atomically. |
|
58 |
OrderAccess::release_store_ptr(&_next, next); |
|
59 |
} |
|
60 |
virtual bool is_jar_file() = 0; |
|
61 |
virtual const char* name() = 0; |
|
62 |
virtual bool is_lazy(); |
|
63 |
// Constructor |
|
64 |
ClassPathEntry(); |
|
65 |
// Attempt to locate file_name through this class path entry. |
|
66 |
// 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
|
67 |
virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0; |
1 | 68 |
// Debugging |
69 |
NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;) |
|
27562 | 70 |
NOT_PRODUCT(virtual bool is_jrt() = 0;) |
1 | 71 |
}; |
72 |
||
73 |
||
74 |
class ClassPathDirEntry: public ClassPathEntry { |
|
75 |
private: |
|
26419 | 76 |
const char* _dir; // Name of directory |
1 | 77 |
public: |
78 |
bool is_jar_file() { return false; } |
|
79 |
const char* name() { return _dir; } |
|
26419 | 80 |
ClassPathDirEntry(const char* dir); |
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
81 |
ClassFileStream* open_stream(const char* name, TRAPS); |
1 | 82 |
// Debugging |
83 |
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
|
27562 | 84 |
NOT_PRODUCT(bool is_jrt();) |
1 | 85 |
}; |
86 |
||
87 |
||
88 |
// Type definitions for zip file and zip file entry |
|
89 |
typedef void* jzfile; |
|
90 |
typedef struct { |
|
91 |
char *name; /* entry name */ |
|
92 |
jlong time; /* modification time */ |
|
93 |
jlong size; /* size of uncompressed data */ |
|
94 |
jlong csize; /* size of compressed data (zero if uncompressed) */ |
|
95 |
jint crc; /* crc of uncompressed data */ |
|
96 |
char *comment; /* optional zip file comment */ |
|
97 |
jbyte *extra; /* optional extra data */ |
|
98 |
jlong pos; /* position of LOC header (if negative) or data */ |
|
99 |
} jzentry; |
|
100 |
||
101 |
||
102 |
class ClassPathZipEntry: public ClassPathEntry { |
|
103 |
private: |
|
26419 | 104 |
jzfile* _zip; // The zip archive |
105 |
const char* _zip_name; // Name of zip archive |
|
1 | 106 |
public: |
107 |
bool is_jar_file() { return true; } |
|
108 |
const char* name() { return _zip_name; } |
|
109 |
ClassPathZipEntry(jzfile* zip, const char* zip_name); |
|
110 |
~ClassPathZipEntry(); |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
111 |
u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS); |
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
112 |
ClassFileStream* open_stream(const char* name, TRAPS); |
1 | 113 |
void contents_do(void f(const char* name, void* context), void* context); |
114 |
// Debugging |
|
115 |
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
|
27562 | 116 |
NOT_PRODUCT(bool is_jrt();) |
1 | 117 |
}; |
118 |
||
119 |
||
120 |
// For lazier loading of boot class path entries |
|
121 |
class LazyClassPathEntry: public ClassPathEntry { |
|
122 |
private: |
|
26419 | 123 |
const char* _path; // dir or file |
1 | 124 |
struct stat _st; |
125 |
MetaIndex* _meta_index; |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
126 |
bool _has_error; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
127 |
bool _throw_exception; |
1 | 128 |
volatile ClassPathEntry* _resolved_entry; |
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
129 |
ClassPathEntry* resolve_entry(TRAPS); |
1 | 130 |
public: |
131 |
bool is_jar_file(); |
|
132 |
const char* name() { return _path; } |
|
26419 | 133 |
LazyClassPathEntry(const char* path, const struct stat* st, bool throw_exception); |
25949 | 134 |
virtual ~LazyClassPathEntry(); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
135 |
u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS); |
25949 | 136 |
|
19685
3df9b00b5d5f
8020675: invalid jar file in the bootclasspath could lead to jvm fatal error
ccheung
parents:
17004
diff
changeset
|
137 |
ClassFileStream* open_stream(const char* name, TRAPS); |
1 | 138 |
void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; } |
139 |
virtual bool is_lazy(); |
|
140 |
// Debugging |
|
141 |
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
|
27562 | 142 |
NOT_PRODUCT(bool is_jrt();) |
143 |
}; |
|
144 |
||
145 |
// For java image files |
|
146 |
class ImageFile; |
|
147 |
class ClassPathImageEntry: public ClassPathEntry { |
|
148 |
private: |
|
149 |
ImageFile *_image; |
|
150 |
public: |
|
151 |
bool is_jar_file() { return false; } |
|
152 |
bool is_open() { return _image != NULL; } |
|
153 |
const char* name(); |
|
154 |
ClassPathImageEntry(char* name); |
|
155 |
~ClassPathImageEntry(); |
|
156 |
ClassFileStream* open_stream(const char* name, TRAPS); |
|
157 |
||
158 |
// Debugging |
|
159 |
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
|
160 |
NOT_PRODUCT(bool is_jrt();) |
|
1 | 161 |
}; |
162 |
||
163 |
class PackageHashtable; |
|
164 |
class PackageInfo; |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
165 |
class SharedPathsMiscInfo; |
13195 | 166 |
template <MEMFLAGS F> class HashtableBucket; |
1 | 167 |
|
168 |
class ClassLoader: AllStatic { |
|
169 |
public: |
|
170 |
enum SomeConstants { |
|
171 |
package_hash_table_size = 31 // Number of buckets |
|
172 |
}; |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
173 |
protected: |
1 | 174 |
friend class LazyClassPathEntry; |
175 |
||
176 |
// Performance counters |
|
177 |
static PerfCounter* _perf_accumulated_time; |
|
178 |
static PerfCounter* _perf_classes_inited; |
|
179 |
static PerfCounter* _perf_class_init_time; |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
180 |
static PerfCounter* _perf_class_init_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
181 |
static PerfCounter* _perf_classes_verified; |
1 | 182 |
static PerfCounter* _perf_class_verify_time; |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
183 |
static PerfCounter* _perf_class_verify_selftime; |
1 | 184 |
static PerfCounter* _perf_classes_linked; |
185 |
static PerfCounter* _perf_class_link_time; |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
186 |
static PerfCounter* _perf_class_link_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
187 |
static PerfCounter* _perf_class_parse_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
188 |
static PerfCounter* _perf_class_parse_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
189 |
static PerfCounter* _perf_sys_class_lookup_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
190 |
static PerfCounter* _perf_shared_classload_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
191 |
static PerfCounter* _perf_sys_classload_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
192 |
static PerfCounter* _perf_app_classload_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
193 |
static PerfCounter* _perf_app_classload_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
194 |
static PerfCounter* _perf_app_classload_count; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
195 |
static PerfCounter* _perf_define_appclasses; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
196 |
static PerfCounter* _perf_define_appclass_time; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
197 |
static PerfCounter* _perf_define_appclass_selftime; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
198 |
static PerfCounter* _perf_app_classfile_bytes_read; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
199 |
static PerfCounter* _perf_sys_classfile_bytes_read; |
1 | 200 |
|
201 |
static PerfCounter* _sync_systemLoaderLockContentionRate; |
|
202 |
static PerfCounter* _sync_nonSystemLoaderLockContentionRate; |
|
203 |
static PerfCounter* _sync_JVMFindLoadedClassLockFreeCounter; |
|
204 |
static PerfCounter* _sync_JVMDefineClassLockFreeCounter; |
|
205 |
static PerfCounter* _sync_JNIDefineClassLockFreeCounter; |
|
206 |
||
207 |
static PerfCounter* _unsafe_defineClassCallCounter; |
|
208 |
static PerfCounter* _isUnsyncloadClass; |
|
209 |
static PerfCounter* _load_instance_class_failCounter; |
|
210 |
||
211 |
// First entry in linked list of ClassPathEntry instances |
|
212 |
static ClassPathEntry* _first_entry; |
|
213 |
// Last entry in linked list of ClassPathEntry instances |
|
214 |
static ClassPathEntry* _last_entry; |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
215 |
static int _num_entries; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
216 |
|
1 | 217 |
// Hash table used to keep track of loaded packages |
218 |
static PackageHashtable* _package_hash_table; |
|
219 |
static const char* _shared_archive; |
|
220 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
221 |
// Info used by CDS |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
222 |
CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;) |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
223 |
|
1 | 224 |
// Hash function |
225 |
static unsigned int hash(const char *s, int n); |
|
226 |
// Returns the package file name corresponding to the specified package |
|
227 |
// or class name, or null if not found. |
|
228 |
static PackageInfo* lookup_package(const char *pkgname); |
|
229 |
// Adds a new package entry for the specified class or package name and |
|
230 |
// corresponding directory or jar file name. |
|
231 |
static bool add_package(const char *pkgname, int classpath_index, TRAPS); |
|
232 |
||
233 |
// Initialization |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
234 |
static void setup_bootstrap_meta_index(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
235 |
static void setup_meta_index(const char* meta_index_path, const char* meta_index_dir, |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
236 |
int start_index); |
1 | 237 |
static void setup_bootstrap_search_path(); |
26419 | 238 |
static void setup_search_path(const char *class_path); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
239 |
|
1 | 240 |
static void load_zip_library(); |
26419 | 241 |
static ClassPathEntry* create_class_path_entry(const char *path, const struct stat* st, |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
242 |
bool lazy, bool throw_exception, TRAPS); |
1 | 243 |
|
244 |
// Canonicalizes path names, so strcmp will work properly. This is mainly |
|
245 |
// to avoid confusing the zip library |
|
26419 | 246 |
static bool get_canonical_path(const char* orig, char* out, int len); |
1 | 247 |
public: |
27562 | 248 |
static jboolean decompress(void *in, u8 inSize, void *out, u8 outSize, char **pmsg); |
27025 | 249 |
static int crc32(int crc, const char* buf, int len); |
26419 | 250 |
static bool update_class_path_entry_list(const char *path, |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
251 |
bool check_for_duplicates, |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
252 |
bool throw_exception=true); |
1 | 253 |
static void print_bootclasspath(); |
254 |
||
255 |
// Timing |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
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
|
260 |
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
|
261 |
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
|
262 |
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
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
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
|
278 |
static PerfCounter* perf_sys_classfile_bytes_read() { return _perf_sys_classfile_bytes_read; } |
1 | 279 |
|
280 |
// Record how often system loader lock object is contended |
|
281 |
static PerfCounter* sync_systemLoaderLockContentionRate() { |
|
282 |
return _sync_systemLoaderLockContentionRate; |
|
283 |
} |
|
284 |
||
285 |
// Record how often non system loader lock object is contended |
|
286 |
static PerfCounter* sync_nonSystemLoaderLockContentionRate() { |
|
287 |
return _sync_nonSystemLoaderLockContentionRate; |
|
288 |
} |
|
289 |
||
290 |
// Record how many calls to JVM_FindLoadedClass w/o holding a lock |
|
291 |
static PerfCounter* sync_JVMFindLoadedClassLockFreeCounter() { |
|
292 |
return _sync_JVMFindLoadedClassLockFreeCounter; |
|
293 |
} |
|
294 |
||
295 |
// Record how many calls to JVM_DefineClass w/o holding a lock |
|
296 |
static PerfCounter* sync_JVMDefineClassLockFreeCounter() { |
|
297 |
return _sync_JVMDefineClassLockFreeCounter; |
|
298 |
} |
|
299 |
||
300 |
// Record how many calls to jni_DefineClass w/o holding a lock |
|
301 |
static PerfCounter* sync_JNIDefineClassLockFreeCounter() { |
|
302 |
return _sync_JNIDefineClassLockFreeCounter; |
|
303 |
} |
|
304 |
||
305 |
// Record how many calls to Unsafe_DefineClass |
|
306 |
static PerfCounter* unsafe_defineClassCallCounter() { |
|
307 |
return _unsafe_defineClassCallCounter; |
|
308 |
} |
|
309 |
||
310 |
// Record how many times SystemDictionary::load_instance_class call |
|
311 |
// fails with linkageError when Unsyncloadclass flag is set. |
|
312 |
static PerfCounter* load_instance_class_failCounter() { |
|
313 |
return _load_instance_class_failCounter; |
|
314 |
} |
|
315 |
||
316 |
// Load individual .class file |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7910
diff
changeset
|
317 |
static instanceKlassHandle load_classfile(Symbol* h_name, TRAPS); |
1 | 318 |
|
319 |
// If the specified package has been loaded by the system, then returns |
|
320 |
// the name of the directory or ZIP file that the package was loaded from. |
|
321 |
// Returns null if the package was not loaded. |
|
322 |
// Note: The specified name can either be the name of a class or package. |
|
323 |
// If a package name is specified, then it must be "/"-separator and also |
|
324 |
// end with a trailing "/". |
|
325 |
static oop get_system_package(const char* name, TRAPS); |
|
326 |
||
327 |
// Returns an array of Java strings representing all of the currently |
|
328 |
// loaded system packages. |
|
329 |
// Note: The package names returned are "/"-separated and end with a |
|
330 |
// trailing "/". |
|
331 |
static objArrayOop get_system_packages(TRAPS); |
|
332 |
||
333 |
// Initialization |
|
334 |
static void initialize(); |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
335 |
CDS_ONLY(static void initialize_shared_path();) |
1 | 336 |
static void create_package_info_table(); |
13195 | 337 |
static void create_package_info_table(HashtableBucket<mtClass> *t, int length, |
1 | 338 |
int number_of_entries); |
339 |
static int compute_Object_vtable(); |
|
340 |
||
341 |
static ClassPathEntry* classpath_entry(int n) { |
|
342 |
ClassPathEntry* e = ClassLoader::_first_entry; |
|
343 |
while (--n >= 0) { |
|
344 |
assert(e != NULL, "Not that many classpath entries."); |
|
345 |
e = e->next(); |
|
346 |
} |
|
347 |
return e; |
|
348 |
} |
|
349 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
350 |
#if INCLUDE_CDS |
1 | 351 |
// Sharing dump and restore |
352 |
static void copy_package_info_buckets(char** top, char* end); |
|
353 |
static void copy_package_info_table(char** top, char* end); |
|
354 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
355 |
static void check_shared_classpath(const char *path); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
356 |
static void finalize_shared_paths_misc_info(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
357 |
static int get_shared_paths_misc_info_size(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
358 |
static void* get_shared_paths_misc_info(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
359 |
static bool check_shared_paths_misc_info(void* info, int size); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
360 |
static void exit_with_path_failure(const char* error, const char* message); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
361 |
#endif |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
362 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
363 |
static void trace_class_path(const char* msg, const char* name = NULL); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
364 |
|
1 | 365 |
// VM monitoring and management support |
366 |
static jlong classloader_time_ms(); |
|
367 |
static jlong class_method_total_size(); |
|
368 |
static jlong class_init_count(); |
|
369 |
static jlong class_init_time_ms(); |
|
370 |
static jlong class_verify_time_ms(); |
|
371 |
static jlong class_link_count(); |
|
372 |
static jlong class_link_time_ms(); |
|
373 |
||
374 |
// indicates if class path already contains a entry (exact match by name) |
|
375 |
static bool contains_entry(ClassPathEntry* entry); |
|
376 |
||
377 |
// adds a class path list |
|
378 |
static void add_to_list(ClassPathEntry* new_entry); |
|
379 |
||
380 |
// creates a class path zip entry (returns NULL if JAR file cannot be opened) |
|
381 |
static ClassPathZipEntry* create_class_path_zip_entry(const char *apath); |
|
382 |
||
383 |
// Debugging |
|
384 |
static void verify() PRODUCT_RETURN; |
|
385 |
||
386 |
// Force compilation of all methods in all classes in bootstrap class path (stress test) |
|
387 |
#ifndef PRODUCT |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25949
diff
changeset
|
388 |
protected: |
17004
4d2371d76a19
8011933: add number of classes, methods and time spent to CompileTheWorld
twisti
parents:
13963
diff
changeset
|
389 |
static int _compile_the_world_class_counter; |
4d2371d76a19
8011933: add number of classes, methods and time spent to CompileTheWorld
twisti
parents:
13963
diff
changeset
|
390 |
static int _compile_the_world_method_counter; |
1 | 391 |
public: |
392 |
static void compile_the_world(); |
|
393 |
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
|
394 |
static int compile_the_world_counter() { return _compile_the_world_class_counter; } |
1 | 395 |
#endif //PRODUCT |
396 |
}; |
|
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
397 |
|
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
398 |
// 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
|
399 |
// 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
|
400 |
// 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
|
401 |
// 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
|
402 |
// 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
|
403 |
// (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
|
404 |
// 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
|
405 |
class PerfClassTraceTime { |
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
406 |
public: |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
407 |
enum { |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
408 |
CLASS_LOAD = 0, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
409 |
PARSE_CLASS = 1, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
410 |
CLASS_LINK = 2, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
411 |
CLASS_VERIFY = 3, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
412 |
CLASS_CLINIT = 4, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
413 |
DEFINE_CLASS = 5, |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
414 |
EVENT_TYPE_COUNT = 6 |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
415 |
}; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
416 |
protected: |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
417 |
// _t tracks time from initialization to destruction of this timer instance |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
418 |
// 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
|
419 |
// 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
|
420 |
elapsedTimer _t; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
421 |
PerfLongCounter* _timep; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
422 |
PerfLongCounter* _selftimep; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
423 |
PerfLongCounter* _eventp; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
424 |
// pointer to thread-local recursion counter and timer array |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
425 |
// The thread_local timers track cumulative time for specific event types |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
426 |
// exclusive of time for other event types, but including recursive calls |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
427 |
// of the same type. |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
428 |
int* _recursion_counters; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
429 |
elapsedTimer* _timers; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
430 |
int _event_type; |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
431 |
int _prev_active_event; |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
432 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
433 |
public: |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
434 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
435 |
inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
436 |
PerfLongCounter* selftimep, /* counter incremented with exclusive time */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
437 |
PerfLongCounter* eventp, /* event counter */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
438 |
int* recursion_counters, /* thread-local recursion counter array */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
439 |
elapsedTimer* timers, /* thread-local timer array */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
440 |
int type /* event type */ ) : |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
441 |
_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
|
442 |
initialize(); |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
443 |
} |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
444 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
445 |
inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
446 |
elapsedTimer* timers, /* thread-local timer array */ |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
447 |
int type /* event type */ ) : |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
448 |
_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
|
449 |
initialize(); |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
450 |
} |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
451 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
452 |
inline void suspend() { _t.stop(); _timers[_event_type].stop(); } |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
453 |
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
|
454 |
|
7910
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
455 |
~PerfClassTraceTime(); |
135031ddb2bb
6966589: hs16-b08 causes java.lang.StackOverflowError
minqi
parents:
7397
diff
changeset
|
456 |
void initialize(); |
3575
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
457 |
}; |
224791e7ecab
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
1
diff
changeset
|
458 |
|
7397 | 459 |
#endif // SHARE_VM_CLASSFILE_CLASSLOADER_HPP |