Mercurial > hg > truffle
comparison src/share/vm/memory/cardTableModRefBS.cpp @ 3256:c69b1043dfb1
7036482: clear argument is redundant and unused in cardtable methods
Summary: Removed the unused clear argument to various cardtbale methods and unused mod_oop_in_space_iterate method. Unrelated to synopsis, added a pair of clarifying parens in AllocationStats constructor.
Reviewed-by: brutisso, jcoomes
author | ysr |
---|---|
date | Thu, 14 Apr 2011 12:10:15 -0700 |
parents | f95d63e2154a |
children | c48ad6ab8bdf |
comparison
equal
deleted
inserted
replaced
3254:59766fd005ff | 3256:c69b1043dfb1 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
457 | 457 |
458 | 458 |
459 void CardTableModRefBS::non_clean_card_iterate(Space* sp, | 459 void CardTableModRefBS::non_clean_card_iterate(Space* sp, |
460 MemRegion mr, | 460 MemRegion mr, |
461 DirtyCardToOopClosure* dcto_cl, | 461 DirtyCardToOopClosure* dcto_cl, |
462 MemRegionClosure* cl, | 462 MemRegionClosure* cl) { |
463 bool clear) { | |
464 if (!mr.is_empty()) { | 463 if (!mr.is_empty()) { |
465 int n_threads = SharedHeap::heap()->n_par_threads(); | 464 int n_threads = SharedHeap::heap()->n_par_threads(); |
466 if (n_threads > 0) { | 465 if (n_threads > 0) { |
467 #ifndef SERIALGC | 466 #ifndef SERIALGC |
468 par_non_clean_card_iterate_work(sp, mr, dcto_cl, cl, clear, n_threads); | 467 par_non_clean_card_iterate_work(sp, mr, dcto_cl, cl, n_threads); |
469 #else // SERIALGC | 468 #else // SERIALGC |
470 fatal("Parallel gc not supported here."); | 469 fatal("Parallel gc not supported here."); |
471 #endif // SERIALGC | 470 #endif // SERIALGC |
472 } else { | 471 } else { |
473 non_clean_card_iterate_work(mr, cl, clear); | 472 non_clean_card_iterate_work(mr, cl); |
474 } | 473 } |
475 } | 474 } |
476 } | 475 } |
477 | 476 |
478 // NOTE: For this to work correctly, it is important that | 477 // NOTE: For this to work correctly, it is important that |
479 // we look for non-clean cards below (so as to catch those | 478 // we look for non-clean cards below (so as to catch those |
480 // marked precleaned), rather than look explicitly for dirty | 479 // marked precleaned), rather than look explicitly for dirty |
481 // cards (and miss those marked precleaned). In that sense, | 480 // cards (and miss those marked precleaned). In that sense, |
482 // the name precleaned is currently somewhat of a misnomer. | 481 // the name precleaned is currently somewhat of a misnomer. |
483 void CardTableModRefBS::non_clean_card_iterate_work(MemRegion mr, | 482 void CardTableModRefBS::non_clean_card_iterate_work(MemRegion mr, |
484 MemRegionClosure* cl, | 483 MemRegionClosure* cl) { |
485 bool clear) { | |
486 // Figure out whether we have to worry about parallelism. | |
487 bool is_par = (SharedHeap::heap()->n_par_threads() > 1); | |
488 for (int i = 0; i < _cur_covered_regions; i++) { | 484 for (int i = 0; i < _cur_covered_regions; i++) { |
489 MemRegion mri = mr.intersection(_covered[i]); | 485 MemRegion mri = mr.intersection(_covered[i]); |
490 if (mri.word_size() > 0) { | 486 if (mri.word_size() > 0) { |
491 jbyte* cur_entry = byte_for(mri.last()); | 487 jbyte* cur_entry = byte_for(mri.last()); |
492 jbyte* limit = byte_for(mri.start()); | 488 jbyte* limit = byte_for(mri.start()); |
504 // objects beyond the end of the region are not processed, make | 500 // objects beyond the end of the region are not processed, make |
505 // cur_cards precise with regard to the end of the memory region. | 501 // cur_cards precise with regard to the end of the memory region. |
506 MemRegion cur_cards(addr_for(cur_entry), | 502 MemRegion cur_cards(addr_for(cur_entry), |
507 non_clean_cards * card_size_in_words); | 503 non_clean_cards * card_size_in_words); |
508 MemRegion dirty_region = cur_cards.intersection(mri); | 504 MemRegion dirty_region = cur_cards.intersection(mri); |
509 if (clear) { | |
510 for (size_t i = 0; i < non_clean_cards; i++) { | |
511 // Clean the dirty cards (but leave the other non-clean | |
512 // alone.) If parallel, do the cleaning atomically. | |
513 jbyte cur_entry_val = cur_entry[i]; | |
514 if (card_is_dirty_wrt_gen_iter(cur_entry_val)) { | |
515 if (is_par) { | |
516 jbyte res = Atomic::cmpxchg(clean_card, &cur_entry[i], cur_entry_val); | |
517 assert(res != clean_card, | |
518 "Dirty card mysteriously cleaned"); | |
519 } else { | |
520 cur_entry[i] = clean_card; | |
521 } | |
522 } | |
523 } | |
524 } | |
525 cl->do_MemRegion(dirty_region); | 505 cl->do_MemRegion(dirty_region); |
526 } | 506 } |
527 cur_entry = next_entry; | 507 cur_entry = next_entry; |
528 } | 508 } |
529 } | 509 } |
530 } | 510 } |
531 } | |
532 | |
533 void CardTableModRefBS::mod_oop_in_space_iterate(Space* sp, | |
534 OopClosure* cl, | |
535 bool clear, | |
536 bool before_save_marks) { | |
537 // Note that dcto_cl is resource-allocated, so there is no | |
538 // corresponding "delete". | |
539 DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision()); | |
540 MemRegion used_mr; | |
541 if (before_save_marks) { | |
542 used_mr = sp->used_region_at_save_marks(); | |
543 } else { | |
544 used_mr = sp->used_region(); | |
545 } | |
546 non_clean_card_iterate(sp, used_mr, dcto_cl, dcto_cl, clear); | |
547 } | 511 } |
548 | 512 |
549 void CardTableModRefBS::dirty_MemRegion(MemRegion mr) { | 513 void CardTableModRefBS::dirty_MemRegion(MemRegion mr) { |
550 assert((HeapWord*)align_size_down((uintptr_t)mr.start(), HeapWordSize) == mr.start(), "Unaligned start"); | 514 assert((HeapWord*)align_size_down((uintptr_t)mr.start(), HeapWordSize) == mr.start(), "Unaligned start"); |
551 assert((HeapWord*)align_size_up ((uintptr_t)mr.end(), HeapWordSize) == mr.end(), "Unaligned end" ); | 515 assert((HeapWord*)align_size_up ((uintptr_t)mr.end(), HeapWordSize) == mr.end(), "Unaligned end" ); |
591 jbyte* first = byte_for(mr.start()); | 555 jbyte* first = byte_for(mr.start()); |
592 jbyte* last = byte_after(mr.last()); | 556 jbyte* last = byte_after(mr.last()); |
593 memset(first, dirty_card, last-first); | 557 memset(first, dirty_card, last-first); |
594 } | 558 } |
595 | 559 |
596 // NOTES: | 560 // Unlike several other card table methods, dirty_card_iterate() |
597 // (1) Unlike mod_oop_in_space_iterate() above, dirty_card_iterate() | 561 // iterates over dirty cards ranges in increasing address order. |
598 // iterates over dirty cards ranges in increasing address order. | |
599 void CardTableModRefBS::dirty_card_iterate(MemRegion mr, | 562 void CardTableModRefBS::dirty_card_iterate(MemRegion mr, |
600 MemRegionClosure* cl) { | 563 MemRegionClosure* cl) { |
601 for (int i = 0; i < _cur_covered_regions; i++) { | 564 for (int i = 0; i < _cur_covered_regions; i++) { |
602 MemRegion mri = mr.intersection(_covered[i]); | 565 MemRegion mri = mr.intersection(_covered[i]); |
603 if (!mri.is_empty()) { | 566 if (!mri.is_empty()) { |
696 } | 659 } |
697 }; | 660 }; |
698 | 661 |
699 void CardTableModRefBS::verify_clean_region(MemRegion mr) { | 662 void CardTableModRefBS::verify_clean_region(MemRegion mr) { |
700 GuaranteeNotModClosure blk(this); | 663 GuaranteeNotModClosure blk(this); |
701 non_clean_card_iterate_work(mr, &blk, false); | 664 non_clean_card_iterate_work(mr, &blk); |
702 } | 665 } |
703 | 666 |
704 // To verify a MemRegion is entirely dirty this closure is passed to | 667 // To verify a MemRegion is entirely dirty this closure is passed to |
705 // dirty_card_iterate. If the region is dirty do_MemRegion will be | 668 // dirty_card_iterate. If the region is dirty do_MemRegion will be |
706 // invoked only once with a MemRegion equal to the one being | 669 // invoked only once with a MemRegion equal to the one being |