10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/g1CollectedHeap.inline.hpp"
27 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
28 #include "gc/g1/heapRegion.hpp"
29 #include "gc/g1/satbQueue.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "runtime/atomic.inline.hpp"
32 #include "runtime/mutexLocker.hpp"
33 #include "runtime/orderAccess.inline.hpp"
34 #include "runtime/thread.inline.hpp"
35
36 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(
37 MemRegion whole_heap,
38 const BarrierSet::FakeRtti& fake_rtti) :
39 CardTableModRefBS(whole_heap, fake_rtti.add_tag(BarrierSet::G1SATBCT))
40 { }
41
42 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
43 // Nulls should have been already filtered.
44 assert(pre_val->is_oop(true), "Error");
45
46 if (!JavaThread::satb_mark_queue_set().is_active()) return;
47 Thread* thr = Thread::current();
48 if (thr->is_Java_thread()) {
49 JavaThread* jt = (JavaThread*)thr;
91
92 // Cached bit can be installed either on a clean card or on a claimed card.
93 jbyte new_val = val;
94 if (val == clean_card_val()) {
95 new_val = (jbyte)deferred_card_val();
96 } else {
97 if (val & claimed_card_val()) {
98 new_val = val | (jbyte)deferred_card_val();
99 }
100 }
101 if (new_val != val) {
102 Atomic::cmpxchg(new_val, &_byte_map[card_index], val);
103 }
104 return true;
105 }
106
107 void G1SATBCardTableModRefBS::g1_mark_as_young(const MemRegion& mr) {
108 jbyte *const first = byte_for(mr.start());
109 jbyte *const last = byte_after(mr.last());
110
111 // Below we may use an explicit loop instead of memset() because on
112 // certain platforms memset() can give concurrent readers phantom zeros.
113 if (UseMemSetInBOT) {
114 memset(first, g1_young_gen, last - first);
115 } else {
116 for (jbyte* i = first; i < last; i++) {
117 *i = g1_young_gen;
118 }
119 }
120 }
121
122 #ifndef PRODUCT
123 void G1SATBCardTableModRefBS::verify_g1_young_region(MemRegion mr) {
124 verify_region(mr, g1_young_gen, true);
125 }
126 #endif
127
128 void G1SATBCardTableLoggingModRefBSChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
129 // Default value for a clean card on the card table is -1. So we cannot take advantage of the zero_filled parameter.
130 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);
131 _card_table->clear(mr);
132 }
133
134 G1SATBCardTableLoggingModRefBS::
135 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap) :
136 G1SATBCardTableModRefBS(whole_heap, BarrierSet::FakeRtti(G1SATBCTLogging)),
137 _dcqs(JavaThread::dirty_card_queue_set()),
138 _listener()
139 {
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/g1CollectedHeap.inline.hpp"
27 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
28 #include "gc/g1/heapRegion.hpp"
29 #include "gc/g1/satbQueue.hpp"
30 #include "gc/shared/memset_with_concurrent_readers.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "runtime/atomic.inline.hpp"
33 #include "runtime/mutexLocker.hpp"
34 #include "runtime/orderAccess.inline.hpp"
35 #include "runtime/thread.inline.hpp"
36
37 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(
38 MemRegion whole_heap,
39 const BarrierSet::FakeRtti& fake_rtti) :
40 CardTableModRefBS(whole_heap, fake_rtti.add_tag(BarrierSet::G1SATBCT))
41 { }
42
43 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
44 // Nulls should have been already filtered.
45 assert(pre_val->is_oop(true), "Error");
46
47 if (!JavaThread::satb_mark_queue_set().is_active()) return;
48 Thread* thr = Thread::current();
49 if (thr->is_Java_thread()) {
50 JavaThread* jt = (JavaThread*)thr;
92
93 // Cached bit can be installed either on a clean card or on a claimed card.
94 jbyte new_val = val;
95 if (val == clean_card_val()) {
96 new_val = (jbyte)deferred_card_val();
97 } else {
98 if (val & claimed_card_val()) {
99 new_val = val | (jbyte)deferred_card_val();
100 }
101 }
102 if (new_val != val) {
103 Atomic::cmpxchg(new_val, &_byte_map[card_index], val);
104 }
105 return true;
106 }
107
108 void G1SATBCardTableModRefBS::g1_mark_as_young(const MemRegion& mr) {
109 jbyte *const first = byte_for(mr.start());
110 jbyte *const last = byte_after(mr.last());
111
112 memset_with_concurrent_readers(first, g1_young_gen, last - first);
113 }
114
115 #ifndef PRODUCT
116 void G1SATBCardTableModRefBS::verify_g1_young_region(MemRegion mr) {
117 verify_region(mr, g1_young_gen, true);
118 }
119 #endif
120
121 void G1SATBCardTableLoggingModRefBSChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
122 // Default value for a clean card on the card table is -1. So we cannot take advantage of the zero_filled parameter.
123 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);
124 _card_table->clear(mr);
125 }
126
127 G1SATBCardTableLoggingModRefBS::
128 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap) :
129 G1SATBCardTableModRefBS(whole_heap, BarrierSet::FakeRtti(G1SATBCTLogging)),
130 _dcqs(JavaThread::dirty_card_queue_set()),
131 _listener()
132 {
|