14 * You should have received a copy of the GNU General Public License version
15 * 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 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_GC_SHARED_BARRIERSET_HPP
25 #define SHARE_VM_GC_SHARED_BARRIERSET_HPP
26
27 #include "gc/shared/barrierSetConfig.hpp"
28 #include "memory/memRegion.hpp"
29 #include "oops/access.hpp"
30 #include "oops/accessBackend.hpp"
31 #include "oops/oopsHierarchy.hpp"
32 #include "utilities/fakeRttiSupport.hpp"
33
34 // This class provides the interface between a barrier implementation and
35 // the rest of the system.
36
37 class BarrierSet: public CHeapObj<mtGC> {
38 friend class VMStructs;
39
40 static BarrierSet* _bs;
41
42 public:
43 enum Name {
44 #define BARRIER_SET_DECLARE_BS_ENUM(bs_name) bs_name ,
45 FOR_EACH_BARRIER_SET_DO(BARRIER_SET_DECLARE_BS_ENUM)
46 #undef BARRIER_SET_DECLARE_BS_ENUM
47 UnknownBS
48 };
49
50 static BarrierSet* barrier_set() { return _bs; }
51
52 protected:
|
14 * You should have received a copy of the GNU General Public License version
15 * 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 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_GC_SHARED_BARRIERSET_HPP
25 #define SHARE_VM_GC_SHARED_BARRIERSET_HPP
26
27 #include "gc/shared/barrierSetConfig.hpp"
28 #include "memory/memRegion.hpp"
29 #include "oops/access.hpp"
30 #include "oops/accessBackend.hpp"
31 #include "oops/oopsHierarchy.hpp"
32 #include "utilities/fakeRttiSupport.hpp"
33
34 class JavaThread;
35
36 // This class provides the interface between a barrier implementation and
37 // the rest of the system.
38
39 class BarrierSet: public CHeapObj<mtGC> {
40 friend class VMStructs;
41
42 static BarrierSet* _bs;
43
44 public:
45 enum Name {
46 #define BARRIER_SET_DECLARE_BS_ENUM(bs_name) bs_name ,
47 FOR_EACH_BARRIER_SET_DO(BARRIER_SET_DECLARE_BS_ENUM)
48 #undef BARRIER_SET_DECLARE_BS_ENUM
49 UnknownBS
50 };
51
52 static BarrierSet* barrier_set() { return _bs; }
53
54 protected:
|
89
90 public:
91 // Operations on arrays, or general regions (e.g., for "clone") may be
92 // optimized by some barriers.
93
94 // Below length is the # array elements being written
95 virtual void write_ref_array_pre(oop* dst, int length,
96 bool dest_uninitialized = false) {}
97 virtual void write_ref_array_pre(narrowOop* dst, int length,
98 bool dest_uninitialized = false) {}
99 // Below count is the # array elements being written, starting
100 // at the address "start", which may not necessarily be HeapWord-aligned
101 inline void write_ref_array(HeapWord* start, size_t count);
102
103 // Static versions, suitable for calling from generated code;
104 // count is # array elements being written, starting with "start",
105 // which may not necessarily be HeapWord-aligned.
106 static void static_write_ref_array_pre(HeapWord* start, size_t count);
107 static void static_write_ref_array_post(HeapWord* start, size_t count);
108
109 protected:
110 virtual void write_ref_array_work(MemRegion mr) = 0;
111
112 public:
113 // (For efficiency reasons, this operation is specialized for certain
114 // barrier types. Semantically, it should be thought of as a call to the
115 // virtual "_work" function below, which must implement the barrier.)
116 void write_region(MemRegion mr);
117
118 protected:
119 virtual void write_region_work(MemRegion mr) = 0;
120
121 public:
122 // Inform the BarrierSet that the the covered heap region that starts
123 // with "base" has been changed to have the given size (possibly from 0,
124 // for initialization.)
125 virtual void resize_covered_region(MemRegion new_region) = 0;
126
127 // If the barrier set imposes any alignment restrictions on boundaries
128 // within the heap, this function tells whether they are met.
129 virtual bool is_aligned(HeapWord* addr) = 0;
130
131 // Print a description of the memory for the barrier set
132 virtual void print_on(outputStream* st) const = 0;
133
134 static void set_bs(BarrierSet* bs) { _bs = bs; }
135
136 // The AccessBarrier of a BarrierSet subclass is called by the Access API
137 // (cf. oops/access.hpp) to perform decorated accesses. GC implementations
138 // may override these default access operations by declaring an
|
91
92 public:
93 // Operations on arrays, or general regions (e.g., for "clone") may be
94 // optimized by some barriers.
95
96 // Below length is the # array elements being written
97 virtual void write_ref_array_pre(oop* dst, int length,
98 bool dest_uninitialized = false) {}
99 virtual void write_ref_array_pre(narrowOop* dst, int length,
100 bool dest_uninitialized = false) {}
101 // Below count is the # array elements being written, starting
102 // at the address "start", which may not necessarily be HeapWord-aligned
103 inline void write_ref_array(HeapWord* start, size_t count);
104
105 // Static versions, suitable for calling from generated code;
106 // count is # array elements being written, starting with "start",
107 // which may not necessarily be HeapWord-aligned.
108 static void static_write_ref_array_pre(HeapWord* start, size_t count);
109 static void static_write_ref_array_post(HeapWord* start, size_t count);
110
111 // Support for optimizing compilers to call the barrier set on slow path allocations
112 // that did not enter a TLAB. Used for e.g. ReduceInitialCardMarks.
113 // The allocation is safe to use iff it returns true. If not, the slow-path allocation
114 // is redone until it succeeds. This can e.g. prevent allocations from the slow path
115 // to be in old.
116 virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) {}
117 virtual void flush_deferred_barriers(JavaThread* thread) {}
118 virtual void make_parsable(JavaThread* thread) {}
119
120 protected:
121 virtual void write_ref_array_work(MemRegion mr) = 0;
122
123 public:
124 // Inform the BarrierSet that the the covered heap region that starts
125 // with "base" has been changed to have the given size (possibly from 0,
126 // for initialization.)
127 virtual void resize_covered_region(MemRegion new_region) = 0;
128
129 // If the barrier set imposes any alignment restrictions on boundaries
130 // within the heap, this function tells whether they are met.
131 virtual bool is_aligned(HeapWord* addr) = 0;
132
133 // Print a description of the memory for the barrier set
134 virtual void print_on(outputStream* st) const = 0;
135
136 static void set_bs(BarrierSet* bs) { _bs = bs; }
137
138 // The AccessBarrier of a BarrierSet subclass is called by the Access API
139 // (cf. oops/access.hpp) to perform decorated accesses. GC implementations
140 // may override these default access operations by declaring an
|