Path: blob/master/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp
40957 views
/*1* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_GC_SHARED_CARDTABLEBARRIERSET_HPP25#define SHARE_GC_SHARED_CARDTABLEBARRIERSET_HPP2627#include "gc/shared/cardTable.hpp"28#include "gc/shared/modRefBarrierSet.hpp"29#include "utilities/align.hpp"3031// This kind of "BarrierSet" allows a "CollectedHeap" to detect and32// enumerate ref fields that have been modified (since the last33// enumeration.)3435// As it currently stands, this barrier is *imprecise*: when a ref field in36// an object "o" is modified, the card table entry for the card containing37// the head of "o" is dirtied, not necessarily the card containing the38// modified field itself. For object arrays, however, the barrier *is*39// precise; only the card containing the modified element is dirtied.40// Closures used to scan dirty cards should take these41// considerations into account.4243class CardTableBarrierSet: public ModRefBarrierSet {44// Some classes get to look at some private stuff.45friend class VMStructs;4647public:4849typedef CardTable::CardValue CardValue;50protected:51// Used in support of ReduceInitialCardMarks; only consulted if COMPILER252// or INCLUDE_JVMCI is being used53bool _defer_initial_card_mark;54CardTable* _card_table;5556CardTableBarrierSet(BarrierSetAssembler* barrier_set_assembler,57BarrierSetC1* barrier_set_c1,58BarrierSetC2* barrier_set_c2,59CardTable* card_table,60const BarrierSet::FakeRtti& fake_rtti);6162public:63CardTableBarrierSet(CardTable* card_table);64~CardTableBarrierSet();6566CardTable* card_table() const { return _card_table; }6768virtual void initialize();6970void write_region(MemRegion mr) {71invalidate(mr);72}7374void write_ref_array_work(MemRegion mr);7576public:77// Record a reference update. Note that these versions are precise!78// The scanning code has to handle the fact that the write barrier may be79// either precise or imprecise. We make non-virtual inline variants of80// these functions here for performance.81template <DecoratorSet decorators, typename T>82void write_ref_field_post(T* field, oop newVal);8384virtual void invalidate(MemRegion mr);8586// ReduceInitialCardMarks87void initialize_deferred_card_mark_barriers();8889// If the CollectedHeap was asked to defer a store barrier above,90// this informs it to flush such a deferred store barrier to the91// remembered set.92void flush_deferred_card_mark_barrier(JavaThread* thread);9394// If a compiler is eliding store barriers for TLAB-allocated objects,95// we will be informed of a slow-path allocation by a call96// to on_slowpath_allocation_exit() below. Such a call precedes the97// initialization of the object itself, and no post-store-barriers will98// be issued. Some heap types require that the barrier strictly follows99// the initializing stores. (This is currently implemented by deferring the100// barrier until the next slow-path allocation or gc-related safepoint.)101// This interface answers whether a particular barrier type needs the card102// mark to be thus strictly sequenced after the stores.103virtual bool card_mark_must_follow_store() const;104105virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj);106virtual void on_thread_detach(Thread* thread);107108virtual void make_parsable(JavaThread* thread) { flush_deferred_card_mark_barrier(thread); }109110virtual void print_on(outputStream* st) const;111112template <DecoratorSet decorators, typename BarrierSetT = CardTableBarrierSet>113class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {};114};115116template<>117struct BarrierSet::GetName<CardTableBarrierSet> {118static const BarrierSet::Name value = BarrierSet::CardTableBarrierSet;119};120121template<>122struct BarrierSet::GetType<BarrierSet::CardTableBarrierSet> {123typedef ::CardTableBarrierSet type;124};125126#endif // SHARE_GC_SHARED_CARDTABLEBARRIERSET_HPP127128129