8209118: Abstract SATBMarkQueueSet's ThreadLocalData access

Reviewed-by: kbarrett, shade
This commit is contained in:
Roman Kennke 2018-08-09 22:51:48 +02:00
parent b037ff24a8
commit 59ca28bf1c
9 changed files with 92 additions and 21 deletions

View File

@ -29,6 +29,7 @@
#include "gc/g1/g1BarrierSetAssembler.hpp"
#include "gc/g1/g1BarrierSetRuntime.hpp"
#include "gc/g1/g1CardTable.hpp"
#include "gc/g1/g1SATBMarkQueueSet.hpp"
#include "gc/g1/g1ThreadLocalData.hpp"
#include "gc/g1/heapRegion.hpp"
#include "interpreter/interp_masm.hpp"
@ -458,7 +459,7 @@ void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler*
__ mflr(R0);
__ std(R0, _abi(lr), R1_SP);
__ push_frame_reg_args(nbytes_save, R0); // dummy frame for C call
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread), R16_thread);
__ call_VM_leaf(CAST_FROM_FN_PTR(address, G1SATBMarkQueueSet::handle_zero_index_for_thread), R16_thread);
__ pop_frame();
__ ld(R0, _abi(lr), R1_SP);
__ mtlr(R0);

View File

@ -30,6 +30,7 @@
#include "gc/g1/g1BarrierSet.hpp"
#include "gc/g1/g1BarrierSetAssembler.hpp"
#include "gc/g1/g1BarrierSetRuntime.hpp"
#include "gc/g1/g1SATBMarkQueueSet.hpp"
#include "gc/g1/g1ThreadLocalData.hpp"
#include "gc/g1/heapRegion.hpp"
#include "interpreter/interp_masm.hpp"
@ -520,7 +521,7 @@ void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler*
__ bind(refill);
save_volatile_registers(sasm);
__ z_lgr(tmp, pre_val); // save pre_val
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread),
__ call_VM_leaf(CAST_FROM_FN_PTR(address, G1SATBMarkQueueSet::handle_zero_index_for_thread),
Z_thread);
__ z_lgr(pre_val, tmp); // restore pre_val
restore_volatile_registers(sasm);

View File

@ -28,6 +28,7 @@
#include "gc/g1/g1BarrierSetAssembler.hpp"
#include "gc/g1/g1BarrierSetRuntime.hpp"
#include "gc/g1/g1CardTable.hpp"
#include "gc/g1/g1SATBMarkQueueSet.hpp"
#include "gc/g1/g1ThreadLocalData.hpp"
#include "gc/g1/heapRegion.hpp"
#include "interpreter/interp_masm.hpp"
@ -160,7 +161,7 @@ static void generate_satb_log_enqueue(bool with_frame) {
address handle_zero =
CAST_FROM_FN_PTR(address,
&SATBMarkQueueSet::handle_zero_index_for_thread);
&G1SATBMarkQueueSet::handle_zero_index_for_thread);
// This should be rare enough that we can afford to save all the
// scratch registers that the calling context might be using.
__ mov(G1_scratch, L0);
@ -606,8 +607,8 @@ void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler*
__ call_VM_leaf(L7_thread_cache,
CAST_FROM_FN_PTR(address,
SATBMarkQueueSet::handle_zero_index_for_thread),
G2_thread);
G1SATBMarkQueueSet::handle_zero_index_for_thread),
G2_thread);
__ restore_live_registers(true);
@ -694,7 +695,7 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler*
__ call_VM_leaf(L7_thread_cache,
CAST_FROM_FN_PTR(address,
DirtyCardQueueSet::handle_zero_index_for_thread),
G2_thread);
G2_thread);
__ restore_live_registers(true);

View File

@ -48,7 +48,7 @@
class G1BarrierSetC1;
class G1BarrierSetC2;
SATBMarkQueueSet G1BarrierSet::_satb_mark_queue_set;
G1SATBMarkQueueSet G1BarrierSet::_satb_mark_queue_set;
DirtyCardQueueSet G1BarrierSet::_dirty_card_queue_set;
G1BarrierSet::G1BarrierSet(G1CardTable* card_table) :

View File

@ -26,7 +26,7 @@
#define SHARE_VM_GC_G1_G1BARRIERSET_HPP
#include "gc/g1/dirtyCardQueue.hpp"
#include "gc/g1/satbMarkQueue.hpp"
#include "gc/g1/g1SATBMarkQueueSet.hpp"
#include "gc/shared/cardTableBarrierSet.hpp"
class DirtyCardQueueSet;
@ -39,7 +39,7 @@ class G1CardTable;
class G1BarrierSet: public CardTableBarrierSet {
friend class VMStructs;
private:
static SATBMarkQueueSet _satb_mark_queue_set;
static G1SATBMarkQueueSet _satb_mark_queue_set;
static DirtyCardQueueSet _dirty_card_queue_set;
public:

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/g1/g1SATBMarkQueueSet.hpp"
#include "gc/g1/g1ThreadLocalData.hpp"
void G1SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
G1ThreadLocalData::satb_mark_queue(t).handle_zero_index();
}
SATBMarkQueue& G1SATBMarkQueueSet::satb_queue_for_thread(JavaThread* const t) const{
return G1ThreadLocalData::satb_mark_queue(t);
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_GC_G1_G1SATBMARKQUEUE_HPP
#define SHARE_VM_GC_G1_G1SATBMARKQUEUE_HPP
#include "gc/g1/satbMarkQueue.hpp"
class JavaThread;
class G1SATBMarkQueueSet : public SATBMarkQueueSet {
public:
static void handle_zero_index_for_thread(JavaThread* t);
virtual SATBMarkQueue& satb_queue_for_thread(JavaThread* const t) const;
};
#endif // SHARE_VM_GC_G1_G1SATBMARKQUEUE_HPP

View File

@ -25,7 +25,6 @@
#include "precompiled.hpp"
#include "jvm.h"
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/g1ThreadLocalData.hpp"
#include "gc/g1/satbMarkQueue.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "memory/allocation.inline.hpp"
@ -117,17 +116,13 @@ void SATBMarkQueueSet::initialize(SATBMarkQueueFilter* filter,
_filter = filter;
}
void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
G1ThreadLocalData::satb_mark_queue(t).handle_zero_index();
}
#ifdef ASSERT
void SATBMarkQueueSet::dump_active_states(bool expected_active) {
log_error(gc, verify)("Expected SATB active state: %s", expected_active ? "ACTIVE" : "INACTIVE");
log_error(gc, verify)("Actual SATB active states:");
log_error(gc, verify)(" Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
log_error(gc, verify)(" Thread \"%s\" queue: %s", t->name(), G1ThreadLocalData::satb_mark_queue(t).is_active() ? "ACTIVE" : "INACTIVE");
log_error(gc, verify)(" Thread \"%s\" queue: %s", t->name(), satb_queue_for_thread(t).is_active() ? "ACTIVE" : "INACTIVE");
}
log_error(gc, verify)(" Shared queue: %s", shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
}
@ -141,7 +136,7 @@ void SATBMarkQueueSet::verify_active_states(bool expected_active) {
// Verify thread queue states
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
if (G1ThreadLocalData::satb_mark_queue(t).is_active() != expected_active) {
if (satb_queue_for_thread(t).is_active() != expected_active) {
dump_active_states(expected_active);
guarantee(false, "Thread SATB queue has an unexpected active state");
}
@ -162,14 +157,14 @@ void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active)
#endif // ASSERT
_all_active = active;
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
G1ThreadLocalData::satb_mark_queue(t).set_active(active);
satb_queue_for_thread(t).set_active(active);
}
shared_satb_queue()->set_active(active);
}
void SATBMarkQueueSet::filter_thread_buffers() {
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
G1ThreadLocalData::satb_mark_queue(t).filter();
satb_queue_for_thread(t).filter();
}
shared_satb_queue()->filter();
}
@ -223,7 +218,7 @@ void SATBMarkQueueSet::print_all(const char* msg) {
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
G1ThreadLocalData::satb_mark_queue(t).print(buffer);
satb_queue_for_thread(t).print(buffer);
}
shared_satb_queue()->print("Shared");
@ -254,7 +249,7 @@ void SATBMarkQueueSet::abandon_partial_marking() {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
// So we can safely manipulate these queues.
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
G1ThreadLocalData::satb_mark_queue(t).reset();
satb_queue_for_thread(t).reset();
}
shared_satb_queue()->reset();
}

View File

@ -113,7 +113,7 @@ public:
int process_completed_threshold,
Mutex* lock);
static void handle_zero_index_for_thread(JavaThread* t);
virtual SATBMarkQueue& satb_queue_for_thread(JavaThread* const t) const = 0;
// Apply "set_active(active)" to all SATB queues in the set. It should be
// called only with the world stopped. The method will assert that the