src/share/vm/classfile/classLoader.cpp

Mon, 15 Jun 2020 14:08:11 +0300

author
apetushkov
date
Mon, 15 Jun 2020 14:08:11 +0300
changeset 9926
d20a5f399218
parent 9858
b985cbb00e68
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

8245167: Top package in method profiling shows null in JMC
Reviewed-by: neugens
Contributed-by: asemenov@azul.com

duke@435 1 /*
drchase@6680 2 * Copyright (c) 1997, 2014, 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 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/classFileParser.hpp"
stefank@2314 27 #include "classfile/classFileStream.hpp"
stefank@2314 28 #include "classfile/classLoader.hpp"
iklam@7089 29 #include "classfile/classLoaderExt.hpp"
coleenp@4304 30 #include "classfile/classLoaderData.inline.hpp"
stefank@2314 31 #include "classfile/javaClasses.hpp"
iklam@7089 32 #if INCLUDE_CDS
iklam@7089 33 #include "classfile/sharedPathsMiscInfo.hpp"
iklam@7089 34 #include "classfile/sharedClassUtil.hpp"
iklam@7089 35 #endif
stefank@2314 36 #include "classfile/systemDictionary.hpp"
stefank@2314 37 #include "classfile/vmSymbols.hpp"
stefank@2314 38 #include "compiler/compileBroker.hpp"
stefank@2314 39 #include "gc_interface/collectedHeap.inline.hpp"
stefank@2314 40 #include "interpreter/bytecodeStream.hpp"
stefank@2314 41 #include "interpreter/oopMapCache.hpp"
stefank@2314 42 #include "memory/allocation.inline.hpp"
iklam@7089 43 #include "memory/filemap.hpp"
stefank@2314 44 #include "memory/generation.hpp"
stefank@2314 45 #include "memory/oopFactory.hpp"
stefank@2314 46 #include "memory/universe.inline.hpp"
stefank@2314 47 #include "oops/instanceKlass.hpp"
stefank@2314 48 #include "oops/instanceRefKlass.hpp"
stefank@2314 49 #include "oops/oop.inline.hpp"
coleenp@2497 50 #include "oops/symbol.hpp"
stefank@2314 51 #include "prims/jvm_misc.hpp"
stefank@2314 52 #include "runtime/arguments.hpp"
stefank@2314 53 #include "runtime/compilationPolicy.hpp"
stefank@2314 54 #include "runtime/fprofiler.hpp"
stefank@2314 55 #include "runtime/handles.hpp"
stefank@2314 56 #include "runtime/handles.inline.hpp"
stefank@2314 57 #include "runtime/init.hpp"
stefank@2314 58 #include "runtime/interfaceSupport.hpp"
stefank@2314 59 #include "runtime/java.hpp"
stefank@2314 60 #include "runtime/javaCalls.hpp"
stefank@2314 61 #include "runtime/threadCritical.hpp"
stefank@2314 62 #include "runtime/timer.hpp"
stefank@2314 63 #include "services/management.hpp"
stefank@2314 64 #include "services/threadService.hpp"
stefank@2314 65 #include "utilities/events.hpp"
stefank@2314 66 #include "utilities/hashtable.hpp"
stefank@2314 67 #include "utilities/hashtable.inline.hpp"
stefank@2314 68 #ifdef TARGET_OS_FAMILY_linux
stefank@2314 69 # include "os_linux.inline.hpp"
stefank@2314 70 #endif
stefank@2314 71 #ifdef TARGET_OS_FAMILY_solaris
stefank@2314 72 # include "os_solaris.inline.hpp"
stefank@2314 73 #endif
stefank@2314 74 #ifdef TARGET_OS_FAMILY_windows
stefank@2314 75 # include "os_windows.inline.hpp"
stefank@2314 76 #endif
goetz@6461 77 #ifdef TARGET_OS_FAMILY_aix
goetz@6461 78 # include "os_aix.inline.hpp"
goetz@6461 79 #endif
never@3156 80 #ifdef TARGET_OS_FAMILY_bsd
never@3156 81 # include "os_bsd.inline.hpp"
never@3156 82 #endif
duke@435 83
duke@435 84
duke@435 85 // Entry points in zip.dll for loading zip/jar file entries
duke@435 86
duke@435 87 typedef void * * (JNICALL *ZipOpen_t)(const char *name, char **pmsg);
duke@435 88 typedef void (JNICALL *ZipClose_t)(jzfile *zip);
duke@435 89 typedef jzentry* (JNICALL *FindEntry_t)(jzfile *zip, const char *name, jint *sizeP, jint *nameLen);
duke@435 90 typedef jboolean (JNICALL *ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf);
duke@435 91 typedef jboolean (JNICALL *ReadMappedEntry_t)(jzfile *zip, jzentry *entry, unsigned char **buf, char *namebuf);
duke@435 92 typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n);
jiangli@6868 93 typedef jint (JNICALL *Crc32_t)(jint crc, const jbyte *buf, jint len);
duke@435 94
duke@435 95 static ZipOpen_t ZipOpen = NULL;
duke@435 96 static ZipClose_t ZipClose = NULL;
duke@435 97 static FindEntry_t FindEntry = NULL;
duke@435 98 static ReadEntry_t ReadEntry = NULL;
duke@435 99 static ReadMappedEntry_t ReadMappedEntry = NULL;
duke@435 100 static GetNextEntry_t GetNextEntry = NULL;
duke@435 101 static canonicalize_fn_t CanonicalizeEntry = NULL;
jiangli@6868 102 static Crc32_t Crc32 = NULL;
duke@435 103
duke@435 104 // Globals
duke@435 105
duke@435 106 PerfCounter* ClassLoader::_perf_accumulated_time = NULL;
duke@435 107 PerfCounter* ClassLoader::_perf_classes_inited = NULL;
duke@435 108 PerfCounter* ClassLoader::_perf_class_init_time = NULL;
mchung@1310 109 PerfCounter* ClassLoader::_perf_class_init_selftime = NULL;
mchung@1310 110 PerfCounter* ClassLoader::_perf_classes_verified = NULL;
duke@435 111 PerfCounter* ClassLoader::_perf_class_verify_time = NULL;
mchung@1310 112 PerfCounter* ClassLoader::_perf_class_verify_selftime = NULL;
duke@435 113 PerfCounter* ClassLoader::_perf_classes_linked = NULL;
duke@435 114 PerfCounter* ClassLoader::_perf_class_link_time = NULL;
mchung@1310 115 PerfCounter* ClassLoader::_perf_class_link_selftime = NULL;
mchung@1310 116 PerfCounter* ClassLoader::_perf_class_parse_time = NULL;
mchung@1310 117 PerfCounter* ClassLoader::_perf_class_parse_selftime = NULL;
mchung@1310 118 PerfCounter* ClassLoader::_perf_sys_class_lookup_time = NULL;
mchung@1310 119 PerfCounter* ClassLoader::_perf_shared_classload_time = NULL;
mchung@1310 120 PerfCounter* ClassLoader::_perf_sys_classload_time = NULL;
mchung@1310 121 PerfCounter* ClassLoader::_perf_app_classload_time = NULL;
mchung@1310 122 PerfCounter* ClassLoader::_perf_app_classload_selftime = NULL;
mchung@1310 123 PerfCounter* ClassLoader::_perf_app_classload_count = NULL;
mchung@1310 124 PerfCounter* ClassLoader::_perf_define_appclasses = NULL;
mchung@1310 125 PerfCounter* ClassLoader::_perf_define_appclass_time = NULL;
mchung@1310 126 PerfCounter* ClassLoader::_perf_define_appclass_selftime = NULL;
mchung@1310 127 PerfCounter* ClassLoader::_perf_app_classfile_bytes_read = NULL;
mchung@1310 128 PerfCounter* ClassLoader::_perf_sys_classfile_bytes_read = NULL;
duke@435 129 PerfCounter* ClassLoader::_sync_systemLoaderLockContentionRate = NULL;
duke@435 130 PerfCounter* ClassLoader::_sync_nonSystemLoaderLockContentionRate = NULL;
duke@435 131 PerfCounter* ClassLoader::_sync_JVMFindLoadedClassLockFreeCounter = NULL;
duke@435 132 PerfCounter* ClassLoader::_sync_JVMDefineClassLockFreeCounter = NULL;
duke@435 133 PerfCounter* ClassLoader::_sync_JNIDefineClassLockFreeCounter = NULL;
duke@435 134 PerfCounter* ClassLoader::_unsafe_defineClassCallCounter = NULL;
duke@435 135 PerfCounter* ClassLoader::_isUnsyncloadClass = NULL;
duke@435 136 PerfCounter* ClassLoader::_load_instance_class_failCounter = NULL;
duke@435 137
duke@435 138 ClassPathEntry* ClassLoader::_first_entry = NULL;
duke@435 139 ClassPathEntry* ClassLoader::_last_entry = NULL;
iklam@7089 140 int ClassLoader::_num_entries = 0;
duke@435 141 PackageHashtable* ClassLoader::_package_hash_table = NULL;
duke@435 142
iklam@7089 143 #if INCLUDE_CDS
iklam@7089 144 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
iklam@7089 145 #endif
duke@435 146 // helper routines
duke@435 147 bool string_starts_with(const char* str, const char* str_to_find) {
duke@435 148 size_t str_len = strlen(str);
duke@435 149 size_t str_to_find_len = strlen(str_to_find);
duke@435 150 if (str_to_find_len > str_len) {
duke@435 151 return false;
duke@435 152 }
duke@435 153 return (strncmp(str, str_to_find, str_to_find_len) == 0);
duke@435 154 }
duke@435 155
duke@435 156 bool string_ends_with(const char* str, const char* str_to_find) {
duke@435 157 size_t str_len = strlen(str);
duke@435 158 size_t str_to_find_len = strlen(str_to_find);
duke@435 159 if (str_to_find_len > str_len) {
duke@435 160 return false;
duke@435 161 }
duke@435 162 return (strncmp(str + (str_len - str_to_find_len), str_to_find, str_to_find_len) == 0);
duke@435 163 }
duke@435 164
apetushkov@9926 165 // Used to obtain the package name from a fully qualified class name.
apetushkov@9926 166 // It is the responsibility of the caller to establish a ResourceMark.
apetushkov@9926 167 const char* ClassLoader::package_from_name(const char* const class_name, bool* bad_class_name) {
apetushkov@9926 168 if (class_name == NULL) {
apetushkov@9926 169 if (bad_class_name != NULL) {
apetushkov@9926 170 *bad_class_name = true;
apetushkov@9926 171 }
apetushkov@9926 172 return NULL;
apetushkov@9926 173 }
apetushkov@9926 174
apetushkov@9926 175 if (bad_class_name != NULL) {
apetushkov@9926 176 *bad_class_name = false;
apetushkov@9926 177 }
apetushkov@9926 178
apetushkov@9926 179 const char* const last_slash = strrchr(class_name, '/');
apetushkov@9926 180 if (last_slash == NULL) {
apetushkov@9926 181 // No package name
apetushkov@9926 182 return NULL;
apetushkov@9926 183 }
apetushkov@9926 184
apetushkov@9926 185 char* class_name_ptr = (char*) class_name;
apetushkov@9926 186 // Skip over '['s
apetushkov@9926 187 if (*class_name_ptr == '[') {
apetushkov@9926 188 do {
apetushkov@9926 189 class_name_ptr++;
apetushkov@9926 190 } while (*class_name_ptr == '[');
apetushkov@9926 191
apetushkov@9926 192 // Fully qualified class names should not contain a 'L'.
apetushkov@9926 193 // Set bad_class_name to true to indicate that the package name
apetushkov@9926 194 // could not be obtained due to an error condition.
apetushkov@9926 195 // In this situation, is_same_class_package returns false.
apetushkov@9926 196 if (*class_name_ptr == 'L') {
apetushkov@9926 197 if (bad_class_name != NULL) {
apetushkov@9926 198 *bad_class_name = true;
apetushkov@9926 199 }
apetushkov@9926 200 return NULL;
apetushkov@9926 201 }
apetushkov@9926 202 }
apetushkov@9926 203
apetushkov@9926 204 int length = last_slash - class_name_ptr;
apetushkov@9926 205
apetushkov@9926 206 // A class name could have just the slash character in the name.
apetushkov@9926 207 if (length <= 0) {
apetushkov@9926 208 // No package name
apetushkov@9926 209 if (bad_class_name != NULL) {
apetushkov@9926 210 *bad_class_name = true;
apetushkov@9926 211 }
apetushkov@9926 212 return NULL;
apetushkov@9926 213 }
apetushkov@9926 214
apetushkov@9926 215 // drop name after last slash (including slash)
apetushkov@9926 216 // Ex., "java/lang/String.class" => "java/lang"
apetushkov@9926 217 char* pkg_name = NEW_RESOURCE_ARRAY(char, length + 1);
apetushkov@9926 218 strncpy(pkg_name, class_name_ptr, length);
apetushkov@9926 219 *(pkg_name+length) = '\0';
apetushkov@9926 220
apetushkov@9926 221 return (const char *)pkg_name;
apetushkov@9926 222 }
duke@435 223
duke@435 224 MetaIndex::MetaIndex(char** meta_package_names, int num_meta_package_names) {
duke@435 225 if (num_meta_package_names == 0) {
duke@435 226 _meta_package_names = NULL;
duke@435 227 _num_meta_package_names = 0;
duke@435 228 } else {
zgu@3900 229 _meta_package_names = NEW_C_HEAP_ARRAY(char*, num_meta_package_names, mtClass);
duke@435 230 _num_meta_package_names = num_meta_package_names;
duke@435 231 memcpy(_meta_package_names, meta_package_names, num_meta_package_names * sizeof(char*));
duke@435 232 }
duke@435 233 }
duke@435 234
duke@435 235
duke@435 236 MetaIndex::~MetaIndex() {
zgu@3900 237 FREE_C_HEAP_ARRAY(char*, _meta_package_names, mtClass);
duke@435 238 }
duke@435 239
duke@435 240
duke@435 241 bool MetaIndex::may_contain(const char* class_name) {
duke@435 242 if ( _num_meta_package_names == 0) {
duke@435 243 return false;
duke@435 244 }
duke@435 245 size_t class_name_len = strlen(class_name);
duke@435 246 for (int i = 0; i < _num_meta_package_names; i++) {
duke@435 247 char* pkg = _meta_package_names[i];
duke@435 248 size_t pkg_len = strlen(pkg);
duke@435 249 size_t min_len = MIN2(class_name_len, pkg_len);
duke@435 250 if (!strncmp(class_name, pkg, min_len)) {
duke@435 251 return true;
duke@435 252 }
duke@435 253 }
duke@435 254 return false;
duke@435 255 }
duke@435 256
duke@435 257
duke@435 258 ClassPathEntry::ClassPathEntry() {
duke@435 259 set_next(NULL);
duke@435 260 }
duke@435 261
duke@435 262
duke@435 263 bool ClassPathEntry::is_lazy() {
duke@435 264 return false;
duke@435 265 }
duke@435 266
iklam@7090 267 ClassPathDirEntry::ClassPathDirEntry(const char* dir) : ClassPathEntry() {
iklam@7090 268 char* copy = NEW_C_HEAP_ARRAY(char, strlen(dir)+1, mtClass);
iklam@7090 269 strcpy(copy, dir);
iklam@7090 270 _dir = copy;
duke@435 271 }
duke@435 272
duke@435 273
ccheung@5603 274 ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) {
duke@435 275 // construct full path name
duke@435 276 char path[JVM_MAXPATHLEN];
duke@435 277 if (jio_snprintf(path, sizeof(path), "%s%s%s", _dir, os::file_separator(), name) == -1) {
duke@435 278 return NULL;
duke@435 279 }
duke@435 280 // check if file exists
duke@435 281 struct stat st;
duke@435 282 if (os::stat(path, &st) == 0) {
iklam@7089 283 #if INCLUDE_CDS
iklam@7089 284 if (DumpSharedSpaces) {
iklam@7089 285 // We have already check in ClassLoader::check_shared_classpath() that the directory is empty, so
iklam@7089 286 // we should never find a file underneath it -- unless user has added a new file while we are running
iklam@7089 287 // the dump, in which case let's quit!
iklam@7089 288 ShouldNotReachHere();
iklam@7089 289 }
iklam@7089 290 #endif
duke@435 291 // found file, open it
ikrylov@2322 292 int file_handle = os::open(path, 0, 0);
duke@435 293 if (file_handle != -1) {
duke@435 294 // read contents into resource array
duke@435 295 u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size);
duke@435 296 size_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
duke@435 297 // close file
ikrylov@2322 298 os::close(file_handle);
duke@435 299 // construct ClassFileStream
duke@435 300 if (num_read == (size_t)st.st_size) {
mchung@1310 301 if (UsePerfData) {
mchung@1310 302 ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read);
mchung@1310 303 }
duke@435 304 return new ClassFileStream(buffer, st.st_size, _dir); // Resource allocated
duke@435 305 }
duke@435 306 }
duke@435 307 }
duke@435 308 return NULL;
duke@435 309 }
duke@435 310
duke@435 311
duke@435 312 ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name) : ClassPathEntry() {
duke@435 313 _zip = zip;
iklam@7090 314 char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass);
iklam@7090 315 strcpy(copy, zip_name);
iklam@7090 316 _zip_name = copy;
duke@435 317 }
duke@435 318
duke@435 319 ClassPathZipEntry::~ClassPathZipEntry() {
duke@435 320 if (ZipClose != NULL) {
duke@435 321 (*ZipClose)(_zip);
duke@435 322 }
zgu@3900 323 FREE_C_HEAP_ARRAY(char, _zip_name, mtClass);
duke@435 324 }
duke@435 325
iklam@7089 326 u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
iklam@7089 327 // enable call to C land
duke@435 328 JavaThread* thread = JavaThread::current();
duke@435 329 ThreadToNativeFromVM ttn(thread);
duke@435 330 // check whether zip archive contains name
iklam@7089 331 jint name_len;
iklam@7089 332 jzentry* entry = (*FindEntry)(_zip, name, filesize, &name_len);
duke@435 333 if (entry == NULL) return NULL;
duke@435 334 u1* buffer;
duke@435 335 char name_buf[128];
duke@435 336 char* filename;
duke@435 337 if (name_len < 128) {
duke@435 338 filename = name_buf;
duke@435 339 } else {
duke@435 340 filename = NEW_RESOURCE_ARRAY(char, name_len + 1);
duke@435 341 }
duke@435 342
iklam@7089 343 // file found, get pointer to the entry in mmapped jar file.
duke@435 344 if (ReadMappedEntry == NULL ||
duke@435 345 !(*ReadMappedEntry)(_zip, entry, &buffer, filename)) {
iklam@7089 346 // mmapped access not available, perhaps due to compression,
duke@435 347 // read contents into resource array
iklam@7089 348 int size = (*filesize) + ((nul_terminate) ? 1 : 0);
iklam@7089 349 buffer = NEW_RESOURCE_ARRAY(u1, size);
duke@435 350 if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL;
duke@435 351 }
iklam@7089 352
iklam@7089 353 // return result
iklam@7089 354 if (nul_terminate) {
iklam@7089 355 buffer[*filesize] = 0;
iklam@7089 356 }
iklam@7089 357 return buffer;
iklam@7089 358 }
iklam@7089 359
iklam@7089 360 ClassFileStream* ClassPathZipEntry::open_stream(const char* name, TRAPS) {
iklam@7089 361 jint filesize;
iklam@7089 362 u1* buffer = open_entry(name, &filesize, false, CHECK_NULL);
iklam@7089 363 if (buffer == NULL) {
iklam@7089 364 return NULL;
iklam@7089 365 }
mchung@1310 366 if (UsePerfData) {
mchung@1310 367 ClassLoader::perf_sys_classfile_bytes_read()->inc(filesize);
mchung@1310 368 }
iklam@7089 369 return new ClassFileStream(buffer, filesize, _zip_name); // Resource allocated
duke@435 370 }
duke@435 371
duke@435 372 // invoke function for each entry in the zip file
duke@435 373 void ClassPathZipEntry::contents_do(void f(const char* name, void* context), void* context) {
duke@435 374 JavaThread* thread = JavaThread::current();
duke@435 375 HandleMark handle_mark(thread);
duke@435 376 ThreadToNativeFromVM ttn(thread);
duke@435 377 for (int n = 0; ; n++) {
duke@435 378 jzentry * ze = ((*GetNextEntry)(_zip, n));
duke@435 379 if (ze == NULL) break;
duke@435 380 (*f)(ze->name, context);
duke@435 381 }
duke@435 382 }
duke@435 383
iklam@7090 384 LazyClassPathEntry::LazyClassPathEntry(const char* path, const struct stat* st, bool throw_exception) : ClassPathEntry() {
duke@435 385 _path = strdup(path);
ccheung@5603 386 _st = *st;
duke@435 387 _meta_index = NULL;
duke@435 388 _resolved_entry = NULL;
ccheung@5603 389 _has_error = false;
iklam@7089 390 _throw_exception = throw_exception;
duke@435 391 }
duke@435 392
duke@435 393 bool LazyClassPathEntry::is_jar_file() {
duke@435 394 return ((_st.st_mode & S_IFREG) == S_IFREG);
duke@435 395 }
duke@435 396
ccheung@5603 397 ClassPathEntry* LazyClassPathEntry::resolve_entry(TRAPS) {
duke@435 398 if (_resolved_entry != NULL) {
duke@435 399 return (ClassPathEntry*) _resolved_entry;
duke@435 400 }
duke@435 401 ClassPathEntry* new_entry = NULL;
iklam@7089 402 new_entry = ClassLoader::create_class_path_entry(_path, &_st, false, _throw_exception, CHECK_NULL);
iklam@7089 403 if (!_throw_exception && new_entry == NULL) {
iklam@7089 404 assert(!HAS_PENDING_EXCEPTION, "must be");
iklam@7089 405 return NULL;
iklam@7089 406 }
duke@435 407 {
duke@435 408 ThreadCritical tc;
duke@435 409 if (_resolved_entry == NULL) {
duke@435 410 _resolved_entry = new_entry;
duke@435 411 return new_entry;
duke@435 412 }
duke@435 413 }
duke@435 414 assert(_resolved_entry != NULL, "bug in MT-safe resolution logic");
duke@435 415 delete new_entry;
duke@435 416 return (ClassPathEntry*) _resolved_entry;
duke@435 417 }
duke@435 418
ccheung@5603 419 ClassFileStream* LazyClassPathEntry::open_stream(const char* name, TRAPS) {
duke@435 420 if (_meta_index != NULL &&
duke@435 421 !_meta_index->may_contain(name)) {
duke@435 422 return NULL;
duke@435 423 }
ccheung@5603 424 if (_has_error) {
ccheung@5603 425 return NULL;
ccheung@5603 426 }
ccheung@5603 427 ClassPathEntry* cpe = resolve_entry(THREAD);
ccheung@5603 428 if (cpe == NULL) {
ccheung@5603 429 _has_error = true;
ccheung@5603 430 return NULL;
ccheung@5603 431 } else {
ccheung@5603 432 return cpe->open_stream(name, THREAD);
ccheung@5603 433 }
duke@435 434 }
duke@435 435
duke@435 436 bool LazyClassPathEntry::is_lazy() {
duke@435 437 return true;
duke@435 438 }
duke@435 439
iklam@7089 440 u1* LazyClassPathEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
iklam@7089 441 if (_has_error) {
iklam@7089 442 return NULL;
iklam@7089 443 }
iklam@7089 444 ClassPathEntry* cpe = resolve_entry(THREAD);
iklam@7089 445 if (cpe == NULL) {
iklam@7089 446 _has_error = true;
iklam@7089 447 return NULL;
iklam@7089 448 } else if (cpe->is_jar_file()) {
iklam@7089 449 return ((ClassPathZipEntry*)cpe)->open_entry(name, filesize, nul_terminate,THREAD);
iklam@7089 450 } else {
iklam@7089 451 ShouldNotReachHere();
iklam@7089 452 *filesize = 0;
iklam@7089 453 return NULL;
iklam@7089 454 }
iklam@7089 455 }
iklam@7089 456
duke@435 457 static void print_meta_index(LazyClassPathEntry* entry,
duke@435 458 GrowableArray<char*>& meta_packages) {
duke@435 459 tty->print("[Meta index for %s=", entry->name());
duke@435 460 for (int i = 0; i < meta_packages.length(); i++) {
duke@435 461 if (i > 0) tty->print(" ");
drchase@6680 462 tty->print("%s", meta_packages.at(i));
duke@435 463 }
duke@435 464 tty->print_cr("]");
duke@435 465 }
duke@435 466
iklam@7089 467 #if INCLUDE_CDS
iklam@7089 468 void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
iklam@7089 469 assert(DumpSharedSpaces, "only called at dump time");
iklam@7089 470 tty->print_cr("Hint: enable -XX:+TraceClassPaths to diagnose the failure");
iklam@7089 471 vm_exit_during_initialization(error, message);
iklam@7089 472 }
iklam@7089 473 #endif
duke@435 474
ccheung@8184 475 void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) {
iklam@7089 476 if (!TraceClassPaths) {
iklam@7089 477 return;
iklam@7089 478 }
iklam@7089 479
iklam@7089 480 if (msg) {
ccheung@8184 481 out->print("%s", msg);
iklam@7089 482 }
iklam@7089 483 if (name) {
iklam@7089 484 if (strlen(name) < 256) {
ccheung@8184 485 out->print("%s", name);
iklam@7089 486 } else {
iklam@7089 487 // For very long paths, we need to print each character separately,
iklam@7089 488 // as print_cr() has a length limit
iklam@7089 489 while (name[0] != '\0') {
ccheung@8184 490 out->print("%c", name[0]);
iklam@7089 491 name++;
iklam@7089 492 }
iklam@7089 493 }
iklam@7089 494 }
iklam@7089 495 if (msg && msg[0] == '[') {
ccheung@8184 496 out->print_cr("]");
iklam@7089 497 } else {
ccheung@8184 498 out->cr();
iklam@7089 499 }
iklam@7089 500 }
iklam@7089 501
iklam@7089 502 void ClassLoader::setup_bootstrap_meta_index() {
duke@435 503 // Set up meta index which allows us to open boot jars lazily if
duke@435 504 // class data sharing is enabled
iklam@7089 505 const char* meta_index_path = Arguments::get_meta_index_path();
iklam@7089 506 const char* meta_index_dir = Arguments::get_meta_index_dir();
iklam@7089 507 setup_meta_index(meta_index_path, meta_index_dir, 0);
iklam@7089 508 }
iklam@7089 509
iklam@7089 510 void ClassLoader::setup_meta_index(const char* meta_index_path, const char* meta_index_dir, int start_index) {
duke@435 511 const char* known_version = "% VERSION 2";
duke@435 512 FILE* file = fopen(meta_index_path, "r");
duke@435 513 int line_no = 0;
iklam@7089 514 #if INCLUDE_CDS
iklam@7089 515 if (DumpSharedSpaces) {
iklam@7089 516 if (file != NULL) {
iklam@7089 517 _shared_paths_misc_info->add_required_file(meta_index_path);
iklam@7089 518 } else {
iklam@7089 519 _shared_paths_misc_info->add_nonexist_path(meta_index_path);
iklam@7089 520 }
iklam@7089 521 }
iklam@7089 522 #endif
duke@435 523 if (file != NULL) {
duke@435 524 ResourceMark rm;
duke@435 525 LazyClassPathEntry* cur_entry = NULL;
duke@435 526 GrowableArray<char*> boot_class_path_packages(10);
duke@435 527 char package_name[256];
duke@435 528 bool skipCurrentJar = false;
duke@435 529 while (fgets(package_name, sizeof(package_name), file) != NULL) {
duke@435 530 ++line_no;
duke@435 531 // Remove trailing newline
duke@435 532 package_name[strlen(package_name) - 1] = '\0';
duke@435 533 switch(package_name[0]) {
duke@435 534 case '%':
duke@435 535 {
duke@435 536 if ((line_no == 1) && (strcmp(package_name, known_version) != 0)) {
duke@435 537 if (TraceClassLoading && Verbose) {
duke@435 538 tty->print("[Unsupported meta index version]");
duke@435 539 }
duke@435 540 fclose(file);
duke@435 541 return;
duke@435 542 }
duke@435 543 }
duke@435 544
duke@435 545 // These directives indicate jar files which contain only
duke@435 546 // classes, only non-classfile resources, or a combination of
duke@435 547 // the two. See src/share/classes/sun/misc/MetaIndex.java and
duke@435 548 // make/tools/MetaIndex/BuildMetaIndex.java in the J2SE
duke@435 549 // workspace.
duke@435 550 case '#':
duke@435 551 case '!':
duke@435 552 case '@':
duke@435 553 {
duke@435 554 // Hand off current packages to current lazy entry (if any)
duke@435 555 if ((cur_entry != NULL) &&
duke@435 556 (boot_class_path_packages.length() > 0)) {
iklam@7089 557 if ((TraceClassLoading || TraceClassPaths) && Verbose) {
duke@435 558 print_meta_index(cur_entry, boot_class_path_packages);
duke@435 559 }
duke@435 560 MetaIndex* index = new MetaIndex(boot_class_path_packages.adr_at(0),
duke@435 561 boot_class_path_packages.length());
duke@435 562 cur_entry->set_meta_index(index);
duke@435 563 }
duke@435 564 cur_entry = NULL;
duke@435 565 boot_class_path_packages.clear();
duke@435 566
duke@435 567 // Find lazy entry corresponding to this jar file
iklam@7089 568 int count = 0;
iklam@7089 569 for (ClassPathEntry* entry = _first_entry; entry != NULL; entry = entry->next(), count++) {
iklam@7089 570 if (count >= start_index &&
iklam@7089 571 entry->is_lazy() &&
duke@435 572 string_starts_with(entry->name(), meta_index_dir) &&
duke@435 573 string_ends_with(entry->name(), &package_name[2])) {
duke@435 574 cur_entry = (LazyClassPathEntry*) entry;
duke@435 575 break;
duke@435 576 }
duke@435 577 }
duke@435 578
duke@435 579 // If the first character is '@', it indicates the following jar
duke@435 580 // file is a resource only jar file in which case, we should skip
duke@435 581 // reading the subsequent entries since the resource loading is
duke@435 582 // totally handled by J2SE side.
duke@435 583 if (package_name[0] == '@') {
duke@435 584 if (cur_entry != NULL) {
duke@435 585 cur_entry->set_meta_index(new MetaIndex(NULL, 0));
duke@435 586 }
duke@435 587 cur_entry = NULL;
duke@435 588 skipCurrentJar = true;
duke@435 589 } else {
duke@435 590 skipCurrentJar = false;
duke@435 591 }
duke@435 592
duke@435 593 break;
duke@435 594 }
duke@435 595
duke@435 596 default:
duke@435 597 {
duke@435 598 if (!skipCurrentJar && cur_entry != NULL) {
duke@435 599 char* new_name = strdup(package_name);
duke@435 600 boot_class_path_packages.append(new_name);
duke@435 601 }
duke@435 602 }
duke@435 603 }
duke@435 604 }
duke@435 605 // Hand off current packages to current lazy entry (if any)
duke@435 606 if ((cur_entry != NULL) &&
duke@435 607 (boot_class_path_packages.length() > 0)) {
iklam@7089 608 if ((TraceClassLoading || TraceClassPaths) && Verbose) {
duke@435 609 print_meta_index(cur_entry, boot_class_path_packages);
duke@435 610 }
duke@435 611 MetaIndex* index = new MetaIndex(boot_class_path_packages.adr_at(0),
duke@435 612 boot_class_path_packages.length());
duke@435 613 cur_entry->set_meta_index(index);
duke@435 614 }
duke@435 615 fclose(file);
duke@435 616 }
duke@435 617 }
duke@435 618
iklam@7089 619 #if INCLUDE_CDS
iklam@7089 620 void ClassLoader::check_shared_classpath(const char *path) {
iklam@7089 621 if (strcmp(path, "") == 0) {
iklam@7089 622 exit_with_path_failure("Cannot have empty path in archived classpaths", NULL);
iklam@7089 623 }
iklam@7089 624
iklam@7089 625 struct stat st;
iklam@7089 626 if (os::stat(path, &st) == 0) {
iklam@7089 627 if ((st.st_mode & S_IFREG) != S_IFREG) { // is directory
iklam@7089 628 if (!os::dir_is_empty(path)) {
iklam@7089 629 tty->print_cr("Error: non-empty directory '%s'", path);
iklam@7089 630 exit_with_path_failure("CDS allows only empty directories in archived classpaths", NULL);
iklam@7089 631 }
iklam@7089 632 }
iklam@7089 633 }
iklam@7089 634 }
iklam@7089 635 #endif
iklam@7089 636
duke@435 637 void ClassLoader::setup_bootstrap_search_path() {
duke@435 638 assert(_first_entry == NULL, "should not setup bootstrap class search path twice");
iklam@7090 639 const char* sys_class_path = Arguments::get_sysclasspath();
iklam@7090 640 if (PrintSharedArchiveAndExit) {
iklam@7090 641 // Don't print sys_class_path - this is the bootcp of this current VM process, not necessarily
iklam@7090 642 // the same as the bootcp of the shared archive.
iklam@7090 643 } else {
ccheung@8184 644 trace_class_path(tty, "[Bootstrap loader class path=", sys_class_path);
duke@435 645 }
iklam@7089 646 #if INCLUDE_CDS
iklam@7089 647 if (DumpSharedSpaces) {
iklam@7090 648 _shared_paths_misc_info->add_boot_classpath(sys_class_path);
iklam@7089 649 }
iklam@7089 650 #endif
iklam@7089 651 setup_search_path(sys_class_path);
iklam@7089 652 }
duke@435 653
iklam@7089 654 #if INCLUDE_CDS
iklam@7089 655 int ClassLoader::get_shared_paths_misc_info_size() {
iklam@7089 656 return _shared_paths_misc_info->get_used_bytes();
iklam@7089 657 }
iklam@7089 658
iklam@7089 659 void* ClassLoader::get_shared_paths_misc_info() {
iklam@7089 660 return _shared_paths_misc_info->buffer();
iklam@7089 661 }
iklam@7089 662
iklam@7089 663 bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) {
iklam@7089 664 SharedPathsMiscInfo* checker = SharedClassUtil::allocate_shared_paths_misc_info((char*)buf, size);
iklam@7089 665 bool result = checker->check();
iklam@7089 666 delete checker;
iklam@7089 667 return result;
iklam@7089 668 }
iklam@7089 669 #endif
iklam@7089 670
iklam@7322 671 void ClassLoader::setup_search_path(const char *class_path, bool canonicalize) {
iklam@7089 672 int offset = 0;
iklam@7089 673 int len = (int)strlen(class_path);
duke@435 674 int end = 0;
duke@435 675
duke@435 676 // Iterate over class path entries
duke@435 677 for (int start = 0; start < len; start = end) {
iklam@7089 678 while (class_path[end] && class_path[end] != os::path_separator()[0]) {
duke@435 679 end++;
duke@435 680 }
iklam@7089 681 EXCEPTION_MARK;
iklam@7089 682 ResourceMark rm(THREAD);
iklam@7089 683 char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
iklam@7089 684 strncpy(path, &class_path[start], end - start);
iklam@7089 685 path[end - start] = '\0';
iklam@7322 686 if (canonicalize) {
iklam@7322 687 char* canonical_path = NEW_RESOURCE_ARRAY(char, JVM_MAXPATHLEN + 1);
iklam@7322 688 if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
iklam@7322 689 path = canonical_path;
iklam@7322 690 }
iklam@7322 691 }
iklam@7322 692 update_class_path_entry_list(path, /*check_for_duplicates=*/canonicalize);
iklam@7089 693 #if INCLUDE_CDS
iklam@7089 694 if (DumpSharedSpaces) {
iklam@7089 695 check_shared_classpath(path);
iklam@7089 696 }
iklam@7089 697 #endif
iklam@7089 698 while (class_path[end] == os::path_separator()[0]) {
duke@435 699 end++;
duke@435 700 }
duke@435 701 }
duke@435 702 }
duke@435 703
iklam@7090 704 ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st,
iklam@7089 705 bool lazy, bool throw_exception, TRAPS) {
duke@435 706 JavaThread* thread = JavaThread::current();
duke@435 707 if (lazy) {
iklam@7089 708 return new LazyClassPathEntry(path, st, throw_exception);
duke@435 709 }
ccheung@5603 710 ClassPathEntry* new_entry = NULL;
ccheung@5603 711 if ((st->st_mode & S_IFREG) == S_IFREG) {
duke@435 712 // Regular file, should be a zip file
duke@435 713 // Canonicalized filename
duke@435 714 char canonical_path[JVM_MAXPATHLEN];
duke@435 715 if (!get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
duke@435 716 // This matches the classic VM
iklam@7089 717 if (throw_exception) {
iklam@7089 718 THROW_MSG_(vmSymbols::java_io_IOException(), "Bad pathname", NULL);
iklam@7089 719 } else {
iklam@7089 720 return NULL;
iklam@7089 721 }
duke@435 722 }
duke@435 723 char* error_msg = NULL;
duke@435 724 jzfile* zip;
duke@435 725 {
duke@435 726 // enable call to C land
duke@435 727 ThreadToNativeFromVM ttn(thread);
duke@435 728 HandleMark hm(thread);
duke@435 729 zip = (*ZipOpen)(canonical_path, &error_msg);
duke@435 730 }
duke@435 731 if (zip != NULL && error_msg == NULL) {
ccheung@5603 732 new_entry = new ClassPathZipEntry(zip, path);
iklam@7089 733 if (TraceClassLoading || TraceClassPaths) {
duke@435 734 tty->print_cr("[Opened %s]", path);
duke@435 735 }
duke@435 736 } else {
duke@435 737 ResourceMark rm(thread);
duke@435 738 char *msg;
duke@435 739 if (error_msg == NULL) {
duke@435 740 msg = NEW_RESOURCE_ARRAY(char, strlen(path) + 128); ;
duke@435 741 jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path);
duke@435 742 } else {
duke@435 743 int len = (int)(strlen(path) + strlen(error_msg) + 128);
duke@435 744 msg = NEW_RESOURCE_ARRAY(char, len); ;
duke@435 745 jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
duke@435 746 }
iklam@7089 747 if (throw_exception) {
iklam@7089 748 THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
iklam@7089 749 } else {
iklam@7089 750 return NULL;
iklam@7089 751 }
duke@435 752 }
duke@435 753 } else {
duke@435 754 // Directory
ccheung@5603 755 new_entry = new ClassPathDirEntry(path);
iklam@7089 756 if (TraceClassLoading || TraceClassPaths) {
duke@435 757 tty->print_cr("[Path %s]", path);
duke@435 758 }
duke@435 759 }
ccheung@5603 760 return new_entry;
duke@435 761 }
duke@435 762
duke@435 763
duke@435 764 // Create a class path zip entry for a given path (return NULL if not found
duke@435 765 // or zip/JAR file cannot be opened)
duke@435 766 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
duke@435 767 // check for a regular file
duke@435 768 struct stat st;
duke@435 769 if (os::stat(path, &st) == 0) {
duke@435 770 if ((st.st_mode & S_IFREG) == S_IFREG) {
duke@435 771 char canonical_path[JVM_MAXPATHLEN];
iklam@7090 772 if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
duke@435 773 char* error_msg = NULL;
duke@435 774 jzfile* zip;
duke@435 775 {
duke@435 776 // enable call to C land
duke@435 777 JavaThread* thread = JavaThread::current();
duke@435 778 ThreadToNativeFromVM ttn(thread);
duke@435 779 HandleMark hm(thread);
duke@435 780 zip = (*ZipOpen)(canonical_path, &error_msg);
duke@435 781 }
duke@435 782 if (zip != NULL && error_msg == NULL) {
duke@435 783 // create using canonical path
duke@435 784 return new ClassPathZipEntry(zip, canonical_path);
duke@435 785 }
duke@435 786 }
duke@435 787 }
duke@435 788 }
duke@435 789 return NULL;
duke@435 790 }
duke@435 791
duke@435 792 // returns true if entry already on class path
duke@435 793 bool ClassLoader::contains_entry(ClassPathEntry *entry) {
duke@435 794 ClassPathEntry* e = _first_entry;
duke@435 795 while (e != NULL) {
duke@435 796 // assume zip entries have been canonicalized
duke@435 797 if (strcmp(entry->name(), e->name()) == 0) {
duke@435 798 return true;
duke@435 799 }
duke@435 800 e = e->next();
duke@435 801 }
duke@435 802 return false;
duke@435 803 }
duke@435 804
duke@435 805 void ClassLoader::add_to_list(ClassPathEntry *new_entry) {
duke@435 806 if (new_entry != NULL) {
duke@435 807 if (_last_entry == NULL) {
duke@435 808 _first_entry = _last_entry = new_entry;
duke@435 809 } else {
duke@435 810 _last_entry->set_next(new_entry);
duke@435 811 _last_entry = new_entry;
duke@435 812 }
duke@435 813 }
iklam@7089 814 _num_entries ++;
duke@435 815 }
duke@435 816
iklam@7089 817 // Returns true IFF the file/dir exists and the entry was successfully created.
iklam@7090 818 bool ClassLoader::update_class_path_entry_list(const char *path,
iklam@7089 819 bool check_for_duplicates,
iklam@7089 820 bool throw_exception) {
duke@435 821 struct stat st;
ccheung@5603 822 if (os::stat(path, &st) == 0) {
duke@435 823 // File or directory found
duke@435 824 ClassPathEntry* new_entry = NULL;
ccheung@5603 825 Thread* THREAD = Thread::current();
iklam@7089 826 new_entry = create_class_path_entry(path, &st, LazyBootClassLoader, throw_exception, CHECK_(false));
iklam@7089 827 if (new_entry == NULL) {
iklam@7089 828 return false;
iklam@7089 829 }
duke@435 830 // The kernel VM adds dynamically to the end of the classloader path and
duke@435 831 // doesn't reorder the bootclasspath which would break java.lang.Package
duke@435 832 // (see PackageInfo).
duke@435 833 // Add new entry to linked list
duke@435 834 if (!check_for_duplicates || !contains_entry(new_entry)) {
iklam@7089 835 ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry);
duke@435 836 }
iklam@7089 837 return true;
iklam@7089 838 } else {
iklam@7089 839 #if INCLUDE_CDS
iklam@7089 840 if (DumpSharedSpaces) {
iklam@7089 841 _shared_paths_misc_info->add_nonexist_path(path);
iklam@7089 842 }
iklam@7090 843 #endif
iklam@7089 844 return false;
duke@435 845 }
duke@435 846 }
duke@435 847
duke@435 848 void ClassLoader::print_bootclasspath() {
duke@435 849 ClassPathEntry* e = _first_entry;
duke@435 850 tty->print("[bootclasspath= ");
duke@435 851 while (e != NULL) {
duke@435 852 tty->print("%s ;", e->name());
duke@435 853 e = e->next();
duke@435 854 }
duke@435 855 tty->print_cr("]");
duke@435 856 }
duke@435 857
duke@435 858 void ClassLoader::load_zip_library() {
duke@435 859 assert(ZipOpen == NULL, "should not load zip library twice");
duke@435 860 // First make sure native library is loaded
duke@435 861 os::native_java_library();
duke@435 862 // Load zip library
duke@435 863 char path[JVM_MAXPATHLEN];
duke@435 864 char ebuf[1024];
bpittore@4261 865 void* handle = NULL;
bpittore@4261 866 if (os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip")) {
bpittore@4261 867 handle = os::dll_load(path, ebuf, sizeof ebuf);
bpittore@4261 868 }
duke@435 869 if (handle == NULL) {
duke@435 870 vm_exit_during_initialization("Unable to load ZIP library", path);
duke@435 871 }
duke@435 872 // Lookup zip entry points
ikrylov@2322 873 ZipOpen = CAST_TO_FN_PTR(ZipOpen_t, os::dll_lookup(handle, "ZIP_Open"));
ikrylov@2322 874 ZipClose = CAST_TO_FN_PTR(ZipClose_t, os::dll_lookup(handle, "ZIP_Close"));
ikrylov@2322 875 FindEntry = CAST_TO_FN_PTR(FindEntry_t, os::dll_lookup(handle, "ZIP_FindEntry"));
ikrylov@2322 876 ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry"));
ikrylov@2322 877 ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, os::dll_lookup(handle, "ZIP_ReadMappedEntry"));
ikrylov@2322 878 GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry"));
jiangli@6868 879 Crc32 = CAST_TO_FN_PTR(Crc32_t, os::dll_lookup(handle, "ZIP_CRC32"));
duke@435 880
duke@435 881 // ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL
jiangli@6868 882 if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL ||
jiangli@6868 883 GetNextEntry == NULL || Crc32 == NULL) {
duke@435 884 vm_exit_during_initialization("Corrupted ZIP library", path);
duke@435 885 }
duke@435 886
duke@435 887 // Lookup canonicalize entry in libjava.dll
duke@435 888 void *javalib_handle = os::native_java_library();
ikrylov@2322 889 CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, os::dll_lookup(javalib_handle, "Canonicalize"));
duke@435 890 // This lookup only works on 1.3. Do not check for non-null here
duke@435 891 }
duke@435 892
jiangli@6868 893 int ClassLoader::crc32(int crc, const char* buf, int len) {
jiangli@6868 894 assert(Crc32 != NULL, "ZIP_CRC32 is not found");
jiangli@6868 895 return (*Crc32)(crc, (const jbyte*)buf, len);
jiangli@6868 896 }
jiangli@6868 897
duke@435 898 // PackageInfo data exists in order to support the java.lang.Package
duke@435 899 // class. A Package object provides information about a java package
duke@435 900 // (version, vendor, etc.) which originates in the manifest of the jar
duke@435 901 // file supplying the package. For application classes, the ClassLoader
duke@435 902 // object takes care of this.
duke@435 903
duke@435 904 // For system (boot) classes, the Java code in the Package class needs
duke@435 905 // to be able to identify which source jar file contained the boot
duke@435 906 // class, so that it can extract the manifest from it. This table
duke@435 907 // identifies java packages with jar files in the boot classpath.
duke@435 908
duke@435 909 // Because the boot classpath cannot change, the classpath index is
duke@435 910 // sufficient to identify the source jar file or directory. (Since
duke@435 911 // directories have no manifests, the directory name is not required,
duke@435 912 // but is available.)
duke@435 913
duke@435 914 // When using sharing -- the pathnames of entries in the boot classpath
duke@435 915 // may not be the same at runtime as they were when the archive was
duke@435 916 // created (NFS, Samba, etc.). The actual files and directories named
duke@435 917 // in the classpath must be the same files, in the same order, even
duke@435 918 // though the exact name is not the same.
duke@435 919
zgu@3900 920 class PackageInfo: public BasicHashtableEntry<mtClass> {
duke@435 921 public:
duke@435 922 const char* _pkgname; // Package name
duke@435 923 int _classpath_index; // Index of directory or JAR file loaded from
duke@435 924
duke@435 925 PackageInfo* next() {
zgu@3900 926 return (PackageInfo*)BasicHashtableEntry<mtClass>::next();
duke@435 927 }
duke@435 928
duke@435 929 const char* pkgname() { return _pkgname; }
duke@435 930 void set_pkgname(char* pkgname) { _pkgname = pkgname; }
duke@435 931
duke@435 932 const char* filename() {
duke@435 933 return ClassLoader::classpath_entry(_classpath_index)->name();
duke@435 934 }
duke@435 935
duke@435 936 void set_index(int index) {
duke@435 937 _classpath_index = index;
duke@435 938 }
duke@435 939 };
duke@435 940
duke@435 941
zgu@3900 942 class PackageHashtable : public BasicHashtable<mtClass> {
duke@435 943 private:
duke@435 944 inline unsigned int compute_hash(const char *s, int n) {
duke@435 945 unsigned int val = 0;
duke@435 946 while (--n >= 0) {
duke@435 947 val = *s++ + 31 * val;
duke@435 948 }
duke@435 949 return val;
duke@435 950 }
duke@435 951
duke@435 952 PackageInfo* bucket(int index) {
zgu@3900 953 return (PackageInfo*)BasicHashtable<mtClass>::bucket(index);
duke@435 954 }
duke@435 955
duke@435 956 PackageInfo* get_entry(int index, unsigned int hash,
duke@435 957 const char* pkgname, size_t n) {
duke@435 958 for (PackageInfo* pp = bucket(index); pp != NULL; pp = pp->next()) {
duke@435 959 if (pp->hash() == hash &&
duke@435 960 strncmp(pkgname, pp->pkgname(), n) == 0 &&
duke@435 961 pp->pkgname()[n] == '\0') {
duke@435 962 return pp;
duke@435 963 }
duke@435 964 }
duke@435 965 return NULL;
duke@435 966 }
duke@435 967
duke@435 968 public:
duke@435 969 PackageHashtable(int table_size)
zgu@3900 970 : BasicHashtable<mtClass>(table_size, sizeof(PackageInfo)) {}
duke@435 971
zgu@3900 972 PackageHashtable(int table_size, HashtableBucket<mtClass>* t, int number_of_entries)
zgu@3900 973 : BasicHashtable<mtClass>(table_size, sizeof(PackageInfo), t, number_of_entries) {}
duke@435 974
duke@435 975 PackageInfo* get_entry(const char* pkgname, int n) {
duke@435 976 unsigned int hash = compute_hash(pkgname, n);
duke@435 977 return get_entry(hash_to_index(hash), hash, pkgname, n);
duke@435 978 }
duke@435 979
duke@435 980 PackageInfo* new_entry(char* pkgname, int n) {
duke@435 981 unsigned int hash = compute_hash(pkgname, n);
duke@435 982 PackageInfo* pp;
zgu@3900 983 pp = (PackageInfo*)BasicHashtable<mtClass>::new_entry(hash);
duke@435 984 pp->set_pkgname(pkgname);
duke@435 985 return pp;
duke@435 986 }
duke@435 987
duke@435 988 void add_entry(PackageInfo* pp) {
duke@435 989 int index = hash_to_index(pp->hash());
zgu@3900 990 BasicHashtable<mtClass>::add_entry(index, pp);
duke@435 991 }
duke@435 992
duke@435 993 void copy_pkgnames(const char** packages) {
duke@435 994 int n = 0;
duke@435 995 for (int i = 0; i < table_size(); ++i) {
duke@435 996 for (PackageInfo* pp = bucket(i); pp != NULL; pp = pp->next()) {
duke@435 997 packages[n++] = pp->pkgname();
duke@435 998 }
duke@435 999 }
duke@435 1000 assert(n == number_of_entries(), "just checking");
duke@435 1001 }
duke@435 1002
iklam@7089 1003 CDS_ONLY(void copy_table(char** top, char* end, PackageHashtable* table);)
duke@435 1004 };
duke@435 1005
iklam@7089 1006 #if INCLUDE_CDS
duke@435 1007 void PackageHashtable::copy_table(char** top, char* end,
duke@435 1008 PackageHashtable* table) {
duke@435 1009 // Copy (relocate) the table to the shared space.
zgu@3900 1010 BasicHashtable<mtClass>::copy_table(top, end);
duke@435 1011
duke@435 1012 // Calculate the space needed for the package name strings.
duke@435 1013 int i;
iklam@7089 1014 intptr_t* tableSize = (intptr_t*)(*top);
iklam@7089 1015 *top += sizeof(intptr_t); // For table size
iklam@7089 1016 char* tableStart = *top;
duke@435 1017
duke@435 1018 for (i = 0; i < table_size(); ++i) {
duke@435 1019 for (PackageInfo* pp = table->bucket(i);
duke@435 1020 pp != NULL;
duke@435 1021 pp = pp->next()) {
duke@435 1022 int n1 = (int)(strlen(pp->pkgname()) + 1);
iklam@7089 1023 if (*top + n1 >= end) {
iklam@7089 1024 report_out_of_shared_space(SharedMiscData);
iklam@7089 1025 }
duke@435 1026 pp->set_pkgname((char*)memcpy(*top, pp->pkgname(), n1));
duke@435 1027 *top += n1;
duke@435 1028 }
duke@435 1029 }
duke@435 1030 *top = (char*)align_size_up((intptr_t)*top, sizeof(HeapWord));
iklam@7089 1031 if (*top >= end) {
iklam@7089 1032 report_out_of_shared_space(SharedMiscData);
iklam@7089 1033 }
iklam@7089 1034
iklam@7089 1035 // Write table size
iklam@7089 1036 intptr_t len = *top - (char*)tableStart;
iklam@7089 1037 *tableSize = len;
duke@435 1038 }
duke@435 1039
duke@435 1040
duke@435 1041 void ClassLoader::copy_package_info_buckets(char** top, char* end) {
duke@435 1042 _package_hash_table->copy_buckets(top, end);
duke@435 1043 }
duke@435 1044
duke@435 1045 void ClassLoader::copy_package_info_table(char** top, char* end) {
duke@435 1046 _package_hash_table->copy_table(top, end, _package_hash_table);
duke@435 1047 }
iklam@7089 1048 #endif
duke@435 1049
duke@435 1050 PackageInfo* ClassLoader::lookup_package(const char *pkgname) {
duke@435 1051 const char *cp = strrchr(pkgname, '/');
duke@435 1052 if (cp != NULL) {
duke@435 1053 // Package prefix found
duke@435 1054 int n = cp - pkgname + 1;
duke@435 1055 return _package_hash_table->get_entry(pkgname, n);
duke@435 1056 }
duke@435 1057 return NULL;
duke@435 1058 }
duke@435 1059
duke@435 1060
duke@435 1061 bool ClassLoader::add_package(const char *pkgname, int classpath_index, TRAPS) {
duke@435 1062 assert(pkgname != NULL, "just checking");
duke@435 1063 // Bootstrap loader no longer holds system loader lock obj serializing
duke@435 1064 // load_instance_class and thereby add_package
duke@435 1065 {
duke@435 1066 MutexLocker ml(PackageTable_lock, THREAD);
duke@435 1067 // First check for previously loaded entry
duke@435 1068 PackageInfo* pp = lookup_package(pkgname);
duke@435 1069 if (pp != NULL) {
duke@435 1070 // Existing entry found, check source of package
duke@435 1071 pp->set_index(classpath_index);
duke@435 1072 return true;
duke@435 1073 }
duke@435 1074
duke@435 1075 const char *cp = strrchr(pkgname, '/');
duke@435 1076 if (cp != NULL) {
duke@435 1077 // Package prefix found
duke@435 1078 int n = cp - pkgname + 1;
duke@435 1079
zgu@3900 1080 char* new_pkgname = NEW_C_HEAP_ARRAY(char, n + 1, mtClass);
duke@435 1081 if (new_pkgname == NULL) {
duke@435 1082 return false;
duke@435 1083 }
duke@435 1084
duke@435 1085 memcpy(new_pkgname, pkgname, n);
duke@435 1086 new_pkgname[n] = '\0';
duke@435 1087 pp = _package_hash_table->new_entry(new_pkgname, n);
duke@435 1088 pp->set_index(classpath_index);
duke@435 1089
duke@435 1090 // Insert into hash table
duke@435 1091 _package_hash_table->add_entry(pp);
duke@435 1092 }
duke@435 1093 return true;
duke@435 1094 }
duke@435 1095 }
duke@435 1096
duke@435 1097
duke@435 1098 oop ClassLoader::get_system_package(const char* name, TRAPS) {
duke@435 1099 PackageInfo* pp;
duke@435 1100 {
duke@435 1101 MutexLocker ml(PackageTable_lock, THREAD);
duke@435 1102 pp = lookup_package(name);
duke@435 1103 }
duke@435 1104 if (pp == NULL) {
duke@435 1105 return NULL;
duke@435 1106 } else {
duke@435 1107 Handle p = java_lang_String::create_from_str(pp->filename(), THREAD);
duke@435 1108 return p();
duke@435 1109 }
duke@435 1110 }
duke@435 1111
duke@435 1112
duke@435 1113 objArrayOop ClassLoader::get_system_packages(TRAPS) {
duke@435 1114 ResourceMark rm(THREAD);
duke@435 1115 int nof_entries;
duke@435 1116 const char** packages;
duke@435 1117 {
duke@435 1118 MutexLocker ml(PackageTable_lock, THREAD);
duke@435 1119 // Allocate resource char* array containing package names
duke@435 1120 nof_entries = _package_hash_table->number_of_entries();
duke@435 1121 if ((packages = NEW_RESOURCE_ARRAY(const char*, nof_entries)) == NULL) {
duke@435 1122 return NULL;
duke@435 1123 }
duke@435 1124 _package_hash_table->copy_pkgnames(packages);
duke@435 1125 }
duke@435 1126 // Allocate objArray and fill with java.lang.String
never@1577 1127 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(),
duke@435 1128 nof_entries, CHECK_0);
duke@435 1129 objArrayHandle result(THREAD, r);
duke@435 1130 for (int i = 0; i < nof_entries; i++) {
duke@435 1131 Handle str = java_lang_String::create_from_str(packages[i], CHECK_0);
duke@435 1132 result->obj_at_put(i, str());
duke@435 1133 }
duke@435 1134
duke@435 1135 return result();
duke@435 1136 }
duke@435 1137
duke@435 1138
coleenp@2497 1139 instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, TRAPS) {
duke@435 1140 ResourceMark rm(THREAD);
iklam@7089 1141 const char* class_name = h_name->as_C_string();
iklam@7089 1142 EventMark m("loading class %s", class_name);
duke@435 1143 ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion);
duke@435 1144
duke@435 1145 stringStream st;
duke@435 1146 // st.print() uses too much stack space while handling a StackOverflowError
duke@435 1147 // st.print("%s.class", h_name->as_utf8());
duke@435 1148 st.print_raw(h_name->as_utf8());
duke@435 1149 st.print_raw(".class");
iklam@7089 1150 const char* file_name = st.as_string();
iklam@7089 1151 ClassLoaderExt::Context context(class_name, file_name, THREAD);
duke@435 1152
duke@435 1153 // Lookup stream for parsing .class file
duke@435 1154 ClassFileStream* stream = NULL;
duke@435 1155 int classpath_index = 0;
iklam@7089 1156 ClassPathEntry* e = NULL;
iklam@7089 1157 instanceKlassHandle h;
duke@435 1158 {
mchung@1310 1159 PerfClassTraceTime vmtimer(perf_sys_class_lookup_time(),
mchung@1310 1160 ((JavaThread*) THREAD)->get_thread_stat()->perf_timers_addr(),
mchung@1310 1161 PerfClassTraceTime::CLASS_LOAD);
iklam@7089 1162 e = _first_entry;
duke@435 1163 while (e != NULL) {
iklam@7089 1164 stream = e->open_stream(file_name, CHECK_NULL);
iklam@7089 1165 if (!context.check(stream, classpath_index)) {
iklam@7089 1166 return h; // NULL
iklam@7089 1167 }
duke@435 1168 if (stream != NULL) {
duke@435 1169 break;
duke@435 1170 }
duke@435 1171 e = e->next();
duke@435 1172 ++classpath_index;
duke@435 1173 }
duke@435 1174 }
duke@435 1175
duke@435 1176 if (stream != NULL) {
duke@435 1177 // class file found, parse it
duke@435 1178 ClassFileParser parser(stream);
coleenp@4304 1179 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
duke@435 1180 Handle protection_domain;
coleenp@2497 1181 TempNewSymbol parsed_name = NULL;
duke@435 1182 instanceKlassHandle result = parser.parseClassFile(h_name,
coleenp@4304 1183 loader_data,
duke@435 1184 protection_domain,
duke@435 1185 parsed_name,
iklam@7089 1186 context.should_verify(classpath_index),
iklam@7089 1187 THREAD);
iklam@7089 1188 if (HAS_PENDING_EXCEPTION) {
iklam@7089 1189 ResourceMark rm;
iklam@7089 1190 if (DumpSharedSpaces) {
iklam@7089 1191 tty->print_cr("Preload Error: Failed to load %s", class_name);
iklam@7089 1192 }
iklam@7089 1193 return h;
iklam@7089 1194 }
apetushkov@9858 1195
apetushkov@9858 1196 #if INCLUDE_JFR
apetushkov@9858 1197 {
apetushkov@9858 1198 InstanceKlass* ik = result();
apetushkov@9858 1199 ON_KLASS_CREATION(ik, parser, THREAD);
apetushkov@9858 1200 result = instanceKlassHandle(ik);
apetushkov@9858 1201 }
apetushkov@9858 1202 #endif
apetushkov@9858 1203
iklam@7089 1204 h = context.record_result(classpath_index, e, result, THREAD);
iklam@7089 1205 } else {
iklam@7089 1206 if (DumpSharedSpaces) {
jiangli@7363 1207 tty->print_cr("Preload Warning: Cannot find %s", class_name);
duke@435 1208 }
duke@435 1209 }
duke@435 1210
duke@435 1211 return h;
duke@435 1212 }
duke@435 1213
duke@435 1214
zgu@3900 1215 void ClassLoader::create_package_info_table(HashtableBucket<mtClass> *t, int length,
duke@435 1216 int number_of_entries) {
duke@435 1217 assert(_package_hash_table == NULL, "One package info table allowed.");
zgu@3900 1218 assert(length == package_hash_table_size * sizeof(HashtableBucket<mtClass>),
duke@435 1219 "bad shared package info size.");
duke@435 1220 _package_hash_table = new PackageHashtable(package_hash_table_size, t,
duke@435 1221 number_of_entries);
duke@435 1222 }
duke@435 1223
duke@435 1224
duke@435 1225 void ClassLoader::create_package_info_table() {
duke@435 1226 assert(_package_hash_table == NULL, "shouldn't have one yet");
duke@435 1227 _package_hash_table = new PackageHashtable(package_hash_table_size);
duke@435 1228 }
duke@435 1229
duke@435 1230
duke@435 1231 // Initialize the class loader's access to methods in libzip. Parse and
duke@435 1232 // process the boot classpath into a list ClassPathEntry objects. Once
duke@435 1233 // this list has been created, it must not change order (see class PackageInfo)
duke@435 1234 // it can be appended to and is by jvmti and the kernel vm.
duke@435 1235
duke@435 1236 void ClassLoader::initialize() {
duke@435 1237 assert(_package_hash_table == NULL, "should have been initialized by now.");
duke@435 1238 EXCEPTION_MARK;
duke@435 1239
duke@435 1240 if (UsePerfData) {
duke@435 1241 // jvmstat performance counters
duke@435 1242 NEWPERFTICKCOUNTER(_perf_accumulated_time, SUN_CLS, "time");
duke@435 1243 NEWPERFTICKCOUNTER(_perf_class_init_time, SUN_CLS, "classInitTime");
mchung@1310 1244 NEWPERFTICKCOUNTER(_perf_class_init_selftime, SUN_CLS, "classInitTime.self");
duke@435 1245 NEWPERFTICKCOUNTER(_perf_class_verify_time, SUN_CLS, "classVerifyTime");
mchung@1310 1246 NEWPERFTICKCOUNTER(_perf_class_verify_selftime, SUN_CLS, "classVerifyTime.self");
duke@435 1247 NEWPERFTICKCOUNTER(_perf_class_link_time, SUN_CLS, "classLinkedTime");
mchung@1310 1248 NEWPERFTICKCOUNTER(_perf_class_link_selftime, SUN_CLS, "classLinkedTime.self");
duke@435 1249 NEWPERFEVENTCOUNTER(_perf_classes_inited, SUN_CLS, "initializedClasses");
duke@435 1250 NEWPERFEVENTCOUNTER(_perf_classes_linked, SUN_CLS, "linkedClasses");
mchung@1310 1251 NEWPERFEVENTCOUNTER(_perf_classes_verified, SUN_CLS, "verifiedClasses");
mchung@1310 1252
mchung@1310 1253 NEWPERFTICKCOUNTER(_perf_class_parse_time, SUN_CLS, "parseClassTime");
mchung@1310 1254 NEWPERFTICKCOUNTER(_perf_class_parse_selftime, SUN_CLS, "parseClassTime.self");
mchung@1310 1255 NEWPERFTICKCOUNTER(_perf_sys_class_lookup_time, SUN_CLS, "lookupSysClassTime");
mchung@1310 1256 NEWPERFTICKCOUNTER(_perf_shared_classload_time, SUN_CLS, "sharedClassLoadTime");
mchung@1310 1257 NEWPERFTICKCOUNTER(_perf_sys_classload_time, SUN_CLS, "sysClassLoadTime");
mchung@1310 1258 NEWPERFTICKCOUNTER(_perf_app_classload_time, SUN_CLS, "appClassLoadTime");
mchung@1310 1259 NEWPERFTICKCOUNTER(_perf_app_classload_selftime, SUN_CLS, "appClassLoadTime.self");
mchung@1310 1260 NEWPERFEVENTCOUNTER(_perf_app_classload_count, SUN_CLS, "appClassLoadCount");
mchung@1310 1261 NEWPERFTICKCOUNTER(_perf_define_appclasses, SUN_CLS, "defineAppClasses");
mchung@1310 1262 NEWPERFTICKCOUNTER(_perf_define_appclass_time, SUN_CLS, "defineAppClassTime");
mchung@1310 1263 NEWPERFTICKCOUNTER(_perf_define_appclass_selftime, SUN_CLS, "defineAppClassTime.self");
mchung@1310 1264 NEWPERFBYTECOUNTER(_perf_app_classfile_bytes_read, SUN_CLS, "appClassBytes");
mchung@1310 1265 NEWPERFBYTECOUNTER(_perf_sys_classfile_bytes_read, SUN_CLS, "sysClassBytes");
mchung@1310 1266
duke@435 1267
duke@435 1268 // The following performance counters are added for measuring the impact
duke@435 1269 // of the bug fix of 6365597. They are mainly focused on finding out
duke@435 1270 // the behavior of system & user-defined classloader lock, whether
duke@435 1271 // ClassLoader.loadClass/findClass is being called synchronized or not.
duke@435 1272 // Also two additional counters are created to see whether 'UnsyncloadClass'
duke@435 1273 // flag is being set or not and how many times load_instance_class call
duke@435 1274 // fails with linkageError etc.
duke@435 1275 NEWPERFEVENTCOUNTER(_sync_systemLoaderLockContentionRate, SUN_CLS,
duke@435 1276 "systemLoaderLockContentionRate");
duke@435 1277 NEWPERFEVENTCOUNTER(_sync_nonSystemLoaderLockContentionRate, SUN_CLS,
duke@435 1278 "nonSystemLoaderLockContentionRate");
duke@435 1279 NEWPERFEVENTCOUNTER(_sync_JVMFindLoadedClassLockFreeCounter, SUN_CLS,
duke@435 1280 "jvmFindLoadedClassNoLockCalls");
duke@435 1281 NEWPERFEVENTCOUNTER(_sync_JVMDefineClassLockFreeCounter, SUN_CLS,
duke@435 1282 "jvmDefineClassNoLockCalls");
duke@435 1283
duke@435 1284 NEWPERFEVENTCOUNTER(_sync_JNIDefineClassLockFreeCounter, SUN_CLS,
duke@435 1285 "jniDefineClassNoLockCalls");
duke@435 1286
duke@435 1287 NEWPERFEVENTCOUNTER(_unsafe_defineClassCallCounter, SUN_CLS,
duke@435 1288 "unsafeDefineClassCalls");
duke@435 1289
duke@435 1290 NEWPERFEVENTCOUNTER(_isUnsyncloadClass, SUN_CLS, "isUnsyncloadClassSet");
duke@435 1291 NEWPERFEVENTCOUNTER(_load_instance_class_failCounter, SUN_CLS,
duke@435 1292 "loadInstanceClassFailRate");
duke@435 1293
duke@435 1294 // increment the isUnsyncloadClass counter if UnsyncloadClass is set.
duke@435 1295 if (UnsyncloadClass) {
duke@435 1296 _isUnsyncloadClass->inc();
duke@435 1297 }
duke@435 1298 }
duke@435 1299
duke@435 1300 // lookup zip library entry points
duke@435 1301 load_zip_library();
iklam@7089 1302 #if INCLUDE_CDS
duke@435 1303 // initialize search path
iklam@7089 1304 if (DumpSharedSpaces) {
iklam@7089 1305 _shared_paths_misc_info = SharedClassUtil::allocate_shared_paths_misc_info();
iklam@7089 1306 }
iklam@7089 1307 #endif
duke@435 1308 setup_bootstrap_search_path();
duke@435 1309 if (LazyBootClassLoader) {
duke@435 1310 // set up meta index which makes boot classpath initialization lazier
iklam@7089 1311 setup_bootstrap_meta_index();
duke@435 1312 }
duke@435 1313 }
duke@435 1314
iklam@7089 1315 #if INCLUDE_CDS
iklam@7089 1316 void ClassLoader::initialize_shared_path() {
iklam@7089 1317 if (DumpSharedSpaces) {
iklam@7089 1318 ClassLoaderExt::setup_search_paths();
iklam@7089 1319 _shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check()
iklam@7089 1320 }
iklam@7089 1321 }
iklam@7089 1322 #endif
duke@435 1323
duke@435 1324 jlong ClassLoader::classloader_time_ms() {
duke@435 1325 return UsePerfData ?
duke@435 1326 Management::ticks_to_ms(_perf_accumulated_time->get_value()) : -1;
duke@435 1327 }
duke@435 1328
duke@435 1329 jlong ClassLoader::class_init_count() {
duke@435 1330 return UsePerfData ? _perf_classes_inited->get_value() : -1;
duke@435 1331 }
duke@435 1332
duke@435 1333 jlong ClassLoader::class_init_time_ms() {
duke@435 1334 return UsePerfData ?
duke@435 1335 Management::ticks_to_ms(_perf_class_init_time->get_value()) : -1;
duke@435 1336 }
duke@435 1337
duke@435 1338 jlong ClassLoader::class_verify_time_ms() {
duke@435 1339 return UsePerfData ?
duke@435 1340 Management::ticks_to_ms(_perf_class_verify_time->get_value()) : -1;
duke@435 1341 }
duke@435 1342
duke@435 1343 jlong ClassLoader::class_link_count() {
duke@435 1344 return UsePerfData ? _perf_classes_linked->get_value() : -1;
duke@435 1345 }
duke@435 1346
duke@435 1347 jlong ClassLoader::class_link_time_ms() {
duke@435 1348 return UsePerfData ?
duke@435 1349 Management::ticks_to_ms(_perf_class_link_time->get_value()) : -1;
duke@435 1350 }
duke@435 1351
duke@435 1352 int ClassLoader::compute_Object_vtable() {
duke@435 1353 // hardwired for JDK1.2 -- would need to duplicate class file parsing
duke@435 1354 // code to determine actual value from file
duke@435 1355 // Would be value '11' if finals were in vtable
duke@435 1356 int JDK_1_2_Object_vtable_size = 5;
duke@435 1357 return JDK_1_2_Object_vtable_size * vtableEntry::size();
duke@435 1358 }
duke@435 1359
duke@435 1360
duke@435 1361 void classLoader_init() {
duke@435 1362 ClassLoader::initialize();
duke@435 1363 }
duke@435 1364
duke@435 1365
iklam@7090 1366 bool ClassLoader::get_canonical_path(const char* orig, char* out, int len) {
duke@435 1367 assert(orig != NULL && out != NULL && len > 0, "bad arguments");
duke@435 1368 if (CanonicalizeEntry != NULL) {
iklam@7090 1369 JavaThread* THREAD = JavaThread::current();
iklam@7090 1370 JNIEnv* env = THREAD->jni_environment();
iklam@7090 1371 ResourceMark rm(THREAD);
iklam@7090 1372
iklam@7090 1373 // os::native_path writes into orig_copy
iklam@7090 1374 char* orig_copy = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(orig)+1);
iklam@7090 1375 strcpy(orig_copy, orig);
iklam@7090 1376 if ((CanonicalizeEntry)(env, os::native_path(orig_copy), out, len) < 0) {
duke@435 1377 return false;
duke@435 1378 }
duke@435 1379 } else {
duke@435 1380 // On JDK 1.2.2 the Canonicalize does not exist, so just do nothing
duke@435 1381 strncpy(out, orig, len);
duke@435 1382 out[len - 1] = '\0';
duke@435 1383 }
duke@435 1384 return true;
duke@435 1385 }
duke@435 1386
duke@435 1387 #ifndef PRODUCT
duke@435 1388
duke@435 1389 void ClassLoader::verify() {
duke@435 1390 _package_hash_table->verify();
duke@435 1391 }
duke@435 1392
duke@435 1393
duke@435 1394 // CompileTheWorld
duke@435 1395 //
duke@435 1396 // Iterates over all class path entries and forces compilation of all methods
duke@435 1397 // in all classes found. Currently, only zip/jar archives are searched.
duke@435 1398 //
duke@435 1399 // The classes are loaded by the Java level bootstrap class loader, and the
duke@435 1400 // initializer is called. If DelayCompilationDuringStartup is true (default),
duke@435 1401 // the interpreter will run the initialization code. Note that forcing
duke@435 1402 // initialization in this way could potentially lead to initialization order
duke@435 1403 // problems, in which case we could just force the initialization bit to be set.
duke@435 1404
duke@435 1405
duke@435 1406 // We need to iterate over the contents of a zip/jar file, so we replicate the
duke@435 1407 // jzcell and jzfile definitions from zip_util.h but rename jzfile to real_jzfile,
duke@435 1408 // since jzfile already has a void* definition.
duke@435 1409 //
duke@435 1410 // Note that this is only used in debug mode.
duke@435 1411 //
duke@435 1412 // HotSpot integration note:
duke@435 1413 // Matches zip_util.h 1.14 99/06/01 from jdk1.3 beta H build
duke@435 1414
duke@435 1415
duke@435 1416 // JDK 1.3 version
duke@435 1417 typedef struct real_jzentry13 { /* Zip file entry */
duke@435 1418 char *name; /* entry name */
duke@435 1419 jint time; /* modification time */
duke@435 1420 jint size; /* size of uncompressed data */
duke@435 1421 jint csize; /* size of compressed data (zero if uncompressed) */
duke@435 1422 jint crc; /* crc of uncompressed data */
duke@435 1423 char *comment; /* optional zip file comment */
duke@435 1424 jbyte *extra; /* optional extra data */
duke@435 1425 jint pos; /* position of LOC header (if negative) or data */
duke@435 1426 } real_jzentry13;
duke@435 1427
duke@435 1428 typedef struct real_jzfile13 { /* Zip file */
duke@435 1429 char *name; /* zip file name */
duke@435 1430 jint refs; /* number of active references */
duke@435 1431 jint fd; /* open file descriptor */
duke@435 1432 void *lock; /* read lock */
duke@435 1433 char *comment; /* zip file comment */
duke@435 1434 char *msg; /* zip error message */
duke@435 1435 void *entries; /* array of hash cells */
duke@435 1436 jint total; /* total number of entries */
duke@435 1437 unsigned short *table; /* Hash chain heads: indexes into entries */
duke@435 1438 jint tablelen; /* number of hash eads */
duke@435 1439 real_jzfile13 *next; /* next zip file in search list */
duke@435 1440 jzentry *cache; /* we cache the most recently freed jzentry */
duke@435 1441 /* Information on metadata names in META-INF directory */
duke@435 1442 char **metanames; /* array of meta names (may have null names) */
duke@435 1443 jint metacount; /* number of slots in metanames array */
duke@435 1444 /* If there are any per-entry comments, they are in the comments array */
duke@435 1445 char **comments;
duke@435 1446 } real_jzfile13;
duke@435 1447
duke@435 1448 // JDK 1.2 version
duke@435 1449 typedef struct real_jzentry12 { /* Zip file entry */
duke@435 1450 char *name; /* entry name */
duke@435 1451 jint time; /* modification time */
duke@435 1452 jint size; /* size of uncompressed data */
duke@435 1453 jint csize; /* size of compressed data (zero if uncompressed) */
duke@435 1454 jint crc; /* crc of uncompressed data */
duke@435 1455 char *comment; /* optional zip file comment */
duke@435 1456 jbyte *extra; /* optional extra data */
duke@435 1457 jint pos; /* position of LOC header (if negative) or data */
duke@435 1458 struct real_jzentry12 *next; /* next entry in hash table */
duke@435 1459 } real_jzentry12;
duke@435 1460
duke@435 1461 typedef struct real_jzfile12 { /* Zip file */
duke@435 1462 char *name; /* zip file name */
duke@435 1463 jint refs; /* number of active references */
duke@435 1464 jint fd; /* open file descriptor */
duke@435 1465 void *lock; /* read lock */
duke@435 1466 char *comment; /* zip file comment */
duke@435 1467 char *msg; /* zip error message */
duke@435 1468 real_jzentry12 *entries; /* array of zip entries */
duke@435 1469 jint total; /* total number of entries */
duke@435 1470 real_jzentry12 **table; /* hash table of entries */
duke@435 1471 jint tablelen; /* number of buckets */
duke@435 1472 jzfile *next; /* next zip file in search list */
duke@435 1473 } real_jzfile12;
duke@435 1474
duke@435 1475
duke@435 1476 void ClassPathDirEntry::compile_the_world(Handle loader, TRAPS) {
duke@435 1477 // For now we only compile all methods in all classes in zip/jar files
duke@435 1478 tty->print_cr("CompileTheWorld : Skipped classes in %s", _dir);
duke@435 1479 tty->cr();
duke@435 1480 }
duke@435 1481
duke@435 1482
duke@435 1483 bool ClassPathDirEntry::is_rt_jar() {
duke@435 1484 return false;
duke@435 1485 }
duke@435 1486
duke@435 1487 void ClassPathZipEntry::compile_the_world(Handle loader, TRAPS) {
duke@435 1488 if (JDK_Version::is_jdk12x_version()) {
duke@435 1489 compile_the_world12(loader, THREAD);
duke@435 1490 } else {
duke@435 1491 compile_the_world13(loader, THREAD);
duke@435 1492 }
duke@435 1493 if (HAS_PENDING_EXCEPTION) {
duke@435 1494 if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
duke@435 1495 CLEAR_PENDING_EXCEPTION;
duke@435 1496 tty->print_cr("\nCompileTheWorld : Ran out of memory\n");
coleenp@4037 1497 tty->print_cr("Increase class metadata storage if a limit was set");
duke@435 1498 } else {
duke@435 1499 tty->print_cr("\nCompileTheWorld : Unexpected exception occurred\n");
duke@435 1500 }
duke@435 1501 }
duke@435 1502 }
duke@435 1503
duke@435 1504 // Version that works for JDK 1.3.x
duke@435 1505 void ClassPathZipEntry::compile_the_world13(Handle loader, TRAPS) {
duke@435 1506 real_jzfile13* zip = (real_jzfile13*) _zip;
duke@435 1507 tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name);
duke@435 1508 tty->cr();
duke@435 1509 // Iterate over all entries in zip file
duke@435 1510 for (int n = 0; ; n++) {
duke@435 1511 real_jzentry13 * ze = (real_jzentry13 *)((*GetNextEntry)(_zip, n));
duke@435 1512 if (ze == NULL) break;
duke@435 1513 ClassLoader::compile_the_world_in(ze->name, loader, CHECK);
duke@435 1514 }
duke@435 1515 }
duke@435 1516
duke@435 1517
duke@435 1518 // Version that works for JDK 1.2.x
duke@435 1519 void ClassPathZipEntry::compile_the_world12(Handle loader, TRAPS) {
duke@435 1520 real_jzfile12* zip = (real_jzfile12*) _zip;
duke@435 1521 tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name);
duke@435 1522 tty->cr();
duke@435 1523 // Iterate over all entries in zip file
duke@435 1524 for (int n = 0; ; n++) {
duke@435 1525 real_jzentry12 * ze = (real_jzentry12 *)((*GetNextEntry)(_zip, n));
duke@435 1526 if (ze == NULL) break;
duke@435 1527 ClassLoader::compile_the_world_in(ze->name, loader, CHECK);
duke@435 1528 }
duke@435 1529 }
duke@435 1530
duke@435 1531 bool ClassPathZipEntry::is_rt_jar() {
duke@435 1532 if (JDK_Version::is_jdk12x_version()) {
duke@435 1533 return is_rt_jar12();
duke@435 1534 } else {
duke@435 1535 return is_rt_jar13();
duke@435 1536 }
duke@435 1537 }
duke@435 1538
duke@435 1539 // JDK 1.3 version
duke@435 1540 bool ClassPathZipEntry::is_rt_jar13() {
duke@435 1541 real_jzfile13* zip = (real_jzfile13*) _zip;
duke@435 1542 int len = (int)strlen(zip->name);
duke@435 1543 // Check whether zip name ends in "rt.jar"
duke@435 1544 // This will match other archives named rt.jar as well, but this is
duke@435 1545 // only used for debugging.
duke@435 1546 return (len >= 6) && (strcasecmp(zip->name + len - 6, "rt.jar") == 0);
duke@435 1547 }
duke@435 1548
duke@435 1549 // JDK 1.2 version
duke@435 1550 bool ClassPathZipEntry::is_rt_jar12() {
duke@435 1551 real_jzfile12* zip = (real_jzfile12*) _zip;
duke@435 1552 int len = (int)strlen(zip->name);
duke@435 1553 // Check whether zip name ends in "rt.jar"
duke@435 1554 // This will match other archives named rt.jar as well, but this is
duke@435 1555 // only used for debugging.
duke@435 1556 return (len >= 6) && (strcasecmp(zip->name + len - 6, "rt.jar") == 0);
duke@435 1557 }
duke@435 1558
duke@435 1559 void LazyClassPathEntry::compile_the_world(Handle loader, TRAPS) {
ccheung@5603 1560 ClassPathEntry* cpe = resolve_entry(THREAD);
ccheung@5603 1561 if (cpe != NULL) {
ccheung@5603 1562 cpe->compile_the_world(loader, CHECK);
ccheung@5603 1563 }
duke@435 1564 }
duke@435 1565
duke@435 1566 bool LazyClassPathEntry::is_rt_jar() {
ccheung@5603 1567 Thread* THREAD = Thread::current();
ccheung@5603 1568 ClassPathEntry* cpe = resolve_entry(THREAD);
ccheung@5603 1569 return (cpe != NULL) ? cpe->is_jar_file() : false;
duke@435 1570 }
duke@435 1571
duke@435 1572 void ClassLoader::compile_the_world() {
duke@435 1573 EXCEPTION_MARK;
duke@435 1574 HandleMark hm(THREAD);
duke@435 1575 ResourceMark rm(THREAD);
duke@435 1576 // Make sure we don't run with background compilation
duke@435 1577 BackgroundCompilation = false;
duke@435 1578 // Find bootstrap loader
duke@435 1579 Handle system_class_loader (THREAD, SystemDictionary::java_system_loader());
duke@435 1580 // Iterate over all bootstrap class path entries
duke@435 1581 ClassPathEntry* e = _first_entry;
twisti@4940 1582 jlong start = os::javaTimeMillis();
duke@435 1583 while (e != NULL) {
duke@435 1584 // We stop at rt.jar, unless it is the first bootstrap path entry
duke@435 1585 if (e->is_rt_jar() && e != _first_entry) break;
duke@435 1586 e->compile_the_world(system_class_loader, CATCH);
duke@435 1587 e = e->next();
duke@435 1588 }
twisti@4940 1589 jlong end = os::javaTimeMillis();
drchase@6680 1590 tty->print_cr("CompileTheWorld : Done (%d classes, %d methods, " JLONG_FORMAT " ms)",
twisti@4940 1591 _compile_the_world_class_counter, _compile_the_world_method_counter, (end - start));
duke@435 1592 {
duke@435 1593 // Print statistics as if before normal exit:
duke@435 1594 extern void print_statistics();
duke@435 1595 print_statistics();
duke@435 1596 }
duke@435 1597 vm_exit(0);
duke@435 1598 }
duke@435 1599
twisti@4940 1600 int ClassLoader::_compile_the_world_class_counter = 0;
twisti@4940 1601 int ClassLoader::_compile_the_world_method_counter = 0;
kvn@1623 1602 static int _codecache_sweep_counter = 0;
duke@435 1603
never@2564 1604 // Filter out all exceptions except OOMs
never@2564 1605 static void clear_pending_exception_if_not_oom(TRAPS) {
never@2564 1606 if (HAS_PENDING_EXCEPTION &&
never@2564 1607 !PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
never@2564 1608 CLEAR_PENDING_EXCEPTION;
never@2564 1609 }
never@2564 1610 // The CHECK at the caller will propagate the exception out
never@2564 1611 }
never@2564 1612
twisti@5723 1613 /**
twisti@5723 1614 * Returns if the given method should be compiled when doing compile-the-world.
twisti@5723 1615 *
twisti@5723 1616 * TODO: This should be a private method in a CompileTheWorld class.
twisti@5723 1617 */
twisti@5723 1618 static bool can_be_compiled(methodHandle m, int comp_level) {
twisti@5723 1619 assert(CompileTheWorld, "must be");
twisti@5723 1620
twisti@5723 1621 // It's not valid to compile a native wrapper for MethodHandle methods
twisti@5723 1622 // that take a MemberName appendix since the bytecode signature is not
twisti@5723 1623 // correct.
twisti@5723 1624 vmIntrinsics::ID iid = m->intrinsic_id();
twisti@5723 1625 if (MethodHandles::is_signature_polymorphic(iid) && MethodHandles::has_member_arg(iid)) {
twisti@5723 1626 return false;
twisti@5723 1627 }
twisti@5723 1628
twisti@5723 1629 return CompilationPolicy::can_be_compiled(m, comp_level);
twisti@5723 1630 }
twisti@5723 1631
duke@435 1632 void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) {
duke@435 1633 int len = (int)strlen(name);
duke@435 1634 if (len > 6 && strcmp(".class", name + len - 6) == 0) {
duke@435 1635 // We have a .class file
duke@435 1636 char buffer[2048];
duke@435 1637 strncpy(buffer, name, len - 6);
duke@435 1638 buffer[len-6] = 0;
duke@435 1639 // If the file has a period after removing .class, it's not really a
duke@435 1640 // valid class file. The class loader will check everything else.
duke@435 1641 if (strchr(buffer, '.') == NULL) {
twisti@4940 1642 _compile_the_world_class_counter++;
twisti@4940 1643 if (_compile_the_world_class_counter > CompileTheWorldStopAt) return;
never@1158 1644
never@1158 1645 // Construct name without extension
coleenp@2497 1646 TempNewSymbol sym = SymbolTable::new_symbol(buffer, CHECK);
never@1158 1647 // Use loader to load and initialize class
coleenp@4037 1648 Klass* ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD);
never@1158 1649 instanceKlassHandle k (THREAD, ik);
never@1158 1650 if (k.not_null() && !HAS_PENDING_EXCEPTION) {
never@1158 1651 k->initialize(THREAD);
never@1158 1652 }
never@1158 1653 bool exception_occurred = HAS_PENDING_EXCEPTION;
never@2564 1654 clear_pending_exception_if_not_oom(CHECK);
never@1158 1655 if (CompileTheWorldPreloadClasses && k.not_null()) {
coleenp@4037 1656 ConstantPool::preload_and_initialize_all_classes(k->constants(), THREAD);
never@1158 1657 if (HAS_PENDING_EXCEPTION) {
never@1158 1658 // If something went wrong in preloading we just ignore it
never@2564 1659 clear_pending_exception_if_not_oom(CHECK);
twisti@4940 1660 tty->print_cr("Preloading failed for (%d) %s", _compile_the_world_class_counter, buffer);
duke@435 1661 }
never@1158 1662 }
never@1158 1663
twisti@4940 1664 if (_compile_the_world_class_counter >= CompileTheWorldStartAt) {
never@2605 1665 if (k.is_null() || exception_occurred) {
duke@435 1666 // If something went wrong (e.g. ExceptionInInitializerError) we skip this class
twisti@4940 1667 tty->print_cr("CompileTheWorld (%d) : Skipping %s", _compile_the_world_class_counter, buffer);
duke@435 1668 } else {
twisti@4940 1669 tty->print_cr("CompileTheWorld (%d) : %s", _compile_the_world_class_counter, buffer);
duke@435 1670 // Preload all classes to get around uncommon traps
duke@435 1671 // Iterate over all methods in class
iignatyev@5032 1672 int comp_level = CompilationPolicy::policy()->initial_compile_level();
duke@435 1673 for (int n = 0; n < k->methods()->length(); n++) {
coleenp@4037 1674 methodHandle m (THREAD, k->methods()->at(n));
twisti@5723 1675 if (can_be_compiled(m, comp_level)) {
kvn@1623 1676 if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) {
kvn@1623 1677 // Give sweeper a chance to keep up with CTW
kvn@1623 1678 VM_ForceSafepoint op;
kvn@1623 1679 VMThread::execute(&op);
kvn@1623 1680 _codecache_sweep_counter = 0;
kvn@1623 1681 }
duke@435 1682 // Force compilation
iignatyev@5032 1683 CompileBroker::compile_method(m, InvocationEntryBci, comp_level,
duke@435 1684 methodHandle(), 0, "CTW", THREAD);
duke@435 1685 if (HAS_PENDING_EXCEPTION) {
never@2564 1686 clear_pending_exception_if_not_oom(CHECK);
twisti@5723 1687 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string());
twisti@4940 1688 } else {
twisti@4940 1689 _compile_the_world_method_counter++;
duke@435 1690 }
iveresov@3035 1691 if (TieredCompilation && TieredStopAtLevel >= CompLevel_full_optimization) {
never@1158 1692 // Clobber the first compile and force second tier compilation
never@1158 1693 nmethod* nm = m->code();
iveresov@7147 1694 if (nm != NULL && !m->is_method_handle_intrinsic()) {
never@1158 1695 // Throw out the code so that the code cache doesn't fill up
never@1158 1696 nm->make_not_entrant();
never@1158 1697 }
iveresov@2138 1698 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_full_optimization,
never@1158 1699 methodHandle(), 0, "CTW", THREAD);
never@1158 1700 if (HAS_PENDING_EXCEPTION) {
never@2564 1701 clear_pending_exception_if_not_oom(CHECK);
twisti@5723 1702 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string());
twisti@4940 1703 } else {
twisti@4940 1704 _compile_the_world_method_counter++;
never@1158 1705 }
duke@435 1706 }
twisti@5723 1707 } else {
twisti@5723 1708 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string());
duke@435 1709 }
never@1158 1710
never@1158 1711 nmethod* nm = m->code();
iveresov@7147 1712 if (nm != NULL && !m->is_method_handle_intrinsic()) {
never@1158 1713 // Throw out the code so that the code cache doesn't fill up
never@1158 1714 nm->make_not_entrant();
duke@435 1715 }
duke@435 1716 }
duke@435 1717 }
duke@435 1718 }
duke@435 1719 }
duke@435 1720 }
duke@435 1721 }
duke@435 1722
duke@435 1723 #endif //PRODUCT
minqi@2459 1724
minqi@2459 1725 // Please keep following two functions at end of this file. With them placed at top or in middle of the file,
minqi@2459 1726 // they could get inlined by agressive compiler, an unknown trick, see bug 6966589.
minqi@2459 1727 void PerfClassTraceTime::initialize() {
minqi@2459 1728 if (!UsePerfData) return;
minqi@2459 1729
minqi@2459 1730 if (_eventp != NULL) {
minqi@2459 1731 // increment the event counter
minqi@2459 1732 _eventp->inc();
minqi@2459 1733 }
minqi@2459 1734
minqi@2459 1735 // stop the current active thread-local timer to measure inclusive time
minqi@2459 1736 _prev_active_event = -1;
minqi@2459 1737 for (int i=0; i < EVENT_TYPE_COUNT; i++) {
minqi@2459 1738 if (_timers[i].is_active()) {
minqi@2459 1739 assert(_prev_active_event == -1, "should have only one active timer");
minqi@2459 1740 _prev_active_event = i;
minqi@2459 1741 _timers[i].stop();
minqi@2459 1742 }
minqi@2459 1743 }
minqi@2459 1744
minqi@2459 1745 if (_recursion_counters == NULL || (_recursion_counters[_event_type])++ == 0) {
minqi@2459 1746 // start the inclusive timer if not recursively called
minqi@2459 1747 _t.start();
minqi@2459 1748 }
minqi@2459 1749
minqi@2459 1750 // start thread-local timer of the given event type
minqi@2459 1751 if (!_timers[_event_type].is_active()) {
minqi@2459 1752 _timers[_event_type].start();
minqi@2459 1753 }
minqi@2459 1754 }
minqi@2459 1755
minqi@2459 1756 PerfClassTraceTime::~PerfClassTraceTime() {
minqi@2459 1757 if (!UsePerfData) return;
minqi@2459 1758
minqi@2459 1759 // stop the thread-local timer as the event completes
minqi@2459 1760 // and resume the thread-local timer of the event next on the stack
minqi@2459 1761 _timers[_event_type].stop();
minqi@2459 1762 jlong selftime = _timers[_event_type].ticks();
minqi@2459 1763
minqi@2459 1764 if (_prev_active_event >= 0) {
minqi@2459 1765 _timers[_prev_active_event].start();
minqi@2459 1766 }
minqi@2459 1767
minqi@2459 1768 if (_recursion_counters != NULL && --(_recursion_counters[_event_type]) > 0) return;
minqi@2459 1769
minqi@2459 1770 // increment the counters only on the leaf call
minqi@2459 1771 _t.stop();
minqi@2459 1772 _timep->inc(_t.ticks());
minqi@2459 1773 if (_selftimep != NULL) {
minqi@2459 1774 _selftimep->inc(selftime);
minqi@2459 1775 }
minqi@2459 1776 // add all class loading related event selftime to the accumulated time counter
minqi@2459 1777 ClassLoader::perf_accumulated_time()->inc(selftime);
minqi@2459 1778
minqi@2459 1779 // reset the timer
minqi@2459 1780 _timers[_event_type].reset();
minqi@2459 1781 }

mercurial