44
45 template <DecoratorSet decorators, typename T>
46 inline void G1SATBCardTableLoggingModRefBS::write_ref_field_post(T* field, oop new_val) {
47 volatile jbyte* byte = byte_for(field);
48 if (*byte != g1_young_gen) {
49 // Take a slow path for cards in old
50 write_ref_field_post_slow(byte);
51 }
52 }
53
54 void G1SATBCardTableModRefBS::set_card_claimed(size_t card_index) {
55 jbyte val = _byte_map[card_index];
56 if (val == clean_card_val()) {
57 val = (jbyte)claimed_card_val();
58 } else {
59 val |= (jbyte)claimed_card_val();
60 }
61 _byte_map[card_index] = val;
62 }
63
64 inline void G1SATBCardTableModRefBS::enqueue_if_weak(DecoratorSet decorators, oop value) {
65 assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
66 const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
67 const bool peek = (decorators & AS_NO_KEEPALIVE) != 0;
68
69 if (!peek && !on_strong_oop_ref && value != NULL) {
70 enqueue(value);
71 }
72 }
73
74 template <DecoratorSet decorators, typename BarrierSetT>
75 template <typename T>
76 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
77 oop_load_not_in_heap(T* addr) {
78 oop value = ModRef::oop_load_not_in_heap(addr);
79 enqueue_if_weak(decorators, value);
80 return value;
81 }
82
83 template <DecoratorSet decorators, typename BarrierSetT>
84 template <typename T>
85 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
86 oop_load_in_heap(T* addr) {
87 oop value = ModRef::oop_load_in_heap(addr);
88 enqueue_if_weak(decorators, value);
89 return value;
90 }
91
92 template <DecoratorSet decorators, typename BarrierSetT>
93 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
94 oop_load_in_heap_at(oop base, ptrdiff_t offset) {
95 oop value = ModRef::oop_load_in_heap_at(base, offset);
96 enqueue_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
97 return value;
98 }
99
100 template <DecoratorSet decorators, typename BarrierSetT>
101 template <typename T>
102 inline void G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
103 oop_store_not_in_heap(T* addr, oop new_value) {
104 if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {
105 // For roots not scanned in a safepoint, we have to apply SATB barriers
106 // even for roots.
107 G1SATBCardTableLoggingModRefBS *bs = barrier_set_cast<G1SATBCardTableLoggingModRefBS>(BarrierSet::barrier_set());
108 bs->write_ref_field_pre<decorators>(addr);
109 }
110 Raw::oop_store(addr, new_value);
111 }
112
113 #endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
|
44
45 template <DecoratorSet decorators, typename T>
46 inline void G1SATBCardTableLoggingModRefBS::write_ref_field_post(T* field, oop new_val) {
47 volatile jbyte* byte = byte_for(field);
48 if (*byte != g1_young_gen) {
49 // Take a slow path for cards in old
50 write_ref_field_post_slow(byte);
51 }
52 }
53
54 void G1SATBCardTableModRefBS::set_card_claimed(size_t card_index) {
55 jbyte val = _byte_map[card_index];
56 if (val == clean_card_val()) {
57 val = (jbyte)claimed_card_val();
58 } else {
59 val |= (jbyte)claimed_card_val();
60 }
61 _byte_map[card_index] = val;
62 }
63
64 inline void G1SATBCardTableModRefBS::enqueue_if_weak_or_archive(DecoratorSet decorators, oop value) {
65 assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
66 // Archive roots need to be enqueued since they add subgraphs to the
67 // Java heap that were not there at the snapshot when marking started.
68 // Weak and phantom references also need enqueueing for similar reasons.
69 const bool in_archive_root = (decorators & IN_ARCHIVE_ROOT) != 0;
70 const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
71 const bool peek = (decorators & AS_NO_KEEPALIVE) != 0;
72 const bool needs_enqueue = in_archive_root || (!peek && !on_strong_oop_ref);
73
74 if (needs_enqueue && value != NULL) {
75 enqueue(value);
76 }
77 }
78
79 template <DecoratorSet decorators, typename BarrierSetT>
80 template <typename T>
81 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
82 oop_load_not_in_heap(T* addr) {
83 oop value = ModRef::oop_load_not_in_heap(addr);
84 enqueue_if_weak_or_archive(decorators, value);
85 return value;
86 }
87
88 template <DecoratorSet decorators, typename BarrierSetT>
89 template <typename T>
90 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
91 oop_load_in_heap(T* addr) {
92 oop value = ModRef::oop_load_in_heap(addr);
93 enqueue_if_weak_or_archive(decorators, value);
94 return value;
95 }
96
97 template <DecoratorSet decorators, typename BarrierSetT>
98 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
99 oop_load_in_heap_at(oop base, ptrdiff_t offset) {
100 oop value = ModRef::oop_load_in_heap_at(base, offset);
101 enqueue_if_weak_or_archive(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
102 return value;
103 }
104
105 template <DecoratorSet decorators, typename BarrierSetT>
106 template <typename T>
107 inline void G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
108 oop_store_not_in_heap(T* addr, oop new_value) {
109 if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {
110 // For roots not scanned in a safepoint, we have to apply SATB barriers
111 // even for roots.
112 G1SATBCardTableLoggingModRefBS *bs = barrier_set_cast<G1SATBCardTableLoggingModRefBS>(BarrierSet::barrier_set());
113 bs->write_ref_field_pre<decorators>(addr);
114 }
115 Raw::oop_store(addr, new_value);
116 }
117
118 #endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
|