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 { |
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 |
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 } |