45 };
46
47 class G1CardTable: public CardTable {
48 friend class VMStructs;
49 friend class G1CardTableChangedListener;
50
51 G1CardTableChangedListener _listener;
52
53 enum G1CardValues {
54 g1_young_gen = CT_MR_BS_last_reserved << 1
55 };
56
57 public:
58 G1CardTable(MemRegion whole_heap): CardTable(whole_heap, /* scanned concurrently */ true), _listener() {
59 _listener.set_card_table(this);
60 }
61 bool is_card_dirty(size_t card_index) {
62 return _byte_map[card_index] == dirty_card_val();
63 }
64
65 static CardValue g1_young_card_val() { return g1_young_gen; }
66
67 /*
68 Claimed and deferred bits are used together in G1 during the evacuation
69 pause. These bits can have the following state transitions:
70 1. The claimed bit can be put over any other card state. Except that
71 the "dirty -> dirty and claimed" transition is checked for in
72 G1 code and is not used.
73 2. Deferred bit can be set only if the previous state of the card
74 was either clean or claimed. mark_card_deferred() is wait-free.
75 We do not care if the operation is be successful because if
76 it does not it will only result in duplicate entry in the update
77 buffer because of the "cache-miss". So it's not worth spinning.
78 */
79
80 bool is_card_claimed(size_t card_index) {
81 CardValue val = _byte_map[card_index];
82 return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val();
83 }
84
85 inline void set_card_claimed(size_t card_index);
86
87 void verify_g1_young_region(MemRegion mr) PRODUCT_RETURN;
88 void g1_mark_as_young(const MemRegion& mr);
89
90 bool mark_card_deferred(size_t card_index);
91
92 bool is_card_deferred(size_t card_index) {
93 CardValue val = _byte_map[card_index];
94 return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val();
95 }
96
97 static size_t compute_size(size_t mem_region_size_in_words) {
98 size_t number_of_slots = (mem_region_size_in_words / card_size_in_words);
99 return ReservedSpace::allocation_align_size_up(number_of_slots);
100 }
101
102 // Returns how many bytes of the heap a single byte of the Card Table corresponds to.
103 static size_t heap_map_factor() { return card_size; }
104
105 void initialize() {}
106 void initialize(G1RegionToSpaceMapper* mapper);
107
|
45 };
46
47 class G1CardTable: public CardTable {
48 friend class VMStructs;
49 friend class G1CardTableChangedListener;
50
51 G1CardTableChangedListener _listener;
52
53 enum G1CardValues {
54 g1_young_gen = CT_MR_BS_last_reserved << 1
55 };
56
57 public:
58 G1CardTable(MemRegion whole_heap): CardTable(whole_heap, /* scanned concurrently */ true), _listener() {
59 _listener.set_card_table(this);
60 }
61 bool is_card_dirty(size_t card_index) {
62 return _byte_map[card_index] == dirty_card_val();
63 }
64
65 static CardValue g1_young_card_val() {
66 assert(!G1FastWriteBarrier, "should not be called");
67 return g1_young_gen;
68 }
69
70 /*
71 Claimed and deferred bits are used together in G1 during the evacuation
72 pause. These bits can have the following state transitions:
73 1. The claimed bit can be put over any other card state. Except that
74 the "dirty -> dirty and claimed" transition is checked for in
75 G1 code and is not used.
76 2. Deferred bit can be set only if the previous state of the card
77 was either clean or claimed. mark_card_deferred() is wait-free.
78 We do not care if the operation is be successful because if
79 it does not it will only result in duplicate entry in the update
80 buffer because of the "cache-miss". So it's not worth spinning.
81 */
82
83 bool is_card_claimed(size_t card_index) {
84 CardValue val = _byte_map[card_index];
85 return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val();
86 }
87
88 inline void set_card_claimed(size_t card_index);
89
90 void verify_g1_young_region(MemRegion mr) PRODUCT_RETURN;
91 void verfiy_claimed_dirty_region(MemRegion mr) PRODUCT_RETURN;
92 void g1_mark_as_young(const MemRegion& mr);
93
94 bool mark_card_deferred(size_t card_index);
95
96 bool is_card_deferred(size_t card_index) {
97 CardValue val = _byte_map[card_index];
98 return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val();
99 }
100
101 static size_t compute_size(size_t mem_region_size_in_words) {
102 size_t number_of_slots = (mem_region_size_in_words / card_size_in_words);
103 return ReservedSpace::allocation_align_size_up(number_of_slots);
104 }
105
106 // Returns how many bytes of the heap a single byte of the Card Table corresponds to.
107 static size_t heap_map_factor() { return card_size; }
108
109 void initialize() {}
110 void initialize(G1RegionToSpaceMapper* mapper);
111
|