0 /*
1 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
|
0 /*
1 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
|
113 verify_region(mr, g1_young_gen, true);
114 }
115 #endif
116
117 void G1SATBCardTableLoggingModRefBSChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
118 // Default value for a clean card on the card table is -1. So we cannot take advantage of the zero_filled parameter.
119 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);
120 _card_table->clear(mr);
121 }
122
123 G1SATBCardTableLoggingModRefBS::
124 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap) :
125 G1SATBCardTableModRefBS(whole_heap, BarrierSet::FakeRtti(G1SATBCTLogging)),
126 _dcqs(JavaThread::dirty_card_queue_set()),
127 _listener()
128 {
129 _listener.set_card_table(this);
130 }
131
132 void G1SATBCardTableLoggingModRefBS::initialize(G1RegionToSpaceMapper* mapper) {
133 mapper->set_mapping_changed_listener(&_listener);
134
135 _byte_map_size = mapper->reserved().byte_size();
136
137 _guard_index = cards_required(_whole_heap.word_size()) - 1;
138 _last_valid_index = _guard_index - 1;
139
140 HeapWord* low_bound = _whole_heap.start();
141 HeapWord* high_bound = _whole_heap.end();
142
143 _cur_covered_regions = 1;
144 _covered[0] = _whole_heap;
145
146 _byte_map = (jbyte*) mapper->reserved().start();
147 byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
148 assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");
149 assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
150
151 log_trace(gc, barrier)("G1SATBCardTableModRefBS::G1SATBCardTableModRefBS: ");
|
113 verify_region(mr, g1_young_gen, true);
114 }
115 #endif
116
117 void G1SATBCardTableLoggingModRefBSChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
118 // Default value for a clean card on the card table is -1. So we cannot take advantage of the zero_filled parameter.
119 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);
120 _card_table->clear(mr);
121 }
122
123 G1SATBCardTableLoggingModRefBS::
124 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap) :
125 G1SATBCardTableModRefBS(whole_heap, BarrierSet::FakeRtti(G1SATBCTLogging)),
126 _dcqs(JavaThread::dirty_card_queue_set()),
127 _listener()
128 {
129 _listener.set_card_table(this);
130 }
131
132 void G1SATBCardTableLoggingModRefBS::initialize(G1RegionToSpaceMapper* mapper) {
133 initialize_deferred_card_mark_barriers();
134 mapper->set_mapping_changed_listener(&_listener);
135
136 _byte_map_size = mapper->reserved().byte_size();
137
138 _guard_index = cards_required(_whole_heap.word_size()) - 1;
139 _last_valid_index = _guard_index - 1;
140
141 HeapWord* low_bound = _whole_heap.start();
142 HeapWord* high_bound = _whole_heap.end();
143
144 _cur_covered_regions = 1;
145 _covered[0] = _whole_heap;
146
147 _byte_map = (jbyte*) mapper->reserved().start();
148 byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
149 assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");
150 assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
151
152 log_trace(gc, barrier)("G1SATBCardTableModRefBS::G1SATBCardTableModRefBS: ");
|
194 }
195 if (*byte != dirty_card) {
196 *byte = dirty_card;
197 jt->dirty_card_queue().enqueue(byte);
198 }
199 }
200 } else {
201 MutexLockerEx x(Shared_DirtyCardQ_lock,
202 Mutex::_no_safepoint_check_flag);
203 for (; byte <= last_byte; byte++) {
204 if (*byte == g1_young_gen) {
205 continue;
206 }
207 if (*byte != dirty_card) {
208 *byte = dirty_card;
209 _dcqs.shared_dirty_card_queue()->enqueue(byte);
210 }
211 }
212 }
213 }
214 }
|
195 }
196 if (*byte != dirty_card) {
197 *byte = dirty_card;
198 jt->dirty_card_queue().enqueue(byte);
199 }
200 }
201 } else {
202 MutexLockerEx x(Shared_DirtyCardQ_lock,
203 Mutex::_no_safepoint_check_flag);
204 for (; byte <= last_byte; byte++) {
205 if (*byte == g1_young_gen) {
206 continue;
207 }
208 if (*byte != dirty_card) {
209 *byte = dirty_card;
210 _dcqs.shared_dirty_card_queue()->enqueue(byte);
211 }
212 }
213 }
214 }
215 }
216
217 bool G1SATBCardTableModRefBS::is_in_young(oop obj) const {
218 volatile jbyte* p = byte_for((void*)obj);
219 return *p == g1_young_card_val();
220 }
221
222 void G1SATBCardTableLoggingModRefBS::flush_deferred_barriers(JavaThread* thread) {
223 CardTableModRefBS::flush_deferred_barriers(thread);
224 thread->satb_mark_queue().flush();
225 thread->dirty_card_queue().flush();
226 }
|