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