22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "gc/g1/g1BarrierSet.inline.hpp" |
26 #include "gc/g1/g1BarrierSet.inline.hpp" |
|
27 #include "gc/g1/g1BarrierSetAssembler.hpp" |
27 #include "gc/g1/g1CardTable.inline.hpp" |
28 #include "gc/g1/g1CardTable.inline.hpp" |
28 #include "gc/g1/g1CollectedHeap.inline.hpp" |
29 #include "gc/g1/g1CollectedHeap.inline.hpp" |
29 #include "gc/g1/heapRegion.hpp" |
30 #include "gc/g1/heapRegion.hpp" |
30 #include "gc/g1/satbMarkQueue.hpp" |
31 #include "gc/g1/satbMarkQueue.hpp" |
31 #include "logging/log.hpp" |
32 #include "logging/log.hpp" |
32 #include "oops/oop.inline.hpp" |
33 #include "oops/oop.inline.hpp" |
33 #include "runtime/mutexLocker.hpp" |
34 #include "runtime/mutexLocker.hpp" |
34 #include "runtime/thread.inline.hpp" |
35 #include "runtime/thread.inline.hpp" |
|
36 #include "utilities/macros.hpp" |
35 |
37 |
36 G1BarrierSet::G1BarrierSet(G1CardTable* card_table) : |
38 G1BarrierSet::G1BarrierSet(G1CardTable* card_table) : |
37 CardTableBarrierSet(card_table, BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)), |
39 CardTableBarrierSet(make_barrier_set_assembler<G1BarrierSetAssembler>(), |
|
40 card_table, |
|
41 BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)), |
38 _dcqs(JavaThread::dirty_card_queue_set()) |
42 _dcqs(JavaThread::dirty_card_queue_set()) |
39 { } |
43 { } |
40 |
44 |
41 void G1BarrierSet::enqueue(oop pre_val) { |
45 void G1BarrierSet::enqueue(oop pre_val) { |
42 // Nulls should have been already filtered. |
46 // Nulls should have been already filtered. |
51 MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag); |
55 MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag); |
52 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val); |
56 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val); |
53 } |
57 } |
54 } |
58 } |
55 |
59 |
|
60 void G1BarrierSet::write_ref_array_pre_oop_entry(oop* dst, size_t length) { |
|
61 G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set()); |
|
62 bs->write_ref_array_pre(dst, length, false); |
|
63 } |
|
64 |
|
65 void G1BarrierSet::write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length) { |
|
66 G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set()); |
|
67 bs->write_ref_array_pre(dst, length, false); |
|
68 } |
|
69 |
|
70 void G1BarrierSet::write_ref_array_post_entry(HeapWord* dst, size_t length) { |
|
71 G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set()); |
|
72 bs->G1BarrierSet::write_ref_array(dst, length); |
|
73 } |
|
74 |
56 template <class T> void |
75 template <class T> void |
57 G1BarrierSet::write_ref_array_pre_work(T* dst, int count) { |
76 G1BarrierSet::write_ref_array_pre_work(T* dst, size_t count) { |
58 if (!JavaThread::satb_mark_queue_set().is_active()) return; |
77 if (!JavaThread::satb_mark_queue_set().is_active()) return; |
59 T* elem_ptr = dst; |
78 T* elem_ptr = dst; |
60 for (int i = 0; i < count; i++, elem_ptr++) { |
79 for (size_t i = 0; i < count; i++, elem_ptr++) { |
61 T heap_oop = oopDesc::load_heap_oop(elem_ptr); |
80 T heap_oop = oopDesc::load_heap_oop(elem_ptr); |
62 if (!oopDesc::is_null(heap_oop)) { |
81 if (!oopDesc::is_null(heap_oop)) { |
63 enqueue(oopDesc::decode_heap_oop_not_null(heap_oop)); |
82 enqueue(oopDesc::decode_heap_oop_not_null(heap_oop)); |
64 } |
83 } |
65 } |
84 } |
66 } |
85 } |
67 |
86 |
68 void G1BarrierSet::write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) { |
87 void G1BarrierSet::write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized) { |
69 if (!dest_uninitialized) { |
88 if (!dest_uninitialized) { |
70 write_ref_array_pre_work(dst, count); |
89 write_ref_array_pre_work(dst, count); |
71 } |
90 } |
72 } |
91 } |
73 |
92 |
74 void G1BarrierSet::write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) { |
93 void G1BarrierSet::write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized) { |
75 if (!dest_uninitialized) { |
94 if (!dest_uninitialized) { |
76 write_ref_array_pre_work(dst, count); |
95 write_ref_array_pre_work(dst, count); |
77 } |
96 } |
78 } |
97 } |
79 |
98 |