< prev index next >

src/share/vm/code/codeCache.cpp

Print this page




 322     nm->do_unloading(is_alive, unloading_occurred);
 323   }
 324 }
 325 
 326 void CodeCache::blobs_do(CodeBlobClosure* f) {
 327   assert_locked_or_safepoint(CodeCache_lock);
 328   FOR_ALL_ALIVE_BLOBS(cb) {
 329     f->do_code_blob(cb);
 330 
 331 #ifdef ASSERT
 332     if (cb->is_nmethod())
 333       ((nmethod*)cb)->verify_scavenge_root_oops();
 334 #endif //ASSERT
 335   }
 336 }
 337 
 338 // Walk the list of methods which might contain non-perm oops.
 339 void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) {
 340   assert_locked_or_safepoint(CodeCache_lock);
 341 
 342   if (UseG1GC) {
 343     return;
 344   }
 345 
 346   debug_only(mark_scavenge_root_nmethods());
 347 
 348   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 349     debug_only(cur->clear_scavenge_root_marked());
 350     assert(cur->scavenge_root_not_marked(), "");
 351     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 352 
 353     bool is_live = (!cur->is_zombie() && !cur->is_unloaded());
 354 #ifndef PRODUCT
 355     if (TraceScavenge) {
 356       cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr();
 357     }
 358 #endif //PRODUCT
 359     if (is_live) {
 360       // Perform cur->oops_do(f), maybe just once per nmethod.
 361       f->do_code_blob(cur);
 362     }
 363   }
 364 
 365   // Check for stray marks.
 366   debug_only(verify_perm_nmethods(NULL));
 367 }
 368 
 369 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
 370   assert_locked_or_safepoint(CodeCache_lock);
 371 
 372   if (UseG1GC) {
 373     return;
 374   }
 375 
 376   nm->set_on_scavenge_root_list();
 377   nm->set_scavenge_root_link(_scavenge_root_nmethods);
 378   set_scavenge_root_nmethods(nm);
 379   print_trace("add_scavenge_root", nm);
 380 }
 381 
 382 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
 383   assert_locked_or_safepoint(CodeCache_lock);
 384 
 385   if (UseG1GC) {
 386     return;
 387   }
 388 
 389   print_trace("drop_scavenge_root", nm);
 390   nmethod* last = NULL;
 391   nmethod* cur = scavenge_root_nmethods();
 392   while (cur != NULL) {
 393     nmethod* next = cur->scavenge_root_link();
 394     if (cur == nm) {
 395       if (last != NULL)
 396             last->set_scavenge_root_link(next);
 397       else  set_scavenge_root_nmethods(next);
 398       nm->set_scavenge_root_link(NULL);
 399       nm->clear_on_scavenge_root_list();
 400       return;
 401     }
 402     last = cur;
 403     cur = next;
 404   }
 405   assert(false, "should have been on list");
 406 }
 407 
 408 void CodeCache::prune_scavenge_root_nmethods() {
 409   assert_locked_or_safepoint(CodeCache_lock);
 410 
 411   if (UseG1GC) {
 412     return;
 413   }
 414 
 415   debug_only(mark_scavenge_root_nmethods());
 416 
 417   nmethod* last = NULL;
 418   nmethod* cur = scavenge_root_nmethods();
 419   while (cur != NULL) {
 420     nmethod* next = cur->scavenge_root_link();
 421     debug_only(cur->clear_scavenge_root_marked());
 422     assert(cur->scavenge_root_not_marked(), "");
 423     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 424 
 425     if (!cur->is_zombie() && !cur->is_unloaded()
 426         && cur->detect_scavenge_root_oops()) {
 427       // Keep it.  Advance 'last' to prevent deletion.
 428       last = cur;
 429     } else {
 430       // Prune it from the list, so we don't have to look at it any more.
 431       print_trace("prune_scavenge_root", cur);
 432       cur->set_scavenge_root_link(NULL);
 433       cur->clear_on_scavenge_root_list();
 434       if (last != NULL)
 435             last->set_scavenge_root_link(next);
 436       else  set_scavenge_root_nmethods(next);
 437     }
 438     cur = next;
 439   }
 440 
 441   // Check for stray marks.
 442   debug_only(verify_perm_nmethods(NULL));
 443 }
 444 
 445 #ifndef PRODUCT
 446 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
 447   if (UseG1GC) {
 448     return;
 449   }
 450 
 451   // While we are here, verify the integrity of the list.
 452   mark_scavenge_root_nmethods();
 453   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 454     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 455     cur->clear_scavenge_root_marked();
 456   }
 457   verify_perm_nmethods(f);
 458 }
 459 
 460 // Temporarily mark nmethods that are claimed to be on the non-perm list.
 461 void CodeCache::mark_scavenge_root_nmethods() {
 462   FOR_ALL_ALIVE_BLOBS(cb) {
 463     if (cb->is_nmethod()) {
 464       nmethod *nm = (nmethod*)cb;
 465       assert(nm->scavenge_root_not_marked(), "clean state");
 466       if (nm->on_scavenge_root_list())
 467         nm->set_scavenge_root_marked();


 958     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
 959                  p2i(_heap->low_boundary()),
 960                  p2i(_heap->high()),
 961                  p2i(_heap->high_boundary()));
 962     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
 963                  " adapters=" UINT32_FORMAT,
 964                  nof_blobs(), nof_nmethods(), nof_adapters());
 965     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
 966                  "enabled" : Arguments::mode() == Arguments::_int ?
 967                  "disabled (interpreter mode)" :
 968                  "disabled (not enough contiguous free space left)");
 969   }
 970 }
 971 
 972 void CodeCache::log_state(outputStream* st) {
 973   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
 974             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
 975             nof_blobs(), nof_nmethods(), nof_adapters(),
 976             unallocated_capacity());
 977 }
 978 


 322     nm->do_unloading(is_alive, unloading_occurred);
 323   }
 324 }
 325 
 326 void CodeCache::blobs_do(CodeBlobClosure* f) {
 327   assert_locked_or_safepoint(CodeCache_lock);
 328   FOR_ALL_ALIVE_BLOBS(cb) {
 329     f->do_code_blob(cb);
 330 
 331 #ifdef ASSERT
 332     if (cb->is_nmethod())
 333       ((nmethod*)cb)->verify_scavenge_root_oops();
 334 #endif //ASSERT
 335   }
 336 }
 337 
 338 // Walk the list of methods which might contain non-perm oops.
 339 void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) {
 340   assert_locked_or_safepoint(CodeCache_lock);
 341 
 342   if (UseG1GC || UseShenandoahGC) {
 343     return;
 344   }
 345 
 346   debug_only(mark_scavenge_root_nmethods());
 347 
 348   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 349     debug_only(cur->clear_scavenge_root_marked());
 350     assert(cur->scavenge_root_not_marked(), "");
 351     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 352 
 353     bool is_live = (!cur->is_zombie() && !cur->is_unloaded());
 354 #ifndef PRODUCT
 355     if (TraceScavenge) {
 356       cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr();
 357     }
 358 #endif //PRODUCT
 359     if (is_live) {
 360       // Perform cur->oops_do(f), maybe just once per nmethod.
 361       f->do_code_blob(cur);
 362     }
 363   }
 364 
 365   // Check for stray marks.
 366   debug_only(verify_perm_nmethods(NULL));
 367 }
 368 
 369 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
 370   assert_locked_or_safepoint(CodeCache_lock);
 371 
 372   if (UseG1GC || UseShenandoahGC) {
 373     return;
 374   }
 375 
 376   nm->set_on_scavenge_root_list();
 377   nm->set_scavenge_root_link(_scavenge_root_nmethods);
 378   set_scavenge_root_nmethods(nm);
 379   print_trace("add_scavenge_root", nm);
 380 }
 381 
 382 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
 383   assert_locked_or_safepoint(CodeCache_lock);
 384 
 385   if (UseG1GC || UseShenandoahGC) {
 386     return;
 387   }
 388 
 389   print_trace("drop_scavenge_root", nm);
 390   nmethod* last = NULL;
 391   nmethod* cur = scavenge_root_nmethods();
 392   while (cur != NULL) {
 393     nmethod* next = cur->scavenge_root_link();
 394     if (cur == nm) {
 395       if (last != NULL)
 396             last->set_scavenge_root_link(next);
 397       else  set_scavenge_root_nmethods(next);
 398       nm->set_scavenge_root_link(NULL);
 399       nm->clear_on_scavenge_root_list();
 400       return;
 401     }
 402     last = cur;
 403     cur = next;
 404   }
 405   assert(false, "should have been on list");
 406 }
 407 
 408 void CodeCache::prune_scavenge_root_nmethods() {
 409   assert_locked_or_safepoint(CodeCache_lock);
 410 
 411   if (UseG1GC || UseShenandoahGC) {
 412     return;
 413   }
 414 
 415   debug_only(mark_scavenge_root_nmethods());
 416 
 417   nmethod* last = NULL;
 418   nmethod* cur = scavenge_root_nmethods();
 419   while (cur != NULL) {
 420     nmethod* next = cur->scavenge_root_link();
 421     debug_only(cur->clear_scavenge_root_marked());
 422     assert(cur->scavenge_root_not_marked(), "");
 423     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 424 
 425     if (!cur->is_zombie() && !cur->is_unloaded()
 426         && cur->detect_scavenge_root_oops()) {
 427       // Keep it.  Advance 'last' to prevent deletion.
 428       last = cur;
 429     } else {
 430       // Prune it from the list, so we don't have to look at it any more.
 431       print_trace("prune_scavenge_root", cur);
 432       cur->set_scavenge_root_link(NULL);
 433       cur->clear_on_scavenge_root_list();
 434       if (last != NULL)
 435             last->set_scavenge_root_link(next);
 436       else  set_scavenge_root_nmethods(next);
 437     }
 438     cur = next;
 439   }
 440 
 441   // Check for stray marks.
 442   debug_only(verify_perm_nmethods(NULL));
 443 }
 444 
 445 #ifndef PRODUCT
 446 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
 447   if (UseG1GC || UseShenandoahGC) {
 448     return;
 449   }
 450 
 451   // While we are here, verify the integrity of the list.
 452   mark_scavenge_root_nmethods();
 453   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 454     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 455     cur->clear_scavenge_root_marked();
 456   }
 457   verify_perm_nmethods(f);
 458 }
 459 
 460 // Temporarily mark nmethods that are claimed to be on the non-perm list.
 461 void CodeCache::mark_scavenge_root_nmethods() {
 462   FOR_ALL_ALIVE_BLOBS(cb) {
 463     if (cb->is_nmethod()) {
 464       nmethod *nm = (nmethod*)cb;
 465       assert(nm->scavenge_root_not_marked(), "clean state");
 466       if (nm->on_scavenge_root_list())
 467         nm->set_scavenge_root_marked();


 958     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
 959                  p2i(_heap->low_boundary()),
 960                  p2i(_heap->high()),
 961                  p2i(_heap->high_boundary()));
 962     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
 963                  " adapters=" UINT32_FORMAT,
 964                  nof_blobs(), nof_nmethods(), nof_adapters());
 965     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
 966                  "enabled" : Arguments::mode() == Arguments::_int ?
 967                  "disabled (interpreter mode)" :
 968                  "disabled (not enough contiguous free space left)");
 969   }
 970 }
 971 
 972 void CodeCache::log_state(outputStream* st) {
 973   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
 974             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
 975             nof_blobs(), nof_nmethods(), nof_adapters(),
 976             unallocated_capacity());
 977 }

< prev index next >