src/share/vm/oops/method.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/oops

src/share/vm/oops/method.cpp

Print this page
rev 6132 : 8037970: make PrintMethodData a diagnostic options
Summary: make PrintMethodData a diagnostic options for performance investigation
Reviewed-by:


 312   // be excuted more than n times.
 313   if (is_accessor() || is_empty_method() || (code() != NULL)) {
 314     // interpreter doesn't bump invocation counter of trivial methods
 315     // compiler does not bump invocation counter of compiled methods
 316     return true;
 317   }
 318   else if ((method_counters() != NULL &&
 319             method_counters()->invocation_counter()->carry()) ||
 320            (method_data() != NULL &&
 321             method_data()->invocation_counter()->carry())) {
 322     // The carry bit is set when the counter overflows and causes
 323     // a compilation to occur.  We don't know how many times
 324     // the counter has been reset, so we simply assume it has
 325     // been executed more than n times.
 326     return true;
 327   } else {
 328     return invocation_count() > n;
 329   }
 330 }
 331 
 332 #ifndef PRODUCT
 333 void Method::print_invocation_count() {
 334   if (is_static()) tty->print("static ");
 335   if (is_final()) tty->print("final ");
 336   if (is_synchronized()) tty->print("synchronized ");
 337   if (is_native()) tty->print("native ");
 338   method_holder()->name()->print_symbol_on(tty);
 339   tty->print(".");
 340   name()->print_symbol_on(tty);
 341   signature()->print_symbol_on(tty);
 342 
 343   if (WizardMode) {
 344     // dump the size of the byte codes
 345     tty->print(" {%d}", code_size());
 346   }
 347   tty->cr();
 348 
 349   tty->print_cr ("  interpreter_invocation_count: %8d ", interpreter_invocation_count());
 350   tty->print_cr ("  invocation_counter:           %8d ", invocation_count());
 351   tty->print_cr ("  backedge_counter:             %8d ", backedge_count());

 352   if (CountCompiledCalls) {
 353     tty->print_cr ("  compiled_invocation_count: %8d ", compiled_invocation_count());
 354   }
 355 
 356 }
 357 #endif

 358 
 359 // Build a MethodData* object to hold information about this method
 360 // collected in the interpreter.
 361 void Method::build_interpreter_method_data(methodHandle method, TRAPS) {
 362   // Do not profile method if current thread holds the pending list lock,
 363   // which avoids deadlock for acquiring the MethodData_lock.
 364   if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
 365     return;
 366   }
 367 
 368   // Grab a lock here to prevent multiple
 369   // MethodData*s from being created.
 370   MutexLocker ml(MethodData_lock, THREAD);
 371   if (method->method_data() == NULL) {
 372     ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
 373     MethodData* method_data = MethodData::allocate(loader_data, method, CHECK);
 374     method->set_method_data(method_data);
 375     if (PrintMethodData && (Verbose || WizardMode)) {
 376       ResourceMark rm(THREAD);
 377       tty->print("build_interpreter_method_data for ");


1426   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1427   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1428 };
1429 
1430 
1431 void Method::print_name(outputStream* st) {
1432   Thread *thread = Thread::current();
1433   ResourceMark rm(thread);
1434   SignatureTypePrinter sig(signature(), st);
1435   st->print("%s ", is_static() ? "static" : "virtual");
1436   sig.print_returntype();
1437   st->print(" %s.", method_holder()->internal_name());
1438   name()->print_symbol_on(st);
1439   st->print("(");
1440   sig.print_parameters();
1441   st->print(")");
1442 }
1443 #endif // !PRODUCT || INCLUDE_JVMTI
1444 
1445 
1446 //-----------------------------------------------------------------------------------
1447 // Non-product code
1448 
1449 #ifndef PRODUCT
1450 void Method::print_codes_on(outputStream* st) const {
1451   print_codes_on(0, code_size(), st);
1452 }
1453 
1454 void Method::print_codes_on(int from, int to, outputStream* st) const {
1455   Thread *thread = Thread::current();
1456   ResourceMark rm(thread);
1457   methodHandle mh (thread, (Method*)this);
1458   BytecodeStream s(mh);
1459   s.set_interval(from, to);
1460   BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1461   while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1462 }
1463 #endif // not PRODUCT
1464 
1465 
1466 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1467 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1468 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1469 // as end-of-stream terminator.
1470 
1471 void CompressedLineNumberWriteStream::write_pair_regular(int bci_delta, int line_delta) {
1472   // bci and line number does not compress into single byte.
1473   // Write out escape character and use regular compression for bci and line number.
1474   write_byte((jubyte)0xFF);
1475   write_signed_int(bci_delta);
1476   write_signed_int(line_delta);
1477 }
1478 
1479 // See comment in method.hpp which explains why this exists.
1480 #if defined(_M_AMD64) && _MSC_VER >= 1400
1481 #pragma optimize("", off)
1482 void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
1483   write_pair_inline(bci, line);




 312   // be excuted more than n times.
 313   if (is_accessor() || is_empty_method() || (code() != NULL)) {
 314     // interpreter doesn't bump invocation counter of trivial methods
 315     // compiler does not bump invocation counter of compiled methods
 316     return true;
 317   }
 318   else if ((method_counters() != NULL &&
 319             method_counters()->invocation_counter()->carry()) ||
 320            (method_data() != NULL &&
 321             method_data()->invocation_counter()->carry())) {
 322     // The carry bit is set when the counter overflows and causes
 323     // a compilation to occur.  We don't know how many times
 324     // the counter has been reset, so we simply assume it has
 325     // been executed more than n times.
 326     return true;
 327   } else {
 328     return invocation_count() > n;
 329   }
 330 }
 331 

 332 void Method::print_invocation_count() {
 333   if (is_static()) tty->print("static ");
 334   if (is_final()) tty->print("final ");
 335   if (is_synchronized()) tty->print("synchronized ");
 336   if (is_native()) tty->print("native ");
 337   tty->print("%s::", method_holder()->external_name());

 338   name()->print_symbol_on(tty);
 339   signature()->print_symbol_on(tty);
 340 
 341   if (WizardMode) {
 342     // dump the size of the byte codes
 343     tty->print(" {%d}", code_size());
 344   }
 345   tty->cr();
 346 
 347   tty->print_cr ("  interpreter_invocation_count: %8d ", interpreter_invocation_count());
 348   tty->print_cr ("  invocation_counter:           %8d ", invocation_count());
 349   tty->print_cr ("  backedge_counter:             %8d ", backedge_count());
 350 #ifndef PRODUCT
 351   if (CountCompiledCalls) {
 352     tty->print_cr ("  compiled_invocation_count: %8d ", compiled_invocation_count());
 353   }


 354 #endif
 355 }
 356 
 357 // Build a MethodData* object to hold information about this method
 358 // collected in the interpreter.
 359 void Method::build_interpreter_method_data(methodHandle method, TRAPS) {
 360   // Do not profile method if current thread holds the pending list lock,
 361   // which avoids deadlock for acquiring the MethodData_lock.
 362   if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
 363     return;
 364   }
 365 
 366   // Grab a lock here to prevent multiple
 367   // MethodData*s from being created.
 368   MutexLocker ml(MethodData_lock, THREAD);
 369   if (method->method_data() == NULL) {
 370     ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
 371     MethodData* method_data = MethodData::allocate(loader_data, method, CHECK);
 372     method->set_method_data(method_data);
 373     if (PrintMethodData && (Verbose || WizardMode)) {
 374       ResourceMark rm(THREAD);
 375       tty->print("build_interpreter_method_data for ");


1424   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1425   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1426 };
1427 
1428 
1429 void Method::print_name(outputStream* st) {
1430   Thread *thread = Thread::current();
1431   ResourceMark rm(thread);
1432   SignatureTypePrinter sig(signature(), st);
1433   st->print("%s ", is_static() ? "static" : "virtual");
1434   sig.print_returntype();
1435   st->print(" %s.", method_holder()->internal_name());
1436   name()->print_symbol_on(st);
1437   st->print("(");
1438   sig.print_parameters();
1439   st->print(")");
1440 }
1441 #endif // !PRODUCT || INCLUDE_JVMTI
1442 
1443 




1444 void Method::print_codes_on(outputStream* st) const {
1445   print_codes_on(0, code_size(), st);
1446 }
1447 
1448 void Method::print_codes_on(int from, int to, outputStream* st) const {
1449   Thread *thread = Thread::current();
1450   ResourceMark rm(thread);
1451   methodHandle mh (thread, (Method*)this);
1452   BytecodeStream s(mh);
1453   s.set_interval(from, to);
1454   BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1455   while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1456 }

1457 
1458 
1459 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1460 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1461 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1462 // as end-of-stream terminator.
1463 
1464 void CompressedLineNumberWriteStream::write_pair_regular(int bci_delta, int line_delta) {
1465   // bci and line number does not compress into single byte.
1466   // Write out escape character and use regular compression for bci and line number.
1467   write_byte((jubyte)0xFF);
1468   write_signed_int(bci_delta);
1469   write_signed_int(line_delta);
1470 }
1471 
1472 // See comment in method.hpp which explains why this exists.
1473 #if defined(_M_AMD64) && _MSC_VER >= 1400
1474 #pragma optimize("", off)
1475 void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
1476   write_pair_inline(bci, line);


src/share/vm/oops/method.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File