50 #endif |
50 #endif |
51 protected: |
51 protected: |
52 |
52 |
53 enum CardValues { |
53 enum CardValues { |
54 clean_card = -1, |
54 clean_card = -1, |
|
55 // The mask contains zeros in places for all other values. |
|
56 clean_card_mask = clean_card - 31, |
|
57 |
55 dirty_card = 0, |
58 dirty_card = 0, |
56 precleaned_card = 1, |
59 precleaned_card = 1, |
57 claimed_card = 3, |
60 claimed_card = 2, |
58 last_card = 4, |
61 deferred_card = 4, |
59 CT_MR_BS_last_reserved = 10 |
62 last_card = 8, |
|
63 CT_MR_BS_last_reserved = 16 |
60 }; |
64 }; |
61 |
65 |
62 // dirty and precleaned are equivalent wrt younger_refs_iter. |
66 // dirty and precleaned are equivalent wrt younger_refs_iter. |
63 static bool card_is_dirty_wrt_gen_iter(jbyte cv) { |
67 static bool card_is_dirty_wrt_gen_iter(jbyte cv) { |
64 return cv == dirty_card || cv == precleaned_card; |
68 return cv == dirty_card || cv == precleaned_card; |
252 card_size = 1 << card_shift, |
256 card_size = 1 << card_shift, |
253 card_size_in_words = card_size / sizeof(HeapWord) |
257 card_size_in_words = card_size / sizeof(HeapWord) |
254 }; |
258 }; |
255 |
259 |
256 static int clean_card_val() { return clean_card; } |
260 static int clean_card_val() { return clean_card; } |
|
261 static int clean_card_mask_val() { return clean_card_mask; } |
257 static int dirty_card_val() { return dirty_card; } |
262 static int dirty_card_val() { return dirty_card; } |
258 static int claimed_card_val() { return claimed_card; } |
263 static int claimed_card_val() { return claimed_card; } |
259 static int precleaned_card_val() { return precleaned_card; } |
264 static int precleaned_card_val() { return precleaned_card; } |
|
265 static int deferred_card_val() { return deferred_card; } |
260 |
266 |
261 // For RTTI simulation. |
267 // For RTTI simulation. |
262 bool is_a(BarrierSet::Name bsn) { |
268 bool is_a(BarrierSet::Name bsn) { |
263 return bsn == BarrierSet::CardTableModRef || ModRefBarrierSet::is_a(bsn); |
269 return bsn == BarrierSet::CardTableModRef || ModRefBarrierSet::is_a(bsn); |
264 } |
270 } |
327 void mark_card_dirty(size_t card_index) { |
333 void mark_card_dirty(size_t card_index) { |
328 _byte_map[card_index] = dirty_card_val(); |
334 _byte_map[card_index] = dirty_card_val(); |
329 } |
335 } |
330 |
336 |
331 bool is_card_claimed(size_t card_index) { |
337 bool is_card_claimed(size_t card_index) { |
332 return _byte_map[card_index] == claimed_card_val(); |
338 jbyte val = _byte_map[card_index]; |
|
339 return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val(); |
333 } |
340 } |
334 |
341 |
335 bool claim_card(size_t card_index); |
342 bool claim_card(size_t card_index); |
336 |
343 |
337 bool is_card_clean(size_t card_index) { |
344 bool is_card_clean(size_t card_index) { |
338 return _byte_map[card_index] == clean_card_val(); |
345 return _byte_map[card_index] == clean_card_val(); |
339 } |
346 } |
|
347 |
|
348 bool is_card_deferred(size_t card_index) { |
|
349 jbyte val = _byte_map[card_index]; |
|
350 return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val(); |
|
351 } |
|
352 |
|
353 bool mark_card_deferred(size_t card_index); |
340 |
354 |
341 // Card marking array base (adjusted for heap low boundary) |
355 // Card marking array base (adjusted for heap low boundary) |
342 // This would be the 0th element of _byte_map, if the heap started at 0x0. |
356 // This would be the 0th element of _byte_map, if the heap started at 0x0. |
343 // But since the heap starts at some higher address, this points to somewhere |
357 // But since the heap starts at some higher address, this points to somewhere |
344 // before the beginning of the actual _byte_map. |
358 // before the beginning of the actual _byte_map. |
432 assert(_whole_heap.contains(p), |
446 assert(_whole_heap.contains(p), |
433 "out of bounds access to card marking array"); |
447 "out of bounds access to card marking array"); |
434 return byte_for(p) - _byte_map; |
448 return byte_for(p) - _byte_map; |
435 } |
449 } |
436 |
450 |
|
451 const jbyte* byte_for_index(const size_t card_index) const { |
|
452 return _byte_map + card_index; |
|
453 } |
|
454 |
437 void verify(); |
455 void verify(); |
438 void verify_guard(); |
456 void verify_guard(); |
439 |
457 |
440 void verify_clean_region(MemRegion mr) PRODUCT_RETURN; |
458 void verify_clean_region(MemRegion mr) PRODUCT_RETURN; |
441 |
459 |