< prev index next >
src/hotspot/share/gc/g1/g1BarrierSet.cpp
Print this page
*** 25,34 ****
--- 25,35 ----
#include "precompiled.hpp"
#include "gc/g1/g1BarrierSet.inline.hpp"
#include "gc/g1/g1BarrierSetAssembler.hpp"
#include "gc/g1/g1CardTable.inline.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp"
+ #include "gc/g1/g1ThreadLocalData.hpp"
#include "gc/g1/heapRegion.hpp"
#include "gc/g1/satbMarkQueue.hpp"
#include "logging/log.hpp"
#include "oops/access.inline.hpp"
#include "oops/compressedOops.inline.hpp"
*** 50,61 ****
assert(oopDesc::is_oop(pre_val, true), "Error");
if (!_satb_mark_queue_set.is_active()) return;
Thread* thr = Thread::current();
if (thr->is_Java_thread()) {
! JavaThread* jt = (JavaThread*)thr;
! jt->satb_mark_queue().enqueue(pre_val);
} else {
MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);
_satb_mark_queue_set.shared_satb_queue()->enqueue(pre_val);
}
}
--- 51,61 ----
assert(oopDesc::is_oop(pre_val, true), "Error");
if (!_satb_mark_queue_set.is_active()) return;
Thread* thr = Thread::current();
if (thr->is_Java_thread()) {
! G1ThreadLocalData::satb_mark_queue(thr).enqueue(pre_val);
} else {
MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);
_satb_mark_queue_set.shared_satb_queue()->enqueue(pre_val);
}
}
*** 105,116 ****
OrderAccess::storeload();
if (*byte != G1CardTable::dirty_card_val()) {
*byte = G1CardTable::dirty_card_val();
Thread* thr = Thread::current();
if (thr->is_Java_thread()) {
! JavaThread* jt = (JavaThread*)thr;
! jt->dirty_card_queue().enqueue(byte);
} else {
MutexLockerEx x(Shared_DirtyCardQ_lock,
Mutex::_no_safepoint_check_flag);
_dirty_card_queue_set.shared_dirty_card_queue()->enqueue(byte);
}
--- 105,115 ----
OrderAccess::storeload();
if (*byte != G1CardTable::dirty_card_val()) {
*byte = G1CardTable::dirty_card_val();
Thread* thr = Thread::current();
if (thr->is_Java_thread()) {
! G1ThreadLocalData::dirty_card_queue(thr).enqueue(byte);
} else {
MutexLockerEx x(Shared_DirtyCardQ_lock,
Mutex::_no_safepoint_check_flag);
_dirty_card_queue_set.shared_dirty_card_queue()->enqueue(byte);
}
*** 129,146 ****
if (byte <= last_byte) {
OrderAccess::storeload();
// Enqueue if necessary.
if (thr->is_Java_thread()) {
- JavaThread* jt = (JavaThread*)thr;
for (; byte <= last_byte; byte++) {
if (*byte == G1CardTable::g1_young_card_val()) {
continue;
}
if (*byte != G1CardTable::dirty_card_val()) {
*byte = G1CardTable::dirty_card_val();
! jt->dirty_card_queue().enqueue(byte);
}
}
} else {
MutexLockerEx x(Shared_DirtyCardQ_lock,
Mutex::_no_safepoint_check_flag);
--- 128,144 ----
if (byte <= last_byte) {
OrderAccess::storeload();
// Enqueue if necessary.
if (thr->is_Java_thread()) {
for (; byte <= last_byte; byte++) {
if (*byte == G1CardTable::g1_young_card_val()) {
continue;
}
if (*byte != G1CardTable::dirty_card_val()) {
*byte = G1CardTable::dirty_card_val();
! G1ThreadLocalData::dirty_card_queue(thr).enqueue(byte);
}
}
} else {
MutexLockerEx x(Shared_DirtyCardQ_lock,
Mutex::_no_safepoint_check_flag);
*** 155,164 ****
--- 153,172 ----
}
}
}
}
+ void G1BarrierSet::on_thread_create(Thread* thread) {
+ // Create thread local data
+ G1ThreadLocalData::create(thread);
+ }
+
+ void G1BarrierSet::on_thread_destroy(Thread* thread) {
+ // Destroy thread local data
+ G1ThreadLocalData::destroy(thread);
+ }
+
void G1BarrierSet::on_thread_attach(JavaThread* thread) {
// This method initializes the SATB and dirty card queues before a
// JavaThread is added to the Java thread list. Right now, we don't
// have to do anything to the dirty card queue (it should have been
// activated when the thread was created), but we have to activate
*** 174,195 ****
// when the thread is created given that, in some cases, safepoints
// might happen between the JavaThread constructor being called and the
// thread being added to the Java thread list (an example of this is
// when the structure for the DestroyJavaVM thread is created).
assert(!SafepointSynchronize::is_at_safepoint(), "We should not be at a safepoint");
! assert(!thread->satb_mark_queue().is_active(), "SATB queue should not be active");
! assert(thread->satb_mark_queue().is_empty(), "SATB queue should be empty");
! assert(thread->dirty_card_queue().is_active(), "Dirty card queue should be active");
// If we are creating the thread during a marking cycle, we should
// set the active field of the SATB queue to true.
if (_satb_mark_queue_set.is_active()) {
! thread->satb_mark_queue().set_active(true);
}
}
void G1BarrierSet::on_thread_detach(JavaThread* thread) {
// Flush any deferred card marks, SATB buffers and dirty card queue buffers
CardTableBarrierSet::on_thread_detach(thread);
! thread->satb_mark_queue().flush();
! thread->dirty_card_queue().flush();
}
--- 182,203 ----
// when the thread is created given that, in some cases, safepoints
// might happen between the JavaThread constructor being called and the
// thread being added to the Java thread list (an example of this is
// when the structure for the DestroyJavaVM thread is created).
assert(!SafepointSynchronize::is_at_safepoint(), "We should not be at a safepoint");
! assert(!G1ThreadLocalData::satb_mark_queue(thread).is_active(), "SATB queue should not be active");
! assert(G1ThreadLocalData::satb_mark_queue(thread).is_empty(), "SATB queue should be empty");
! assert(G1ThreadLocalData::dirty_card_queue(thread).is_active(), "Dirty card queue should be active");
// If we are creating the thread during a marking cycle, we should
// set the active field of the SATB queue to true.
if (_satb_mark_queue_set.is_active()) {
! G1ThreadLocalData::satb_mark_queue(thread).set_active(true);
}
}
void G1BarrierSet::on_thread_detach(JavaThread* thread) {
// Flush any deferred card marks, SATB buffers and dirty card queue buffers
CardTableBarrierSet::on_thread_detach(thread);
! G1ThreadLocalData::satb_mark_queue(thread).flush();
! G1ThreadLocalData::dirty_card_queue(thread).flush();
}
< prev index next >