21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "memory/cardTableRS.hpp"
28 #include "memory/genCollectedHeap.hpp"
29 #include "memory/generation.hpp"
30 #include "memory/space.inline.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "runtime/atomic.inline.hpp"
33 #include "runtime/java.hpp"
34 #include "runtime/os.hpp"
35 #include "utilities/macros.hpp"
36
37 CardTableRS::CardTableRS(MemRegion whole_heap) :
38 GenRemSet(),
39 _cur_youngergen_card_val(youngergenP1_card)
40 {
41 guarantee(Universe::heap()->kind() == CollectedHeap::GenCollectedHeap, "sanity");
42 _ct_bs = new CardTableModRefBSForCTRS(whole_heap);
43 _ct_bs->initialize();
44 set_bs(_ct_bs);
45 // max_gens is really GenCollectedHeap::heap()->gen_policy()->number_of_generations()
46 // (which is always 2, young & old), but GenCollectedHeap has not been initialized yet.
47 uint max_gens = 2;
48 _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, max_gens + 1,
49 mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
50 if (_last_cur_val_in_gen == NULL) {
51 vm_exit_during_initialization("Could not create last_cur_val_in_gen array.");
52 }
53 for (uint i = 0; i < max_gens + 1; i++) {
54 _last_cur_val_in_gen[i] = clean_card_val();
55 }
56 _ct_bs->set_CTRS(this);
57 }
58
59 CardTableRS::~CardTableRS() {
60 if (_ct_bs) {
61 delete _ct_bs;
577 // lie in the occupied part of the space at the beginning of a
578 // young collection, its rank can either decline or stay unchanged.
579 // In this case, no extra work is done in terms of redundant
580 // younger refs scanning of that card.
581 // Then, the case analysis above reveals that, in the worst case,
582 // any such stale card will be scanned unnecessarily at most twice.
583 //
584 // It is nonetheless advisable to try and get rid of some of this
585 // redundant work in a subsequent (low priority) re-design of
586 // the card-scanning code, if only to simplify the underlying
587 // state machine analysis/proof. ysr 1/28/2002. XXX
588 cur_entry++;
589 }
590 }
591 }
592
593 void CardTableRS::verify() {
594 // At present, we only know how to verify the card table RS for
595 // generational heaps.
596 VerifyCTGenClosure blk(this);
597 CollectedHeap* ch = Universe::heap();
598
599 if (ch->kind() == CollectedHeap::GenCollectedHeap) {
600 GenCollectedHeap::heap()->generation_iterate(&blk, false);
601 _ct_bs->verify();
602 }
603 }
|
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "memory/cardTableRS.hpp"
28 #include "memory/genCollectedHeap.hpp"
29 #include "memory/generation.hpp"
30 #include "memory/space.inline.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "runtime/atomic.inline.hpp"
33 #include "runtime/java.hpp"
34 #include "runtime/os.hpp"
35 #include "utilities/macros.hpp"
36
37 CardTableRS::CardTableRS(MemRegion whole_heap) :
38 GenRemSet(),
39 _cur_youngergen_card_val(youngergenP1_card)
40 {
41 _ct_bs = new CardTableModRefBSForCTRS(whole_heap);
42 _ct_bs->initialize();
43 set_bs(_ct_bs);
44 // max_gens is really GenCollectedHeap::heap()->gen_policy()->number_of_generations()
45 // (which is always 2, young & old), but GenCollectedHeap has not been initialized yet.
46 uint max_gens = 2;
47 _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, max_gens + 1,
48 mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
49 if (_last_cur_val_in_gen == NULL) {
50 vm_exit_during_initialization("Could not create last_cur_val_in_gen array.");
51 }
52 for (uint i = 0; i < max_gens + 1; i++) {
53 _last_cur_val_in_gen[i] = clean_card_val();
54 }
55 _ct_bs->set_CTRS(this);
56 }
57
58 CardTableRS::~CardTableRS() {
59 if (_ct_bs) {
60 delete _ct_bs;
576 // lie in the occupied part of the space at the beginning of a
577 // young collection, its rank can either decline or stay unchanged.
578 // In this case, no extra work is done in terms of redundant
579 // younger refs scanning of that card.
580 // Then, the case analysis above reveals that, in the worst case,
581 // any such stale card will be scanned unnecessarily at most twice.
582 //
583 // It is nonetheless advisable to try and get rid of some of this
584 // redundant work in a subsequent (low priority) re-design of
585 // the card-scanning code, if only to simplify the underlying
586 // state machine analysis/proof. ysr 1/28/2002. XXX
587 cur_entry++;
588 }
589 }
590 }
591
592 void CardTableRS::verify() {
593 // At present, we only know how to verify the card table RS for
594 // generational heaps.
595 VerifyCTGenClosure blk(this);
596 GenCollectedHeap::heap()->generation_iterate(&blk, false);
597 _ct_bs->verify();
598 }
|