< prev index next >

src/share/vm/runtime/sweeper.cpp

Print this page
rev 13523 : [mq]: 8186837


  36 #include "runtime/compilationPolicy.hpp"
  37 #include "runtime/mutexLocker.hpp"
  38 #include "runtime/orderAccess.inline.hpp"
  39 #include "runtime/os.hpp"
  40 #include "runtime/sweeper.hpp"
  41 #include "runtime/thread.inline.hpp"
  42 #include "runtime/vm_operations.hpp"
  43 #include "trace/tracing.hpp"
  44 #include "utilities/events.hpp"
  45 #include "utilities/ticks.inline.hpp"
  46 #include "utilities/xmlstream.hpp"
  47 
  48 #ifdef ASSERT
  49 
  50 #define SWEEP(nm) record_sweep(nm, __LINE__)
  51 // Sweeper logging code
  52 class SweeperRecord {
  53  public:
  54   int traversal;
  55   int compile_id;
  56   jlong traversal_mark;
  57   int state;
  58   const char* kind;
  59   address vep;
  60   address uep;
  61   int line;
  62 
  63   void print() {
  64       tty->print_cr("traversal = %d compile_id = %d %s uep = " PTR_FORMAT " vep = "
  65                     PTR_FORMAT " state = %d traversal_mark "JLONG_FORMAT" line = %d",
  66                     traversal,
  67                     compile_id,
  68                     kind == NULL ? "" : kind,
  69                     p2i(uep),
  70                     p2i(vep),
  71                     state,
  72                     traversal_mark,
  73                     line);
  74   }
  75 };
  76 
  77 static int _sweep_index = 0;
  78 static SweeperRecord* _records = NULL;
  79 
  80 void NMethodSweeper::report_events(int id, address entry) {
  81   if (_records != NULL) {
  82     for (int i = _sweep_index; i < SweeperLogEntries; i++) {
  83       if (_records[i].uep == entry ||
  84           _records[i].vep == entry ||
  85           _records[i].compile_id == id) {


 612     // But still remember to clean-up inline caches for alive nmethods
 613     if (cm->is_alive()) {
 614       // Clean inline caches that point to zombie/non-entrant/unloaded nmethods
 615       MutexLocker cl(CompiledIC_lock);
 616       cm->cleanup_inline_caches();
 617       SWEEP(cm);
 618     }
 619     return result;
 620   }
 621 
 622   if (cm->is_zombie()) {
 623     // All inline caches that referred to this nmethod were cleaned in the
 624     // previous sweeper cycle. Now flush the nmethod from the code cache.
 625     assert(!cm->is_locked_by_vm(), "must not flush locked Compiled Methods");
 626     release_compiled_method(cm);
 627     assert(result == None, "sanity");
 628     result = Flushed;
 629   } else if (cm->is_not_entrant()) {
 630     // If there are no current activations of this method on the
 631     // stack we can safely convert it to a zombie method

 632     if (cm->can_convert_to_zombie()) {
 633       // Clear ICStubs to prevent back patching stubs of zombie or flushed
 634       // nmethods during the next safepoint (see ICStub::finalize).
 635       {
 636         MutexLocker cl(CompiledIC_lock);
 637         cm->clear_ic_stubs();
 638       }
 639       // Code cache state change is tracked in make_zombie()
 640       cm->make_zombie();
 641       SWEEP(cm);
 642       // The nmethod may have been locked by JVMTI after being made zombie (see
 643       // JvmtiDeferredEvent::compiled_method_unload_event()). If so, we cannot
 644       // flush the osr nmethod directly but have to wait for a later sweeper cycle.
 645       if (cm->is_osr_method() && !cm->is_locked_by_vm()) {
 646         // No inline caches will ever point to osr methods, so we can just remove it.
 647         // Make sure that we unregistered the nmethod with the heap and flushed all
 648         // dependencies before removing the nmethod (done in make_zombie()).
 649         assert(cm->is_zombie(), "nmethod must be unregistered");
 650         release_compiled_method(cm);
 651         assert(result == None, "sanity");




  36 #include "runtime/compilationPolicy.hpp"
  37 #include "runtime/mutexLocker.hpp"
  38 #include "runtime/orderAccess.inline.hpp"
  39 #include "runtime/os.hpp"
  40 #include "runtime/sweeper.hpp"
  41 #include "runtime/thread.inline.hpp"
  42 #include "runtime/vm_operations.hpp"
  43 #include "trace/tracing.hpp"
  44 #include "utilities/events.hpp"
  45 #include "utilities/ticks.inline.hpp"
  46 #include "utilities/xmlstream.hpp"
  47 
  48 #ifdef ASSERT
  49 
  50 #define SWEEP(nm) record_sweep(nm, __LINE__)
  51 // Sweeper logging code
  52 class SweeperRecord {
  53  public:
  54   int traversal;
  55   int compile_id;
  56   long traversal_mark;
  57   int state;
  58   const char* kind;
  59   address vep;
  60   address uep;
  61   int line;
  62 
  63   void print() {
  64       tty->print_cr("traversal = %d compile_id = %d %s uep = " PTR_FORMAT " vep = "
  65                     PTR_FORMAT " state = %d traversal_mark %ld line = %d",
  66                     traversal,
  67                     compile_id,
  68                     kind == NULL ? "" : kind,
  69                     p2i(uep),
  70                     p2i(vep),
  71                     state,
  72                     traversal_mark,
  73                     line);
  74   }
  75 };
  76 
  77 static int _sweep_index = 0;
  78 static SweeperRecord* _records = NULL;
  79 
  80 void NMethodSweeper::report_events(int id, address entry) {
  81   if (_records != NULL) {
  82     for (int i = _sweep_index; i < SweeperLogEntries; i++) {
  83       if (_records[i].uep == entry ||
  84           _records[i].vep == entry ||
  85           _records[i].compile_id == id) {


 612     // But still remember to clean-up inline caches for alive nmethods
 613     if (cm->is_alive()) {
 614       // Clean inline caches that point to zombie/non-entrant/unloaded nmethods
 615       MutexLocker cl(CompiledIC_lock);
 616       cm->cleanup_inline_caches();
 617       SWEEP(cm);
 618     }
 619     return result;
 620   }
 621 
 622   if (cm->is_zombie()) {
 623     // All inline caches that referred to this nmethod were cleaned in the
 624     // previous sweeper cycle. Now flush the nmethod from the code cache.
 625     assert(!cm->is_locked_by_vm(), "must not flush locked Compiled Methods");
 626     release_compiled_method(cm);
 627     assert(result == None, "sanity");
 628     result = Flushed;
 629   } else if (cm->is_not_entrant()) {
 630     // If there are no current activations of this method on the
 631     // stack we can safely convert it to a zombie method
 632     OrderAccess::loadload(); // _stack_traversal_mark and _state
 633     if (cm->can_convert_to_zombie()) {
 634       // Clear ICStubs to prevent back patching stubs of zombie or flushed
 635       // nmethods during the next safepoint (see ICStub::finalize).
 636       {
 637         MutexLocker cl(CompiledIC_lock);
 638         cm->clear_ic_stubs();
 639       }
 640       // Code cache state change is tracked in make_zombie()
 641       cm->make_zombie();
 642       SWEEP(cm);
 643       // The nmethod may have been locked by JVMTI after being made zombie (see
 644       // JvmtiDeferredEvent::compiled_method_unload_event()). If so, we cannot
 645       // flush the osr nmethod directly but have to wait for a later sweeper cycle.
 646       if (cm->is_osr_method() && !cm->is_locked_by_vm()) {
 647         // No inline caches will ever point to osr methods, so we can just remove it.
 648         // Make sure that we unregistered the nmethod with the heap and flushed all
 649         // dependencies before removing the nmethod (done in make_zombie()).
 650         assert(cm->is_zombie(), "nmethod must be unregistered");
 651         release_compiled_method(cm);
 652         assert(result == None, "sanity");


< prev index next >