1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| class CardTableModRefBS: public ModRefBarrierSet {
public: enum SomePublicConstants { card_shift = 9, card_size = 1 << card_shift, card_size_in_words = card_size / sizeof(HeapWord) }; enum CardValues { clean_card = -1, clean_card_mask = clean_card - 31,
dirty_card = 0, precleaned_card = 1, claimed_card = 2, deferred_card = 4, last_card = 8, CT_MR_BS_last_reserved = 16 }; static int clean_card_val() { return clean_card; } static int clean_card_mask_val() { return clean_card_mask; } static int dirty_card_val() { return dirty_card; } static int claimed_card_val() { return claimed_card; } static int precleaned_card_val() { return precleaned_card; } static int deferred_card_val() { return deferred_card; } const MemRegion _whole_heap; size_t _byte_map_size; jbyte* _byte_map; jbyte* byte_map_base; void CardTableModRefBS::initialize() { HeapWord* low_bound = _whole_heap.start(); HeapWord* high_bound = _whole_heap.end();
ReservedSpace heap_rs(_byte_map_size, rs_align, false);
_byte_map = (jbyte*) heap_rs.base(); byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift); assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map"); assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
} jbyte* byte_for(const void* p) const { assert(_whole_heap.contains(p), err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of " " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")", p2i(p), p2i(_whole_heap.start()), p2i(_whole_heap.end()))); jbyte* result = &byte_map_base[uintptr_t(p) >> card_shift]; assert(result >= _byte_map && result < _byte_map + _byte_map_size, "out of bounds accessor for card marking array"); return result; } size_t index_for(void* p) { assert(_whole_heap.contains(p), err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of " " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")", p2i(p), p2i(_whole_heap.start()), p2i(_whole_heap.end()))); return byte_for(p) - _byte_map; } bool is_card_dirty(size_t card_index) { return _byte_map[card_index] == dirty_card_val(); } }
|