src/share/vm/runtime/sweeper.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/vm/runtime/sweeper.cpp Tue Nov 5 12:41:27 2013
--- new/src/share/vm/runtime/sweeper.cpp Tue Nov 5 12:41:27 2013
*** 135,148 ****
--- 135,144 ----
int NMethodSweeper::_marked_count = 0; // Nof. nmethods marked for reclaim in current sweep
volatile int NMethodSweeper::_invocations = 0; // Nof. invocations left until we are completed with this pass
volatile int NMethodSweeper::_sweep_started = 0; // Whether a sweep is in progress.
jint NMethodSweeper::_locked_seen = 0;
jint NMethodSweeper::_not_entrant_seen_on_stack = 0;
bool NMethodSweeper::_request_mark_phase = false;
int NMethodSweeper::_total_nof_methods_reclaimed = 0;
jlong NMethodSweeper::_total_time_sweeping = 0;
jlong NMethodSweeper::_total_time_this_sweep = 0;
jlong NMethodSweeper::_peak_sweep_time = 0;
jlong NMethodSweeper::_peak_sweep_fraction_time = 0;
*** 191,207 ****
--- 187,203 ----
// safepoint.
void NMethodSweeper::mark_active_nmethods() {
assert(SafepointSynchronize::is_at_safepoint(), "must be executed at a safepoint");
// If we do not want to reclaim not-entrant or zombie methods there is no need
// to scan stacks
! if (!MethodFlushing || !UseCodeCacheFlushing) {
return;
}
// Check for restart
assert(CodeCache::find_blob_unsafe(_current) == _current, "Sweeper nmethod cached state invalid");
- if (!sweep_in_progress() && need_marking_phase()) {
_seen = 0;
_invocations = NmethodSweepFraction;
_current = CodeCache::first_nmethod();
_traversals += 1;
_total_time_this_sweep = 0;
*** 209,222 ****
--- 205,214 ----
if (PrintMethodFlushing) {
tty->print_cr("### Sweep: stack traversal %d", _traversals);
}
Threads::nmethods_do(&mark_activation_closure);
// reset the flags since we started a scan from the beginning.
reset_nmethod_marking();
_locked_seen = 0;
_not_entrant_seen_on_stack = 0;
} else {
// Only set hotness counter
Threads::nmethods_do(&set_hotness_closure);
}
*** 244,259 ****
--- 236,251 ----
#endif
if (_invocations > 0) {
sweep_code_cache();
_invocations--;
}
+
_sweep_started = 0;
}
}
void NMethodSweeper::sweep_code_cache() {
jlong sweep_start_counter = os::elapsed_counter();
_flushed_count = 0;
_zombified_count = 0;
_marked_count = 0;
*** 314,335 ****
--- 306,315 ----
}
}
assert(_invocations > 1 || _current == NULL, "must have scanned the whole cache");
if (!sweep_in_progress() && !need_marking_phase() && (_locked_seen || _not_entrant_seen_on_stack)) {
// we've completed a scan without making progress but there were
// nmethods we were unable to process either because they were
// locked or were still on stack. We don't have to aggressively
// clean them up so just stop scanning. We could scan once more
// but that complicates the control logic and it's unlikely to
// matter much.
if (PrintMethodFlushing) {
tty->print_cr("### Couldn't make progress on some nmethods so stopping sweep");
}
}
jlong sweep_end_counter = os::elapsed_counter();
jlong sweep_time = sweep_end_counter - sweep_start_counter;
_total_time_sweeping += sweep_time;
_total_time_this_sweep += sweep_time;
_peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time);
*** 422,434 ****
--- 402,411 ----
if (nm->is_alive()) {
// Clean inline caches that point to zombie/non-entrant methods
MutexLocker cl(CompiledIC_lock);
nm->cleanup_inline_caches();
SWEEP(nm);
} else {
_locked_seen++;
SWEEP(nm);
}
return freed_memory;
}
if (nm->is_zombie()) {
*** 446,456 ****
--- 423,432 ----
} else {
if (PrintMethodFlushing && Verbose) {
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), nm);
}
nm->mark_for_reclamation();
request_nmethod_marking();
_marked_count++;
SWEEP(nm);
}
} else if (nm->is_not_entrant()) {
// If there are no current activations of this method on the
*** 458,478 ****
--- 434,449 ----
if (nm->can_not_entrant_be_converted()) {
if (PrintMethodFlushing && Verbose) {
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm);
}
nm->make_zombie();
request_nmethod_marking();
_zombified_count++;
SWEEP(nm);
} else {
// Still alive, clean up its inline caches
MutexLocker cl(CompiledIC_lock);
nm->cleanup_inline_caches();
// we coudn't transition this nmethod so don't immediately
// request a rescan. If this method stays on the stack for a
// long time we don't want to keep rescanning the code cache.
_not_entrant_seen_on_stack++;
SWEEP(nm);
}
} else if (nm->is_unloaded()) {
// Unloaded code, just make it a zombie
if (PrintMethodFlushing && Verbose) {
*** 484,494 ****
--- 455,464 ----
freed_memory = nm->total_size();
release_nmethod(nm);
_flushed_count++;
} else {
nm->make_zombie();
request_nmethod_marking();
_zombified_count++;
SWEEP(nm);
}
} else {
if (UseCodeCacheFlushing) {
*** 512,522 ****
--- 482,491 ----
// The second condition is necessary if we are dealing with very small code cache
// sizes (e.g., <10m) and the code cache size is too small to hold all hot methods.
// The second condition ensures that methods are not immediately made not-entrant
// after compilation.
nm->make_not_entrant();
request_nmethod_marking();
}
}
}
// Clean-up all inline caches that point to zombie/non-reentrant methods
MutexLocker cl(CompiledIC_lock);
src/share/vm/runtime/sweeper.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File