523 freed_memory = nm->total_size(); 524 if (nm->is_compiled_by_c2()) { 525 _total_nof_c2_methods_reclaimed++; 526 } 527 release_nmethod(nm); 528 _flushed_count++; 529 } else { 530 if (PrintMethodFlushing && Verbose) { 531 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), nm); 532 } 533 nm->mark_for_reclamation(); 534 // Keep track of code cache state change 535 _bytes_changed += nm->total_size(); 536 _marked_for_reclamation_count++; 537 SWEEP(nm); 538 } 539 } else if (nm->is_not_entrant()) { 540 // If there are no current activations of this method on the 541 // stack we can safely convert it to a zombie method 542 if (nm->can_not_entrant_be_converted()) { 543 if (PrintMethodFlushing && Verbose) { 544 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm); 545 } 546 // Clear ICStubs to prevent back patching stubs of zombie or unloaded 547 // nmethods during the next safepoint (see ICStub::finalize). 548 MutexLocker cl(CompiledIC_lock); 549 nm->clear_ic_stubs(); 550 // Code cache state change is tracked in make_zombie() 551 nm->make_zombie(); 552 _zombified_count++; 553 SWEEP(nm); 554 } else { 555 // Still alive, clean up its inline caches 556 MutexLocker cl(CompiledIC_lock); 557 nm->cleanup_inline_caches(); 558 SWEEP(nm); 559 } 560 } else if (nm->is_unloaded()) { 561 // Unloaded code, just make it a zombie 562 if (PrintMethodFlushing && Verbose) { 563 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), nm); 564 } 565 if (nm->is_osr_method()) { 566 SWEEP(nm); 567 // No inline caches will ever point to osr methods, so we can just remove it 568 freed_memory = nm->total_size(); 569 if (nm->is_compiled_by_c2()) { 570 _total_nof_c2_methods_reclaimed++; 571 } 572 release_nmethod(nm); 573 _flushed_count++; | 523 freed_memory = nm->total_size(); 524 if (nm->is_compiled_by_c2()) { 525 _total_nof_c2_methods_reclaimed++; 526 } 527 release_nmethod(nm); 528 _flushed_count++; 529 } else { 530 if (PrintMethodFlushing && Verbose) { 531 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), nm); 532 } 533 nm->mark_for_reclamation(); 534 // Keep track of code cache state change 535 _bytes_changed += nm->total_size(); 536 _marked_for_reclamation_count++; 537 SWEEP(nm); 538 } 539 } else if (nm->is_not_entrant()) { 540 // If there are no current activations of this method on the 541 // stack we can safely convert it to a zombie method 542 if (nm->can_not_entrant_be_converted()) { 543 // Clear ICStubs to prevent back patching stubs of zombie or unloaded 544 // nmethods during the next safepoint (see ICStub::finalize). 545 MutexLocker cl(CompiledIC_lock); 546 nm->clear_ic_stubs(); 547 // Acquiring the CompiledIC_lock may block for a safepoint and set the 548 // nmethod to zombie (see 'CodeCache::make_marked_nmethods_zombies'). 549 // Check if nmethod is still non-entrant at this point. 550 if (nm->is_not_entrant()) { 551 if (PrintMethodFlushing && Verbose) { 552 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm); 553 } 554 // Code cache state change is tracked in make_zombie() 555 nm->make_zombie(); 556 _zombified_count++; 557 SWEEP(nm); 558 } 559 assert(nm->is_zombie(), "nmethod must be zombie"); 560 } else { 561 // Still alive, clean up its inline caches 562 MutexLocker cl(CompiledIC_lock); 563 nm->cleanup_inline_caches(); 564 SWEEP(nm); 565 } 566 } else if (nm->is_unloaded()) { 567 // Unloaded code, just make it a zombie 568 if (PrintMethodFlushing && Verbose) { 569 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), nm); 570 } 571 if (nm->is_osr_method()) { 572 SWEEP(nm); 573 // No inline caches will ever point to osr methods, so we can just remove it 574 freed_memory = nm->total_size(); 575 if (nm->is_compiled_by_c2()) { 576 _total_nof_c2_methods_reclaimed++; 577 } 578 release_nmethod(nm); 579 _flushed_count++; |