1 /*
2 * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP
27
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/bufferNode.hpp"
30 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
31
32 class ShenandoahHeap;
33 class ShenandoahBarrierSetAssembler;
34
35 class ShenandoahBarrierSet: public BarrierSet {
36 private:
37 ShenandoahHeap* const _heap;
38 BufferNode::Allocator _satb_mark_queue_buffer_allocator;
39 ShenandoahSATBMarkQueueSet _satb_mark_queue_set;
40
41 public:
42 ShenandoahBarrierSet(ShenandoahHeap* heap);
43
44 static ShenandoahBarrierSetAssembler* assembler();
45
46 inline static ShenandoahBarrierSet* barrier_set() {
47 return barrier_set_cast<ShenandoahBarrierSet>(BarrierSet::barrier_set());
48 }
49
50 static ShenandoahSATBMarkQueueSet& satb_mark_queue_set() {
51 return barrier_set()->_satb_mark_queue_set;
52 }
53
54 static bool need_load_reference_barrier(DecoratorSet decorators, BasicType type);
55 static bool need_keep_alive_barrier(DecoratorSet decorators, BasicType type);
56
57 static bool is_strong_access(DecoratorSet decorators) {
58 return (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) == 0;
59 }
60
61 static bool is_weak_access(DecoratorSet decorators) {
62 return (decorators & ON_WEAK_OOP_REF) != 0;
63 }
64
65 static bool is_phantom_access(DecoratorSet decorators) {
66 return (decorators & ON_PHANTOM_OOP_REF) != 0;
67 }
68
69 static bool is_native_access(DecoratorSet decorators) {
72
73 void print_on(outputStream* st) const;
74
75 template <class T>
76 inline void arraycopy_barrier(T* src, T* dst, size_t count);
77 inline void clone_barrier(oop src);
78 void clone_barrier_runtime(oop src);
79
80 virtual void on_thread_create(Thread* thread);
81 virtual void on_thread_destroy(Thread* thread);
82 virtual void on_thread_attach(Thread* thread);
83 virtual void on_thread_detach(Thread* thread);
84
85 static inline oop resolve_forwarded_not_null(oop p);
86 static inline oop resolve_forwarded_not_null_mutator(oop p);
87 static inline oop resolve_forwarded(oop p);
88
89 template <DecoratorSet decorators, typename T>
90 inline void satb_barrier(T* field);
91 inline void satb_enqueue(oop value);
92 inline void iu_barrier(oop obj);
93
94 inline void keep_alive_if_weak(DecoratorSet decorators, oop value);
95
96 inline void enqueue(oop obj);
97
98 inline oop load_reference_barrier(oop obj);
99
100 template <class T>
101 inline oop load_reference_barrier_mutator(oop obj, T* load_addr);
102
103 template <class T>
104 inline oop load_reference_barrier(DecoratorSet decorators, oop obj, T* load_addr);
105
106 template <typename T>
107 inline oop oop_load(DecoratorSet decorators, T* addr);
108
109 template <typename T>
110 inline oop oop_cmpxchg(DecoratorSet decorators, T* addr, oop compare_value, oop new_value);
111
112 template <typename T>
113 inline oop oop_xchg(DecoratorSet decorators, T* addr, oop new_value);
114
115 private:
116 template <class T>
117 inline void arraycopy_marking(T* src, T* dst, size_t count);
118 template <class T>
119 inline void arraycopy_evacuation(T* src, size_t count);
120 template <class T>
121 inline void arraycopy_update(T* src, size_t count);
122
123 inline void clone_marking(oop src);
124 inline void clone_evacuation(oop src);
125 inline void clone_update(oop src);
126
127 template <class T, bool HAS_FWD, bool EVAC, bool ENQUEUE>
128 inline void arraycopy_work(T* src, size_t count);
129
130 inline bool need_bulk_update(HeapWord* dst);
131 public:
132 // Callbacks for runtime accesses.
133 template <DecoratorSet decorators, typename BarrierSetT = ShenandoahBarrierSet>
134 class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
135 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
136
137 private:
138 template <typename T>
139 static void oop_store_common(T* addr, oop value);
140
141 public:
142 // Heap oop accesses. These accessors get resolved when
143 // IN_HEAP is set (e.g. when using the HeapAccess API), it is
|
1 /*
2 * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP
28
29 #include "gc/shared/barrierSet.hpp"
30 #include "gc/shared/bufferNode.hpp"
31 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
32
33 class ShenandoahHeap;
34 class ShenandoahBarrierSetAssembler;
35 class ShenandoahCardTable;
36
37 class ShenandoahBarrierSet: public BarrierSet {
38 private:
39 ShenandoahHeap* const _heap;
40 ShenandoahCardTable* _card_table;
41 BufferNode::Allocator _satb_mark_queue_buffer_allocator;
42 ShenandoahSATBMarkQueueSet _satb_mark_queue_set;
43
44 public:
45 ShenandoahBarrierSet(ShenandoahHeap* heap, MemRegion heap_region);
46
47 static ShenandoahBarrierSetAssembler* assembler();
48
49 inline static ShenandoahBarrierSet* barrier_set() {
50 return barrier_set_cast<ShenandoahBarrierSet>(BarrierSet::barrier_set());
51 }
52
53 inline ShenandoahCardTable* card_table() {
54 return _card_table;
55 }
56
57 static ShenandoahSATBMarkQueueSet& satb_mark_queue_set() {
58 return barrier_set()->_satb_mark_queue_set;
59 }
60
61 static bool need_load_reference_barrier(DecoratorSet decorators, BasicType type);
62 static bool need_keep_alive_barrier(DecoratorSet decorators, BasicType type);
63
64 static bool is_strong_access(DecoratorSet decorators) {
65 return (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) == 0;
66 }
67
68 static bool is_weak_access(DecoratorSet decorators) {
69 return (decorators & ON_WEAK_OOP_REF) != 0;
70 }
71
72 static bool is_phantom_access(DecoratorSet decorators) {
73 return (decorators & ON_PHANTOM_OOP_REF) != 0;
74 }
75
76 static bool is_native_access(DecoratorSet decorators) {
79
80 void print_on(outputStream* st) const;
81
82 template <class T>
83 inline void arraycopy_barrier(T* src, T* dst, size_t count);
84 inline void clone_barrier(oop src);
85 void clone_barrier_runtime(oop src);
86
87 virtual void on_thread_create(Thread* thread);
88 virtual void on_thread_destroy(Thread* thread);
89 virtual void on_thread_attach(Thread* thread);
90 virtual void on_thread_detach(Thread* thread);
91
92 static inline oop resolve_forwarded_not_null(oop p);
93 static inline oop resolve_forwarded_not_null_mutator(oop p);
94 static inline oop resolve_forwarded(oop p);
95
96 template <DecoratorSet decorators, typename T>
97 inline void satb_barrier(T* field);
98 inline void satb_enqueue(oop value);
99
100 inline void keep_alive_if_weak(DecoratorSet decorators, oop value);
101
102 inline void enqueue(oop obj);
103
104 inline oop load_reference_barrier(oop obj);
105
106 template <class T>
107 inline oop load_reference_barrier_mutator(oop obj, T* load_addr);
108
109 template <class T>
110 inline oop load_reference_barrier(DecoratorSet decorators, oop obj, T* load_addr);
111
112 template <typename T>
113 inline oop oop_load(DecoratorSet decorators, T* addr);
114
115 template <typename T>
116 inline oop oop_cmpxchg(DecoratorSet decorators, T* addr, oop compare_value, oop new_value);
117
118 template <typename T>
119 inline oop oop_xchg(DecoratorSet decorators, T* addr, oop new_value);
120
121 template <DecoratorSet decorators, typename T>
122 void write_ref_field_post(T* field);
123
124 void write_ref_array(HeapWord* start, size_t count);
125
126 private:
127 template <class T>
128 inline void arraycopy_marking(T* src, T* dst, size_t count, bool is_old_marking);
129 template <class T>
130 inline void arraycopy_evacuation(T* src, size_t count);
131 template <class T>
132 inline void arraycopy_update(T* src, size_t count);
133
134 inline void clone_evacuation(oop src);
135 inline void clone_update(oop src);
136
137 template <class T, bool HAS_FWD, bool EVAC, bool ENQUEUE>
138 inline void arraycopy_work(T* src, size_t count);
139
140 inline bool need_bulk_update(HeapWord* dst);
141 public:
142 // Callbacks for runtime accesses.
143 template <DecoratorSet decorators, typename BarrierSetT = ShenandoahBarrierSet>
144 class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
145 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
146
147 private:
148 template <typename T>
149 static void oop_store_common(T* addr, oop value);
150
151 public:
152 // Heap oop accesses. These accessors get resolved when
153 // IN_HEAP is set (e.g. when using the HeapAccess API), it is
|