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/g1BarrierSet.inline.hpp" 27 #include "gc/g1/g1CardTable.inline.hpp" 28 #include "gc/g1/g1CollectedHeap.inline.hpp" 29 #include "gc/g1/heapRegion.hpp" 30 #include "gc/g1/satbMarkQueue.hpp" 31 #include "logging/log.hpp" 32 #include "oops/oop.inline.hpp" 33 #include "runtime/mutexLocker.hpp" 34 #include "runtime/thread.inline.hpp" 35 36 G1BarrierSet::G1BarrierSet(G1CardTable* card_table) : 37 CardTableModRefBS(card_table, BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)), 38 _dcqs(JavaThread::dirty_card_queue_set()) 39 { } 40 41 void G1BarrierSet::enqueue(oop pre_val) { 42 // Nulls should have been already filtered. 43 assert(oopDesc::is_oop(pre_val, true), "Error"); 44 45 if (!JavaThread::satb_mark_queue_set().is_active()) return; 46 Thread* thr = Thread::current(); 47 if (thr->is_Java_thread()) { 48 JavaThread* jt = (JavaThread*)thr; 49 jt->satb_mark_queue().enqueue(pre_val); 50 } else { 51 MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag); 52 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val); 53 } 54 } 55 56 template <class T> void 57 G1BarrierSet::write_ref_array_pre_work(T* dst, int count) { 58 if (!JavaThread::satb_mark_queue_set().is_active()) return; 59 T* elem_ptr = dst; 60 for (int i = 0; i < count; i++, elem_ptr++) { 61 T heap_oop = oopDesc::load_heap_oop(elem_ptr); 62 if (!oopDesc::is_null(heap_oop)) { 63 enqueue(oopDesc::decode_heap_oop_not_null(heap_oop)); 64 } 65 } 66 } 67 68 void G1BarrierSet::write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) { 69 if (!dest_uninitialized) { 70 write_ref_array_pre_work(dst, count); 71 } 72 } 73 74 void G1BarrierSet::write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) { 75 if (!dest_uninitialized) { 76 write_ref_array_pre_work(dst, count); 77 } 78 } 79 80 void G1BarrierSet::write_ref_field_post_slow(volatile jbyte* byte) { 81 // In the slow path, we know a card is not young 82 assert(*byte != G1CardTable::g1_young_card_val(), "slow path invoked without filtering"); 83 OrderAccess::storeload(); | 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/g1BarrierSet.inline.hpp" 27 #include "gc/g1/g1CardTable.inline.hpp" 28 #include "gc/g1/g1CollectedHeap.inline.hpp" 29 #include "gc/g1/heapRegion.hpp" 30 #include "gc/g1/satbMarkQueue.hpp" 31 #include "logging/log.hpp" 32 #include "oops/access.inline.hpp" 33 #include "oops/compressedOops.inline.hpp" 34 #include "oops/oop.inline.hpp" 35 #include "runtime/mutexLocker.hpp" 36 #include "runtime/thread.inline.hpp" 37 38 G1BarrierSet::G1BarrierSet(G1CardTable* card_table) : 39 CardTableModRefBS(card_table, BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)), 40 _dcqs(JavaThread::dirty_card_queue_set()) 41 { } 42 43 void G1BarrierSet::enqueue(oop pre_val) { 44 // Nulls should have been already filtered. 45 assert(oopDesc::is_oop(pre_val, 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; 51 jt->satb_mark_queue().enqueue(pre_val); 52 } else { 53 MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag); 54 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val); 55 } 56 } 57 58 template <class T> void 59 G1BarrierSet::write_ref_array_pre_work(T* dst, int count) { 60 if (!JavaThread::satb_mark_queue_set().is_active()) return; 61 T* elem_ptr = dst; 62 for (int i = 0; i < count; i++, elem_ptr++) { 63 T heap_oop = RawAccess<>::oop_load(elem_ptr); 64 if (!CompressedOops::is_null(heap_oop)) { 65 enqueue(CompressedOops::decode_not_null(heap_oop)); 66 } 67 } 68 } 69 70 void G1BarrierSet::write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) { 71 if (!dest_uninitialized) { 72 write_ref_array_pre_work(dst, count); 73 } 74 } 75 76 void G1BarrierSet::write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) { 77 if (!dest_uninitialized) { 78 write_ref_array_pre_work(dst, count); 79 } 80 } 81 82 void G1BarrierSet::write_ref_field_post_slow(volatile jbyte* byte) { 83 // In the slow path, we know a card is not young 84 assert(*byte != G1CardTable::g1_young_card_val(), "slow path invoked without filtering"); 85 OrderAccess::storeload(); |