461 if (call_f) f_or_null->do_code_blob(cb); |
461 if (call_f) f_or_null->do_code_blob(cb); |
462 } |
462 } |
463 } |
463 } |
464 #endif //PRODUCT |
464 #endif //PRODUCT |
465 |
465 |
466 |
466 /** |
467 nmethod* CodeCache::find_and_remove_saved_code(Method* m) { |
467 * Remove and return nmethod from the saved code list in order to reanimate it. |
|
468 */ |
|
469 nmethod* CodeCache::reanimate_saved_code(Method* m) { |
468 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
470 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
469 nmethod* saved = _saved_nmethods; |
471 nmethod* saved = _saved_nmethods; |
470 nmethod* prev = NULL; |
472 nmethod* prev = NULL; |
471 while (saved != NULL) { |
473 while (saved != NULL) { |
472 if (saved->is_in_use() && saved->method() == m) { |
474 if (saved->is_in_use() && saved->method() == m) { |
477 } |
479 } |
478 assert(saved->is_speculatively_disconnected(), "shouldn't call for other nmethods"); |
480 assert(saved->is_speculatively_disconnected(), "shouldn't call for other nmethods"); |
479 saved->set_speculatively_disconnected(false); |
481 saved->set_speculatively_disconnected(false); |
480 saved->set_saved_nmethod_link(NULL); |
482 saved->set_saved_nmethod_link(NULL); |
481 if (PrintMethodFlushing) { |
483 if (PrintMethodFlushing) { |
482 saved->print_on(tty, " ### nmethod is reconnected\n"); |
484 saved->print_on(tty, " ### nmethod is reconnected"); |
483 } |
485 } |
484 if (LogCompilation && (xtty != NULL)) { |
486 if (LogCompilation && (xtty != NULL)) { |
485 ttyLocker ttyl; |
487 ttyLocker ttyl; |
486 xtty->begin_elem("nmethod_reconnected compile_id='%3d'", saved->compile_id()); |
488 xtty->begin_elem("nmethod_reconnected compile_id='%3d'", saved->compile_id()); |
487 xtty->method(m); |
489 xtty->method(m); |
494 saved = saved->saved_nmethod_link(); |
496 saved = saved->saved_nmethod_link(); |
495 } |
497 } |
496 return NULL; |
498 return NULL; |
497 } |
499 } |
498 |
500 |
|
501 /** |
|
502 * Remove nmethod from the saved code list in order to discard it permanently |
|
503 */ |
499 void CodeCache::remove_saved_code(nmethod* nm) { |
504 void CodeCache::remove_saved_code(nmethod* nm) { |
500 // For conc swpr this will be called with CodeCache_lock taken by caller |
505 // For conc swpr this will be called with CodeCache_lock taken by caller |
501 assert_locked_or_safepoint(CodeCache_lock); |
506 assert_locked_or_safepoint(CodeCache_lock); |
502 assert(nm->is_speculatively_disconnected(), "shouldn't call for other nmethods"); |
507 assert(nm->is_speculatively_disconnected(), "shouldn't call for other nmethods"); |
503 nmethod* saved = _saved_nmethods; |
508 nmethod* saved = _saved_nmethods; |
527 assert_locked_or_safepoint(CodeCache_lock); |
532 assert_locked_or_safepoint(CodeCache_lock); |
528 assert(nm->is_in_use() && !nm->is_speculatively_disconnected(), "should only disconnect live nmethods"); |
533 assert(nm->is_in_use() && !nm->is_speculatively_disconnected(), "should only disconnect live nmethods"); |
529 nm->set_saved_nmethod_link(_saved_nmethods); |
534 nm->set_saved_nmethod_link(_saved_nmethods); |
530 _saved_nmethods = nm; |
535 _saved_nmethods = nm; |
531 if (PrintMethodFlushing) { |
536 if (PrintMethodFlushing) { |
532 nm->print_on(tty, " ### nmethod is speculatively disconnected\n"); |
537 nm->print_on(tty, " ### nmethod is speculatively disconnected"); |
533 } |
538 } |
534 if (LogCompilation && (xtty != NULL)) { |
539 if (LogCompilation && (xtty != NULL)) { |
535 ttyLocker ttyl; |
540 ttyLocker ttyl; |
536 xtty->begin_elem("nmethod_disconnected compile_id='%3d'", nm->compile_id()); |
541 xtty->begin_elem("nmethod_disconnected compile_id='%3d'", nm->compile_id()); |
537 xtty->method(nm->method()); |
542 xtty->method(nm->method()); |