1.1 --- a/src/share/vm/memory/cardTableModRefBS.hpp Wed Jun 04 13:51:09 2008 -0700 1.2 +++ b/src/share/vm/memory/cardTableModRefBS.hpp Thu Jun 05 15:57:56 2008 -0700 1.3 @@ -54,6 +54,7 @@ 1.4 clean_card = -1, 1.5 dirty_card = 0, 1.6 precleaned_card = 1, 1.7 + claimed_card = 3, 1.8 last_card = 4, 1.9 CT_MR_BS_last_reserved = 10 1.10 }; 1.11 @@ -150,17 +151,6 @@ 1.12 return byte_for(p) + 1; 1.13 } 1.14 1.15 - // Mapping from card marking array entry to address of first word 1.16 - HeapWord* addr_for(const jbyte* p) const { 1.17 - assert(p >= _byte_map && p < _byte_map + _byte_map_size, 1.18 - "out of bounds access to card marking array"); 1.19 - size_t delta = pointer_delta(p, byte_map_base, sizeof(jbyte)); 1.20 - HeapWord* result = (HeapWord*) (delta << card_shift); 1.21 - assert(_whole_heap.contains(result), 1.22 - "out of bounds accessor from card marking array"); 1.23 - return result; 1.24 - } 1.25 - 1.26 // Iterate over the portion of the card-table which covers the given 1.27 // region mr in the given space and apply cl to any dirty sub-regions 1.28 // of mr. cl and dcto_cl must either be the same closure or cl must 1.29 @@ -263,16 +253,22 @@ 1.30 card_size_in_words = card_size / sizeof(HeapWord) 1.31 }; 1.32 1.33 + static int clean_card_val() { return clean_card; } 1.34 + static int dirty_card_val() { return dirty_card; } 1.35 + static int claimed_card_val() { return claimed_card; } 1.36 + static int precleaned_card_val() { return precleaned_card; } 1.37 + 1.38 // For RTTI simulation. 1.39 - BarrierSet::Name kind() { return BarrierSet::CardTableModRef; } 1.40 bool is_a(BarrierSet::Name bsn) { 1.41 - return bsn == BarrierSet::CardTableModRef || bsn == BarrierSet::ModRef; 1.42 + return bsn == BarrierSet::CardTableModRef || ModRefBarrierSet::is_a(bsn); 1.43 } 1.44 1.45 CardTableModRefBS(MemRegion whole_heap, int max_covered_regions); 1.46 1.47 // *** Barrier set functions. 1.48 1.49 + bool has_write_ref_pre_barrier() { return false; } 1.50 + 1.51 inline bool write_ref_needs_barrier(void* field, oop new_val) { 1.52 // Note that this assumes the perm gen is the highest generation 1.53 // in the address space 1.54 @@ -315,11 +311,33 @@ 1.55 1.56 // *** Card-table-barrier-specific things. 1.57 1.58 + inline void inline_write_ref_field_pre(void* field, oop newVal) {} 1.59 + 1.60 inline void inline_write_ref_field(void* field, oop newVal) { 1.61 jbyte* byte = byte_for(field); 1.62 *byte = dirty_card; 1.63 } 1.64 1.65 + // These are used by G1, when it uses the card table as a temporary data 1.66 + // structure for card claiming. 1.67 + bool is_card_dirty(size_t card_index) { 1.68 + return _byte_map[card_index] == dirty_card_val(); 1.69 + } 1.70 + 1.71 + void mark_card_dirty(size_t card_index) { 1.72 + _byte_map[card_index] = dirty_card_val(); 1.73 + } 1.74 + 1.75 + bool is_card_claimed(size_t card_index) { 1.76 + return _byte_map[card_index] == claimed_card_val(); 1.77 + } 1.78 + 1.79 + bool claim_card(size_t card_index); 1.80 + 1.81 + bool is_card_clean(size_t card_index) { 1.82 + return _byte_map[card_index] == clean_card_val(); 1.83 + } 1.84 + 1.85 // Card marking array base (adjusted for heap low boundary) 1.86 // This would be the 0th element of _byte_map, if the heap started at 0x0. 1.87 // But since the heap starts at some higher address, this points to somewhere 1.88 @@ -344,8 +362,9 @@ 1.89 } 1.90 1.91 // ModRefBS functions. 1.92 - void invalidate(MemRegion mr); 1.93 + virtual void invalidate(MemRegion mr, bool whole_heap = false); 1.94 void clear(MemRegion mr); 1.95 + void dirty(MemRegion mr); 1.96 void mod_oop_in_space_iterate(Space* sp, OopClosure* cl, 1.97 bool clear = false, 1.98 bool before_save_marks = false); 1.99 @@ -375,18 +394,39 @@ 1.100 1.101 static uintx ct_max_alignment_constraint(); 1.102 1.103 - // Apply closure cl to the dirty cards lying completely 1.104 - // within MemRegion mr, setting the cards to precleaned. 1.105 - void dirty_card_iterate(MemRegion mr, MemRegionClosure* cl); 1.106 + // Apply closure "cl" to the dirty cards containing some part of 1.107 + // MemRegion "mr". 1.108 + void dirty_card_iterate(MemRegion mr, MemRegionClosure* cl); 1.109 1.110 // Return the MemRegion corresponding to the first maximal run 1.111 - // of dirty cards lying completely within MemRegion mr, after 1.112 - // marking those cards precleaned. 1.113 - MemRegion dirty_card_range_after_preclean(MemRegion mr); 1.114 + // of dirty cards lying completely within MemRegion mr. 1.115 + // If reset is "true", then sets those card table entries to the given 1.116 + // value. 1.117 + MemRegion dirty_card_range_after_reset(MemRegion mr, bool reset, 1.118 + int reset_val); 1.119 1.120 // Set all the dirty cards in the given region to precleaned state. 1.121 void preclean_dirty_cards(MemRegion mr); 1.122 1.123 + // Provide read-only access to the card table array. 1.124 + const jbyte* byte_for_const(const void* p) const { 1.125 + return byte_for(p); 1.126 + } 1.127 + const jbyte* byte_after_const(const void* p) const { 1.128 + return byte_after(p); 1.129 + } 1.130 + 1.131 + // Mapping from card marking array entry to address of first word 1.132 + HeapWord* addr_for(const jbyte* p) const { 1.133 + assert(p >= _byte_map && p < _byte_map + _byte_map_size, 1.134 + "out of bounds access to card marking array"); 1.135 + size_t delta = pointer_delta(p, byte_map_base, sizeof(jbyte)); 1.136 + HeapWord* result = (HeapWord*) (delta << card_shift); 1.137 + assert(_whole_heap.contains(result), 1.138 + "out of bounds accessor from card marking array"); 1.139 + return result; 1.140 + } 1.141 + 1.142 // Mapping from address to card marking array index. 1.143 int index_for(void* p) { 1.144 assert(_whole_heap.contains(p), 1.145 @@ -402,6 +442,7 @@ 1.146 static size_t par_chunk_heapword_alignment() { 1.147 return CardsPerStrideChunk * card_size_in_words; 1.148 } 1.149 + 1.150 }; 1.151 1.152 class CardTableRS;