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/shenandoah/shenandoahSATBMarkQueueSet.hpp"
30
31 class ShenandoahHeap;
32 class ShenandoahBarrierSetAssembler;
33
34 class ShenandoahBarrierSet: public BarrierSet {
35 private:
36 ShenandoahHeap* const _heap;
37 BufferNode::Allocator _satb_mark_queue_buffer_allocator;
38 ShenandoahSATBMarkQueueSet _satb_mark_queue_set;
39
40 public:
41 ShenandoahBarrierSet(ShenandoahHeap* heap);
42
43 static ShenandoahBarrierSetAssembler* assembler();
44
45 inline static ShenandoahBarrierSet* barrier_set() {
46 return barrier_set_cast<ShenandoahBarrierSet>(BarrierSet::barrier_set());
47 }
48
49 static ShenandoahSATBMarkQueueSet& satb_mark_queue_set() {
50 return barrier_set()->_satb_mark_queue_set;
51 }
52
53 static bool need_load_reference_barrier(DecoratorSet decorators, BasicType type);
54 static bool need_keep_alive_barrier(DecoratorSet decorators, BasicType type);
55
56 static bool is_strong_access(DecoratorSet decorators) {
57 return (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) == 0;
58 }
59
60 static bool is_weak_access(DecoratorSet decorators) {
61 return (decorators & ON_WEAK_OOP_REF) != 0;
62 }
63
64 static bool is_phantom_access(DecoratorSet decorators) {
65 return (decorators & ON_PHANTOM_OOP_REF) != 0;
66 }
67
68 static bool is_native_access(DecoratorSet decorators) {
71
72 void print_on(outputStream* st) const;
73
74 template <class T>
75 inline void arraycopy_barrier(T* src, T* dst, size_t count);
76 inline void clone_barrier(oop src);
77 void clone_barrier_runtime(oop src);
78
79 virtual void on_thread_create(Thread* thread);
80 virtual void on_thread_destroy(Thread* thread);
81 virtual void on_thread_attach(Thread* thread);
82 virtual void on_thread_detach(Thread* thread);
83
84 static inline oop resolve_forwarded_not_null(oop p);
85 static inline oop resolve_forwarded_not_null_mutator(oop p);
86 static inline oop resolve_forwarded(oop p);
87
88 template <DecoratorSet decorators, typename T>
89 inline void satb_barrier(T* field);
90 inline void satb_enqueue(oop value);
91 inline void iu_barrier(oop obj);
92
93 inline void keep_alive_if_weak(DecoratorSet decorators, oop value);
94
95 inline void enqueue(oop obj);
96
97 inline oop load_reference_barrier(oop obj);
98
99 template <class T>
100 inline oop load_reference_barrier_mutator(oop obj, T* load_addr);
101
102 template <class T>
103 inline oop load_reference_barrier(DecoratorSet decorators, oop obj, T* load_addr);
104
105 template <typename T>
106 inline oop oop_load(DecoratorSet decorators, T* addr);
107
108 template <typename T>
109 inline oop oop_cmpxchg(DecoratorSet decorators, T* addr, oop compare_value, oop new_value);
110
111 template <typename T>
112 inline oop oop_xchg(DecoratorSet decorators, T* addr, oop new_value);
113
114 private:
115 template <class T>
116 inline void arraycopy_marking(T* src, T* dst, size_t count);
117 template <class T>
118 inline void arraycopy_evacuation(T* src, size_t count);
119 template <class T>
120 inline void arraycopy_update(T* src, size_t count);
121
122 inline void clone_marking(oop src);
123 inline void clone_evacuation(oop src);
124 inline void clone_update(oop src);
125
126 template <class T, bool HAS_FWD, bool EVAC, bool ENQUEUE>
127 inline void arraycopy_work(T* src, size_t count);
128
129 inline bool need_bulk_update(HeapWord* dst);
130 public:
131 // Callbacks for runtime accesses.
132 template <DecoratorSet decorators, typename BarrierSetT = ShenandoahBarrierSet>
133 class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
134 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
135
136 private:
137 template <typename T>
138 static void oop_store_common(T* addr, oop value);
139
140 public:
141 // Heap oop accesses. These accessors get resolved when
142 // 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/shenandoah/shenandoahSATBMarkQueueSet.hpp"
31
32 class ShenandoahHeap;
33 class ShenandoahBarrierSetAssembler;
34 class ShenandoahCardTable;
35
36 class ShenandoahBarrierSet: public BarrierSet {
37 private:
38 ShenandoahHeap* const _heap;
39 ShenandoahCardTable* _card_table;
40 BufferNode::Allocator _satb_mark_queue_buffer_allocator;
41 ShenandoahSATBMarkQueueSet _satb_mark_queue_set;
42
43 public:
44 ShenandoahBarrierSet(ShenandoahHeap* heap, MemRegion heap_region);
45
46 static ShenandoahBarrierSetAssembler* assembler();
47
48 inline static ShenandoahBarrierSet* barrier_set() {
49 return barrier_set_cast<ShenandoahBarrierSet>(BarrierSet::barrier_set());
50 }
51
52 inline ShenandoahCardTable* card_table() {
53 return _card_table;
54 }
55
56 static ShenandoahSATBMarkQueueSet& satb_mark_queue_set() {
57 return barrier_set()->_satb_mark_queue_set;
58 }
59
60 static bool need_load_reference_barrier(DecoratorSet decorators, BasicType type);
61 static bool need_keep_alive_barrier(DecoratorSet decorators, BasicType type);
62
63 static bool is_strong_access(DecoratorSet decorators) {
64 return (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) == 0;
65 }
66
67 static bool is_weak_access(DecoratorSet decorators) {
68 return (decorators & ON_WEAK_OOP_REF) != 0;
69 }
70
71 static bool is_phantom_access(DecoratorSet decorators) {
72 return (decorators & ON_PHANTOM_OOP_REF) != 0;
73 }
74
75 static bool is_native_access(DecoratorSet decorators) {
78
79 void print_on(outputStream* st) const;
80
81 template <class T>
82 inline void arraycopy_barrier(T* src, T* dst, size_t count);
83 inline void clone_barrier(oop src);
84 void clone_barrier_runtime(oop src);
85
86 virtual void on_thread_create(Thread* thread);
87 virtual void on_thread_destroy(Thread* thread);
88 virtual void on_thread_attach(Thread* thread);
89 virtual void on_thread_detach(Thread* thread);
90
91 static inline oop resolve_forwarded_not_null(oop p);
92 static inline oop resolve_forwarded_not_null_mutator(oop p);
93 static inline oop resolve_forwarded(oop p);
94
95 template <DecoratorSet decorators, typename T>
96 inline void satb_barrier(T* field);
97 inline void satb_enqueue(oop value);
98
99 inline void keep_alive_if_weak(DecoratorSet decorators, oop value);
100
101 inline void enqueue(oop obj);
102
103 inline oop load_reference_barrier(oop obj);
104
105 template <class T>
106 inline oop load_reference_barrier_mutator(oop obj, T* load_addr);
107
108 template <class T>
109 inline oop load_reference_barrier(DecoratorSet decorators, oop obj, T* load_addr);
110
111 template <typename T>
112 inline oop oop_load(DecoratorSet decorators, T* addr);
113
114 template <typename T>
115 inline oop oop_cmpxchg(DecoratorSet decorators, T* addr, oop compare_value, oop new_value);
116
117 template <typename T>
118 inline oop oop_xchg(DecoratorSet decorators, T* addr, oop new_value);
119
120 template <DecoratorSet decorators, typename T>
121 void write_ref_field_post(T* field);
122
123 void write_ref_array(HeapWord* start, size_t count);
124
125 private:
126 template <class T>
127 inline void arraycopy_marking(T* src, T* dst, size_t count, bool is_old_marking);
128 template <class T>
129 inline void arraycopy_evacuation(T* src, size_t count);
130 template <class T>
131 inline void arraycopy_update(T* src, size_t count);
132
133 inline void clone_evacuation(oop src);
134 inline void clone_update(oop src);
135
136 template <class T, bool HAS_FWD, bool EVAC, bool ENQUEUE>
137 inline void arraycopy_work(T* src, size_t count);
138
139 inline bool need_bulk_update(HeapWord* dst);
140 public:
141 // Callbacks for runtime accesses.
142 template <DecoratorSet decorators, typename BarrierSetT = ShenandoahBarrierSet>
143 class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
144 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
145
146 private:
147 template <typename T>
148 static void oop_store_common(T* addr, oop value);
149
150 public:
151 // Heap oop accesses. These accessors get resolved when
152 // IN_HEAP is set (e.g. when using the HeapAccess API), it is
|