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_G1_G1BARRIERSET_HPP
26 #define SHARE_GC_G1_G1BARRIERSET_HPP
27
28 #include "gc/g1/g1SATBMarkQueueSet.hpp"
29 #include "gc/shared/bufferNode.hpp"
30 #include "gc/shared/cardTable.hpp"
31 #include "gc/shared/cardTableBarrierSet.hpp"
32
33 class G1CardTable;
34 class Thread;
35
36 // This barrier set is specialized to manage two card tables:
37 // * one the mutator is currently working on ("card table")
38 // * one the refinement threads or GC during pause are working on ("refinement table")
39 //
40 // The card table acts like a regular card table where the mutator dirties cards
41 // containing potentially interesting references.
42 //
43 // When the amount of dirty cards on the card table exceeds a threshold, G1 swaps
44 // the card tables and has the refinement threads reduce them by "refining"
45 // them.
46 // I.e. refinement looks at all dirty cards on the refinement table, and updates
47 // the remembered sets accordingly, clearing the cards on the refinement table.
98
99 template <DecoratorSet decorators, typename T>
100 void write_ref_field_pre(T* field);
101
102 virtual void write_region(MemRegion mr);
103
104 template <DecoratorSet decorators = DECORATORS_NONE, typename T>
105 void write_ref_field_post(T* field);
106
107 virtual void on_thread_create(Thread* thread);
108 virtual void on_thread_destroy(Thread* thread);
109 virtual void on_thread_attach(Thread* thread);
110 virtual void on_thread_detach(Thread* thread);
111
112 static G1SATBMarkQueueSet& satb_mark_queue_set() {
113 return g1_barrier_set()->_satb_mark_queue_set;
114 }
115
116 virtual void print_on(outputStream* st) const;
117
118 // Callbacks for runtime accesses.
119 template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
120 class AccessBarrier: public CardTableBarrierSet::AccessBarrier<decorators, BarrierSetT> {
121 typedef CardTableBarrierSet::AccessBarrier<decorators, BarrierSetT> CardTableBS;
122 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
123
124 public:
125 // Needed for loads on non-heap weak references
126 template <typename T>
127 static oop oop_load_not_in_heap(T* addr);
128
129 // Needed for non-heap stores
130 template <typename T>
131 static void oop_store_not_in_heap(T* addr, oop new_value);
132
133 // Needed for weak references
134 static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
135
136 // Defensive: will catch weak oops at addresses in heap
137 template <typename T>
|
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_G1_G1BARRIERSET_HPP
26 #define SHARE_GC_G1_G1BARRIERSET_HPP
27
28 #include "gc/g1/g1HeapRegion.hpp"
29 #include "gc/g1/g1SATBMarkQueueSet.hpp"
30 #include "gc/shared/bufferNode.hpp"
31 #include "gc/shared/cardTable.hpp"
32 #include "gc/shared/cardTableBarrierSet.hpp"
33
34 class G1CardTable;
35 class Thread;
36
37 // This barrier set is specialized to manage two card tables:
38 // * one the mutator is currently working on ("card table")
39 // * one the refinement threads or GC during pause are working on ("refinement table")
40 //
41 // The card table acts like a regular card table where the mutator dirties cards
42 // containing potentially interesting references.
43 //
44 // When the amount of dirty cards on the card table exceeds a threshold, G1 swaps
45 // the card tables and has the refinement threads reduce them by "refining"
46 // them.
47 // I.e. refinement looks at all dirty cards on the refinement table, and updates
48 // the remembered sets accordingly, clearing the cards on the refinement table.
99
100 template <DecoratorSet decorators, typename T>
101 void write_ref_field_pre(T* field);
102
103 virtual void write_region(MemRegion mr);
104
105 template <DecoratorSet decorators = DECORATORS_NONE, typename T>
106 void write_ref_field_post(T* field);
107
108 virtual void on_thread_create(Thread* thread);
109 virtual void on_thread_destroy(Thread* thread);
110 virtual void on_thread_attach(Thread* thread);
111 virtual void on_thread_detach(Thread* thread);
112
113 static G1SATBMarkQueueSet& satb_mark_queue_set() {
114 return g1_barrier_set()->_satb_mark_queue_set;
115 }
116
117 virtual void print_on(outputStream* st) const;
118
119 virtual uint grain_shift() { return G1HeapRegion::LogOfHRGrainBytes; }
120
121 // Callbacks for runtime accesses.
122 template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
123 class AccessBarrier: public CardTableBarrierSet::AccessBarrier<decorators, BarrierSetT> {
124 typedef CardTableBarrierSet::AccessBarrier<decorators, BarrierSetT> CardTableBS;
125 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
126
127 public:
128 // Needed for loads on non-heap weak references
129 template <typename T>
130 static oop oop_load_not_in_heap(T* addr);
131
132 // Needed for non-heap stores
133 template <typename T>
134 static void oop_store_not_in_heap(T* addr, oop new_value);
135
136 // Needed for weak references
137 static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
138
139 // Defensive: will catch weak oops at addresses in heap
140 template <typename T>
|