src/share/vm/code/nmethod.cpp

Print this page
rev 5878 : [mq]: usdt1-gone


  33 #include "compiler/compileLog.hpp"
  34 #include "compiler/compilerOracle.hpp"
  35 #include "compiler/disassembler.hpp"
  36 #include "interpreter/bytecode.hpp"
  37 #include "oops/methodData.hpp"
  38 #include "prims/jvmtiRedefineClassesTrace.hpp"
  39 #include "prims/jvmtiImpl.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 #include "runtime/sweeper.hpp"
  42 #include "utilities/dtrace.hpp"
  43 #include "utilities/events.hpp"
  44 #include "utilities/xmlstream.hpp"
  45 #ifdef SHARK
  46 #include "shark/sharkCompiler.hpp"
  47 #endif
  48 
  49 #ifdef DTRACE_ENABLED
  50 
  51 // Only bother with this argument setup if dtrace is available
  52 
  53 #ifndef USDT2
  54 HS_DTRACE_PROBE_DECL8(hotspot, compiled__method__load,
  55   const char*, int, const char*, int, const char*, int, void*, size_t);
  56 
  57 HS_DTRACE_PROBE_DECL6(hotspot, compiled__method__unload,
  58   char*, int, char*, int, char*, int);
  59 
  60 #define DTRACE_METHOD_UNLOAD_PROBE(method)                                \
  61   {                                                                       \
  62     Method* m = (method);                                                 \
  63     if (m != NULL) {                                                      \
  64       Symbol* klass_name = m->klass_name();                               \
  65       Symbol* name = m->name();                                           \
  66       Symbol* signature = m->signature();                                 \
  67       HS_DTRACE_PROBE6(hotspot, compiled__method__unload,                 \
  68         klass_name->bytes(), klass_name->utf8_length(),                   \
  69         name->bytes(), name->utf8_length(),                               \
  70         signature->bytes(), signature->utf8_length());                    \
  71     }                                                                     \
  72   }
  73 #else /* USDT2 */
  74 #define DTRACE_METHOD_UNLOAD_PROBE(method)                                \
  75   {                                                                       \
  76     Method* m = (method);                                                 \
  77     if (m != NULL) {                                                      \
  78       Symbol* klass_name = m->klass_name();                               \
  79       Symbol* name = m->name();                                           \
  80       Symbol* signature = m->signature();                                 \
  81       HOTSPOT_COMPILED_METHOD_UNLOAD(                                     \
  82         (char *) klass_name->bytes(), klass_name->utf8_length(),                   \
  83         (char *) name->bytes(), name->utf8_length(),                               \
  84         (char *) signature->bytes(), signature->utf8_length());                    \
  85     }                                                                     \
  86   }
  87 #endif /* USDT2 */
  88 
  89 #else //  ndef DTRACE_ENABLED
  90 
  91 #define DTRACE_METHOD_UNLOAD_PROBE(method)
  92 
  93 #endif
  94 
  95 bool nmethod::is_compiled_by_c1() const {
  96   if (compiler() == NULL) {
  97     return false;
  98   }
  99   return compiler()->is_c1();
 100 }
 101 bool nmethod::is_compiled_by_c2() const {
 102   if (compiler() == NULL) {
 103     return false;
 104   }
 105   return compiler()->is_c2();
 106 }
 107 bool nmethod::is_compiled_by_shark() const {


1503   oop obj = *root;
1504   if (obj == NULL || is_alive->do_object_b(obj)) {
1505       return false;
1506   }
1507 
1508   // If ScavengeRootsInCode is true, an nmethod might be unloaded
1509   // simply because one of its constant oops has gone dead.
1510   // No actual classes need to be unloaded in order for this to occur.
1511   assert(unloading_occurred || ScavengeRootsInCode, "Inconsistency in unloading");
1512   make_unloaded(is_alive, obj);
1513   return true;
1514 }
1515 
1516 // ------------------------------------------------------------------
1517 // post_compiled_method_load_event
1518 // new method for install_code() path
1519 // Transfer information from compilation to jvmti
1520 void nmethod::post_compiled_method_load_event() {
1521 
1522   Method* moop = method();
1523 #ifndef USDT2
1524   HS_DTRACE_PROBE8(hotspot, compiled__method__load,
1525       moop->klass_name()->bytes(),
1526       moop->klass_name()->utf8_length(),
1527       moop->name()->bytes(),
1528       moop->name()->utf8_length(),
1529       moop->signature()->bytes(),
1530       moop->signature()->utf8_length(),
1531       insts_begin(), insts_size());
1532 #else /* USDT2 */
1533   HOTSPOT_COMPILED_METHOD_LOAD(
1534       (char *) moop->klass_name()->bytes(),
1535       moop->klass_name()->utf8_length(),
1536       (char *) moop->name()->bytes(),
1537       moop->name()->utf8_length(),
1538       (char *) moop->signature()->bytes(),
1539       moop->signature()->utf8_length(),
1540       insts_begin(), insts_size());
1541 #endif /* USDT2 */
1542 
1543   if (JvmtiExport::should_post_compiled_method_load() ||
1544       JvmtiExport::should_post_compiled_method_unload()) {
1545     get_and_cache_jmethod_id();
1546   }
1547 
1548   if (JvmtiExport::should_post_compiled_method_load()) {
1549     // Let the Service thread (which is a real Java thread) post the event
1550     MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
1551     JvmtiDeferredEventQueue::enqueue(
1552       JvmtiDeferredEvent::compiled_method_load_event(this));
1553   }
1554 }
1555 
1556 jmethodID nmethod::get_and_cache_jmethod_id() {
1557   if (_jmethod_id == NULL) {
1558     // Cache the jmethod_id since it can no longer be looked up once the
1559     // method itself has been marked for unloading.
1560     _jmethod_id = method()->jmethod_id();
1561   }




  33 #include "compiler/compileLog.hpp"
  34 #include "compiler/compilerOracle.hpp"
  35 #include "compiler/disassembler.hpp"
  36 #include "interpreter/bytecode.hpp"
  37 #include "oops/methodData.hpp"
  38 #include "prims/jvmtiRedefineClassesTrace.hpp"
  39 #include "prims/jvmtiImpl.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 #include "runtime/sweeper.hpp"
  42 #include "utilities/dtrace.hpp"
  43 #include "utilities/events.hpp"
  44 #include "utilities/xmlstream.hpp"
  45 #ifdef SHARK
  46 #include "shark/sharkCompiler.hpp"
  47 #endif
  48 
  49 #ifdef DTRACE_ENABLED
  50 
  51 // Only bother with this argument setup if dtrace is available
  52 





















  53 #define DTRACE_METHOD_UNLOAD_PROBE(method)                                \
  54   {                                                                       \
  55     Method* m = (method);                                                 \
  56     if (m != NULL) {                                                      \
  57       Symbol* klass_name = m->klass_name();                               \
  58       Symbol* name = m->name();                                           \
  59       Symbol* signature = m->signature();                                 \
  60       HOTSPOT_COMPILED_METHOD_UNLOAD(                                     \
  61         (char *) klass_name->bytes(), klass_name->utf8_length(),                   \
  62         (char *) name->bytes(), name->utf8_length(),                               \
  63         (char *) signature->bytes(), signature->utf8_length());                    \
  64     }                                                                     \
  65   }

  66 
  67 #else //  ndef DTRACE_ENABLED
  68 
  69 #define DTRACE_METHOD_UNLOAD_PROBE(method)
  70 
  71 #endif
  72 
  73 bool nmethod::is_compiled_by_c1() const {
  74   if (compiler() == NULL) {
  75     return false;
  76   }
  77   return compiler()->is_c1();
  78 }
  79 bool nmethod::is_compiled_by_c2() const {
  80   if (compiler() == NULL) {
  81     return false;
  82   }
  83   return compiler()->is_c2();
  84 }
  85 bool nmethod::is_compiled_by_shark() const {


1481   oop obj = *root;
1482   if (obj == NULL || is_alive->do_object_b(obj)) {
1483       return false;
1484   }
1485 
1486   // If ScavengeRootsInCode is true, an nmethod might be unloaded
1487   // simply because one of its constant oops has gone dead.
1488   // No actual classes need to be unloaded in order for this to occur.
1489   assert(unloading_occurred || ScavengeRootsInCode, "Inconsistency in unloading");
1490   make_unloaded(is_alive, obj);
1491   return true;
1492 }
1493 
1494 // ------------------------------------------------------------------
1495 // post_compiled_method_load_event
1496 // new method for install_code() path
1497 // Transfer information from compilation to jvmti
1498 void nmethod::post_compiled_method_load_event() {
1499 
1500   Method* moop = method();










1501   HOTSPOT_COMPILED_METHOD_LOAD(
1502       (char *) moop->klass_name()->bytes(),
1503       moop->klass_name()->utf8_length(),
1504       (char *) moop->name()->bytes(),
1505       moop->name()->utf8_length(),
1506       (char *) moop->signature()->bytes(),
1507       moop->signature()->utf8_length(),
1508       insts_begin(), insts_size());

1509 
1510   if (JvmtiExport::should_post_compiled_method_load() ||
1511       JvmtiExport::should_post_compiled_method_unload()) {
1512     get_and_cache_jmethod_id();
1513   }
1514 
1515   if (JvmtiExport::should_post_compiled_method_load()) {
1516     // Let the Service thread (which is a real Java thread) post the event
1517     MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
1518     JvmtiDeferredEventQueue::enqueue(
1519       JvmtiDeferredEvent::compiled_method_load_event(this));
1520   }
1521 }
1522 
1523 jmethodID nmethod::get_and_cache_jmethod_id() {
1524   if (_jmethod_id == NULL) {
1525     // Cache the jmethod_id since it can no longer be looked up once the
1526     // method itself has been marked for unloading.
1527     _jmethod_id = method()->jmethod_id();
1528   }