Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp
40961 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 | ON_UNKNOWN_OOP_REF)) == 0;57}5859static bool is_weak_access(DecoratorSet decorators) {60return (decorators & (ON_WEAK_OOP_REF | ON_UNKNOWN_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);9192template <DecoratorSet decorators>93inline void keep_alive_if_weak(oop value);94inline void keep_alive_if_weak(DecoratorSet decorators, oop value);9596inline void enqueue(oop obj);9798inline oop load_reference_barrier(oop obj);99100template <class T>101inline oop load_reference_barrier_mutator(oop obj, T* load_addr);102103template <DecoratorSet decorators, class T>104inline oop load_reference_barrier(oop obj, T* load_addr);105106private:107template <class T>108inline void arraycopy_marking(T* src, T* dst, size_t count);109template <class T>110inline void arraycopy_evacuation(T* src, size_t count);111template <class T>112inline void arraycopy_update(T* src, size_t count);113114inline void clone_marking(oop src);115inline void clone_evacuation(oop src);116inline void clone_update(oop src);117118template <class T, bool HAS_FWD, bool EVAC, bool ENQUEUE>119inline void arraycopy_work(T* src, size_t count);120121inline bool need_bulk_update(HeapWord* dst);122public:123// Callbacks for runtime accesses.124template <DecoratorSet decorators, typename BarrierSetT = ShenandoahBarrierSet>125class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {126typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;127128public:129// Heap oop accesses. These accessors get resolved when130// IN_HEAP is set (e.g. when using the HeapAccess API), it is131// an oop_* overload, and the barrier strength is AS_NORMAL.132template <typename T>133static oop oop_load_in_heap(T* addr);134static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);135136template <typename T>137static void oop_store_in_heap(T* addr, oop value);138static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value);139140template <typename T>141static oop oop_atomic_cmpxchg_in_heap(T* addr, oop compare_value, oop new_value);142static oop oop_atomic_cmpxchg_in_heap_at(oop base, ptrdiff_t offset, oop compare_value, oop new_value);143144template <typename T>145static oop oop_atomic_xchg_in_heap(T* addr, oop new_value);146static oop oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value);147148template <typename T>149static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,150arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,151size_t length);152153// Clone barrier support154static void clone_in_heap(oop src, oop dst, size_t size);155156// Support for concurrent roots evacuation, updating and weak roots clearing157template <typename T>158static oop oop_load_not_in_heap(T* addr);159160// Support for concurrent roots marking161template <typename T>162static void oop_store_not_in_heap(T* addr, oop value);163164template <typename T>165static oop oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value);166167template <typename T>168static oop oop_atomic_xchg_not_in_heap(T* addr, oop new_value);169170};171172};173174template<>175struct BarrierSet::GetName<ShenandoahBarrierSet> {176static const BarrierSet::Name value = BarrierSet::ShenandoahBarrierSet;177};178179template<>180struct BarrierSet::GetType<BarrierSet::ShenandoahBarrierSet> {181typedef ::ShenandoahBarrierSet type;182};183184#endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP185186187