Mercurial > hg > truffle
comparison src/share/vm/code/codeCache.cpp @ 20804:7848fc12602b
Merge with jdk8u40-b25
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 07 Apr 2015 14:58:49 +0200 |
parents | 52b4284cb496 aff6ccb506cb |
children |
comparison
equal
deleted
inserted
replaced
20184:84105dcdb05b | 20804:7848fc12602b |
---|---|
335 } | 335 } |
336 | 336 |
337 // Walk the list of methods which might contain non-perm oops. | 337 // Walk the list of methods which might contain non-perm oops. |
338 void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) { | 338 void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) { |
339 assert_locked_or_safepoint(CodeCache_lock); | 339 assert_locked_or_safepoint(CodeCache_lock); |
340 | |
341 if (UseG1GC) { | |
342 return; | |
343 } | |
344 | |
340 debug_only(mark_scavenge_root_nmethods()); | 345 debug_only(mark_scavenge_root_nmethods()); |
341 | 346 |
342 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { | 347 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
343 debug_only(cur->clear_scavenge_root_marked()); | 348 debug_only(cur->clear_scavenge_root_marked()); |
344 assert(cur->scavenge_root_not_marked(), ""); | 349 assert(cur->scavenge_root_not_marked(), ""); |
360 debug_only(verify_perm_nmethods(NULL)); | 365 debug_only(verify_perm_nmethods(NULL)); |
361 } | 366 } |
362 | 367 |
363 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { | 368 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { |
364 assert_locked_or_safepoint(CodeCache_lock); | 369 assert_locked_or_safepoint(CodeCache_lock); |
370 | |
371 if (UseG1GC) { | |
372 return; | |
373 } | |
374 | |
365 nm->set_on_scavenge_root_list(); | 375 nm->set_on_scavenge_root_list(); |
366 nm->set_scavenge_root_link(_scavenge_root_nmethods); | 376 nm->set_scavenge_root_link(_scavenge_root_nmethods); |
367 set_scavenge_root_nmethods(nm); | 377 set_scavenge_root_nmethods(nm); |
368 print_trace("add_scavenge_root", nm); | 378 print_trace("add_scavenge_root", nm); |
369 } | 379 } |
370 | 380 |
371 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { | 381 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { |
372 assert_locked_or_safepoint(CodeCache_lock); | 382 assert_locked_or_safepoint(CodeCache_lock); |
383 | |
384 if (UseG1GC) { | |
385 return; | |
386 } | |
387 | |
373 print_trace("drop_scavenge_root", nm); | 388 print_trace("drop_scavenge_root", nm); |
374 nmethod* last = NULL; | 389 nmethod* last = NULL; |
375 nmethod* cur = scavenge_root_nmethods(); | 390 nmethod* cur = scavenge_root_nmethods(); |
376 while (cur != NULL) { | 391 while (cur != NULL) { |
377 nmethod* next = cur->scavenge_root_link(); | 392 nmethod* next = cur->scavenge_root_link(); |
389 assert(false, "should have been on list"); | 404 assert(false, "should have been on list"); |
390 } | 405 } |
391 | 406 |
392 void CodeCache::prune_scavenge_root_nmethods() { | 407 void CodeCache::prune_scavenge_root_nmethods() { |
393 assert_locked_or_safepoint(CodeCache_lock); | 408 assert_locked_or_safepoint(CodeCache_lock); |
409 | |
410 if (UseG1GC) { | |
411 return; | |
412 } | |
413 | |
394 debug_only(mark_scavenge_root_nmethods()); | 414 debug_only(mark_scavenge_root_nmethods()); |
395 | 415 |
396 nmethod* last = NULL; | 416 nmethod* last = NULL; |
397 nmethod* cur = scavenge_root_nmethods(); | 417 nmethod* cur = scavenge_root_nmethods(); |
398 while (cur != NULL) { | 418 while (cur != NULL) { |
421 debug_only(verify_perm_nmethods(NULL)); | 441 debug_only(verify_perm_nmethods(NULL)); |
422 } | 442 } |
423 | 443 |
424 #ifndef PRODUCT | 444 #ifndef PRODUCT |
425 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { | 445 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { |
446 if (UseG1GC) { | |
447 return; | |
448 } | |
449 | |
426 // While we are here, verify the integrity of the list. | 450 // While we are here, verify the integrity of the list. |
427 mark_scavenge_root_nmethods(); | 451 mark_scavenge_root_nmethods(); |
428 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { | 452 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
429 assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); | 453 assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
430 cur->clear_scavenge_root_marked(); | 454 cur->clear_scavenge_root_marked(); |
461 if (call_f) f_or_null->do_code_blob(cb); | 485 if (call_f) f_or_null->do_code_blob(cb); |
462 } | 486 } |
463 } | 487 } |
464 #endif //PRODUCT | 488 #endif //PRODUCT |
465 | 489 |
490 void CodeCache::verify_clean_inline_caches() { | |
491 #ifdef ASSERT | |
492 FOR_ALL_ALIVE_BLOBS(cb) { | |
493 if (cb->is_nmethod()) { | |
494 nmethod* nm = (nmethod*)cb; | |
495 assert(!nm->is_unloaded(), "Tautology"); | |
496 nm->verify_clean_inline_caches(); | |
497 nm->verify(); | |
498 } | |
499 } | |
500 #endif | |
501 } | |
502 | |
503 void CodeCache::verify_icholder_relocations() { | |
504 #ifdef ASSERT | |
505 // make sure that we aren't leaking icholders | |
506 int count = 0; | |
507 FOR_ALL_BLOBS(cb) { | |
508 if (cb->is_nmethod()) { | |
509 nmethod* nm = (nmethod*)cb; | |
510 count += nm->verify_icholder_relocations(); | |
511 } | |
512 } | |
513 | |
514 assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() == | |
515 CompiledICHolder::live_count(), "must agree"); | |
516 #endif | |
517 } | |
466 | 518 |
467 void CodeCache::gc_prologue() { | 519 void CodeCache::gc_prologue() { |
468 assert(!nmethod::oops_do_marking_is_active(), "oops_do_marking_epilogue must be called"); | |
469 } | 520 } |
470 | 521 |
471 void CodeCache::gc_epilogue() { | 522 void CodeCache::gc_epilogue() { |
472 assert_locked_or_safepoint(CodeCache_lock); | 523 assert_locked_or_safepoint(CodeCache_lock); |
473 FOR_ALL_ALIVE_BLOBS(cb) { | 524 FOR_ALL_ALIVE_BLOBS(cb) { |
476 assert(!nm->is_unloaded(), "Tautology"); | 527 assert(!nm->is_unloaded(), "Tautology"); |
477 if (needs_cache_clean()) { | 528 if (needs_cache_clean()) { |
478 nm->cleanup_inline_caches(); | 529 nm->cleanup_inline_caches(); |
479 } | 530 } |
480 DEBUG_ONLY(nm->verify()); | 531 DEBUG_ONLY(nm->verify()); |
481 nm->fix_oop_relocations(); | 532 DEBUG_ONLY(nm->verify_oop_relocations()); |
482 } | 533 } |
483 } | 534 } |
484 set_needs_cache_clean(false); | 535 set_needs_cache_clean(false); |
485 prune_scavenge_root_nmethods(); | 536 prune_scavenge_root_nmethods(); |
486 assert(!nmethod::oops_do_marking_is_active(), "oops_do_marking_prologue must be called"); | 537 |
487 | 538 verify_icholder_relocations(); |
488 #ifdef ASSERT | 539 } |
489 // make sure that we aren't leaking icholders | |
490 int count = 0; | |
491 FOR_ALL_BLOBS(cb) { | |
492 if (cb->is_nmethod()) { | |
493 RelocIterator iter((nmethod*)cb); | |
494 while(iter.next()) { | |
495 if (iter.type() == relocInfo::virtual_call_type) { | |
496 if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) { | |
497 CompiledIC *ic = CompiledIC_at(iter.reloc()); | |
498 if (TraceCompiledIC) { | |
499 tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); | |
500 ic->print(); | |
501 } | |
502 assert(ic->cached_icholder() != NULL, "must be non-NULL"); | |
503 count++; | |
504 } | |
505 } | |
506 } | |
507 } | |
508 } | |
509 | |
510 assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() == | |
511 CompiledICHolder::live_count(), "must agree"); | |
512 #endif | |
513 } | |
514 | |
515 | 540 |
516 void CodeCache::verify_oops() { | 541 void CodeCache::verify_oops() { |
517 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | 542 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
518 VerifyOopClosure voc; | 543 VerifyOopClosure voc; |
519 FOR_ALL_ALIVE_BLOBS(cb) { | 544 FOR_ALL_ALIVE_BLOBS(cb) { |
685 | 710 |
686 // Deoptimize all methods | 711 // Deoptimize all methods |
687 void CodeCache::mark_all_nmethods_for_deoptimization() { | 712 void CodeCache::mark_all_nmethods_for_deoptimization() { |
688 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | 713 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
689 FOR_ALL_ALIVE_NMETHODS(nm) { | 714 FOR_ALL_ALIVE_NMETHODS(nm) { |
690 nm->mark_for_deoptimization(); | 715 if (!nm->method()->is_method_handle_intrinsic()) { |
716 nm->mark_for_deoptimization(); | |
717 } | |
691 } | 718 } |
692 } | 719 } |
693 | 720 |
694 | 721 |
695 int CodeCache::mark_for_deoptimization(Method* dependee) { | 722 int CodeCache::mark_for_deoptimization(Method* dependee) { |