Tue, 05 Apr 2011 14:12:31 -0700
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
Summary: Update the copyright to be 2010 on all changed files in OpenJDK
Reviewed-by: ohair
duke@435 | 1 | /* |
trims@2708 | 2 | * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "code/codeCache.hpp" |
stefank@2314 | 27 | #include "code/nmethod.hpp" |
stefank@2314 | 28 | #include "compiler/compileBroker.hpp" |
stefank@2314 | 29 | #include "memory/resourceArea.hpp" |
stefank@2314 | 30 | #include "oops/methodOop.hpp" |
stefank@2314 | 31 | #include "runtime/atomic.hpp" |
stefank@2314 | 32 | #include "runtime/compilationPolicy.hpp" |
stefank@2314 | 33 | #include "runtime/mutexLocker.hpp" |
stefank@2314 | 34 | #include "runtime/os.hpp" |
stefank@2314 | 35 | #include "runtime/sweeper.hpp" |
stefank@2314 | 36 | #include "runtime/vm_operations.hpp" |
stefank@2314 | 37 | #include "utilities/events.hpp" |
stefank@2314 | 38 | #include "utilities/xmlstream.hpp" |
duke@435 | 39 | |
duke@435 | 40 | long NMethodSweeper::_traversals = 0; // No. of stack traversals performed |
never@1970 | 41 | nmethod* NMethodSweeper::_current = NULL; // Current nmethod |
never@1999 | 42 | int NMethodSweeper::_seen = 0 ; // No. of nmethods we have currently processed in current pass of CodeCache |
never@1999 | 43 | |
never@1999 | 44 | volatile int NMethodSweeper::_invocations = 0; // No. of invocations left until we are completed with this pass |
never@1999 | 45 | volatile int NMethodSweeper::_sweep_started = 0; // Whether a sweep is in progress. |
duke@435 | 46 | |
duke@435 | 47 | jint NMethodSweeper::_locked_seen = 0; |
duke@435 | 48 | jint NMethodSweeper::_not_entrant_seen_on_stack = 0; |
duke@435 | 49 | bool NMethodSweeper::_rescan = false; |
never@1893 | 50 | bool NMethodSweeper::_do_sweep = false; |
kvn@1637 | 51 | bool NMethodSweeper::_was_full = false; |
kvn@1637 | 52 | jint NMethodSweeper::_advise_to_sweep = 0; |
kvn@1637 | 53 | jlong NMethodSweeper::_last_was_full = 0; |
kvn@1637 | 54 | uint NMethodSweeper::_highest_marked = 0; |
kvn@1637 | 55 | long NMethodSweeper::_was_full_traversal = 0; |
duke@435 | 56 | |
jrose@1424 | 57 | class MarkActivationClosure: public CodeBlobClosure { |
jrose@1424 | 58 | public: |
jrose@1424 | 59 | virtual void do_code_blob(CodeBlob* cb) { |
jrose@1424 | 60 | // If we see an activation belonging to a non_entrant nmethod, we mark it. |
jrose@1424 | 61 | if (cb->is_nmethod() && ((nmethod*)cb)->is_not_entrant()) { |
jrose@1424 | 62 | ((nmethod*)cb)->mark_as_seen_on_stack(); |
jrose@1424 | 63 | } |
jrose@1424 | 64 | } |
jrose@1424 | 65 | }; |
jrose@1424 | 66 | static MarkActivationClosure mark_activation_closure; |
jrose@1424 | 67 | |
never@1893 | 68 | void NMethodSweeper::scan_stacks() { |
duke@435 | 69 | assert(SafepointSynchronize::is_at_safepoint(), "must be executed at a safepoint"); |
duke@435 | 70 | if (!MethodFlushing) return; |
never@1893 | 71 | _do_sweep = true; |
duke@435 | 72 | |
duke@435 | 73 | // No need to synchronize access, since this is always executed at a |
duke@435 | 74 | // safepoint. If we aren't in the middle of scan and a rescan |
never@1893 | 75 | // hasn't been requested then just return. If UseCodeCacheFlushing is on and |
never@1893 | 76 | // code cache flushing is in progress, don't skip sweeping to help make progress |
never@1893 | 77 | // clearing space in the code cache. |
never@1893 | 78 | if ((_current == NULL && !_rescan) && !(UseCodeCacheFlushing && !CompileBroker::should_compile_new_jobs())) { |
never@1893 | 79 | _do_sweep = false; |
never@1893 | 80 | return; |
never@1893 | 81 | } |
duke@435 | 82 | |
duke@435 | 83 | // Make sure CompiledIC_lock in unlocked, since we might update some |
duke@435 | 84 | // inline caches. If it is, we just bail-out and try later. |
duke@435 | 85 | if (CompiledIC_lock->is_locked() || Patching_lock->is_locked()) return; |
duke@435 | 86 | |
duke@435 | 87 | // Check for restart |
duke@435 | 88 | assert(CodeCache::find_blob_unsafe(_current) == _current, "Sweeper nmethod cached state invalid"); |
duke@435 | 89 | if (_current == NULL) { |
duke@435 | 90 | _seen = 0; |
duke@435 | 91 | _invocations = NmethodSweepFraction; |
never@1893 | 92 | _current = CodeCache::first_nmethod(); |
duke@435 | 93 | _traversals += 1; |
duke@435 | 94 | if (PrintMethodFlushing) { |
duke@435 | 95 | tty->print_cr("### Sweep: stack traversal %d", _traversals); |
duke@435 | 96 | } |
jrose@1424 | 97 | Threads::nmethods_do(&mark_activation_closure); |
duke@435 | 98 | |
duke@435 | 99 | // reset the flags since we started a scan from the beginning. |
duke@435 | 100 | _rescan = false; |
duke@435 | 101 | _locked_seen = 0; |
duke@435 | 102 | _not_entrant_seen_on_stack = 0; |
duke@435 | 103 | } |
duke@435 | 104 | |
kvn@1637 | 105 | if (UseCodeCacheFlushing) { |
kvn@1637 | 106 | if (!CodeCache::needs_flushing()) { |
never@1893 | 107 | // scan_stacks() runs during a safepoint, no race with setters |
kvn@1637 | 108 | _advise_to_sweep = 0; |
kvn@1637 | 109 | } |
kvn@1637 | 110 | |
kvn@1637 | 111 | if (was_full()) { |
kvn@1637 | 112 | // There was some progress so attempt to restart the compiler |
kvn@1637 | 113 | jlong now = os::javaTimeMillis(); |
kvn@1637 | 114 | jlong max_interval = (jlong)MinCodeCacheFlushingInterval * (jlong)1000; |
kvn@1637 | 115 | jlong curr_interval = now - _last_was_full; |
kvn@1637 | 116 | if ((!CodeCache::needs_flushing()) && (curr_interval > max_interval)) { |
kvn@1637 | 117 | CompileBroker::set_should_compile_new_jobs(CompileBroker::run_compilation); |
kvn@1637 | 118 | set_was_full(false); |
kvn@1637 | 119 | |
kvn@1637 | 120 | // Update the _last_was_full time so we can tell how fast the |
kvn@1637 | 121 | // code cache is filling up |
kvn@1637 | 122 | _last_was_full = os::javaTimeMillis(); |
kvn@1637 | 123 | |
never@1999 | 124 | log_sweep("restart_compiler"); |
kvn@1637 | 125 | } |
kvn@1637 | 126 | } |
kvn@1637 | 127 | } |
duke@435 | 128 | } |
duke@435 | 129 | |
never@1893 | 130 | void NMethodSweeper::possibly_sweep() { |
never@1999 | 131 | assert(JavaThread::current()->thread_state() == _thread_in_vm, "must run in vm mode"); |
never@1893 | 132 | if ((!MethodFlushing) || (!_do_sweep)) return; |
never@1893 | 133 | |
never@1893 | 134 | if (_invocations > 0) { |
never@1893 | 135 | // Only one thread at a time will sweep |
never@1893 | 136 | jint old = Atomic::cmpxchg( 1, &_sweep_started, 0 ); |
never@1893 | 137 | if (old != 0) { |
never@1893 | 138 | return; |
never@1893 | 139 | } |
never@1999 | 140 | if (_invocations > 0) { |
never@1999 | 141 | sweep_code_cache(); |
never@1999 | 142 | _invocations--; |
never@1999 | 143 | } |
never@1999 | 144 | _sweep_started = 0; |
never@1893 | 145 | } |
never@1893 | 146 | } |
never@1893 | 147 | |
never@1893 | 148 | void NMethodSweeper::sweep_code_cache() { |
never@1893 | 149 | #ifdef ASSERT |
never@1893 | 150 | jlong sweep_start; |
never@1999 | 151 | if (PrintMethodFlushing) { |
never@1893 | 152 | sweep_start = os::javaTimeMillis(); |
never@1893 | 153 | } |
never@1893 | 154 | #endif |
never@1893 | 155 | if (PrintMethodFlushing && Verbose) { |
never@1999 | 156 | tty->print_cr("### Sweep at %d out of %d. Invocations left: %d", _seen, CodeCache::nof_nmethods(), _invocations); |
never@1893 | 157 | } |
never@1893 | 158 | |
never@1999 | 159 | // We want to visit all nmethods after NmethodSweepFraction |
never@1999 | 160 | // invocations so divide the remaining number of nmethods by the |
never@1999 | 161 | // remaining number of invocations. This is only an estimate since |
never@1999 | 162 | // the number of nmethods changes during the sweep so the final |
never@1999 | 163 | // stage must iterate until it there are no more nmethods. |
never@1999 | 164 | int todo = (CodeCache::nof_nmethods() - _seen) / _invocations; |
never@1893 | 165 | |
never@1893 | 166 | assert(!SafepointSynchronize::is_at_safepoint(), "should not be in safepoint when we get here"); |
never@1893 | 167 | assert(!CodeCache_lock->owned_by_self(), "just checking"); |
never@1893 | 168 | |
never@1893 | 169 | { |
never@1893 | 170 | MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
never@1893 | 171 | |
never@1999 | 172 | // The last invocation iterates until there are no more nmethods |
never@1999 | 173 | for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { |
never@1893 | 174 | |
never@1999 | 175 | // Since we will give up the CodeCache_lock, always skip ahead |
never@1999 | 176 | // to the next nmethod. Other blobs can be deleted by other |
never@1999 | 177 | // threads but nmethods are only reclaimed by the sweeper. |
never@1970 | 178 | nmethod* next = CodeCache::next_nmethod(_current); |
never@1893 | 179 | |
never@1893 | 180 | // Now ready to process nmethod and give up CodeCache_lock |
never@1893 | 181 | { |
never@1893 | 182 | MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
never@1970 | 183 | process_nmethod(_current); |
never@1893 | 184 | } |
never@1893 | 185 | _seen++; |
never@1893 | 186 | _current = next; |
never@1893 | 187 | } |
never@1893 | 188 | } |
never@1893 | 189 | |
never@1999 | 190 | assert(_invocations > 1 || _current == NULL, "must have scanned the whole cache"); |
never@1999 | 191 | |
never@1893 | 192 | if (_current == NULL && !_rescan && (_locked_seen || _not_entrant_seen_on_stack)) { |
never@1893 | 193 | // we've completed a scan without making progress but there were |
never@1893 | 194 | // nmethods we were unable to process either because they were |
never@1893 | 195 | // locked or were still on stack. We don't have to aggresively |
never@1893 | 196 | // clean them up so just stop scanning. We could scan once more |
never@1893 | 197 | // but that complicates the control logic and it's unlikely to |
never@1893 | 198 | // matter much. |
never@1893 | 199 | if (PrintMethodFlushing) { |
never@1893 | 200 | tty->print_cr("### Couldn't make progress on some nmethods so stopping sweep"); |
never@1893 | 201 | } |
never@1893 | 202 | } |
never@1893 | 203 | |
never@1893 | 204 | #ifdef ASSERT |
never@1893 | 205 | if(PrintMethodFlushing) { |
never@1893 | 206 | jlong sweep_end = os::javaTimeMillis(); |
never@1893 | 207 | tty->print_cr("### sweeper: sweep time(%d): " INT64_FORMAT, _invocations, sweep_end - sweep_start); |
never@1893 | 208 | } |
never@1893 | 209 | #endif |
never@1999 | 210 | |
never@1999 | 211 | if (_invocations == 1) { |
never@1999 | 212 | log_sweep("finished"); |
never@1999 | 213 | } |
never@1893 | 214 | } |
never@1893 | 215 | |
duke@435 | 216 | |
duke@435 | 217 | void NMethodSweeper::process_nmethod(nmethod *nm) { |
never@1893 | 218 | assert(!CodeCache_lock->owned_by_self(), "just checking"); |
never@1893 | 219 | |
duke@435 | 220 | // Skip methods that are currently referenced by the VM |
duke@435 | 221 | if (nm->is_locked_by_vm()) { |
duke@435 | 222 | // But still remember to clean-up inline caches for alive nmethods |
duke@435 | 223 | if (nm->is_alive()) { |
duke@435 | 224 | // Clean-up all inline caches that points to zombie/non-reentrant methods |
never@1893 | 225 | MutexLocker cl(CompiledIC_lock); |
duke@435 | 226 | nm->cleanup_inline_caches(); |
duke@435 | 227 | } else { |
duke@435 | 228 | _locked_seen++; |
duke@435 | 229 | } |
duke@435 | 230 | return; |
duke@435 | 231 | } |
duke@435 | 232 | |
duke@435 | 233 | if (nm->is_zombie()) { |
duke@435 | 234 | // If it is first time, we see nmethod then we mark it. Otherwise, |
duke@435 | 235 | // we reclame it. When we have seen a zombie method twice, we know that |
never@1999 | 236 | // there are no inline caches that refer to it. |
duke@435 | 237 | if (nm->is_marked_for_reclamation()) { |
duke@435 | 238 | assert(!nm->is_locked_by_vm(), "must not flush locked nmethods"); |
ysr@1376 | 239 | if (PrintMethodFlushing && Verbose) { |
kvn@1637 | 240 | tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (marked for reclamation) being flushed", nm->compile_id(), nm); |
ysr@1376 | 241 | } |
never@1893 | 242 | MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
duke@435 | 243 | nm->flush(); |
duke@435 | 244 | } else { |
ysr@1376 | 245 | if (PrintMethodFlushing && Verbose) { |
kvn@1637 | 246 | tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), nm); |
ysr@1376 | 247 | } |
duke@435 | 248 | nm->mark_for_reclamation(); |
duke@435 | 249 | _rescan = true; |
duke@435 | 250 | } |
duke@435 | 251 | } else if (nm->is_not_entrant()) { |
duke@435 | 252 | // If there is no current activations of this method on the |
duke@435 | 253 | // stack we can safely convert it to a zombie method |
duke@435 | 254 | if (nm->can_not_entrant_be_converted()) { |
ysr@1376 | 255 | if (PrintMethodFlushing && Verbose) { |
kvn@1637 | 256 | tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm); |
ysr@1376 | 257 | } |
duke@435 | 258 | nm->make_zombie(); |
duke@435 | 259 | _rescan = true; |
duke@435 | 260 | } else { |
duke@435 | 261 | // Still alive, clean up its inline caches |
never@1893 | 262 | MutexLocker cl(CompiledIC_lock); |
duke@435 | 263 | nm->cleanup_inline_caches(); |
duke@435 | 264 | // we coudn't transition this nmethod so don't immediately |
duke@435 | 265 | // request a rescan. If this method stays on the stack for a |
never@1893 | 266 | // long time we don't want to keep rescanning the code cache. |
duke@435 | 267 | _not_entrant_seen_on_stack++; |
duke@435 | 268 | } |
duke@435 | 269 | } else if (nm->is_unloaded()) { |
duke@435 | 270 | // Unloaded code, just make it a zombie |
ysr@1376 | 271 | if (PrintMethodFlushing && Verbose) |
kvn@1637 | 272 | tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), nm); |
ysr@1376 | 273 | if (nm->is_osr_method()) { |
duke@435 | 274 | // No inline caches will ever point to osr methods, so we can just remove it |
never@1893 | 275 | MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
duke@435 | 276 | nm->flush(); |
duke@435 | 277 | } else { |
duke@435 | 278 | nm->make_zombie(); |
duke@435 | 279 | _rescan = true; |
duke@435 | 280 | } |
duke@435 | 281 | } else { |
duke@435 | 282 | assert(nm->is_alive(), "should be alive"); |
kvn@1637 | 283 | |
kvn@1637 | 284 | if (UseCodeCacheFlushing) { |
kvn@1637 | 285 | if ((nm->method()->code() != nm) && !(nm->is_locked_by_vm()) && !(nm->is_osr_method()) && |
kvn@1637 | 286 | (_traversals > _was_full_traversal+2) && (((uint)nm->compile_id()) < _highest_marked) && |
kvn@1637 | 287 | CodeCache::needs_flushing()) { |
kvn@1637 | 288 | // This method has not been called since the forced cleanup happened |
kvn@1637 | 289 | nm->make_not_entrant(); |
kvn@1637 | 290 | } |
kvn@1637 | 291 | } |
kvn@1637 | 292 | |
duke@435 | 293 | // Clean-up all inline caches that points to zombie/non-reentrant methods |
never@1893 | 294 | MutexLocker cl(CompiledIC_lock); |
duke@435 | 295 | nm->cleanup_inline_caches(); |
duke@435 | 296 | } |
duke@435 | 297 | } |
kvn@1637 | 298 | |
kvn@1637 | 299 | // Code cache unloading: when compilers notice the code cache is getting full, |
kvn@1637 | 300 | // they will call a vm op that comes here. This code attempts to speculatively |
kvn@1637 | 301 | // unload the oldest half of the nmethods (based on the compile job id) by |
kvn@1637 | 302 | // saving the old code in a list in the CodeCache. Then |
never@1893 | 303 | // execution resumes. If a method so marked is not called by the second sweeper |
never@1893 | 304 | // stack traversal after the current one, the nmethod will be marked non-entrant and |
kvn@1637 | 305 | // got rid of by normal sweeping. If the method is called, the methodOop's |
kvn@1637 | 306 | // _code field is restored and the methodOop/nmethod |
kvn@1637 | 307 | // go back to their normal state. |
kvn@1637 | 308 | void NMethodSweeper::handle_full_code_cache(bool is_full) { |
kvn@1637 | 309 | // Only the first one to notice can advise us to start early cleaning |
kvn@1637 | 310 | if (!is_full){ |
kvn@1637 | 311 | jint old = Atomic::cmpxchg( 1, &_advise_to_sweep, 0 ); |
kvn@1637 | 312 | if (old != 0) { |
kvn@1637 | 313 | return; |
kvn@1637 | 314 | } |
kvn@1637 | 315 | } |
kvn@1637 | 316 | |
kvn@1637 | 317 | if (is_full) { |
kvn@1637 | 318 | // Since code cache is full, immediately stop new compiles |
kvn@1637 | 319 | bool did_set = CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation); |
kvn@1637 | 320 | if (!did_set) { |
kvn@1637 | 321 | // only the first to notice can start the cleaning, |
kvn@1637 | 322 | // others will go back and block |
kvn@1637 | 323 | return; |
kvn@1637 | 324 | } |
kvn@1637 | 325 | set_was_full(true); |
kvn@1637 | 326 | |
kvn@1637 | 327 | // If we run out within MinCodeCacheFlushingInterval of the last unload time, give up |
kvn@1637 | 328 | jlong now = os::javaTimeMillis(); |
kvn@1637 | 329 | jlong max_interval = (jlong)MinCodeCacheFlushingInterval * (jlong)1000; |
kvn@1637 | 330 | jlong curr_interval = now - _last_was_full; |
kvn@1637 | 331 | if (curr_interval < max_interval) { |
kvn@1637 | 332 | _rescan = true; |
never@1999 | 333 | log_sweep("disable_compiler", "flushing_interval='" UINT64_FORMAT "'", |
never@1999 | 334 | curr_interval/1000); |
kvn@1637 | 335 | return; |
kvn@1637 | 336 | } |
kvn@1637 | 337 | } |
kvn@1637 | 338 | |
kvn@1637 | 339 | VM_HandleFullCodeCache op(is_full); |
kvn@1637 | 340 | VMThread::execute(&op); |
kvn@1637 | 341 | |
kvn@1637 | 342 | // rescan again as soon as possible |
kvn@1637 | 343 | _rescan = true; |
kvn@1637 | 344 | } |
kvn@1637 | 345 | |
kvn@1637 | 346 | void NMethodSweeper::speculative_disconnect_nmethods(bool is_full) { |
kvn@1637 | 347 | // If there was a race in detecting full code cache, only run |
kvn@1637 | 348 | // one vm op for it or keep the compiler shut off |
kvn@1637 | 349 | |
kvn@1637 | 350 | debug_only(jlong start = os::javaTimeMillis();) |
kvn@1637 | 351 | |
kvn@1637 | 352 | if ((!was_full()) && (is_full)) { |
kvn@1637 | 353 | if (!CodeCache::needs_flushing()) { |
never@1999 | 354 | log_sweep("restart_compiler"); |
kvn@1637 | 355 | CompileBroker::set_should_compile_new_jobs(CompileBroker::run_compilation); |
kvn@1637 | 356 | return; |
kvn@1637 | 357 | } |
kvn@1637 | 358 | } |
kvn@1637 | 359 | |
kvn@1637 | 360 | // Traverse the code cache trying to dump the oldest nmethods |
kvn@1637 | 361 | uint curr_max_comp_id = CompileBroker::get_compilation_id(); |
kvn@1637 | 362 | uint flush_target = ((curr_max_comp_id - _highest_marked) >> 1) + _highest_marked; |
never@1999 | 363 | log_sweep("start_cleaning"); |
kvn@1637 | 364 | |
kvn@1637 | 365 | nmethod* nm = CodeCache::alive_nmethod(CodeCache::first()); |
kvn@1637 | 366 | jint disconnected = 0; |
kvn@1637 | 367 | jint made_not_entrant = 0; |
kvn@1637 | 368 | while ((nm != NULL)){ |
kvn@1637 | 369 | uint curr_comp_id = nm->compile_id(); |
kvn@1637 | 370 | |
kvn@1637 | 371 | // OSR methods cannot be flushed like this. Also, don't flush native methods |
kvn@1637 | 372 | // since they are part of the JDK in most cases |
kvn@1637 | 373 | if (nm->is_in_use() && (!nm->is_osr_method()) && (!nm->is_locked_by_vm()) && |
kvn@1637 | 374 | (!nm->is_native_method()) && ((curr_comp_id < flush_target))) { |
kvn@1637 | 375 | |
kvn@1637 | 376 | if ((nm->method()->code() == nm)) { |
kvn@1637 | 377 | // This method has not been previously considered for |
kvn@1637 | 378 | // unloading or it was restored already |
kvn@1637 | 379 | CodeCache::speculatively_disconnect(nm); |
kvn@1637 | 380 | disconnected++; |
kvn@1637 | 381 | } else if (nm->is_speculatively_disconnected()) { |
kvn@1637 | 382 | // This method was previously considered for preemptive unloading and was not called since then |
iveresov@2138 | 383 | CompilationPolicy::policy()->delay_compilation(nm->method()); |
kvn@1637 | 384 | nm->make_not_entrant(); |
kvn@1637 | 385 | made_not_entrant++; |
kvn@1637 | 386 | } |
kvn@1637 | 387 | |
kvn@1637 | 388 | if (curr_comp_id > _highest_marked) { |
kvn@1637 | 389 | _highest_marked = curr_comp_id; |
kvn@1637 | 390 | } |
kvn@1637 | 391 | } |
kvn@1637 | 392 | nm = CodeCache::alive_nmethod(CodeCache::next(nm)); |
kvn@1637 | 393 | } |
kvn@1637 | 394 | |
never@1999 | 395 | log_sweep("stop_cleaning", |
never@1999 | 396 | "disconnected='" UINT32_FORMAT "' made_not_entrant='" UINT32_FORMAT "'", |
never@1999 | 397 | disconnected, made_not_entrant); |
kvn@1637 | 398 | |
never@1893 | 399 | // Shut off compiler. Sweeper will start over with a new stack scan and |
never@1893 | 400 | // traversal cycle and turn it back on if it clears enough space. |
kvn@1637 | 401 | if (was_full()) { |
kvn@1637 | 402 | _last_was_full = os::javaTimeMillis(); |
kvn@1637 | 403 | CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation); |
kvn@1637 | 404 | } |
kvn@1637 | 405 | |
kvn@1637 | 406 | // After two more traversals the sweeper will get rid of unrestored nmethods |
kvn@1637 | 407 | _was_full_traversal = _traversals; |
kvn@1637 | 408 | #ifdef ASSERT |
kvn@1637 | 409 | jlong end = os::javaTimeMillis(); |
kvn@1637 | 410 | if(PrintMethodFlushing && Verbose) { |
kvn@1637 | 411 | tty->print_cr("### sweeper: unload time: " INT64_FORMAT, end-start); |
kvn@1637 | 412 | } |
kvn@1637 | 413 | #endif |
kvn@1637 | 414 | } |
never@1999 | 415 | |
never@1999 | 416 | |
never@1999 | 417 | // Print out some state information about the current sweep and the |
never@1999 | 418 | // state of the code cache if it's requested. |
never@1999 | 419 | void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) { |
never@1999 | 420 | if (PrintMethodFlushing) { |
never@1999 | 421 | ttyLocker ttyl; |
never@1999 | 422 | tty->print("### sweeper: %s ", msg); |
never@1999 | 423 | if (format != NULL) { |
never@1999 | 424 | va_list ap; |
never@1999 | 425 | va_start(ap, format); |
never@1999 | 426 | tty->vprint(format, ap); |
never@1999 | 427 | va_end(ap); |
never@1999 | 428 | } |
kvn@2635 | 429 | CodeCache::log_state(tty); tty->cr(); |
never@1999 | 430 | } |
never@1999 | 431 | |
never@1999 | 432 | if (LogCompilation && (xtty != NULL)) { |
never@1999 | 433 | ttyLocker ttyl; |
never@2001 | 434 | xtty->begin_elem("sweeper state='%s' traversals='" INTX_FORMAT "' ", msg, (intx)traversal_count()); |
never@1999 | 435 | if (format != NULL) { |
never@1999 | 436 | va_list ap; |
never@1999 | 437 | va_start(ap, format); |
never@1999 | 438 | xtty->vprint(format, ap); |
never@1999 | 439 | va_end(ap); |
never@1999 | 440 | } |
kvn@2635 | 441 | CodeCache::log_state(xtty); |
never@1999 | 442 | xtty->stamp(); |
never@1999 | 443 | xtty->end_elem(); |
never@1999 | 444 | } |
never@1999 | 445 | } |