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/satbMarkQueue.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;
130
131 void G1SATBCardTableLoggingModRefBS::initialize(G1RegionToSpaceMapper* mapper) {
132 mapper->set_mapping_changed_listener(&_listener);
133
134 _byte_map_size = mapper->reserved().byte_size();
135
136 _guard_index = cards_required(_whole_heap.word_size()) - 1;
137 _last_valid_index = _guard_index - 1;
138
139 HeapWord* low_bound = _whole_heap.start();
140 HeapWord* high_bound = _whole_heap.end();
141
142 _cur_covered_regions = 1;
143 _covered[0] = _whole_heap;
144
145 _byte_map = (jbyte*) mapper->reserved().start();
146 byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
147 assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");
148 assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
149
150 if (TraceCardTableModRefBS) {
151 gclog_or_tty->print_cr("G1SATBCardTableModRefBS::G1SATBCardTableModRefBS: ");
152 gclog_or_tty->print_cr(" "
153 " &_byte_map[0]: " INTPTR_FORMAT
154 " &_byte_map[_last_valid_index]: " INTPTR_FORMAT,
155 p2i(&_byte_map[0]),
156 p2i(&_byte_map[_last_valid_index]));
157 gclog_or_tty->print_cr(" "
158 " byte_map_base: " INTPTR_FORMAT,
159 p2i(byte_map_base));
160 }
161 }
162
163 void
164 G1SATBCardTableLoggingModRefBS::write_ref_field_work(void* field,
165 oop new_val,
166 bool release) {
167 volatile jbyte* byte = byte_for(field);
168 if (*byte == g1_young_gen) {
169 return;
170 }
171 OrderAccess::storeload();
172 if (*byte != dirty_card) {
173 *byte = dirty_card;
174 Thread* thr = Thread::current();
175 if (thr->is_Java_thread()) {
176 JavaThread* jt = (JavaThread*)thr;
177 jt->dirty_card_queue().enqueue(byte);
178 } else {
179 MutexLockerEx x(Shared_DirtyCardQ_lock,
180 Mutex::_no_safepoint_check_flag);
|
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/satbMarkQueue.hpp"
30 #include "gc/shared/memset_with_concurrent_readers.hpp"
31 #include "logging/log.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/atomic.inline.hpp"
34 #include "runtime/mutexLocker.hpp"
35 #include "runtime/orderAccess.inline.hpp"
36 #include "runtime/thread.inline.hpp"
37
38 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(
39 MemRegion whole_heap,
40 const BarrierSet::FakeRtti& fake_rtti) :
41 CardTableModRefBS(whole_heap, fake_rtti.add_tag(BarrierSet::G1SATBCT))
42 { }
43
44 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
45 // Nulls should have been already filtered.
46 assert(pre_val->is_oop(true), "Error");
47
48 if (!JavaThread::satb_mark_queue_set().is_active()) return;
49 Thread* thr = Thread::current();
50 if (thr->is_Java_thread()) {
51 JavaThread* jt = (JavaThread*)thr;
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: ");
152 log_trace(gc, barrier)(" &_byte_map[0]: " INTPTR_FORMAT " &_byte_map[_last_valid_index]: " INTPTR_FORMAT,
153 p2i(&_byte_map[0]), p2i(&_byte_map[_last_valid_index]));
154 log_trace(gc, barrier)(" byte_map_base: " INTPTR_FORMAT, p2i(byte_map_base));
155 }
156
157 void
158 G1SATBCardTableLoggingModRefBS::write_ref_field_work(void* field,
159 oop new_val,
160 bool release) {
161 volatile jbyte* byte = byte_for(field);
162 if (*byte == g1_young_gen) {
163 return;
164 }
165 OrderAccess::storeload();
166 if (*byte != dirty_card) {
167 *byte = dirty_card;
168 Thread* thr = Thread::current();
169 if (thr->is_Java_thread()) {
170 JavaThread* jt = (JavaThread*)thr;
171 jt->dirty_card_queue().enqueue(byte);
172 } else {
173 MutexLockerEx x(Shared_DirtyCardQ_lock,
174 Mutex::_no_safepoint_check_flag);
|