< prev index next >

src/share/vm/code/codeCache.cpp

Print this page




 329     nm->do_unloading(is_alive, unloading_occurred);
 330   }
 331 }
 332 
 333 void CodeCache::blobs_do(CodeBlobClosure* f) {
 334   assert_locked_or_safepoint(CodeCache_lock);
 335   FOR_ALL_ALIVE_BLOBS(cb) {
 336     f->do_code_blob(cb);
 337 
 338 #ifdef ASSERT
 339     if (cb->is_nmethod())
 340       ((nmethod*)cb)->verify_scavenge_root_oops();
 341 #endif //ASSERT
 342   }
 343 }
 344 
 345 // Walk the list of methods which might contain non-perm oops.
 346 void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) {
 347   assert_locked_or_safepoint(CodeCache_lock);
 348 
 349   if (UseG1GC) {
 350     return;
 351   }
 352 
 353   const bool fix_relocations = f->fix_relocations();
 354   debug_only(mark_scavenge_root_nmethods());
 355 
 356   nmethod* prev = NULL;
 357   nmethod* cur = scavenge_root_nmethods();
 358   while (cur != NULL) {
 359     debug_only(cur->clear_scavenge_root_marked());
 360     assert(cur->scavenge_root_not_marked(), "");
 361     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 362 
 363     bool is_live = (!cur->is_zombie() && !cur->is_unloaded());
 364 #ifndef PRODUCT
 365     if (TraceScavenge) {
 366       cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr();
 367     }
 368 #endif //PRODUCT
 369     if (is_live) {


 374     // The scavengable nmethod list must contain all methods with scavengable
 375     // oops. It is safe to include more nmethod on the list, but we do not
 376     // expect any live non-scavengable nmethods on the list.
 377     if (fix_relocations) {
 378       if (!is_live || !cur->detect_scavenge_root_oops()) {
 379         unlink_scavenge_root_nmethod(cur, prev);
 380       } else {
 381         prev = cur;
 382       }
 383     }
 384     cur = next;
 385   }
 386 
 387   // Check for stray marks.
 388   debug_only(verify_perm_nmethods(NULL));
 389 }
 390 
 391 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
 392   assert_locked_or_safepoint(CodeCache_lock);
 393 
 394   if (UseG1GC) {
 395     return;
 396   }
 397 
 398   nm->set_on_scavenge_root_list();
 399   nm->set_scavenge_root_link(_scavenge_root_nmethods);
 400   set_scavenge_root_nmethods(nm);
 401   print_trace("add_scavenge_root", nm);
 402 }
 403 
 404 void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) {
 405   assert_locked_or_safepoint(CodeCache_lock);
 406 
 407   assert((prev == NULL && scavenge_root_nmethods() == nm) ||
 408          (prev != NULL && prev->scavenge_root_link() == nm), "precondition");
 409 
 410   assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list");
 411 
 412   print_trace("unlink_scavenge_root", nm);
 413   if (prev == NULL) {
 414     set_scavenge_root_nmethods(nm->scavenge_root_link());
 415   } else {
 416     prev->set_scavenge_root_link(nm->scavenge_root_link());
 417   }
 418   nm->set_scavenge_root_link(NULL);
 419   nm->clear_on_scavenge_root_list();
 420 }
 421 
 422 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
 423   assert_locked_or_safepoint(CodeCache_lock);
 424 
 425   if (UseG1GC) {
 426     return;
 427   }
 428 
 429   print_trace("drop_scavenge_root", nm);
 430   nmethod* prev = NULL;
 431   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 432     if (cur == nm) {
 433       unlink_scavenge_root_nmethod(cur, prev);
 434       return;
 435     }
 436     prev = cur;
 437   }
 438   assert(false, "should have been on list");
 439 }
 440 
 441 void CodeCache::prune_scavenge_root_nmethods() {
 442   assert_locked_or_safepoint(CodeCache_lock);
 443 
 444   if (UseG1GC) {
 445     return;
 446   }
 447 
 448   debug_only(mark_scavenge_root_nmethods());
 449 
 450   nmethod* last = NULL;
 451   nmethod* cur = scavenge_root_nmethods();
 452   while (cur != NULL) {
 453     nmethod* next = cur->scavenge_root_link();
 454     debug_only(cur->clear_scavenge_root_marked());
 455     assert(cur->scavenge_root_not_marked(), "");
 456     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 457 
 458     if (!cur->is_zombie() && !cur->is_unloaded()
 459         && cur->detect_scavenge_root_oops()) {
 460       // Keep it.  Advance 'last' to prevent deletion.
 461       last = cur;
 462     } else {
 463       // Prune it from the list, so we don't have to look at it any more.
 464       print_trace("prune_scavenge_root", cur);
 465       unlink_scavenge_root_nmethod(cur, last);
 466     }
 467     cur = next;
 468   }
 469 
 470   // Check for stray marks.
 471   debug_only(verify_perm_nmethods(NULL));
 472 }
 473 
 474 #ifndef PRODUCT
 475 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
 476   if (UseG1GC) {
 477     return;
 478   }
 479 
 480   // While we are here, verify the integrity of the list.
 481   mark_scavenge_root_nmethods();
 482   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 483     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 484     cur->clear_scavenge_root_marked();
 485   }
 486   verify_perm_nmethods(f);
 487 }
 488 
 489 // Temporarily mark nmethods that are claimed to be on the non-perm list.
 490 void CodeCache::mark_scavenge_root_nmethods() {
 491   FOR_ALL_ALIVE_BLOBS(cb) {
 492     if (cb->is_nmethod()) {
 493       nmethod *nm = (nmethod*)cb;
 494       assert(nm->scavenge_root_not_marked(), "clean state");
 495       if (nm->on_scavenge_root_list())
 496         nm->set_scavenge_root_marked();


 988     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
 989                  p2i(_heap->low_boundary()),
 990                  p2i(_heap->high()),
 991                  p2i(_heap->high_boundary()));
 992     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
 993                  " adapters=" UINT32_FORMAT,
 994                  nof_blobs(), nof_nmethods(), nof_adapters());
 995     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
 996                  "enabled" : Arguments::mode() == Arguments::_int ?
 997                  "disabled (interpreter mode)" :
 998                  "disabled (not enough contiguous free space left)");
 999   }
1000 }
1001 
1002 void CodeCache::log_state(outputStream* st) {
1003   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
1004             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
1005             nof_blobs(), nof_nmethods(), nof_adapters(),
1006             unallocated_capacity());
1007 }
1008 


 329     nm->do_unloading(is_alive, unloading_occurred);
 330   }
 331 }
 332 
 333 void CodeCache::blobs_do(CodeBlobClosure* f) {
 334   assert_locked_or_safepoint(CodeCache_lock);
 335   FOR_ALL_ALIVE_BLOBS(cb) {
 336     f->do_code_blob(cb);
 337 
 338 #ifdef ASSERT
 339     if (cb->is_nmethod())
 340       ((nmethod*)cb)->verify_scavenge_root_oops();
 341 #endif //ASSERT
 342   }
 343 }
 344 
 345 // Walk the list of methods which might contain non-perm oops.
 346 void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) {
 347   assert_locked_or_safepoint(CodeCache_lock);
 348 
 349   if (UseG1GC || UseShenandoahGC) {
 350     return;
 351   }
 352 
 353   const bool fix_relocations = f->fix_relocations();
 354   debug_only(mark_scavenge_root_nmethods());
 355 
 356   nmethod* prev = NULL;
 357   nmethod* cur = scavenge_root_nmethods();
 358   while (cur != NULL) {
 359     debug_only(cur->clear_scavenge_root_marked());
 360     assert(cur->scavenge_root_not_marked(), "");
 361     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 362 
 363     bool is_live = (!cur->is_zombie() && !cur->is_unloaded());
 364 #ifndef PRODUCT
 365     if (TraceScavenge) {
 366       cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr();
 367     }
 368 #endif //PRODUCT
 369     if (is_live) {


 374     // The scavengable nmethod list must contain all methods with scavengable
 375     // oops. It is safe to include more nmethod on the list, but we do not
 376     // expect any live non-scavengable nmethods on the list.
 377     if (fix_relocations) {
 378       if (!is_live || !cur->detect_scavenge_root_oops()) {
 379         unlink_scavenge_root_nmethod(cur, prev);
 380       } else {
 381         prev = cur;
 382       }
 383     }
 384     cur = next;
 385   }
 386 
 387   // Check for stray marks.
 388   debug_only(verify_perm_nmethods(NULL));
 389 }
 390 
 391 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
 392   assert_locked_or_safepoint(CodeCache_lock);
 393 
 394   if (UseG1GC || UseShenandoahGC) {
 395     return;
 396   }
 397 
 398   nm->set_on_scavenge_root_list();
 399   nm->set_scavenge_root_link(_scavenge_root_nmethods);
 400   set_scavenge_root_nmethods(nm);
 401   print_trace("add_scavenge_root", nm);
 402 }
 403 
 404 void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) {
 405   assert_locked_or_safepoint(CodeCache_lock);
 406 
 407   assert((prev == NULL && scavenge_root_nmethods() == nm) ||
 408          (prev != NULL && prev->scavenge_root_link() == nm), "precondition");
 409 
 410   assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list");
 411 
 412   print_trace("unlink_scavenge_root", nm);
 413   if (prev == NULL) {
 414     set_scavenge_root_nmethods(nm->scavenge_root_link());
 415   } else {
 416     prev->set_scavenge_root_link(nm->scavenge_root_link());
 417   }
 418   nm->set_scavenge_root_link(NULL);
 419   nm->clear_on_scavenge_root_list();
 420 }
 421 
 422 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
 423   assert_locked_or_safepoint(CodeCache_lock);
 424 
 425   if (UseG1GC || UseShenandoahGC) {
 426     return;
 427   }
 428 
 429   print_trace("drop_scavenge_root", nm);
 430   nmethod* prev = NULL;
 431   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 432     if (cur == nm) {
 433       unlink_scavenge_root_nmethod(cur, prev);
 434       return;
 435     }
 436     prev = cur;
 437   }
 438   assert(false, "should have been on list");
 439 }
 440 
 441 void CodeCache::prune_scavenge_root_nmethods() {
 442   assert_locked_or_safepoint(CodeCache_lock);
 443 
 444   if (UseG1GC || UseShenandoahGC) {
 445     return;
 446   }
 447 
 448   debug_only(mark_scavenge_root_nmethods());
 449 
 450   nmethod* last = NULL;
 451   nmethod* cur = scavenge_root_nmethods();
 452   while (cur != NULL) {
 453     nmethod* next = cur->scavenge_root_link();
 454     debug_only(cur->clear_scavenge_root_marked());
 455     assert(cur->scavenge_root_not_marked(), "");
 456     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 457 
 458     if (!cur->is_zombie() && !cur->is_unloaded()
 459         && cur->detect_scavenge_root_oops()) {
 460       // Keep it.  Advance 'last' to prevent deletion.
 461       last = cur;
 462     } else {
 463       // Prune it from the list, so we don't have to look at it any more.
 464       print_trace("prune_scavenge_root", cur);
 465       unlink_scavenge_root_nmethod(cur, last);
 466     }
 467     cur = next;
 468   }
 469 
 470   // Check for stray marks.
 471   debug_only(verify_perm_nmethods(NULL));
 472 }
 473 
 474 #ifndef PRODUCT
 475 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
 476   if (UseG1GC || UseShenandoahGC) {
 477     return;
 478   }
 479 
 480   // While we are here, verify the integrity of the list.
 481   mark_scavenge_root_nmethods();
 482   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
 483     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
 484     cur->clear_scavenge_root_marked();
 485   }
 486   verify_perm_nmethods(f);
 487 }
 488 
 489 // Temporarily mark nmethods that are claimed to be on the non-perm list.
 490 void CodeCache::mark_scavenge_root_nmethods() {
 491   FOR_ALL_ALIVE_BLOBS(cb) {
 492     if (cb->is_nmethod()) {
 493       nmethod *nm = (nmethod*)cb;
 494       assert(nm->scavenge_root_not_marked(), "clean state");
 495       if (nm->on_scavenge_root_list())
 496         nm->set_scavenge_root_marked();


 988     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
 989                  p2i(_heap->low_boundary()),
 990                  p2i(_heap->high()),
 991                  p2i(_heap->high_boundary()));
 992     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
 993                  " adapters=" UINT32_FORMAT,
 994                  nof_blobs(), nof_nmethods(), nof_adapters());
 995     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
 996                  "enabled" : Arguments::mode() == Arguments::_int ?
 997                  "disabled (interpreter mode)" :
 998                  "disabled (not enough contiguous free space left)");
 999   }
1000 }
1001 
1002 void CodeCache::log_state(outputStream* st) {
1003   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
1004             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
1005             nof_blobs(), nof_nmethods(), nof_adapters(),
1006             unallocated_capacity());
1007 }

< prev index next >