Path: blob/master/src/hotspot/share/gc/g1/g1BarrierSet.hpp
40960 views
/*1* Copyright (c) 2001, 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_G1_G1BARRIERSET_HPP25#define SHARE_GC_G1_G1BARRIERSET_HPP2627#include "gc/g1/g1DirtyCardQueue.hpp"28#include "gc/g1/g1SATBMarkQueueSet.hpp"29#include "gc/g1/g1SharedDirtyCardQueue.hpp"30#include "gc/shared/cardTable.hpp"31#include "gc/shared/cardTableBarrierSet.hpp"3233class G1CardTable;3435// This barrier is specialized to use a logging barrier to support36// snapshot-at-the-beginning marking.3738class G1BarrierSet: public CardTableBarrierSet {39friend class VMStructs;40private:41BufferNode::Allocator _satb_mark_queue_buffer_allocator;42BufferNode::Allocator _dirty_card_queue_buffer_allocator;43G1SATBMarkQueueSet _satb_mark_queue_set;44G1DirtyCardQueueSet _dirty_card_queue_set;45G1SharedDirtyCardQueue _shared_dirty_card_queue;4647static G1BarrierSet* g1_barrier_set() {48return barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());49}5051public:52G1BarrierSet(G1CardTable* table);53~G1BarrierSet() { }5455virtual bool card_mark_must_follow_store() const {56return true;57}5859// Add "pre_val" to a set of objects that may have been disconnected from the60// pre-marking object graph.61static void enqueue(oop pre_val);6263static void enqueue_if_weak(DecoratorSet decorators, oop value);6465template <class T> void write_ref_array_pre_work(T* dst, size_t count);66virtual void write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized);67virtual void write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized);6869template <DecoratorSet decorators, typename T>70void write_ref_field_pre(T* field);7172// NB: if you do a whole-heap invalidation, the "usual invariant" defined73// above no longer applies.74void invalidate(MemRegion mr);7576void write_region(MemRegion mr) { invalidate(mr); }77void write_ref_array_work(MemRegion mr) { invalidate(mr); }7879template <DecoratorSet decorators, typename T>80void write_ref_field_post(T* field, oop new_val);81void write_ref_field_post_slow(volatile CardValue* byte);8283virtual void on_thread_create(Thread* thread);84virtual void on_thread_destroy(Thread* thread);85virtual void on_thread_attach(Thread* thread);86virtual void on_thread_detach(Thread* thread);8788static G1SATBMarkQueueSet& satb_mark_queue_set() {89return g1_barrier_set()->_satb_mark_queue_set;90}9192static G1DirtyCardQueueSet& dirty_card_queue_set() {93return g1_barrier_set()->_dirty_card_queue_set;94}9596static G1SharedDirtyCardQueue& shared_dirty_card_queue() {97return g1_barrier_set()->_shared_dirty_card_queue;98}99100// Callbacks for runtime accesses.101template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>102class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {103typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;104typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;105106public:107// Needed for loads on non-heap weak references108template <typename T>109static oop oop_load_not_in_heap(T* addr);110111// Needed for non-heap stores112template <typename T>113static void oop_store_not_in_heap(T* addr, oop new_value);114115// Needed for weak references116static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);117118// Defensive: will catch weak oops at addresses in heap119template <typename T>120static oop oop_load_in_heap(T* addr);121};122};123124template<>125struct BarrierSet::GetName<G1BarrierSet> {126static const BarrierSet::Name value = BarrierSet::G1BarrierSet;127};128129template<>130struct BarrierSet::GetType<BarrierSet::G1BarrierSet> {131typedef ::G1BarrierSet type;132};133134#endif // SHARE_GC_G1_G1BARRIERSET_HPP135136137