367 if (is_accessor() || is_empty_method() || (code() != NULL)) { 368 // interpreter doesn't bump invocation counter of trivial methods 369 // compiler does not bump invocation counter of compiled methods 370 return true; 371 } 372 else if ((method_counters() != NULL && 373 method_counters()->invocation_counter()->carry()) || 374 (method_data() != NULL && 375 method_data()->invocation_counter()->carry())) { 376 // The carry bit is set when the counter overflows and causes 377 // a compilation to occur. We don't know how many times 378 // the counter has been reset, so we simply assume it has 379 // been executed more than n times. 380 return true; 381 } else { 382 return invocation_count() > n; 383 } 384 } 385 386 void Method::print_invocation_count() { 387 if (is_static()) tty->print("static "); 388 if (is_final()) tty->print("final "); 389 if (is_synchronized()) tty->print("synchronized "); 390 if (is_native()) tty->print("native "); 391 tty->print("%s::", method_holder()->external_name()); 392 name()->print_symbol_on(tty); 393 signature()->print_symbol_on(tty); 394 395 if (WizardMode) { 396 // dump the size of the byte codes 397 tty->print(" {%d}", code_size()); 398 } 399 tty->cr(); 400 401 tty->print_cr (" interpreter_invocation_count: %8d ", interpreter_invocation_count()); 402 tty->print_cr (" invocation_counter: %8d ", invocation_count()); 403 tty->print_cr (" backedge_counter: %8d ", backedge_count()); 404 #ifndef PRODUCT 405 if (CountCompiledCalls) { 406 tty->print_cr (" compiled_invocation_count: %8d ", compiled_invocation_count()); 407 } 408 #endif 409 } 410 411 // Build a MethodData* object to hold information about this method 412 // collected in the interpreter. 413 void Method::build_interpreter_method_data(const methodHandle& method, TRAPS) { 414 // Do not profile the method if metaspace has hit an OOM previously 415 // allocating profiling data. Callers clear pending exception so don't 416 // add one here. 417 if (ClassLoaderDataGraph::has_metaspace_oom()) { 418 return; 419 } 420 421 // Grab a lock here to prevent multiple 422 // MethodData*s from being created. 423 MutexLocker ml(MethodData_lock, THREAD); 424 if (method->method_data() == NULL) { 425 ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); 426 MethodData* method_data = MethodData::allocate(loader_data, method, THREAD); | 367 if (is_accessor() || is_empty_method() || (code() != NULL)) { 368 // interpreter doesn't bump invocation counter of trivial methods 369 // compiler does not bump invocation counter of compiled methods 370 return true; 371 } 372 else if ((method_counters() != NULL && 373 method_counters()->invocation_counter()->carry()) || 374 (method_data() != NULL && 375 method_data()->invocation_counter()->carry())) { 376 // The carry bit is set when the counter overflows and causes 377 // a compilation to occur. We don't know how many times 378 // the counter has been reset, so we simply assume it has 379 // been executed more than n times. 380 return true; 381 } else { 382 return invocation_count() > n; 383 } 384 } 385 386 void Method::print_invocation_count() { 387 //---< compose+print method return type, klass, name, and signature >--- 388 if (is_static()) tty->print("static "); 389 if (is_final()) tty->print("final "); 390 if (is_synchronized()) tty->print("synchronized "); 391 if (is_native()) tty->print("native "); 392 tty->print("%s::", method_holder()->external_name()); 393 name()->print_symbol_on(tty); 394 signature()->print_symbol_on(tty); 395 396 if (WizardMode) { 397 // dump the size of the byte codes 398 tty->print(" {%d}", code_size()); 399 } 400 tty->cr(); 401 402 // Counting based on signed int counters tends to overflow with 403 // longer-running workloads on fast machines. The counters under 404 // consideration here, however, are limited in range by counting 405 // logic. See InvocationCounter:count_limit for example. 406 // No "overflow precautions" need to be implemented here. 407 tty->print_cr (" interpreter_invocation_count: " INT32_FORMAT_W(11), interpreter_invocation_count()); 408 tty->print_cr (" invocation_counter: " INT32_FORMAT_W(11), invocation_count()); 409 tty->print_cr (" backedge_counter: " INT32_FORMAT_W(11), backedge_count()); 410 411 if (method_data() != NULL) { 412 tty->print_cr (" decompile_count: " UINT32_FORMAT_W(11), method_data()->decompile_count()); 413 } 414 415 #ifndef PRODUCT 416 if (CountCompiledCalls) { 417 tty->print_cr (" compiled_invocation_count: " INT64_FORMAT_W(11), compiled_invocation_count()); 418 } 419 #endif 420 } 421 422 // Build a MethodData* object to hold information about this method 423 // collected in the interpreter. 424 void Method::build_interpreter_method_data(const methodHandle& method, TRAPS) { 425 // Do not profile the method if metaspace has hit an OOM previously 426 // allocating profiling data. Callers clear pending exception so don't 427 // add one here. 428 if (ClassLoaderDataGraph::has_metaspace_oom()) { 429 return; 430 } 431 432 // Grab a lock here to prevent multiple 433 // MethodData*s from being created. 434 MutexLocker ml(MethodData_lock, THREAD); 435 if (method->method_data() == NULL) { 436 ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); 437 MethodData* method_data = MethodData::allocate(loader_data, method, THREAD); |