Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp
66644 views
/*1* Copyright (c) 2013, 2021, Red Hat, Inc. 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_SHENANDOAH_SHENANDOAHBARRIERSET_HPP25#define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP2627#include "gc/shared/barrierSet.hpp"28#include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"2930class ShenandoahHeap;31class ShenandoahBarrierSetAssembler;3233class ShenandoahBarrierSet: public BarrierSet {34private:35ShenandoahHeap* const _heap;36BufferNode::Allocator _satb_mark_queue_buffer_allocator;37ShenandoahSATBMarkQueueSet _satb_mark_queue_set;3839public:40ShenandoahBarrierSet(ShenandoahHeap* heap);4142static ShenandoahBarrierSetAssembler* assembler();4344inline static ShenandoahBarrierSet* barrier_set() {45return barrier_set_cast<ShenandoahBarrierSet>(BarrierSet::barrier_set());46}4748static ShenandoahSATBMarkQueueSet& satb_mark_queue_set() {49return barrier_set()->_satb_mark_queue_set;50}5152static bool need_load_reference_barrier(DecoratorSet decorators, BasicType type);53static bool need_keep_alive_barrier(DecoratorSet decorators, BasicType type);5455static bool is_strong_access(DecoratorSet decorators) {56return (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) == 0;57}5859static bool is_weak_access(DecoratorSet decorators) {60return (decorators & ON_WEAK_OOP_REF) != 0;61}6263static bool is_phantom_access(DecoratorSet decorators) {64return (decorators & ON_PHANTOM_OOP_REF) != 0;65}6667static bool is_native_access(DecoratorSet decorators) {68return (decorators & IN_NATIVE) != 0;69}7071void print_on(outputStream* st) const;7273template <class T>74inline void arraycopy_barrier(T* src, T* dst, size_t count);75inline void clone_barrier(oop src);76void clone_barrier_runtime(oop src);7778virtual void on_thread_create(Thread* thread);79virtual void on_thread_destroy(Thread* thread);80virtual void on_thread_attach(Thread* thread);81virtual void on_thread_detach(Thread* thread);8283static inline oop resolve_forwarded_not_null(oop p);84static inline oop resolve_forwarded_not_null_mutator(oop p);85static inline oop resolve_forwarded(oop p);8687template <DecoratorSet decorators, typename T>88inline void satb_barrier(T* field);89inline void satb_enqueue(oop value);90inline void iu_barrier(oop obj);9192inline void keep_alive_if_weak(DecoratorSet decorators, oop value);9394inline void enqueue(oop obj);9596inline oop load_reference_barrier(oop obj);9798template <class T>99inline oop load_reference_barrier_mutator(oop obj, T* load_addr);100101template <class T>102inline oop load_reference_barrier(DecoratorSet decorators, oop obj, T* load_addr);103104template <typename T>105inline oop oop_load(DecoratorSet decorators, T* addr);106107template <typename T>108inline oop oop_cmpxchg(DecoratorSet decorators, T* addr, oop compare_value, oop new_value);109110template <typename T>111inline oop oop_xchg(DecoratorSet decorators, T* addr, oop new_value);112113private:114template <class T>115inline void arraycopy_marking(T* src, T* dst, size_t count);116template <class T>117inline void arraycopy_evacuation(T* src, size_t count);118template <class T>119inline void arraycopy_update(T* src, size_t count);120121inline void clone_marking(oop src);122inline void clone_evacuation(oop src);123inline void clone_update(oop src);124125template <class T, bool HAS_FWD, bool EVAC, bool ENQUEUE>126inline void arraycopy_work(T* src, size_t count);127128inline bool need_bulk_update(HeapWord* dst);129public:130// Callbacks for runtime accesses.131template <DecoratorSet decorators, typename BarrierSetT = ShenandoahBarrierSet>132class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {133typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;134135public:136// Heap oop accesses. These accessors get resolved when137// IN_HEAP is set (e.g. when using the HeapAccess API), it is138// an oop_* overload, and the barrier strength is AS_NORMAL.139template <typename T>140static oop oop_load_in_heap(T* addr);141static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);142143template <typename T>144static void oop_store_in_heap(T* addr, oop value);145static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value);146147template <typename T>148static oop oop_atomic_cmpxchg_in_heap(T* addr, oop compare_value, oop new_value);149static oop oop_atomic_cmpxchg_in_heap_at(oop base, ptrdiff_t offset, oop compare_value, oop new_value);150151template <typename T>152static oop oop_atomic_xchg_in_heap(T* addr, oop new_value);153static oop oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value);154155template <typename T>156static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,157arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,158size_t length);159160// Clone barrier support161static void clone_in_heap(oop src, oop dst, size_t size);162163// Support for concurrent roots evacuation, updating and weak roots clearing164template <typename T>165static oop oop_load_not_in_heap(T* addr);166167// Support for concurrent roots marking168template <typename T>169static void oop_store_not_in_heap(T* addr, oop value);170171template <typename T>172static oop oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value);173174template <typename T>175static oop oop_atomic_xchg_not_in_heap(T* addr, oop new_value);176177};178179};180181template<>182struct BarrierSet::GetName<ShenandoahBarrierSet> {183static const BarrierSet::Name value = BarrierSet::ShenandoahBarrierSet;184};185186template<>187struct BarrierSet::GetType<BarrierSet::ShenandoahBarrierSet> {188typedef ::ShenandoahBarrierSet type;189};190191#endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP192193194