7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
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_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP
25 #define SHARE_VM_GC_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP
26
27 #include "c1/c1_CodeStubs.hpp"
28 #include "gc/shared/c1/barrierSetC1.hpp"
29
30
31 class ShenandoahPreBarrierStub: public CodeStub {
32 friend class ShenandoahBarrierSetC1;
33 private:
34 bool _do_load;
35 LIR_Opr _addr;
36 LIR_Opr _pre_val;
37 LIR_PatchCode _patch_code;
38 CodeEmitInfo* _info;
39
40 public:
41 // Version that _does_ generate a load of the previous value from addr.
42 // addr (the address of the field to be read) must be a LIR_Address
43 // pre_val (a temporary register) must be a register;
44 ShenandoahPreBarrierStub(LIR_Opr addr, LIR_Opr pre_val, LIR_PatchCode patch_code, CodeEmitInfo* info) :
45 _do_load(true), _addr(addr), _pre_val(pre_val),
46 _patch_code(patch_code), _info(info)
47 {
48 assert(_pre_val->is_register(), "should be temporary register");
49 assert(_addr->is_address(), "should be the address of the field");
50 }
51
52 // Version that _does not_ generate load of the previous value; the
53 // previous value is assumed to have already been loaded into pre_val.
54 ShenandoahPreBarrierStub(LIR_Opr pre_val) :
55 _do_load(false), _addr(LIR_OprFact::illegalOpr), _pre_val(pre_val),
56 _patch_code(lir_patch_none), _info(NULL)
57 {
58 assert(_pre_val->is_register(), "should be a register");
59 }
60
61 LIR_Opr addr() const { return _addr; }
62 LIR_Opr pre_val() const { return _pre_val; }
63 LIR_PatchCode patch_code() const { return _patch_code; }
64 CodeEmitInfo* info() const { return _info; }
65 bool do_load() const { return _do_load; }
66
67 virtual void emit_code(LIR_Assembler* e);
68 virtual void visit(LIR_OpVisitState* visitor) {
69 if (_do_load) {
70 // don't pass in the code emit info since it's processed in the fast
71 // path
72 if (_info != NULL)
73 visitor->do_slow_case(_info);
74 else
75 visitor->do_slow_case();
76
77 visitor->do_input(_addr);
78 visitor->do_temp(_pre_val);
79 } else {
80 visitor->do_slow_case();
81 visitor->do_input(_pre_val);
82 }
83 }
84 #ifndef PRODUCT
85 virtual void print_name(outputStream* out) const { out->print("ShenandoahPreBarrierStub"); }
86 #endif // PRODUCT
87 };
88
89 class ShenandoahWriteBarrierStub: public CodeStub {
90 friend class ShenandoahBarrierSetC1;
91 private:
92 LIR_Opr _obj;
93 LIR_Opr _result;
94 CodeEmitInfo* _info;
95 bool _needs_null_check;
96
97 public:
98 ShenandoahWriteBarrierStub(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info, bool needs_null_check) :
99 _obj(obj), _result(result), _info(info), _needs_null_check(needs_null_check)
100 {
101 assert(_obj->is_register(), "should be register");
102 assert(_result->is_register(), "should be register");
103 }
104
105 LIR_Opr obj() const { return _obj; }
106 LIR_Opr result() const { return _result; }
107 CodeEmitInfo* info() const { return _info; }
108 bool needs_null_check() const { return _needs_null_check; }
109
110 virtual void emit_code(LIR_Assembler* e);
111 virtual void visit(LIR_OpVisitState* visitor) {
112 visitor->do_slow_case();
113 visitor->do_input(_obj);
114 visitor->do_temp(_result);
115 }
116 #ifndef PRODUCT
117 virtual void print_name(outputStream* out) const { out->print("ShenandoahWritePreBarrierStub"); }
118 #endif // PRODUCT
119 };
120
121 class LIR_OpShenandoahCompareAndSwap : public LIR_Op {
122 friend class LIR_OpVisitState;
123
124 private:
125 LIR_Opr _addr;
126 LIR_Opr _cmp_value;
127 LIR_Opr _new_value;
128 LIR_Opr _tmp1;
129 LIR_Opr _tmp2;
130
131 public:
132 LIR_OpShenandoahCompareAndSwap(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
133 LIR_Opr t1, LIR_Opr t2, LIR_Opr result)
134 : LIR_Op(lir_none, result, NULL) // no info
135 , _addr(addr)
136 , _cmp_value(cmp_value)
137 , _new_value(new_value)
138 , _tmp1(t1)
139 , _tmp2(t2) { }
140
141 LIR_Opr addr() const { return _addr; }
142 LIR_Opr cmp_value() const { return _cmp_value; }
143 LIR_Opr new_value() const { return _new_value; }
144 LIR_Opr tmp1() const { return _tmp1; }
145 LIR_Opr tmp2() const { return _tmp2; }
146
147 virtual void visit(LIR_OpVisitState* state) {
148 assert(_addr->is_valid(), "used");
149 assert(_cmp_value->is_valid(), "used");
150 assert(_new_value->is_valid(), "used");
151 if (_info) state->do_info(_info);
152 state->do_input(_addr);
153 state->do_temp(_addr);
154 state->do_input(_cmp_value);
155 state->do_temp(_cmp_value);
156 state->do_input(_new_value);
157 state->do_temp(_new_value);
158 if (_tmp1->is_valid()) state->do_temp(_tmp1);
159 if (_tmp2->is_valid()) state->do_temp(_tmp2);
160 if (_result->is_valid()) state->do_output(_result);
161 }
162
163 virtual void emit_code(LIR_Assembler* masm);
164
165 virtual void print_instr(outputStream* out) const {
166 addr()->print(out); out->print(" ");
167 cmp_value()->print(out); out->print(" ");
168 new_value()->print(out); out->print(" ");
169 tmp1()->print(out); out->print(" ");
170 tmp2()->print(out); out->print(" ");
171 }
172 #ifndef PRODUCT
173 virtual const char* name() const {
174 return "shenandoah_cas_obj";
175 }
176 #endif // PRODUCT
177 };
178
179 class ShenandoahBarrierSetC1 : public BarrierSetC1 {
180 private:
181 CodeBlob* _pre_barrier_c1_runtime_code_blob;
182
183 void pre_barrier(LIRGenerator* gen, CodeEmitInfo* info, DecoratorSet decorators, LIR_Opr addr_opr, LIR_Opr pre_val);
184
185 LIR_Opr read_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
186 LIR_Opr write_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
187 LIR_Opr storeval_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, DecoratorSet decorators);
188
189 LIR_Opr read_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
190 LIR_Opr write_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
191
192 LIR_Opr ensure_in_register(LIRGenerator* gen, LIR_Opr obj);
193
194 virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);
195
196 public:
197 CodeBlob* pre_barrier_c1_runtime_code_blob() { return _pre_barrier_c1_runtime_code_blob; }
198
199 virtual void store_at(LIRAccess& access, LIR_Opr value);
200 virtual void load_at(LIRAccess& access, LIR_Opr result);
201
202 virtual LIR_Opr atomic_cmpxchg_at(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);
203
204 virtual LIR_Opr atomic_xchg_at(LIRAccess& access, LIRItem& value);
205 virtual LIR_Opr atomic_add_at(LIRAccess& access, LIRItem& value);
206
207 virtual LIR_Opr resolve(LIRGenerator* gen, DecoratorSet decorators, LIR_Opr obj);
208
209 virtual void generate_c1_runtime_stubs(BufferBlob* buffer_blob);
210 };
211
212 #endif // SHARE_VM_GC_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP
|
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
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_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP
25 #define SHARE_VM_GC_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP
26
27 #include "gc/shenandoah/c1/shenandoahBaseBarrierSetC1.hpp"
28
29 class ShenandoahBarrierSetC1 : public ShenandoahBaseBarrierSetC1 {
30 public:
31 virtual void store_at(LIRAccess &access, LIR_Opr value);
32 virtual void load_at(LIRAccess &access, LIR_Opr result);
33 virtual LIR_Opr atomic_cmpxchg_at(LIRAccess &access, LIRItem &cmp_value, LIRItem &new_value);
34 virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess &access, LIRItem &cmp_value, LIRItem &new_value);
35 virtual LIR_Opr atomic_xchg_at(LIRAccess &access, LIRItem &value);
36 virtual LIR_Opr atomic_add_at(LIRAccess &access, LIRItem &value);
37 virtual LIR_Opr resolve(LIRGenerator *gen, DecoratorSet decorators, LIR_Opr obj);
38 };
39
40 #endif // SHARE_VM_GC_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP
|