30 public: |
30 public: |
31 enum Name { |
31 enum Name { |
32 ModRef, |
32 ModRef, |
33 CardTableModRef, |
33 CardTableModRef, |
34 CardTableExtension, |
34 CardTableExtension, |
|
35 G1SATBCT, |
|
36 G1SATBCTLogging, |
35 Other, |
37 Other, |
36 Uninit |
38 Uninit |
37 }; |
39 }; |
38 |
40 |
39 protected: |
41 protected: |
40 int _max_covered_regions; |
42 int _max_covered_regions; |
41 Name _kind; |
43 Name _kind; |
42 |
44 |
43 public: |
45 public: |
44 |
46 |
|
47 BarrierSet() { _kind = Uninit; } |
45 // To get around prohibition on RTTI. |
48 // To get around prohibition on RTTI. |
46 virtual BarrierSet::Name kind() { return _kind; } |
49 BarrierSet::Name kind() { return _kind; } |
47 virtual bool is_a(BarrierSet::Name bsn) = 0; |
50 virtual bool is_a(BarrierSet::Name bsn) = 0; |
48 |
51 |
49 // These operations indicate what kind of barriers the BarrierSet has. |
52 // These operations indicate what kind of barriers the BarrierSet has. |
50 virtual bool has_read_ref_barrier() = 0; |
53 virtual bool has_read_ref_barrier() = 0; |
51 virtual bool has_read_prim_barrier() = 0; |
54 virtual bool has_read_prim_barrier() = 0; |
52 virtual bool has_write_ref_barrier() = 0; |
55 virtual bool has_write_ref_barrier() = 0; |
|
56 virtual bool has_write_ref_pre_barrier() = 0; |
53 virtual bool has_write_prim_barrier() = 0; |
57 virtual bool has_write_prim_barrier() = 0; |
54 |
58 |
55 // These functions indicate whether a particular access of the given |
59 // These functions indicate whether a particular access of the given |
56 // kinds requires a barrier. |
60 // kinds requires a barrier. |
57 virtual bool read_ref_needs_barrier(void* field) = 0; |
61 virtual bool read_ref_needs_barrier(void* field) = 0; |
58 virtual bool read_prim_needs_barrier(HeapWord* field, size_t bytes) = 0; |
62 virtual bool read_prim_needs_barrier(HeapWord* field, size_t bytes) = 0; |
59 virtual bool write_ref_needs_barrier(void* field, oop new_val) = 0; |
63 virtual bool write_ref_needs_barrier(void* field, oop new_val) = 0; |
60 virtual bool write_prim_needs_barrier(HeapWord* field, size_t bytes, juint val1, juint val2) = 0; |
64 virtual bool write_prim_needs_barrier(HeapWord* field, size_t bytes, |
|
65 juint val1, juint val2) = 0; |
61 |
66 |
62 // The first four operations provide a direct implementation of the |
67 // The first four operations provide a direct implementation of the |
63 // barrier set. An interpreter loop, for example, could call these |
68 // barrier set. An interpreter loop, for example, could call these |
64 // directly, as appropriate. |
69 // directly, as appropriate. |
65 |
70 |
73 // Invoke the barrier, if any, necessary when writing "new_val" into the |
78 // Invoke the barrier, if any, necessary when writing "new_val" into the |
74 // ref field at "offset" in "obj". |
79 // ref field at "offset" in "obj". |
75 // (For efficiency reasons, this operation is specialized for certain |
80 // (For efficiency reasons, this operation is specialized for certain |
76 // barrier types. Semantically, it should be thought of as a call to the |
81 // barrier types. Semantically, it should be thought of as a call to the |
77 // virtual "_work" function below, which must implement the barrier.) |
82 // virtual "_work" function below, which must implement the barrier.) |
|
83 // First the pre-write versions... |
|
84 inline void write_ref_field_pre(void* field, oop new_val); |
|
85 protected: |
|
86 virtual void write_ref_field_pre_work(void* field, oop new_val) {}; |
|
87 public: |
|
88 |
|
89 // ...then the post-write version. |
78 inline void write_ref_field(void* field, oop new_val); |
90 inline void write_ref_field(void* field, oop new_val); |
79 protected: |
91 protected: |
80 virtual void write_ref_field_work(void* field, oop new_val) = 0; |
92 virtual void write_ref_field_work(void* field, oop new_val) = 0; |
81 public: |
93 public: |
82 |
94 |
90 |
102 |
91 // The first six operations tell whether such an optimization exists for |
103 // The first six operations tell whether such an optimization exists for |
92 // the particular barrier. |
104 // the particular barrier. |
93 virtual bool has_read_ref_array_opt() = 0; |
105 virtual bool has_read_ref_array_opt() = 0; |
94 virtual bool has_read_prim_array_opt() = 0; |
106 virtual bool has_read_prim_array_opt() = 0; |
|
107 virtual bool has_write_ref_array_pre_opt() { return true; } |
95 virtual bool has_write_ref_array_opt() = 0; |
108 virtual bool has_write_ref_array_opt() = 0; |
96 virtual bool has_write_prim_array_opt() = 0; |
109 virtual bool has_write_prim_array_opt() = 0; |
97 |
110 |
98 virtual bool has_read_region_opt() = 0; |
111 virtual bool has_read_region_opt() = 0; |
99 virtual bool has_write_region_opt() = 0; |
112 virtual bool has_write_region_opt() = 0; |
102 // above returns true. Otherwise, they should perform an appropriate |
115 // above returns true. Otherwise, they should perform an appropriate |
103 // barrier for an array whose elements are all in the given memory region. |
116 // barrier for an array whose elements are all in the given memory region. |
104 virtual void read_ref_array(MemRegion mr) = 0; |
117 virtual void read_ref_array(MemRegion mr) = 0; |
105 virtual void read_prim_array(MemRegion mr) = 0; |
118 virtual void read_prim_array(MemRegion mr) = 0; |
106 |
119 |
|
120 virtual void write_ref_array_pre(MemRegion mr) {} |
107 inline void write_ref_array(MemRegion mr); |
121 inline void write_ref_array(MemRegion mr); |
|
122 |
|
123 // Static versions, suitable for calling from generated code. |
|
124 static void static_write_ref_array_pre(HeapWord* start, size_t count); |
|
125 static void static_write_ref_array_post(HeapWord* start, size_t count); |
|
126 |
108 protected: |
127 protected: |
109 virtual void write_ref_array_work(MemRegion mr) = 0; |
128 virtual void write_ref_array_work(MemRegion mr) = 0; |
110 public: |
129 public: |
111 virtual void write_prim_array(MemRegion mr) = 0; |
130 virtual void write_prim_array(MemRegion mr) = 0; |
112 |
131 |
117 // virtual "_work" function below, which must implement the barrier.) |
136 // virtual "_work" function below, which must implement the barrier.) |
118 inline void write_region(MemRegion mr); |
137 inline void write_region(MemRegion mr); |
119 protected: |
138 protected: |
120 virtual void write_region_work(MemRegion mr) = 0; |
139 virtual void write_region_work(MemRegion mr) = 0; |
121 public: |
140 public: |
122 |
|
123 // The remaining sets of operations are called by compilers or other code |
|
124 // generators to insert barriers into generated code. There may be |
|
125 // several such code generators; the signatures of these |
|
126 // barrier-generating functions may differ from generator to generator. |
|
127 // There will be a set of four function signatures for each code |
|
128 // generator, which accomplish the generation of barriers of the four |
|
129 // kinds listed above. |
|
130 |
|
131 #ifdef TBD |
|
132 // Generates code to invoke the barrier, if any, necessary when reading |
|
133 // the ref field at "offset" in "obj". |
|
134 virtual void gen_read_ref_field() = 0; |
|
135 |
|
136 // Generates code to invoke the barrier, if any, necessary when reading |
|
137 // the primitive field of "bytes" bytes at offset" in "obj". |
|
138 virtual void gen_read_prim_field() = 0; |
|
139 |
|
140 // Generates code to invoke the barrier, if any, necessary when writing |
|
141 // "new_val" into the ref field at "offset" in "obj". |
|
142 virtual void gen_write_ref_field() = 0; |
|
143 |
|
144 // Generates code to invoke the barrier, if any, necessary when writing |
|
145 // the "bytes"-byte value "new_val" into the primitive field at "offset" |
|
146 // in "obj". |
|
147 virtual void gen_write_prim_field() = 0; |
|
148 #endif |
|
149 |
141 |
150 // Some barrier sets create tables whose elements correspond to parts of |
142 // Some barrier sets create tables whose elements correspond to parts of |
151 // the heap; the CardTableModRefBS is an example. Such barrier sets will |
143 // the heap; the CardTableModRefBS is an example. Such barrier sets will |
152 // normally reserve space for such tables, and commit parts of the table |
144 // normally reserve space for such tables, and commit parts of the table |
153 // "covering" parts of the heap that are committed. The constructor is |
145 // "covering" parts of the heap that are committed. The constructor is |