author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58516 | d376d86b0a01 |
permissions | -rw-r--r-- |
55379 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. 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 |
#include "precompiled.hpp" |
|
25 |
#include "asm/macroAssembler.inline.hpp" |
|
26 |
#include "code/codeBlob.hpp" |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
27 |
#include "code/vmreg.inline.hpp" |
55379 | 28 |
#include "gc/z/zBarrier.inline.hpp" |
29 |
#include "gc/z/zBarrierSet.hpp" |
|
30 |
#include "gc/z/zBarrierSetAssembler.hpp" |
|
31 |
#include "gc/z/zBarrierSetRuntime.hpp" |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
32 |
#include "gc/z/zThreadLocalData.hpp" |
55379 | 33 |
#include "memory/resourceArea.hpp" |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
34 |
#include "runtime/sharedRuntime.hpp" |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
35 |
#include "utilities/macros.hpp" |
55379 | 36 |
#ifdef COMPILER1 |
37 |
#include "c1/c1_LIRAssembler.hpp" |
|
38 |
#include "c1/c1_MacroAssembler.hpp" |
|
39 |
#include "gc/z/c1/zBarrierSetC1.hpp" |
|
40 |
#endif // COMPILER1 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
41 |
#ifdef COMPILER2 |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
42 |
#include "gc/z/c2/zBarrierSetC2.hpp" |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
43 |
#endif // COMPILER2 |
55379 | 44 |
|
45 |
#ifdef PRODUCT |
|
46 |
#define BLOCK_COMMENT(str) /* nothing */ |
|
47 |
#else |
|
48 |
#define BLOCK_COMMENT(str) __ block_comment(str) |
|
49 |
#endif |
|
50 |
||
51 |
#undef __ |
|
52 |
#define __ masm-> |
|
53 |
||
54 |
void ZBarrierSetAssembler::load_at(MacroAssembler* masm, |
|
55 |
DecoratorSet decorators, |
|
56 |
BasicType type, |
|
57 |
Register dst, |
|
58 |
Address src, |
|
59 |
Register tmp1, |
|
60 |
Register tmp_thread) { |
|
61 |
if (!ZBarrierSet::barrier_needed(decorators, type)) { |
|
62 |
// Barrier not needed |
|
63 |
BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread); |
|
64 |
return; |
|
65 |
} |
|
66 |
||
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
67 |
assert_different_registers(rscratch1, rscratch2, src.base()); |
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
68 |
assert_different_registers(rscratch1, rscratch2, dst); |
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
69 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
70 |
RegSet savedRegs = RegSet::range(r0, r28) - RegSet::of(dst, rscratch1, rscratch2); |
55379 | 71 |
|
72 |
Label done; |
|
73 |
||
74 |
// Load bad mask into scratch register. |
|
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
75 |
__ ldr(rscratch1, address_bad_mask_from_thread(rthread)); |
55379 | 76 |
__ lea(rscratch2, src); |
77 |
__ ldr(dst, src); |
|
78 |
||
79 |
// Test reference against bad mask. If mask bad, then we need to fix it up. |
|
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
80 |
__ tst(dst, rscratch1); |
55379 | 81 |
__ br(Assembler::EQ, done); |
82 |
||
83 |
__ enter(); |
|
84 |
||
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
85 |
__ push(savedRegs, sp); |
55379 | 86 |
|
87 |
if (c_rarg0 != dst) { |
|
88 |
__ mov(c_rarg0, dst); |
|
89 |
} |
|
90 |
__ mov(c_rarg1, rscratch2); |
|
91 |
||
92 |
int step = 4 * wordSize; |
|
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
93 |
__ mov(rscratch2, -step); |
55379 | 94 |
__ sub(sp, sp, step); |
95 |
||
96 |
for (int i = 28; i >= 4; i -= 4) { |
|
97 |
__ st1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2), |
|
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
98 |
as_FloatRegister(i+3), __ T1D, Address(__ post(sp, rscratch2))); |
55379 | 99 |
} |
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
100 |
__ st1(as_FloatRegister(0), as_FloatRegister(1), as_FloatRegister(2), |
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
101 |
as_FloatRegister(3), __ T1D, Address(sp)); |
55379 | 102 |
|
103 |
__ call_VM_leaf(ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), 2); |
|
104 |
||
105 |
for (int i = 0; i <= 28; i += 4) { |
|
106 |
__ ld1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2), |
|
107 |
as_FloatRegister(i+3), __ T1D, Address(__ post(sp, step))); |
|
108 |
} |
|
109 |
||
110 |
// Make sure dst has the return value. |
|
111 |
if (dst != r0) { |
|
112 |
__ mov(dst, r0); |
|
113 |
} |
|
114 |
||
55504
b7f68ddec66f
8226515: AArch64: float point register corruption in ZBarrierSetAssembler::load_at
smonteith
parents:
55379
diff
changeset
|
115 |
__ pop(savedRegs, sp); |
55379 | 116 |
__ leave(); |
117 |
||
118 |
__ bind(done); |
|
119 |
} |
|
120 |
||
121 |
#ifdef ASSERT |
|
122 |
||
123 |
void ZBarrierSetAssembler::store_at(MacroAssembler* masm, |
|
124 |
DecoratorSet decorators, |
|
125 |
BasicType type, |
|
126 |
Address dst, |
|
127 |
Register val, |
|
128 |
Register tmp1, |
|
129 |
Register tmp2) { |
|
130 |
// Verify value |
|
58273
08a5148e7c4e
8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents:
55504
diff
changeset
|
131 |
if (is_reference_type(type)) { |
55379 | 132 |
// Note that src could be noreg, which means we |
133 |
// are storing null and can skip verification. |
|
134 |
if (val != noreg) { |
|
135 |
Label done; |
|
136 |
||
137 |
// tmp1 and tmp2 are often set to noreg. |
|
138 |
RegSet savedRegs = RegSet::of(rscratch1); |
|
139 |
__ push(savedRegs, sp); |
|
140 |
||
141 |
__ ldr(rscratch1, address_bad_mask_from_thread(rthread)); |
|
142 |
__ tst(val, rscratch1); |
|
143 |
__ br(Assembler::EQ, done); |
|
144 |
__ stop("Verify oop store failed"); |
|
145 |
__ should_not_reach_here(); |
|
146 |
__ bind(done); |
|
147 |
__ pop(savedRegs, sp); |
|
148 |
} |
|
149 |
} |
|
150 |
||
151 |
// Store value |
|
152 |
BarrierSetAssembler::store_at(masm, decorators, type, dst, val, tmp1, tmp2); |
|
153 |
} |
|
154 |
||
155 |
#endif // ASSERT |
|
156 |
||
157 |
void ZBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, |
|
158 |
DecoratorSet decorators, |
|
159 |
bool is_oop, |
|
160 |
Register src, |
|
161 |
Register dst, |
|
162 |
Register count, |
|
163 |
RegSet saved_regs) { |
|
164 |
if (!is_oop) { |
|
165 |
// Barrier not needed |
|
166 |
return; |
|
167 |
} |
|
168 |
||
169 |
BLOCK_COMMENT("ZBarrierSetAssembler::arraycopy_prologue {"); |
|
170 |
||
171 |
assert_different_registers(src, count, rscratch1); |
|
172 |
||
173 |
__ pusha(); |
|
174 |
||
175 |
if (count == c_rarg0) { |
|
176 |
if (src == c_rarg1) { |
|
177 |
// exactly backwards!! |
|
178 |
__ mov(rscratch1, c_rarg0); |
|
179 |
__ mov(c_rarg0, c_rarg1); |
|
180 |
__ mov(c_rarg1, rscratch1); |
|
181 |
} else { |
|
182 |
__ mov(c_rarg1, count); |
|
183 |
__ mov(c_rarg0, src); |
|
184 |
} |
|
185 |
} else { |
|
186 |
__ mov(c_rarg0, src); |
|
187 |
__ mov(c_rarg1, count); |
|
188 |
} |
|
189 |
||
190 |
__ call_VM_leaf(ZBarrierSetRuntime::load_barrier_on_oop_array_addr(), 2); |
|
191 |
||
192 |
__ popa(); |
|
193 |
BLOCK_COMMENT("} ZBarrierSetAssembler::arraycopy_prologue"); |
|
194 |
} |
|
195 |
||
196 |
void ZBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, |
|
197 |
Register jni_env, |
|
198 |
Register robj, |
|
199 |
Register tmp, |
|
200 |
Label& slowpath) { |
|
201 |
BLOCK_COMMENT("ZBarrierSetAssembler::try_resolve_jobject_in_native {"); |
|
202 |
||
203 |
assert_different_registers(jni_env, robj, tmp); |
|
204 |
||
205 |
// Resolve jobject |
|
206 |
BarrierSetAssembler::try_resolve_jobject_in_native(masm, jni_env, robj, tmp, slowpath); |
|
207 |
||
208 |
// The Address offset is too large to direct load - -784. Our range is +127, -128. |
|
209 |
__ mov(tmp, (long int)(in_bytes(ZThreadLocalData::address_bad_mask_offset()) - |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
210 |
in_bytes(JavaThread::jni_environment_offset()))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
211 |
|
55379 | 212 |
// Load address bad mask |
213 |
__ add(tmp, jni_env, tmp); |
|
214 |
__ ldr(tmp, Address(tmp)); |
|
215 |
||
216 |
// Check address bad mask |
|
217 |
__ tst(robj, tmp); |
|
218 |
__ br(Assembler::NE, slowpath); |
|
219 |
||
220 |
BLOCK_COMMENT("} ZBarrierSetAssembler::try_resolve_jobject_in_native"); |
|
221 |
} |
|
222 |
||
223 |
#ifdef COMPILER1 |
|
224 |
||
225 |
#undef __ |
|
226 |
#define __ ce->masm()-> |
|
227 |
||
228 |
void ZBarrierSetAssembler::generate_c1_load_barrier_test(LIR_Assembler* ce, |
|
229 |
LIR_Opr ref) const { |
|
230 |
assert_different_registers(rheapbase, rthread, ref->as_register()); |
|
231 |
||
232 |
__ ldr(rheapbase, address_bad_mask_from_thread(rthread)); |
|
233 |
__ tst(ref->as_register(), rheapbase); |
|
234 |
} |
|
235 |
||
236 |
void ZBarrierSetAssembler::generate_c1_load_barrier_stub(LIR_Assembler* ce, |
|
237 |
ZLoadBarrierStubC1* stub) const { |
|
238 |
// Stub entry |
|
239 |
__ bind(*stub->entry()); |
|
240 |
||
241 |
Register ref = stub->ref()->as_register(); |
|
242 |
Register ref_addr = noreg; |
|
243 |
Register tmp = noreg; |
|
244 |
||
245 |
if (stub->tmp()->is_valid()) { |
|
246 |
// Load address into tmp register |
|
247 |
ce->leal(stub->ref_addr(), stub->tmp()); |
|
248 |
ref_addr = tmp = stub->tmp()->as_pointer_register(); |
|
249 |
} else { |
|
250 |
// Address already in register |
|
251 |
ref_addr = stub->ref_addr()->as_address_ptr()->base()->as_pointer_register(); |
|
252 |
} |
|
253 |
||
254 |
assert_different_registers(ref, ref_addr, noreg); |
|
255 |
||
256 |
// Save r0 unless it is the result or tmp register |
|
257 |
// Set up SP to accomodate parameters and maybe r0.. |
|
258 |
if (ref != r0 && tmp != r0) { |
|
259 |
__ sub(sp, sp, 32); |
|
260 |
__ str(r0, Address(sp, 16)); |
|
261 |
} else { |
|
262 |
__ sub(sp, sp, 16); |
|
263 |
} |
|
264 |
||
265 |
// Setup arguments and call runtime stub |
|
266 |
ce->store_parameter(ref_addr, 1); |
|
267 |
ce->store_parameter(ref, 0); |
|
268 |
||
269 |
__ far_call(stub->runtime_stub()); |
|
270 |
||
271 |
// Verify result |
|
272 |
__ verify_oop(r0, "Bad oop"); |
|
273 |
||
274 |
// Move result into place |
|
275 |
if (ref != r0) { |
|
276 |
__ mov(ref, r0); |
|
277 |
} |
|
278 |
||
279 |
// Restore r0 unless it is the result or tmp register |
|
280 |
if (ref != r0 && tmp != r0) { |
|
281 |
__ ldr(r0, Address(sp, 16)); |
|
282 |
__ add(sp, sp, 32); |
|
283 |
} else { |
|
284 |
__ add(sp, sp, 16); |
|
285 |
} |
|
286 |
||
287 |
// Stub exit |
|
288 |
__ b(*stub->continuation()); |
|
289 |
} |
|
290 |
||
291 |
#undef __ |
|
292 |
#define __ sasm-> |
|
293 |
||
294 |
void ZBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, |
|
295 |
DecoratorSet decorators) const { |
|
296 |
__ prologue("zgc_load_barrier stub", false); |
|
297 |
||
298 |
// We don't use push/pop_clobbered_registers() - we need to pull out the result from r0. |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
299 |
for (int i = 0; i < 32; i += 2) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
300 |
__ stpd(as_FloatRegister(i), as_FloatRegister(i + 1), Address(__ pre(sp,-16))); |
55379 | 301 |
} |
302 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
303 |
const RegSet save_regs = RegSet::range(r1, r28); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
304 |
__ push(save_regs, sp); |
55379 | 305 |
|
306 |
// Setup arguments |
|
307 |
__ load_parameter(0, c_rarg0); |
|
308 |
__ load_parameter(1, c_rarg1); |
|
309 |
||
310 |
__ call_VM_leaf(ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), 2); |
|
311 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
312 |
__ pop(save_regs, sp); |
55379 | 313 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
314 |
for (int i = 30; i >= 0; i -= 2) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
315 |
__ ldpd(as_FloatRegister(i), as_FloatRegister(i + 1), Address(__ post(sp, 16))); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
316 |
} |
55379 | 317 |
|
318 |
__ epilogue(); |
|
319 |
} |
|
320 |
#endif // COMPILER1 |
|
321 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
322 |
#ifdef COMPILER2 |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
323 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
324 |
OptoReg::Name ZBarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
325 |
if (!OptoReg::is_reg(opto_reg)) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
326 |
return OptoReg::Bad; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
327 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
328 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
329 |
const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
330 |
if (vm_reg->is_FloatRegister()) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
331 |
return opto_reg & ~1; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
332 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
333 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
334 |
return opto_reg; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
335 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
336 |
|
55379 | 337 |
#undef __ |
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
338 |
#define __ _masm-> |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
339 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
340 |
class ZSaveLiveRegisters { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
341 |
private: |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
342 |
MacroAssembler* const _masm; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
343 |
RegSet _gp_regs; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
344 |
RegSet _fp_regs; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
345 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
346 |
public: |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
347 |
void initialize(ZLoadBarrierStubC2* stub) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
348 |
// Create mask of live registers |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
349 |
RegMask live = stub->live(); |
55379 | 350 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
351 |
// Record registers that needs to be saved/restored |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
352 |
while (live.is_NotEmpty()) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
353 |
const OptoReg::Name opto_reg = live.find_first_elem(); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
354 |
live.Remove(opto_reg); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
355 |
if (OptoReg::is_reg(opto_reg)) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
356 |
const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
357 |
if (vm_reg->is_Register()) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
358 |
_gp_regs += RegSet::of(vm_reg->as_Register()); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
359 |
} else if (vm_reg->is_FloatRegister()) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
360 |
_fp_regs += RegSet::of((Register)vm_reg->as_FloatRegister()); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
361 |
} else { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
362 |
fatal("Unknown register type"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
363 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
364 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
365 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
366 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
367 |
// Remove C-ABI SOE registers, scratch regs and _ref register that will be updated |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
368 |
_gp_regs -= RegSet::range(r19, r30) + RegSet::of(r8, r9, stub->ref()); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
369 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
370 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
371 |
ZSaveLiveRegisters(MacroAssembler* masm, ZLoadBarrierStubC2* stub) : |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
372 |
_masm(masm), |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
373 |
_gp_regs(), |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
374 |
_fp_regs() { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
375 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
376 |
// Figure out what registers to save/restore |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
377 |
initialize(stub); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
378 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
379 |
// Save registers |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
380 |
__ push(_gp_regs, sp); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
381 |
__ push_fp(_fp_regs, sp); |
55379 | 382 |
} |
383 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
384 |
~ZSaveLiveRegisters() { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
385 |
// Restore registers |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
386 |
__ pop_fp(_fp_regs, sp); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
387 |
__ pop(_gp_regs, sp); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
388 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
389 |
}; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
390 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
391 |
#undef __ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
392 |
#define __ _masm-> |
55379 | 393 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
394 |
class ZSetupArguments { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
395 |
private: |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
396 |
MacroAssembler* const _masm; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
397 |
const Register _ref; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
398 |
const Address _ref_addr; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
399 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
400 |
public: |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
401 |
ZSetupArguments(MacroAssembler* masm, ZLoadBarrierStubC2* stub) : |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
402 |
_masm(masm), |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
403 |
_ref(stub->ref()), |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
404 |
_ref_addr(stub->ref_addr()) { |
55379 | 405 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
406 |
// Setup arguments |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
407 |
if (_ref_addr.base() == noreg) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
408 |
// No self healing |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
409 |
if (_ref != c_rarg0) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
410 |
__ mov(c_rarg0, _ref); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
411 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
412 |
__ mov(c_rarg1, 0); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
413 |
} else { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
414 |
// Self healing |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
415 |
if (_ref == c_rarg0) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
416 |
// _ref is already at correct place |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
417 |
__ lea(c_rarg1, _ref_addr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
418 |
} else if (_ref != c_rarg1) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
419 |
// _ref is in wrong place, but not in c_rarg1, so fix it first |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
420 |
__ lea(c_rarg1, _ref_addr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
421 |
__ mov(c_rarg0, _ref); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
422 |
} else if (_ref_addr.base() != c_rarg0 && _ref_addr.index() != c_rarg0) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
423 |
assert(_ref == c_rarg1, "Mov ref first, vacating c_rarg0"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
424 |
__ mov(c_rarg0, _ref); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
425 |
__ lea(c_rarg1, _ref_addr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
426 |
} else { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
427 |
assert(_ref == c_rarg1, "Need to vacate c_rarg1 and _ref_addr is using c_rarg0"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
428 |
if (_ref_addr.base() == c_rarg0 || _ref_addr.index() == c_rarg0) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
429 |
__ mov(rscratch2, c_rarg1); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
430 |
__ lea(c_rarg1, _ref_addr); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
431 |
__ mov(c_rarg0, rscratch2); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
432 |
} else { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
433 |
ShouldNotReachHere(); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
434 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
435 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
436 |
} |
55379 | 437 |
} |
438 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
439 |
~ZSetupArguments() { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
440 |
// Transfer result |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
441 |
if (_ref != r0) { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
442 |
__ mov(_ref, r0); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
443 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
444 |
} |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
445 |
}; |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
446 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
447 |
#undef __ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
448 |
#define __ masm-> |
55379 | 449 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
450 |
void ZBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, ZLoadBarrierStubC2* stub) const { |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
451 |
BLOCK_COMMENT("ZLoadBarrierStubC2"); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
452 |
|
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
453 |
// Stub entry |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
454 |
__ bind(*stub->entry()); |
55379 | 455 |
|
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
456 |
{ |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
457 |
ZSaveLiveRegisters save_live_registers(masm, stub); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
458 |
ZSetupArguments setup_arguments(masm, stub); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
459 |
__ mov(rscratch1, stub->slow_path()); |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
460 |
__ blr(rscratch1); |
55379 | 461 |
} |
462 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
463 |
// Stub exit |
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
464 |
__ b(*stub->continuation()); |
55379 | 465 |
} |
466 |
||
467 |
#undef __ |
|
468 |
||
58516
d376d86b0a01
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents:
58273
diff
changeset
|
469 |
#endif // COMPILER2 |