hotspot/src/share/vm/runtime/sweeper.cpp
changeset 33148 68fa8b6c4340
parent 32466 915d0c3d25aa
child 34158 1f8d643b02d5
equal deleted inserted replaced
33146:77349b58b4c0 33148:68fa8b6c4340
    41 #include "trace/tracing.hpp"
    41 #include "trace/tracing.hpp"
    42 #include "utilities/events.hpp"
    42 #include "utilities/events.hpp"
    43 #include "utilities/ticks.inline.hpp"
    43 #include "utilities/ticks.inline.hpp"
    44 #include "utilities/xmlstream.hpp"
    44 #include "utilities/xmlstream.hpp"
    45 
    45 
    46 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
       
    47 
       
    48 #ifdef ASSERT
    46 #ifdef ASSERT
    49 
    47 
    50 #define SWEEP(nm) record_sweep(nm, __LINE__)
    48 #define SWEEP(nm) record_sweep(nm, __LINE__)
    51 // Sweeper logging code
    49 // Sweeper logging code
    52 class SweeperRecord {
    50 class SweeperRecord {
    60   address uep;
    58   address uep;
    61   int line;
    59   int line;
    62 
    60 
    63   void print() {
    61   void print() {
    64       tty->print_cr("traversal = %d compile_id = %d %s uep = " PTR_FORMAT " vep = "
    62       tty->print_cr("traversal = %d compile_id = %d %s uep = " PTR_FORMAT " vep = "
    65                     PTR_FORMAT " state = %d traversal_mark %d line = %d",
    63                     PTR_FORMAT " state = %d traversal_mark %ld line = %d",
    66                     traversal,
    64                     traversal,
    67                     compile_id,
    65                     compile_id,
    68                     kind == NULL ? "" : kind,
    66                     kind == NULL ? "" : kind,
    69                     uep,
    67                     p2i(uep),
    70                     vep,
    68                     p2i(vep),
    71                     state,
    69                     state,
    72                     traversal_mark,
    70                     traversal_mark,
    73                     line);
    71                     line);
    74   }
    72   }
    75 };
    73 };
   221     _current.next();
   219     _current.next();
   222     _traversals += 1;
   220     _traversals += 1;
   223     _total_time_this_sweep = Tickspan();
   221     _total_time_this_sweep = Tickspan();
   224 
   222 
   225     if (PrintMethodFlushing) {
   223     if (PrintMethodFlushing) {
   226       tty->print_cr("### Sweep: stack traversal %d", _traversals);
   224       tty->print_cr("### Sweep: stack traversal %ld", _traversals);
   227     }
   225     }
   228     Threads::nmethods_do(&mark_activation_closure);
   226     Threads::nmethods_do(&mark_activation_closure);
   229 
   227 
   230   } else {
   228   } else {
   231     // Only set hotness counter
   229     // Only set hotness counter
   480     event.commit();
   478     event.commit();
   481   }
   479   }
   482 
   480 
   483 #ifdef ASSERT
   481 #ifdef ASSERT
   484   if(PrintMethodFlushing) {
   482   if(PrintMethodFlushing) {
   485     tty->print_cr("### sweeper:      sweep time(%d): ", (jlong)sweep_time.value());
   483     tty->print_cr("### sweeper:      sweep time(" JLONG_FORMAT "): ", sweep_time.value());
   486   }
   484   }
   487 #endif
   485 #endif
   488 
   486 
   489   log_sweep("finished");
   487   log_sweep("finished");
   490 
   488 
   590     // we reclaim it. When we have seen a zombie method twice, we know that
   588     // we reclaim it. When we have seen a zombie method twice, we know that
   591     // there are no inline caches that refer to it.
   589     // there are no inline caches that refer to it.
   592     if (nm->is_marked_for_reclamation()) {
   590     if (nm->is_marked_for_reclamation()) {
   593       assert(!nm->is_locked_by_vm(), "must not flush locked nmethods");
   591       assert(!nm->is_locked_by_vm(), "must not flush locked nmethods");
   594       if (PrintMethodFlushing && Verbose) {
   592       if (PrintMethodFlushing && Verbose) {
   595         tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (marked for reclamation) being flushed", nm->compile_id(), nm);
   593         tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (marked for reclamation) being flushed", nm->compile_id(), p2i(nm));
   596       }
   594       }
   597       release_nmethod(nm);
   595       release_nmethod(nm);
   598       assert(result == None, "sanity");
   596       assert(result == None, "sanity");
   599       result = Flushed;
   597       result = Flushed;
   600     } else {
   598     } else {
   601       if (PrintMethodFlushing && Verbose) {
   599       if (PrintMethodFlushing && Verbose) {
   602         tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), nm);
   600         tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), p2i(nm));
   603       }
   601       }
   604       nm->mark_for_reclamation();
   602       nm->mark_for_reclamation();
   605       // Keep track of code cache state change
   603       // Keep track of code cache state change
   606       _bytes_changed += nm->total_size();
   604       _bytes_changed += nm->total_size();
   607       SWEEP(nm);
   605       SWEEP(nm);
   617       {
   615       {
   618         MutexLocker cl(CompiledIC_lock);
   616         MutexLocker cl(CompiledIC_lock);
   619         nm->clear_ic_stubs();
   617         nm->clear_ic_stubs();
   620       }
   618       }
   621       if (PrintMethodFlushing && Verbose) {
   619       if (PrintMethodFlushing && Verbose) {
   622         tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm);
   620         tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), p2i(nm));
   623       }
   621       }
   624       // Code cache state change is tracked in make_zombie()
   622       // Code cache state change is tracked in make_zombie()
   625       nm->make_zombie();
   623       nm->make_zombie();
   626       SWEEP(nm);
   624       SWEEP(nm);
   627       assert(result == None, "sanity");
   625       assert(result == None, "sanity");
   634       SWEEP(nm);
   632       SWEEP(nm);
   635     }
   633     }
   636   } else if (nm->is_unloaded()) {
   634   } else if (nm->is_unloaded()) {
   637     // Unloaded code, just make it a zombie
   635     // Unloaded code, just make it a zombie
   638     if (PrintMethodFlushing && Verbose) {
   636     if (PrintMethodFlushing && Verbose) {
   639       tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), nm);
   637       tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), p2i(nm));
   640     }
   638     }
   641     if (nm->is_osr_method()) {
   639     if (nm->is_osr_method()) {
   642       SWEEP(nm);
   640       SWEEP(nm);
   643       // No inline caches will ever point to osr methods, so we can just remove it
   641       // No inline caches will ever point to osr methods, so we can just remove it
   644       release_nmethod(nm);
   642       release_nmethod(nm);
   741         nm->make_not_entrant();
   739         nm->make_not_entrant();
   742 
   740 
   743         // Code cache state change is tracked in make_not_entrant()
   741         // Code cache state change is tracked in make_not_entrant()
   744         if (PrintMethodFlushing && Verbose) {
   742         if (PrintMethodFlushing && Verbose) {
   745           tty->print_cr("### Nmethod %d/" PTR_FORMAT "made not-entrant: hotness counter %d/%d threshold %f",
   743           tty->print_cr("### Nmethod %d/" PTR_FORMAT "made not-entrant: hotness counter %d/%d threshold %f",
   746               nm->compile_id(), nm, nm->hotness_counter(), reset_val, threshold);
   744               nm->compile_id(), p2i(nm), nm->hotness_counter(), reset_val, threshold);
   747         }
   745         }
   748       }
   746       }
   749     }
   747     }
   750   }
   748   }
   751 }
   749 }