author | fyang |
Sat, 05 Mar 2016 22:22:37 +0800 | |
changeset 36565 | 8e38f7594806 |
parent 36562 | 4d1e93624d6a |
child 37269 | 5c2c4e5bb067 |
permissions | -rw-r--r-- |
29184 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. |
29184 | 3 |
* Copyright (c) 2014, Red Hat Inc. All rights reserved. |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
26 |
#include "precompiled.hpp" |
|
27 |
#include "asm/assembler.hpp" |
|
28 |
#include "c1/c1_CodeStubs.hpp" |
|
29 |
#include "c1/c1_Compilation.hpp" |
|
30 |
#include "c1/c1_LIRAssembler.hpp" |
|
31 |
#include "c1/c1_MacroAssembler.hpp" |
|
32 |
#include "c1/c1_Runtime1.hpp" |
|
33 |
#include "c1/c1_ValueStack.hpp" |
|
34 |
#include "ci/ciArrayKlass.hpp" |
|
35 |
#include "ci/ciInstance.hpp" |
|
30764 | 36 |
#include "gc/shared/barrierSet.hpp" |
37 |
#include "gc/shared/cardTableModRefBS.hpp" |
|
38 |
#include "gc/shared/collectedHeap.hpp" |
|
29184 | 39 |
#include "nativeInst_aarch64.hpp" |
40 |
#include "oops/objArrayKlass.hpp" |
|
41 |
#include "runtime/sharedRuntime.hpp" |
|
42 |
#include "vmreg_aarch64.inline.hpp" |
|
43 |
||
44 |
||
45 |
||
46 |
#ifndef PRODUCT |
|
47 |
#define COMMENT(x) do { __ block_comment(x); } while (0) |
|
48 |
#else |
|
49 |
#define COMMENT(x) |
|
50 |
#endif |
|
51 |
||
52 |
NEEDS_CLEANUP // remove this definitions ? |
|
53 |
const Register IC_Klass = rscratch2; // where the IC klass is cached |
|
54 |
const Register SYNC_header = r0; // synchronization header |
|
55 |
const Register SHIFT_count = r0; // where count for shift operations must be |
|
56 |
||
57 |
#define __ _masm-> |
|
58 |
||
59 |
||
60 |
static void select_different_registers(Register preserve, |
|
61 |
Register extra, |
|
62 |
Register &tmp1, |
|
63 |
Register &tmp2) { |
|
64 |
if (tmp1 == preserve) { |
|
65 |
assert_different_registers(tmp1, tmp2, extra); |
|
66 |
tmp1 = extra; |
|
67 |
} else if (tmp2 == preserve) { |
|
68 |
assert_different_registers(tmp1, tmp2, extra); |
|
69 |
tmp2 = extra; |
|
70 |
} |
|
71 |
assert_different_registers(preserve, tmp1, tmp2); |
|
72 |
} |
|
73 |
||
74 |
||
75 |
||
76 |
static void select_different_registers(Register preserve, |
|
77 |
Register extra, |
|
78 |
Register &tmp1, |
|
79 |
Register &tmp2, |
|
80 |
Register &tmp3) { |
|
81 |
if (tmp1 == preserve) { |
|
82 |
assert_different_registers(tmp1, tmp2, tmp3, extra); |
|
83 |
tmp1 = extra; |
|
84 |
} else if (tmp2 == preserve) { |
|
85 |
assert_different_registers(tmp1, tmp2, tmp3, extra); |
|
86 |
tmp2 = extra; |
|
87 |
} else if (tmp3 == preserve) { |
|
88 |
assert_different_registers(tmp1, tmp2, tmp3, extra); |
|
89 |
tmp3 = extra; |
|
90 |
} |
|
91 |
assert_different_registers(preserve, tmp1, tmp2, tmp3); |
|
92 |
} |
|
93 |
||
94 |
||
95 |
bool LIR_Assembler::is_small_constant(LIR_Opr opr) { Unimplemented(); return false; } |
|
96 |
||
97 |
||
98 |
LIR_Opr LIR_Assembler::receiverOpr() { |
|
99 |
return FrameMap::receiver_opr; |
|
100 |
} |
|
101 |
||
102 |
LIR_Opr LIR_Assembler::osrBufferPointer() { |
|
103 |
return FrameMap::as_pointer_opr(receiverOpr()->as_register()); |
|
104 |
} |
|
105 |
||
106 |
//--------------fpu register translations----------------------- |
|
107 |
||
108 |
||
109 |
address LIR_Assembler::float_constant(float f) { |
|
110 |
address const_addr = __ float_constant(f); |
|
111 |
if (const_addr == NULL) { |
|
112 |
bailout("const section overflow"); |
|
113 |
return __ code()->consts()->start(); |
|
114 |
} else { |
|
115 |
return const_addr; |
|
116 |
} |
|
117 |
} |
|
118 |
||
119 |
||
120 |
address LIR_Assembler::double_constant(double d) { |
|
121 |
address const_addr = __ double_constant(d); |
|
122 |
if (const_addr == NULL) { |
|
123 |
bailout("const section overflow"); |
|
124 |
return __ code()->consts()->start(); |
|
125 |
} else { |
|
126 |
return const_addr; |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
address LIR_Assembler::int_constant(jlong n) { |
|
131 |
address const_addr = __ long_constant(n); |
|
132 |
if (const_addr == NULL) { |
|
133 |
bailout("const section overflow"); |
|
134 |
return __ code()->consts()->start(); |
|
135 |
} else { |
|
136 |
return const_addr; |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
void LIR_Assembler::set_24bit_FPU() { Unimplemented(); } |
|
141 |
||
142 |
void LIR_Assembler::reset_FPU() { Unimplemented(); } |
|
143 |
||
144 |
void LIR_Assembler::fpop() { Unimplemented(); } |
|
145 |
||
146 |
void LIR_Assembler::fxch(int i) { Unimplemented(); } |
|
147 |
||
148 |
void LIR_Assembler::fld(int i) { Unimplemented(); } |
|
149 |
||
150 |
void LIR_Assembler::ffree(int i) { Unimplemented(); } |
|
151 |
||
152 |
void LIR_Assembler::breakpoint() { Unimplemented(); } |
|
153 |
||
154 |
void LIR_Assembler::push(LIR_Opr opr) { Unimplemented(); } |
|
155 |
||
156 |
void LIR_Assembler::pop(LIR_Opr opr) { Unimplemented(); } |
|
157 |
||
158 |
bool LIR_Assembler::is_literal_address(LIR_Address* addr) { Unimplemented(); return false; } |
|
159 |
//------------------------------------------- |
|
160 |
||
161 |
static Register as_reg(LIR_Opr op) { |
|
162 |
return op->is_double_cpu() ? op->as_register_lo() : op->as_register(); |
|
163 |
} |
|
164 |
||
165 |
static jlong as_long(LIR_Opr data) { |
|
166 |
jlong result; |
|
167 |
switch (data->type()) { |
|
168 |
case T_INT: |
|
169 |
result = (data->as_jint()); |
|
170 |
break; |
|
171 |
case T_LONG: |
|
172 |
result = (data->as_jlong()); |
|
173 |
break; |
|
174 |
default: |
|
175 |
ShouldNotReachHere(); |
|
35127 | 176 |
result = 0; // unreachable |
29184 | 177 |
} |
178 |
return result; |
|
179 |
} |
|
180 |
||
181 |
Address LIR_Assembler::as_Address(LIR_Address* addr, Register tmp) { |
|
182 |
Register base = addr->base()->as_pointer_register(); |
|
183 |
LIR_Opr opr = addr->index(); |
|
184 |
if (opr->is_cpu_register()) { |
|
185 |
Register index; |
|
186 |
if (opr->is_single_cpu()) |
|
187 |
index = opr->as_register(); |
|
188 |
else |
|
189 |
index = opr->as_register_lo(); |
|
190 |
assert(addr->disp() == 0, "must be"); |
|
191 |
switch(opr->type()) { |
|
192 |
case T_INT: |
|
193 |
return Address(base, index, Address::sxtw(addr->scale())); |
|
194 |
case T_LONG: |
|
195 |
return Address(base, index, Address::lsl(addr->scale())); |
|
196 |
default: |
|
197 |
ShouldNotReachHere(); |
|
198 |
} |
|
199 |
} else { |
|
200 |
intptr_t addr_offset = intptr_t(addr->disp()); |
|
201 |
if (Address::offset_ok_for_immed(addr_offset, addr->scale())) |
|
202 |
return Address(base, addr_offset, Address::lsl(addr->scale())); |
|
203 |
else { |
|
204 |
__ mov(tmp, addr_offset); |
|
205 |
return Address(base, tmp, Address::lsl(addr->scale())); |
|
206 |
} |
|
207 |
} |
|
208 |
return Address(); |
|
209 |
} |
|
210 |
||
211 |
Address LIR_Assembler::as_Address_hi(LIR_Address* addr) { |
|
212 |
ShouldNotReachHere(); |
|
213 |
return Address(); |
|
214 |
} |
|
215 |
||
216 |
Address LIR_Assembler::as_Address(LIR_Address* addr) { |
|
217 |
return as_Address(addr, rscratch1); |
|
218 |
} |
|
219 |
||
220 |
Address LIR_Assembler::as_Address_lo(LIR_Address* addr) { |
|
221 |
return as_Address(addr, rscratch1); // Ouch |
|
222 |
// FIXME: This needs to be much more clever. See x86. |
|
223 |
} |
|
224 |
||
225 |
||
226 |
void LIR_Assembler::osr_entry() { |
|
227 |
offsets()->set_value(CodeOffsets::OSR_Entry, code_offset()); |
|
228 |
BlockBegin* osr_entry = compilation()->hir()->osr_entry(); |
|
229 |
ValueStack* entry_state = osr_entry->state(); |
|
230 |
int number_of_locks = entry_state->locks_size(); |
|
231 |
||
232 |
// we jump here if osr happens with the interpreter |
|
233 |
// state set up to continue at the beginning of the |
|
234 |
// loop that triggered osr - in particular, we have |
|
235 |
// the following registers setup: |
|
236 |
// |
|
237 |
// r2: osr buffer |
|
238 |
// |
|
239 |
||
240 |
// build frame |
|
241 |
ciMethod* m = compilation()->method(); |
|
242 |
__ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes()); |
|
243 |
||
244 |
// OSR buffer is |
|
245 |
// |
|
246 |
// locals[nlocals-1..0] |
|
247 |
// monitors[0..number_of_locks] |
|
248 |
// |
|
249 |
// locals is a direct copy of the interpreter frame so in the osr buffer |
|
250 |
// so first slot in the local array is the last local from the interpreter |
|
251 |
// and last slot is local[0] (receiver) from the interpreter |
|
252 |
// |
|
253 |
// Similarly with locks. The first lock slot in the osr buffer is the nth lock |
|
254 |
// from the interpreter frame, the nth lock slot in the osr buffer is 0th lock |
|
255 |
// in the interpreter frame (the method lock if a sync method) |
|
256 |
||
257 |
// Initialize monitors in the compiled activation. |
|
258 |
// r2: pointer to osr buffer |
|
259 |
// |
|
260 |
// All other registers are dead at this point and the locals will be |
|
261 |
// copied into place by code emitted in the IR. |
|
262 |
||
263 |
Register OSR_buf = osrBufferPointer()->as_pointer_register(); |
|
264 |
{ assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below"); |
|
265 |
int monitor_offset = BytesPerWord * method()->max_locals() + |
|
266 |
(2 * BytesPerWord) * (number_of_locks - 1); |
|
267 |
// SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in |
|
268 |
// the OSR buffer using 2 word entries: first the lock and then |
|
269 |
// the oop. |
|
270 |
for (int i = 0; i < number_of_locks; i++) { |
|
271 |
int slot_offset = monitor_offset - ((i * 2) * BytesPerWord); |
|
272 |
#ifdef ASSERT |
|
273 |
// verify the interpreter's monitor has a non-null object |
|
274 |
{ |
|
275 |
Label L; |
|
276 |
__ ldr(rscratch1, Address(OSR_buf, slot_offset + 1*BytesPerWord)); |
|
277 |
__ cbnz(rscratch1, L); |
|
278 |
__ stop("locked object is NULL"); |
|
279 |
__ bind(L); |
|
280 |
} |
|
281 |
#endif |
|
282 |
__ ldr(r19, Address(OSR_buf, slot_offset + 0)); |
|
283 |
__ str(r19, frame_map()->address_for_monitor_lock(i)); |
|
284 |
__ ldr(r19, Address(OSR_buf, slot_offset + 1*BytesPerWord)); |
|
285 |
__ str(r19, frame_map()->address_for_monitor_object(i)); |
|
286 |
} |
|
287 |
} |
|
288 |
} |
|
289 |
||
290 |
||
291 |
// inline cache check; done before the frame is built. |
|
292 |
int LIR_Assembler::check_icache() { |
|
293 |
Register receiver = FrameMap::receiver_opr->as_register(); |
|
294 |
Register ic_klass = IC_Klass; |
|
295 |
int start_offset = __ offset(); |
|
296 |
__ inline_cache_check(receiver, ic_klass); |
|
297 |
||
298 |
// if icache check fails, then jump to runtime routine |
|
299 |
// Note: RECEIVER must still contain the receiver! |
|
300 |
Label dont; |
|
301 |
__ br(Assembler::EQ, dont); |
|
302 |
__ far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub())); |
|
303 |
||
304 |
// We align the verified entry point unless the method body |
|
305 |
// (including its inline cache check) will fit in a single 64-byte |
|
306 |
// icache line. |
|
307 |
if (! method()->is_accessor() || __ offset() - start_offset > 4 * 4) { |
|
308 |
// force alignment after the cache check. |
|
309 |
__ align(CodeEntryAlignment); |
|
310 |
} |
|
311 |
||
312 |
__ bind(dont); |
|
313 |
return start_offset; |
|
314 |
} |
|
315 |
||
316 |
||
317 |
void LIR_Assembler::jobject2reg(jobject o, Register reg) { |
|
318 |
if (o == NULL) { |
|
319 |
__ mov(reg, zr); |
|
320 |
} else { |
|
321 |
__ movoop(reg, o, /*immediate*/true); |
|
322 |
} |
|
323 |
} |
|
324 |
||
325 |
void LIR_Assembler::deoptimize_trap(CodeEmitInfo *info) { |
|
326 |
address target = NULL; |
|
327 |
relocInfo::relocType reloc_type = relocInfo::none; |
|
328 |
||
329 |
switch (patching_id(info)) { |
|
330 |
case PatchingStub::access_field_id: |
|
331 |
target = Runtime1::entry_for(Runtime1::access_field_patching_id); |
|
332 |
reloc_type = relocInfo::section_word_type; |
|
333 |
break; |
|
334 |
case PatchingStub::load_klass_id: |
|
335 |
target = Runtime1::entry_for(Runtime1::load_klass_patching_id); |
|
336 |
reloc_type = relocInfo::metadata_type; |
|
337 |
break; |
|
338 |
case PatchingStub::load_mirror_id: |
|
339 |
target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); |
|
340 |
reloc_type = relocInfo::oop_type; |
|
341 |
break; |
|
342 |
case PatchingStub::load_appendix_id: |
|
343 |
target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); |
|
344 |
reloc_type = relocInfo::oop_type; |
|
345 |
break; |
|
346 |
default: ShouldNotReachHere(); |
|
347 |
} |
|
348 |
||
349 |
__ far_call(RuntimeAddress(target)); |
|
350 |
add_call_info_here(info); |
|
351 |
} |
|
352 |
||
353 |
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo *info) { |
|
354 |
deoptimize_trap(info); |
|
355 |
} |
|
356 |
||
357 |
||
358 |
// This specifies the rsp decrement needed to build the frame |
|
359 |
int LIR_Assembler::initial_frame_size_in_bytes() const { |
|
360 |
// if rounding, must let FrameMap know! |
|
361 |
||
362 |
// The frame_map records size in slots (32bit word) |
|
363 |
||
364 |
// subtract two words to account for return address and link |
|
365 |
return (frame_map()->framesize() - (2*VMRegImpl::slots_per_word)) * VMRegImpl::stack_slot_size; |
|
366 |
} |
|
367 |
||
368 |
||
369 |
int LIR_Assembler::emit_exception_handler() { |
|
370 |
// if the last instruction is a call (typically to do a throw which |
|
371 |
// is coming at the end after block reordering) the return address |
|
372 |
// must still point into the code area in order to avoid assertion |
|
373 |
// failures when searching for the corresponding bci => add a nop |
|
374 |
// (was bug 5/14/1999 - gri) |
|
375 |
__ nop(); |
|
376 |
||
377 |
// generate code for exception handler |
|
378 |
address handler_base = __ start_a_stub(exception_handler_size); |
|
379 |
if (handler_base == NULL) { |
|
380 |
// not enough space left for the handler |
|
381 |
bailout("exception handler overflow"); |
|
382 |
return -1; |
|
383 |
} |
|
384 |
||
385 |
int offset = code_offset(); |
|
386 |
||
387 |
// the exception oop and pc are in r0, and r3 |
|
388 |
// no other registers need to be preserved, so invalidate them |
|
389 |
__ invalidate_registers(false, true, true, false, true, true); |
|
390 |
||
391 |
// check that there is really an exception |
|
392 |
__ verify_not_null_oop(r0); |
|
393 |
||
394 |
// search an exception handler (r0: exception oop, r3: throwing pc) |
|
395 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id))); __ should_not_reach_here(); |
|
396 |
guarantee(code_offset() - offset <= exception_handler_size, "overflow"); |
|
397 |
__ end_a_stub(); |
|
398 |
||
399 |
return offset; |
|
400 |
} |
|
401 |
||
402 |
||
403 |
// Emit the code to remove the frame from the stack in the exception |
|
404 |
// unwind path. |
|
405 |
int LIR_Assembler::emit_unwind_handler() { |
|
406 |
#ifndef PRODUCT |
|
407 |
if (CommentedAssembly) { |
|
408 |
_masm->block_comment("Unwind handler"); |
|
409 |
} |
|
410 |
#endif |
|
411 |
||
412 |
int offset = code_offset(); |
|
413 |
||
414 |
// Fetch the exception from TLS and clear out exception related thread state |
|
415 |
__ ldr(r0, Address(rthread, JavaThread::exception_oop_offset())); |
|
416 |
__ str(zr, Address(rthread, JavaThread::exception_oop_offset())); |
|
417 |
__ str(zr, Address(rthread, JavaThread::exception_pc_offset())); |
|
418 |
||
419 |
__ bind(_unwind_handler_entry); |
|
420 |
__ verify_not_null_oop(r0); |
|
421 |
if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) { |
|
422 |
__ mov(r19, r0); // Preserve the exception |
|
423 |
} |
|
424 |
||
425 |
// Preform needed unlocking |
|
426 |
MonitorExitStub* stub = NULL; |
|
427 |
if (method()->is_synchronized()) { |
|
428 |
monitor_address(0, FrameMap::r0_opr); |
|
429 |
stub = new MonitorExitStub(FrameMap::r0_opr, true, 0); |
|
430 |
__ unlock_object(r5, r4, r0, *stub->entry()); |
|
431 |
__ bind(*stub->continuation()); |
|
432 |
} |
|
433 |
||
434 |
if (compilation()->env()->dtrace_method_probes()) { |
|
435 |
__ call_Unimplemented(); |
|
436 |
#if 0 |
|
437 |
__ movptr(Address(rsp, 0), rax); |
|
438 |
__ mov_metadata(Address(rsp, sizeof(void*)), method()->constant_encoding()); |
|
439 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit))); |
|
440 |
#endif |
|
441 |
} |
|
442 |
||
443 |
if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) { |
|
444 |
__ mov(r0, r19); // Restore the exception |
|
445 |
} |
|
446 |
||
447 |
// remove the activation and dispatch to the unwind handler |
|
448 |
__ block_comment("remove_frame and dispatch to the unwind handler"); |
|
449 |
__ remove_frame(initial_frame_size_in_bytes()); |
|
450 |
__ far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id))); |
|
451 |
||
452 |
// Emit the slow path assembly |
|
453 |
if (stub != NULL) { |
|
454 |
stub->emit_code(this); |
|
455 |
} |
|
456 |
||
457 |
return offset; |
|
458 |
} |
|
459 |
||
460 |
||
461 |
int LIR_Assembler::emit_deopt_handler() { |
|
462 |
// if the last instruction is a call (typically to do a throw which |
|
463 |
// is coming at the end after block reordering) the return address |
|
464 |
// must still point into the code area in order to avoid assertion |
|
465 |
// failures when searching for the corresponding bci => add a nop |
|
466 |
// (was bug 5/14/1999 - gri) |
|
467 |
__ nop(); |
|
468 |
||
469 |
// generate code for exception handler |
|
470 |
address handler_base = __ start_a_stub(deopt_handler_size); |
|
471 |
if (handler_base == NULL) { |
|
472 |
// not enough space left for the handler |
|
473 |
bailout("deopt handler overflow"); |
|
474 |
return -1; |
|
475 |
} |
|
476 |
||
477 |
int offset = code_offset(); |
|
478 |
||
479 |
__ adr(lr, pc()); |
|
480 |
__ far_jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack())); |
|
481 |
guarantee(code_offset() - offset <= deopt_handler_size, "overflow"); |
|
482 |
__ end_a_stub(); |
|
483 |
||
484 |
return offset; |
|
485 |
} |
|
486 |
||
487 |
void LIR_Assembler::add_debug_info_for_branch(address adr, CodeEmitInfo* info) { |
|
488 |
_masm->code_section()->relocate(adr, relocInfo::poll_type); |
|
489 |
int pc_offset = code_offset(); |
|
490 |
flush_debug_info(pc_offset); |
|
491 |
info->record_debug_info(compilation()->debug_info_recorder(), pc_offset); |
|
492 |
if (info->exception_handlers() != NULL) { |
|
493 |
compilation()->add_exception_handlers_for_pco(pc_offset, info->exception_handlers()); |
|
494 |
} |
|
495 |
} |
|
496 |
||
497 |
// Rather than take a segfault when the polling page is protected, |
|
498 |
// explicitly check for a safepoint in progress and if there is one, |
|
499 |
// fake a call to the handler as if a segfault had been caught. |
|
500 |
void LIR_Assembler::poll_for_safepoint(relocInfo::relocType rtype, CodeEmitInfo* info) { |
|
501 |
__ mov(rscratch1, SafepointSynchronize::address_of_state()); |
|
502 |
__ ldrb(rscratch1, Address(rscratch1)); |
|
503 |
Label nope, poll; |
|
504 |
__ cbz(rscratch1, nope); |
|
505 |
__ block_comment("safepoint"); |
|
506 |
__ enter(); |
|
507 |
__ push(0x3, sp); // r0 & r1 |
|
508 |
__ push(0x3ffffffc, sp); // integer registers except lr & sp & r0 & r1 |
|
509 |
__ adr(r0, poll); |
|
510 |
__ str(r0, Address(rthread, JavaThread::saved_exception_pc_offset())); |
|
511 |
__ mov(rscratch1, CAST_FROM_FN_PTR(address, SharedRuntime::get_poll_stub)); |
|
512 |
__ blrt(rscratch1, 1, 0, 1); |
|
513 |
__ maybe_isb(); |
|
514 |
__ pop(0x3ffffffc, sp); // integer registers except lr & sp & r0 & r1 |
|
515 |
__ mov(rscratch1, r0); |
|
516 |
__ pop(0x3, sp); // r0 & r1 |
|
517 |
__ leave(); |
|
518 |
__ br(rscratch1); |
|
519 |
address polling_page(os::get_polling_page()); |
|
520 |
assert(os::is_poll_address(polling_page), "should be"); |
|
521 |
unsigned long off; |
|
522 |
__ adrp(rscratch1, Address(polling_page, rtype), off); |
|
523 |
__ bind(poll); |
|
524 |
if (info) |
|
525 |
add_debug_info_for_branch(info); // This isn't just debug info: |
|
526 |
// it's the oop map |
|
527 |
else |
|
528 |
__ code_section()->relocate(pc(), rtype); |
|
529 |
__ ldrw(zr, Address(rscratch1, off)); |
|
530 |
__ bind(nope); |
|
531 |
} |
|
532 |
||
533 |
void LIR_Assembler::return_op(LIR_Opr result) { |
|
534 |
assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == r0, "word returns are in r0,"); |
|
535 |
// Pop the stack before the safepoint code |
|
536 |
__ remove_frame(initial_frame_size_in_bytes()); |
|
537 |
address polling_page(os::get_polling_page()); |
|
538 |
__ read_polling_page(rscratch1, polling_page, relocInfo::poll_return_type); |
|
539 |
__ ret(lr); |
|
540 |
} |
|
541 |
||
542 |
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) { |
|
543 |
address polling_page(os::get_polling_page()); |
|
544 |
guarantee(info != NULL, "Shouldn't be NULL"); |
|
545 |
assert(os::is_poll_address(polling_page), "should be"); |
|
546 |
unsigned long off; |
|
547 |
__ adrp(rscratch1, Address(polling_page, relocInfo::poll_type), off); |
|
548 |
assert(off == 0, "must be"); |
|
549 |
add_debug_info_for_branch(info); // This isn't just debug info: |
|
550 |
// it's the oop map |
|
551 |
__ read_polling_page(rscratch1, relocInfo::poll_type); |
|
552 |
return __ offset(); |
|
553 |
} |
|
554 |
||
555 |
||
556 |
void LIR_Assembler::move_regs(Register from_reg, Register to_reg) { |
|
557 |
if (from_reg == r31_sp) |
|
558 |
from_reg = sp; |
|
559 |
if (to_reg == r31_sp) |
|
560 |
to_reg = sp; |
|
561 |
__ mov(to_reg, from_reg); |
|
562 |
} |
|
563 |
||
564 |
void LIR_Assembler::swap_reg(Register a, Register b) { Unimplemented(); } |
|
565 |
||
566 |
||
567 |
void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) { |
|
568 |
assert(src->is_constant(), "should not call otherwise"); |
|
569 |
assert(dest->is_register(), "should not call otherwise"); |
|
570 |
LIR_Const* c = src->as_constant_ptr(); |
|
571 |
||
572 |
switch (c->type()) { |
|
573 |
case T_INT: { |
|
574 |
assert(patch_code == lir_patch_none, "no patching handled here"); |
|
575 |
__ movw(dest->as_register(), c->as_jint()); |
|
576 |
break; |
|
577 |
} |
|
578 |
||
579 |
case T_ADDRESS: { |
|
580 |
assert(patch_code == lir_patch_none, "no patching handled here"); |
|
581 |
__ mov(dest->as_register(), c->as_jint()); |
|
582 |
break; |
|
583 |
} |
|
584 |
||
585 |
case T_LONG: { |
|
586 |
assert(patch_code == lir_patch_none, "no patching handled here"); |
|
587 |
__ mov(dest->as_register_lo(), (intptr_t)c->as_jlong()); |
|
588 |
break; |
|
589 |
} |
|
590 |
||
591 |
case T_OBJECT: { |
|
592 |
if (patch_code == lir_patch_none) { |
|
593 |
jobject2reg(c->as_jobject(), dest->as_register()); |
|
594 |
} else { |
|
595 |
jobject2reg_with_patching(dest->as_register(), info); |
|
596 |
} |
|
597 |
break; |
|
598 |
} |
|
599 |
||
600 |
case T_METADATA: { |
|
601 |
if (patch_code != lir_patch_none) { |
|
602 |
klass2reg_with_patching(dest->as_register(), info); |
|
603 |
} else { |
|
604 |
__ mov_metadata(dest->as_register(), c->as_metadata()); |
|
605 |
} |
|
606 |
break; |
|
607 |
} |
|
608 |
||
609 |
case T_FLOAT: { |
|
610 |
if (__ operand_valid_for_float_immediate(c->as_jfloat())) { |
|
611 |
__ fmovs(dest->as_float_reg(), (c->as_jfloat())); |
|
612 |
} else { |
|
613 |
__ adr(rscratch1, InternalAddress(float_constant(c->as_jfloat()))); |
|
614 |
__ ldrs(dest->as_float_reg(), Address(rscratch1)); |
|
615 |
} |
|
616 |
break; |
|
617 |
} |
|
618 |
||
619 |
case T_DOUBLE: { |
|
620 |
if (__ operand_valid_for_float_immediate(c->as_jdouble())) { |
|
621 |
__ fmovd(dest->as_double_reg(), (c->as_jdouble())); |
|
622 |
} else { |
|
623 |
__ adr(rscratch1, InternalAddress(double_constant(c->as_jdouble()))); |
|
624 |
__ ldrd(dest->as_double_reg(), Address(rscratch1)); |
|
625 |
} |
|
626 |
break; |
|
627 |
} |
|
628 |
||
629 |
default: |
|
630 |
ShouldNotReachHere(); |
|
631 |
} |
|
632 |
} |
|
633 |
||
634 |
void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) { |
|
635 |
LIR_Const* c = src->as_constant_ptr(); |
|
636 |
switch (c->type()) { |
|
637 |
case T_OBJECT: |
|
638 |
{ |
|
639 |
if (! c->as_jobject()) |
|
640 |
__ str(zr, frame_map()->address_for_slot(dest->single_stack_ix())); |
|
641 |
else { |
|
642 |
const2reg(src, FrameMap::rscratch1_opr, lir_patch_none, NULL); |
|
643 |
reg2stack(FrameMap::rscratch1_opr, dest, c->type(), false); |
|
644 |
} |
|
645 |
} |
|
646 |
break; |
|
647 |
case T_ADDRESS: |
|
648 |
{ |
|
649 |
const2reg(src, FrameMap::rscratch1_opr, lir_patch_none, NULL); |
|
650 |
reg2stack(FrameMap::rscratch1_opr, dest, c->type(), false); |
|
651 |
} |
|
652 |
case T_INT: |
|
653 |
case T_FLOAT: |
|
654 |
{ |
|
655 |
Register reg = zr; |
|
656 |
if (c->as_jint_bits() == 0) |
|
657 |
__ strw(zr, frame_map()->address_for_slot(dest->single_stack_ix())); |
|
658 |
else { |
|
659 |
__ movw(rscratch1, c->as_jint_bits()); |
|
660 |
__ strw(rscratch1, frame_map()->address_for_slot(dest->single_stack_ix())); |
|
661 |
} |
|
662 |
} |
|
663 |
break; |
|
664 |
case T_LONG: |
|
665 |
case T_DOUBLE: |
|
666 |
{ |
|
667 |
Register reg = zr; |
|
668 |
if (c->as_jlong_bits() == 0) |
|
669 |
__ str(zr, frame_map()->address_for_slot(dest->double_stack_ix(), |
|
670 |
lo_word_offset_in_bytes)); |
|
671 |
else { |
|
672 |
__ mov(rscratch1, (intptr_t)c->as_jlong_bits()); |
|
673 |
__ str(rscratch1, frame_map()->address_for_slot(dest->double_stack_ix(), |
|
674 |
lo_word_offset_in_bytes)); |
|
675 |
} |
|
676 |
} |
|
677 |
break; |
|
678 |
default: |
|
679 |
ShouldNotReachHere(); |
|
680 |
} |
|
681 |
} |
|
682 |
||
683 |
void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info, bool wide) { |
|
684 |
assert(src->is_constant(), "should not call otherwise"); |
|
685 |
LIR_Const* c = src->as_constant_ptr(); |
|
686 |
LIR_Address* to_addr = dest->as_address_ptr(); |
|
687 |
||
688 |
void (Assembler::* insn)(Register Rt, const Address &adr); |
|
689 |
||
690 |
switch (type) { |
|
691 |
case T_ADDRESS: |
|
692 |
assert(c->as_jint() == 0, "should be"); |
|
693 |
insn = &Assembler::str; |
|
694 |
break; |
|
695 |
case T_LONG: |
|
696 |
assert(c->as_jlong() == 0, "should be"); |
|
697 |
insn = &Assembler::str; |
|
698 |
break; |
|
699 |
case T_INT: |
|
700 |
assert(c->as_jint() == 0, "should be"); |
|
701 |
insn = &Assembler::strw; |
|
702 |
break; |
|
703 |
case T_OBJECT: |
|
704 |
case T_ARRAY: |
|
705 |
assert(c->as_jobject() == 0, "should be"); |
|
706 |
if (UseCompressedOops && !wide) { |
|
707 |
insn = &Assembler::strw; |
|
708 |
} else { |
|
709 |
insn = &Assembler::str; |
|
710 |
} |
|
711 |
break; |
|
712 |
case T_CHAR: |
|
713 |
case T_SHORT: |
|
714 |
assert(c->as_jint() == 0, "should be"); |
|
715 |
insn = &Assembler::strh; |
|
716 |
break; |
|
717 |
case T_BOOLEAN: |
|
718 |
case T_BYTE: |
|
719 |
assert(c->as_jint() == 0, "should be"); |
|
720 |
insn = &Assembler::strb; |
|
721 |
break; |
|
722 |
default: |
|
723 |
ShouldNotReachHere(); |
|
35127 | 724 |
insn = &Assembler::str; // unreachable |
29184 | 725 |
} |
726 |
||
727 |
if (info) add_debug_info_for_null_check_here(info); |
|
728 |
(_masm->*insn)(zr, as_Address(to_addr, rscratch1)); |
|
729 |
} |
|
730 |
||
731 |
void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) { |
|
732 |
assert(src->is_register(), "should not call otherwise"); |
|
733 |
assert(dest->is_register(), "should not call otherwise"); |
|
734 |
||
735 |
// move between cpu-registers |
|
736 |
if (dest->is_single_cpu()) { |
|
737 |
if (src->type() == T_LONG) { |
|
738 |
// Can do LONG -> OBJECT |
|
739 |
move_regs(src->as_register_lo(), dest->as_register()); |
|
740 |
return; |
|
741 |
} |
|
742 |
assert(src->is_single_cpu(), "must match"); |
|
743 |
if (src->type() == T_OBJECT) { |
|
744 |
__ verify_oop(src->as_register()); |
|
745 |
} |
|
746 |
move_regs(src->as_register(), dest->as_register()); |
|
747 |
||
748 |
} else if (dest->is_double_cpu()) { |
|
749 |
if (src->type() == T_OBJECT || src->type() == T_ARRAY) { |
|
750 |
// Surprising to me but we can see move of a long to t_object |
|
751 |
__ verify_oop(src->as_register()); |
|
752 |
move_regs(src->as_register(), dest->as_register_lo()); |
|
753 |
return; |
|
754 |
} |
|
755 |
assert(src->is_double_cpu(), "must match"); |
|
756 |
Register f_lo = src->as_register_lo(); |
|
757 |
Register f_hi = src->as_register_hi(); |
|
758 |
Register t_lo = dest->as_register_lo(); |
|
759 |
Register t_hi = dest->as_register_hi(); |
|
760 |
assert(f_hi == f_lo, "must be same"); |
|
761 |
assert(t_hi == t_lo, "must be same"); |
|
762 |
move_regs(f_lo, t_lo); |
|
763 |
||
764 |
} else if (dest->is_single_fpu()) { |
|
765 |
__ fmovs(dest->as_float_reg(), src->as_float_reg()); |
|
766 |
||
767 |
} else if (dest->is_double_fpu()) { |
|
768 |
__ fmovd(dest->as_double_reg(), src->as_double_reg()); |
|
769 |
||
770 |
} else { |
|
771 |
ShouldNotReachHere(); |
|
772 |
} |
|
773 |
} |
|
774 |
||
775 |
void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool pop_fpu_stack) { |
|
776 |
if (src->is_single_cpu()) { |
|
777 |
if (type == T_ARRAY || type == T_OBJECT) { |
|
778 |
__ str(src->as_register(), frame_map()->address_for_slot(dest->single_stack_ix())); |
|
779 |
__ verify_oop(src->as_register()); |
|
780 |
} else if (type == T_METADATA || type == T_DOUBLE) { |
|
781 |
__ str(src->as_register(), frame_map()->address_for_slot(dest->single_stack_ix())); |
|
782 |
} else { |
|
783 |
__ strw(src->as_register(), frame_map()->address_for_slot(dest->single_stack_ix())); |
|
784 |
} |
|
785 |
||
786 |
} else if (src->is_double_cpu()) { |
|
787 |
Address dest_addr_LO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes); |
|
788 |
__ str(src->as_register_lo(), dest_addr_LO); |
|
789 |
||
790 |
} else if (src->is_single_fpu()) { |
|
791 |
Address dest_addr = frame_map()->address_for_slot(dest->single_stack_ix()); |
|
792 |
__ strs(src->as_float_reg(), dest_addr); |
|
793 |
||
794 |
} else if (src->is_double_fpu()) { |
|
795 |
Address dest_addr = frame_map()->address_for_slot(dest->double_stack_ix()); |
|
796 |
__ strd(src->as_double_reg(), dest_addr); |
|
797 |
||
798 |
} else { |
|
799 |
ShouldNotReachHere(); |
|
800 |
} |
|
801 |
||
802 |
} |
|
803 |
||
804 |
||
805 |
void LIR_Assembler::reg2mem(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide, bool /* unaligned */) { |
|
806 |
LIR_Address* to_addr = dest->as_address_ptr(); |
|
807 |
PatchingStub* patch = NULL; |
|
808 |
Register compressed_src = rscratch1; |
|
809 |
||
810 |
if (patch_code != lir_patch_none) { |
|
811 |
deoptimize_trap(info); |
|
812 |
return; |
|
813 |
} |
|
814 |
||
815 |
if (type == T_ARRAY || type == T_OBJECT) { |
|
816 |
__ verify_oop(src->as_register()); |
|
817 |
||
818 |
if (UseCompressedOops && !wide) { |
|
819 |
__ encode_heap_oop(compressed_src, src->as_register()); |
|
820 |
} else { |
|
821 |
compressed_src = src->as_register(); |
|
822 |
} |
|
823 |
} |
|
824 |
||
825 |
int null_check_here = code_offset(); |
|
826 |
switch (type) { |
|
827 |
case T_FLOAT: { |
|
828 |
__ strs(src->as_float_reg(), as_Address(to_addr)); |
|
829 |
break; |
|
830 |
} |
|
831 |
||
832 |
case T_DOUBLE: { |
|
833 |
__ strd(src->as_double_reg(), as_Address(to_addr)); |
|
834 |
break; |
|
835 |
} |
|
836 |
||
837 |
case T_ARRAY: // fall through |
|
838 |
case T_OBJECT: // fall through |
|
839 |
if (UseCompressedOops && !wide) { |
|
840 |
__ strw(compressed_src, as_Address(to_addr, rscratch2)); |
|
841 |
} else { |
|
842 |
__ str(compressed_src, as_Address(to_addr)); |
|
843 |
} |
|
844 |
break; |
|
845 |
case T_METADATA: |
|
846 |
// We get here to store a method pointer to the stack to pass to |
|
847 |
// a dtrace runtime call. This can't work on 64 bit with |
|
848 |
// compressed klass ptrs: T_METADATA can be a compressed klass |
|
849 |
// ptr or a 64 bit method pointer. |
|
850 |
ShouldNotReachHere(); |
|
851 |
__ str(src->as_register(), as_Address(to_addr)); |
|
852 |
break; |
|
853 |
case T_ADDRESS: |
|
854 |
__ str(src->as_register(), as_Address(to_addr)); |
|
855 |
break; |
|
856 |
case T_INT: |
|
857 |
__ strw(src->as_register(), as_Address(to_addr)); |
|
858 |
break; |
|
859 |
||
860 |
case T_LONG: { |
|
861 |
__ str(src->as_register_lo(), as_Address_lo(to_addr)); |
|
862 |
break; |
|
863 |
} |
|
864 |
||
865 |
case T_BYTE: // fall through |
|
866 |
case T_BOOLEAN: { |
|
867 |
__ strb(src->as_register(), as_Address(to_addr)); |
|
868 |
break; |
|
869 |
} |
|
870 |
||
871 |
case T_CHAR: // fall through |
|
872 |
case T_SHORT: |
|
873 |
__ strh(src->as_register(), as_Address(to_addr)); |
|
874 |
break; |
|
875 |
||
876 |
default: |
|
877 |
ShouldNotReachHere(); |
|
878 |
} |
|
879 |
if (info != NULL) { |
|
880 |
add_debug_info_for_null_check(null_check_here, info); |
|
881 |
} |
|
882 |
} |
|
883 |
||
884 |
||
885 |
void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) { |
|
886 |
assert(src->is_stack(), "should not call otherwise"); |
|
887 |
assert(dest->is_register(), "should not call otherwise"); |
|
888 |
||
889 |
if (dest->is_single_cpu()) { |
|
890 |
if (type == T_ARRAY || type == T_OBJECT) { |
|
891 |
__ ldr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); |
|
892 |
__ verify_oop(dest->as_register()); |
|
893 |
} else if (type == T_METADATA) { |
|
894 |
__ ldr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); |
|
895 |
} else { |
|
896 |
__ ldrw(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); |
|
897 |
} |
|
898 |
||
899 |
} else if (dest->is_double_cpu()) { |
|
900 |
Address src_addr_LO = frame_map()->address_for_slot(src->double_stack_ix(), lo_word_offset_in_bytes); |
|
901 |
__ ldr(dest->as_register_lo(), src_addr_LO); |
|
902 |
||
903 |
} else if (dest->is_single_fpu()) { |
|
904 |
Address src_addr = frame_map()->address_for_slot(src->single_stack_ix()); |
|
905 |
__ ldrs(dest->as_float_reg(), src_addr); |
|
906 |
||
907 |
} else if (dest->is_double_fpu()) { |
|
908 |
Address src_addr = frame_map()->address_for_slot(src->double_stack_ix()); |
|
909 |
__ ldrd(dest->as_double_reg(), src_addr); |
|
910 |
||
911 |
} else { |
|
912 |
ShouldNotReachHere(); |
|
913 |
} |
|
914 |
} |
|
915 |
||
916 |
||
917 |
void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo* info) { |
|
918 |
address target = NULL; |
|
919 |
relocInfo::relocType reloc_type = relocInfo::none; |
|
920 |
||
921 |
switch (patching_id(info)) { |
|
922 |
case PatchingStub::access_field_id: |
|
923 |
target = Runtime1::entry_for(Runtime1::access_field_patching_id); |
|
924 |
reloc_type = relocInfo::section_word_type; |
|
925 |
break; |
|
926 |
case PatchingStub::load_klass_id: |
|
927 |
target = Runtime1::entry_for(Runtime1::load_klass_patching_id); |
|
928 |
reloc_type = relocInfo::metadata_type; |
|
929 |
break; |
|
930 |
case PatchingStub::load_mirror_id: |
|
931 |
target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); |
|
932 |
reloc_type = relocInfo::oop_type; |
|
933 |
break; |
|
934 |
case PatchingStub::load_appendix_id: |
|
935 |
target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); |
|
936 |
reloc_type = relocInfo::oop_type; |
|
937 |
break; |
|
938 |
default: ShouldNotReachHere(); |
|
939 |
} |
|
940 |
||
941 |
__ far_call(RuntimeAddress(target)); |
|
942 |
add_call_info_here(info); |
|
943 |
} |
|
944 |
||
945 |
void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) { |
|
946 |
||
947 |
LIR_Opr temp; |
|
948 |
if (type == T_LONG || type == T_DOUBLE) |
|
949 |
temp = FrameMap::rscratch1_long_opr; |
|
950 |
else |
|
951 |
temp = FrameMap::rscratch1_opr; |
|
952 |
||
953 |
stack2reg(src, temp, src->type()); |
|
954 |
reg2stack(temp, dest, dest->type(), false); |
|
955 |
} |
|
956 |
||
957 |
||
958 |
void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool wide, bool /* unaligned */) { |
|
959 |
LIR_Address* addr = src->as_address_ptr(); |
|
960 |
LIR_Address* from_addr = src->as_address_ptr(); |
|
961 |
||
962 |
if (addr->base()->type() == T_OBJECT) { |
|
963 |
__ verify_oop(addr->base()->as_pointer_register()); |
|
964 |
} |
|
965 |
||
966 |
if (patch_code != lir_patch_none) { |
|
967 |
deoptimize_trap(info); |
|
968 |
return; |
|
969 |
} |
|
970 |
||
971 |
if (info != NULL) { |
|
972 |
add_debug_info_for_null_check_here(info); |
|
973 |
} |
|
974 |
int null_check_here = code_offset(); |
|
975 |
switch (type) { |
|
976 |
case T_FLOAT: { |
|
977 |
__ ldrs(dest->as_float_reg(), as_Address(from_addr)); |
|
978 |
break; |
|
979 |
} |
|
980 |
||
981 |
case T_DOUBLE: { |
|
982 |
__ ldrd(dest->as_double_reg(), as_Address(from_addr)); |
|
983 |
break; |
|
984 |
} |
|
985 |
||
986 |
case T_ARRAY: // fall through |
|
987 |
case T_OBJECT: // fall through |
|
988 |
if (UseCompressedOops && !wide) { |
|
989 |
__ ldrw(dest->as_register(), as_Address(from_addr)); |
|
990 |
} else { |
|
991 |
__ ldr(dest->as_register(), as_Address(from_addr)); |
|
992 |
} |
|
993 |
break; |
|
994 |
case T_METADATA: |
|
995 |
// We get here to store a method pointer to the stack to pass to |
|
996 |
// a dtrace runtime call. This can't work on 64 bit with |
|
997 |
// compressed klass ptrs: T_METADATA can be a compressed klass |
|
998 |
// ptr or a 64 bit method pointer. |
|
999 |
ShouldNotReachHere(); |
|
1000 |
__ ldr(dest->as_register(), as_Address(from_addr)); |
|
1001 |
break; |
|
1002 |
case T_ADDRESS: |
|
1003 |
// FIXME: OMG this is a horrible kludge. Any offset from an |
|
1004 |
// address that matches klass_offset_in_bytes() will be loaded |
|
1005 |
// as a word, not a long. |
|
1006 |
if (UseCompressedClassPointers && addr->disp() == oopDesc::klass_offset_in_bytes()) { |
|
1007 |
__ ldrw(dest->as_register(), as_Address(from_addr)); |
|
1008 |
} else { |
|
1009 |
__ ldr(dest->as_register(), as_Address(from_addr)); |
|
1010 |
} |
|
1011 |
break; |
|
1012 |
case T_INT: |
|
1013 |
__ ldrw(dest->as_register(), as_Address(from_addr)); |
|
1014 |
break; |
|
1015 |
||
1016 |
case T_LONG: { |
|
1017 |
__ ldr(dest->as_register_lo(), as_Address_lo(from_addr)); |
|
1018 |
break; |
|
1019 |
} |
|
1020 |
||
1021 |
case T_BYTE: |
|
1022 |
__ ldrsb(dest->as_register(), as_Address(from_addr)); |
|
1023 |
break; |
|
1024 |
case T_BOOLEAN: { |
|
1025 |
__ ldrb(dest->as_register(), as_Address(from_addr)); |
|
1026 |
break; |
|
1027 |
} |
|
1028 |
||
1029 |
case T_CHAR: |
|
1030 |
__ ldrh(dest->as_register(), as_Address(from_addr)); |
|
1031 |
break; |
|
1032 |
case T_SHORT: |
|
1033 |
__ ldrsh(dest->as_register(), as_Address(from_addr)); |
|
1034 |
break; |
|
1035 |
||
1036 |
default: |
|
1037 |
ShouldNotReachHere(); |
|
1038 |
} |
|
1039 |
||
1040 |
if (type == T_ARRAY || type == T_OBJECT) { |
|
1041 |
if (UseCompressedOops && !wide) { |
|
1042 |
__ decode_heap_oop(dest->as_register()); |
|
1043 |
} |
|
1044 |
__ verify_oop(dest->as_register()); |
|
1045 |
} else if (type == T_ADDRESS && addr->disp() == oopDesc::klass_offset_in_bytes()) { |
|
1046 |
if (UseCompressedClassPointers) { |
|
1047 |
__ decode_klass_not_null(dest->as_register()); |
|
1048 |
} |
|
1049 |
} |
|
1050 |
} |
|
1051 |
||
1052 |
||
1053 |
int LIR_Assembler::array_element_size(BasicType type) const { |
|
1054 |
int elem_size = type2aelembytes(type); |
|
1055 |
return exact_log2(elem_size); |
|
1056 |
} |
|
1057 |
||
1058 |
void LIR_Assembler::emit_op3(LIR_Op3* op) { |
|
1059 |
Register Rdividend = op->in_opr1()->as_register(); |
|
1060 |
Register Rdivisor = op->in_opr2()->as_register(); |
|
1061 |
Register Rscratch = op->in_opr3()->as_register(); |
|
1062 |
Register Rresult = op->result_opr()->as_register(); |
|
1063 |
int divisor = -1; |
|
1064 |
||
1065 |
/* |
|
1066 |
TODO: For some reason, using the Rscratch that gets passed in is |
|
1067 |
not possible because the register allocator does not see the tmp reg |
|
1068 |
as used, and assignes it the same register as Rdividend. We use rscratch1 |
|
1069 |
instead. |
|
1070 |
||
1071 |
assert(Rdividend != Rscratch, ""); |
|
1072 |
assert(Rdivisor != Rscratch, ""); |
|
1073 |
*/ |
|
1074 |
||
1075 |
if (Rdivisor == noreg && is_power_of_2(divisor)) { |
|
1076 |
// convert division by a power of two into some shifts and logical operations |
|
1077 |
} |
|
1078 |
||
1079 |
if (op->code() == lir_irem) { |
|
1080 |
__ corrected_idivl(Rresult, Rdividend, Rdivisor, true, rscratch1); |
|
1081 |
} else if (op->code() == lir_idiv) { |
|
1082 |
__ corrected_idivl(Rresult, Rdividend, Rdivisor, false, rscratch1); |
|
1083 |
} else |
|
1084 |
ShouldNotReachHere(); |
|
1085 |
} |
|
1086 |
||
1087 |
void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) { |
|
1088 |
#ifdef ASSERT |
|
1089 |
assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label"); |
|
1090 |
if (op->block() != NULL) _branch_target_blocks.append(op->block()); |
|
1091 |
if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock()); |
|
1092 |
#endif |
|
1093 |
||
1094 |
if (op->cond() == lir_cond_always) { |
|
1095 |
if (op->info() != NULL) add_debug_info_for_branch(op->info()); |
|
1096 |
__ b(*(op->label())); |
|
1097 |
} else { |
|
1098 |
Assembler::Condition acond; |
|
1099 |
if (op->code() == lir_cond_float_branch) { |
|
1100 |
bool is_unordered = (op->ublock() == op->block()); |
|
1101 |
// Assembler::EQ does not permit unordered branches, so we add |
|
1102 |
// another branch here. Likewise, Assembler::NE does not permit |
|
1103 |
// ordered branches. |
|
1104 |
if (is_unordered && op->cond() == lir_cond_equal |
|
1105 |
|| !is_unordered && op->cond() == lir_cond_notEqual) |
|
1106 |
__ br(Assembler::VS, *(op->ublock()->label())); |
|
1107 |
switch(op->cond()) { |
|
1108 |
case lir_cond_equal: acond = Assembler::EQ; break; |
|
1109 |
case lir_cond_notEqual: acond = Assembler::NE; break; |
|
1110 |
case lir_cond_less: acond = (is_unordered ? Assembler::LT : Assembler::LO); break; |
|
1111 |
case lir_cond_lessEqual: acond = (is_unordered ? Assembler::LE : Assembler::LS); break; |
|
1112 |
case lir_cond_greaterEqual: acond = (is_unordered ? Assembler::HS : Assembler::GE); break; |
|
1113 |
case lir_cond_greater: acond = (is_unordered ? Assembler::HI : Assembler::GT); break; |
|
1114 |
default: ShouldNotReachHere(); |
|
35127 | 1115 |
acond = Assembler::EQ; // unreachable |
29184 | 1116 |
} |
1117 |
} else { |
|
1118 |
switch (op->cond()) { |
|
1119 |
case lir_cond_equal: acond = Assembler::EQ; break; |
|
1120 |
case lir_cond_notEqual: acond = Assembler::NE; break; |
|
1121 |
case lir_cond_less: acond = Assembler::LT; break; |
|
1122 |
case lir_cond_lessEqual: acond = Assembler::LE; break; |
|
1123 |
case lir_cond_greaterEqual: acond = Assembler::GE; break; |
|
1124 |
case lir_cond_greater: acond = Assembler::GT; break; |
|
1125 |
case lir_cond_belowEqual: acond = Assembler::LS; break; |
|
1126 |
case lir_cond_aboveEqual: acond = Assembler::HS; break; |
|
35127 | 1127 |
default: ShouldNotReachHere(); |
1128 |
acond = Assembler::EQ; // unreachable |
|
29184 | 1129 |
} |
1130 |
} |
|
1131 |
__ br(acond,*(op->label())); |
|
1132 |
} |
|
1133 |
} |
|
1134 |
||
1135 |
||
1136 |
||
1137 |
void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) { |
|
1138 |
LIR_Opr src = op->in_opr(); |
|
1139 |
LIR_Opr dest = op->result_opr(); |
|
1140 |
||
1141 |
switch (op->bytecode()) { |
|
1142 |
case Bytecodes::_i2f: |
|
1143 |
{ |
|
1144 |
__ scvtfws(dest->as_float_reg(), src->as_register()); |
|
1145 |
break; |
|
1146 |
} |
|
1147 |
case Bytecodes::_i2d: |
|
1148 |
{ |
|
1149 |
__ scvtfwd(dest->as_double_reg(), src->as_register()); |
|
1150 |
break; |
|
1151 |
} |
|
1152 |
case Bytecodes::_l2d: |
|
1153 |
{ |
|
1154 |
__ scvtfd(dest->as_double_reg(), src->as_register_lo()); |
|
1155 |
break; |
|
1156 |
} |
|
1157 |
case Bytecodes::_l2f: |
|
1158 |
{ |
|
1159 |
__ scvtfs(dest->as_float_reg(), src->as_register_lo()); |
|
1160 |
break; |
|
1161 |
} |
|
1162 |
case Bytecodes::_f2d: |
|
1163 |
{ |
|
1164 |
__ fcvts(dest->as_double_reg(), src->as_float_reg()); |
|
1165 |
break; |
|
1166 |
} |
|
1167 |
case Bytecodes::_d2f: |
|
1168 |
{ |
|
1169 |
__ fcvtd(dest->as_float_reg(), src->as_double_reg()); |
|
1170 |
break; |
|
1171 |
} |
|
1172 |
case Bytecodes::_i2c: |
|
1173 |
{ |
|
1174 |
__ ubfx(dest->as_register(), src->as_register(), 0, 16); |
|
1175 |
break; |
|
1176 |
} |
|
1177 |
case Bytecodes::_i2l: |
|
1178 |
{ |
|
1179 |
__ sxtw(dest->as_register_lo(), src->as_register()); |
|
1180 |
break; |
|
1181 |
} |
|
1182 |
case Bytecodes::_i2s: |
|
1183 |
{ |
|
1184 |
__ sxth(dest->as_register(), src->as_register()); |
|
1185 |
break; |
|
1186 |
} |
|
1187 |
case Bytecodes::_i2b: |
|
1188 |
{ |
|
1189 |
__ sxtb(dest->as_register(), src->as_register()); |
|
1190 |
break; |
|
1191 |
} |
|
1192 |
case Bytecodes::_l2i: |
|
1193 |
{ |
|
1194 |
_masm->block_comment("FIXME: This could be a no-op"); |
|
1195 |
__ uxtw(dest->as_register(), src->as_register_lo()); |
|
1196 |
break; |
|
1197 |
} |
|
1198 |
case Bytecodes::_d2l: |
|
1199 |
{ |
|
1200 |
__ fcvtzd(dest->as_register_lo(), src->as_double_reg()); |
|
1201 |
break; |
|
1202 |
} |
|
1203 |
case Bytecodes::_f2i: |
|
1204 |
{ |
|
1205 |
__ fcvtzsw(dest->as_register(), src->as_float_reg()); |
|
1206 |
break; |
|
1207 |
} |
|
1208 |
case Bytecodes::_f2l: |
|
1209 |
{ |
|
1210 |
__ fcvtzs(dest->as_register_lo(), src->as_float_reg()); |
|
1211 |
break; |
|
1212 |
} |
|
1213 |
case Bytecodes::_d2i: |
|
1214 |
{ |
|
1215 |
__ fcvtzdw(dest->as_register(), src->as_double_reg()); |
|
1216 |
break; |
|
1217 |
} |
|
1218 |
default: ShouldNotReachHere(); |
|
1219 |
} |
|
1220 |
} |
|
1221 |
||
1222 |
void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { |
|
1223 |
if (op->init_check()) { |
|
1224 |
__ ldrb(rscratch1, Address(op->klass()->as_register(), |
|
1225 |
InstanceKlass::init_state_offset())); |
|
1226 |
__ cmpw(rscratch1, InstanceKlass::fully_initialized); |
|
1227 |
add_debug_info_for_null_check_here(op->stub()->info()); |
|
1228 |
__ br(Assembler::NE, *op->stub()->entry()); |
|
1229 |
} |
|
1230 |
__ allocate_object(op->obj()->as_register(), |
|
1231 |
op->tmp1()->as_register(), |
|
1232 |
op->tmp2()->as_register(), |
|
1233 |
op->header_size(), |
|
1234 |
op->object_size(), |
|
1235 |
op->klass()->as_register(), |
|
1236 |
*op->stub()->entry()); |
|
1237 |
__ bind(*op->stub()->continuation()); |
|
1238 |
} |
|
1239 |
||
1240 |
void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) { |
|
1241 |
Register len = op->len()->as_register(); |
|
1242 |
__ uxtw(len, len); |
|
1243 |
||
1244 |
if (UseSlowPath || |
|
1245 |
(!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) || |
|
1246 |
(!UseFastNewTypeArray && (op->type() != T_OBJECT && op->type() != T_ARRAY))) { |
|
1247 |
__ b(*op->stub()->entry()); |
|
1248 |
} else { |
|
1249 |
Register tmp1 = op->tmp1()->as_register(); |
|
1250 |
Register tmp2 = op->tmp2()->as_register(); |
|
1251 |
Register tmp3 = op->tmp3()->as_register(); |
|
1252 |
if (len == tmp1) { |
|
1253 |
tmp1 = tmp3; |
|
1254 |
} else if (len == tmp2) { |
|
1255 |
tmp2 = tmp3; |
|
1256 |
} else if (len == tmp3) { |
|
1257 |
// everything is ok |
|
1258 |
} else { |
|
1259 |
__ mov(tmp3, len); |
|
1260 |
} |
|
1261 |
__ allocate_array(op->obj()->as_register(), |
|
1262 |
len, |
|
1263 |
tmp1, |
|
1264 |
tmp2, |
|
1265 |
arrayOopDesc::header_size(op->type()), |
|
1266 |
array_element_size(op->type()), |
|
1267 |
op->klass()->as_register(), |
|
1268 |
*op->stub()->entry()); |
|
1269 |
} |
|
1270 |
__ bind(*op->stub()->continuation()); |
|
1271 |
} |
|
1272 |
||
1273 |
void LIR_Assembler::type_profile_helper(Register mdo, |
|
1274 |
ciMethodData *md, ciProfileData *data, |
|
1275 |
Register recv, Label* update_done) { |
|
1276 |
for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) { |
|
1277 |
Label next_test; |
|
1278 |
// See if the receiver is receiver[n]. |
|
1279 |
__ lea(rscratch2, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)))); |
|
1280 |
__ ldr(rscratch1, Address(rscratch2)); |
|
1281 |
__ cmp(recv, rscratch1); |
|
1282 |
__ br(Assembler::NE, next_test); |
|
1283 |
Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))); |
|
1284 |
__ addptr(data_addr, DataLayout::counter_increment); |
|
1285 |
__ b(*update_done); |
|
1286 |
__ bind(next_test); |
|
1287 |
} |
|
1288 |
||
1289 |
// Didn't find receiver; find next empty slot and fill it in |
|
1290 |
for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) { |
|
1291 |
Label next_test; |
|
1292 |
__ lea(rscratch2, |
|
1293 |
Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)))); |
|
1294 |
Address recv_addr(rscratch2); |
|
1295 |
__ ldr(rscratch1, recv_addr); |
|
1296 |
__ cbnz(rscratch1, next_test); |
|
1297 |
__ str(recv, recv_addr); |
|
1298 |
__ mov(rscratch1, DataLayout::counter_increment); |
|
1299 |
__ lea(rscratch2, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)))); |
|
1300 |
__ str(rscratch1, Address(rscratch2)); |
|
1301 |
__ b(*update_done); |
|
1302 |
__ bind(next_test); |
|
1303 |
} |
|
1304 |
} |
|
1305 |
||
1306 |
void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) { |
|
1307 |
// we always need a stub for the failure case. |
|
1308 |
CodeStub* stub = op->stub(); |
|
1309 |
Register obj = op->object()->as_register(); |
|
1310 |
Register k_RInfo = op->tmp1()->as_register(); |
|
1311 |
Register klass_RInfo = op->tmp2()->as_register(); |
|
1312 |
Register dst = op->result_opr()->as_register(); |
|
1313 |
ciKlass* k = op->klass(); |
|
1314 |
Register Rtmp1 = noreg; |
|
1315 |
||
1316 |
// check if it needs to be profiled |
|
1317 |
ciMethodData* md; |
|
1318 |
ciProfileData* data; |
|
1319 |
||
35127 | 1320 |
const bool should_profile = op->should_profile(); |
1321 |
||
1322 |
if (should_profile) { |
|
29184 | 1323 |
ciMethod* method = op->profiled_method(); |
1324 |
assert(method != NULL, "Should have method"); |
|
1325 |
int bci = op->profiled_bci(); |
|
1326 |
md = method->method_data_or_null(); |
|
1327 |
assert(md != NULL, "Sanity"); |
|
1328 |
data = md->bci_to_data(bci); |
|
1329 |
assert(data != NULL, "need data for type check"); |
|
1330 |
assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check"); |
|
1331 |
} |
|
1332 |
Label profile_cast_success, profile_cast_failure; |
|
35127 | 1333 |
Label *success_target = should_profile ? &profile_cast_success : success; |
1334 |
Label *failure_target = should_profile ? &profile_cast_failure : failure; |
|
29184 | 1335 |
|
1336 |
if (obj == k_RInfo) { |
|
1337 |
k_RInfo = dst; |
|
1338 |
} else if (obj == klass_RInfo) { |
|
1339 |
klass_RInfo = dst; |
|
1340 |
} |
|
1341 |
if (k->is_loaded() && !UseCompressedClassPointers) { |
|
1342 |
select_different_registers(obj, dst, k_RInfo, klass_RInfo); |
|
1343 |
} else { |
|
1344 |
Rtmp1 = op->tmp3()->as_register(); |
|
1345 |
select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1); |
|
1346 |
} |
|
1347 |
||
1348 |
assert_different_registers(obj, k_RInfo, klass_RInfo); |
|
1349 |
||
35127 | 1350 |
if (should_profile) { |
29184 | 1351 |
Label not_null; |
1352 |
__ cbnz(obj, not_null); |
|
1353 |
// Object is null; update MDO and exit |
|
1354 |
Register mdo = klass_RInfo; |
|
1355 |
__ mov_metadata(mdo, md->constant_encoding()); |
|
1356 |
Address data_addr |
|
1357 |
= __ form_address(rscratch2, mdo, |
|
1358 |
md->byte_offset_of_slot(data, DataLayout::DataLayout::header_offset()), |
|
1359 |
LogBytesPerWord); |
|
1360 |
int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant()); |
|
1361 |
__ ldr(rscratch1, data_addr); |
|
1362 |
__ orr(rscratch1, rscratch1, header_bits); |
|
1363 |
__ str(rscratch1, data_addr); |
|
1364 |
__ b(*obj_is_null); |
|
1365 |
__ bind(not_null); |
|
1366 |
} else { |
|
1367 |
__ cbz(obj, *obj_is_null); |
|
1368 |
} |
|
1369 |
||
1370 |
if (!k->is_loaded()) { |
|
1371 |
klass2reg_with_patching(k_RInfo, op->info_for_patch()); |
|
1372 |
} else { |
|
1373 |
__ mov_metadata(k_RInfo, k->constant_encoding()); |
|
1374 |
} |
|
1375 |
__ verify_oop(obj); |
|
1376 |
||
1377 |
if (op->fast_check()) { |
|
1378 |
// get object class |
|
1379 |
// not a safepoint as obj null check happens earlier |
|
1380 |
__ load_klass(rscratch1, obj); |
|
1381 |
__ cmp( rscratch1, k_RInfo); |
|
1382 |
||
1383 |
__ br(Assembler::NE, *failure_target); |
|
1384 |
// successful cast, fall through to profile or jump |
|
1385 |
} else { |
|
1386 |
// get object class |
|
1387 |
// not a safepoint as obj null check happens earlier |
|
1388 |
__ load_klass(klass_RInfo, obj); |
|
1389 |
if (k->is_loaded()) { |
|
1390 |
// See if we get an immediate positive hit |
|
1391 |
__ ldr(rscratch1, Address(klass_RInfo, long(k->super_check_offset()))); |
|
1392 |
__ cmp(k_RInfo, rscratch1); |
|
1393 |
if ((juint)in_bytes(Klass::secondary_super_cache_offset()) != k->super_check_offset()) { |
|
1394 |
__ br(Assembler::NE, *failure_target); |
|
1395 |
// successful cast, fall through to profile or jump |
|
1396 |
} else { |
|
1397 |
// See if we get an immediate positive hit |
|
1398 |
__ br(Assembler::EQ, *success_target); |
|
1399 |
// check for self |
|
1400 |
__ cmp(klass_RInfo, k_RInfo); |
|
1401 |
__ br(Assembler::EQ, *success_target); |
|
1402 |
||
1403 |
__ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize))); |
|
1404 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); |
|
1405 |
__ ldr(klass_RInfo, Address(__ post(sp, 2 * wordSize))); |
|
1406 |
// result is a boolean |
|
1407 |
__ cbzw(klass_RInfo, *failure_target); |
|
1408 |
// successful cast, fall through to profile or jump |
|
1409 |
} |
|
1410 |
} else { |
|
1411 |
// perform the fast part of the checking logic |
|
1412 |
__ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL); |
|
1413 |
// call out-of-line instance of __ check_klass_subtype_slow_path(...): |
|
1414 |
__ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize))); |
|
1415 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); |
|
1416 |
__ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize))); |
|
1417 |
// result is a boolean |
|
1418 |
__ cbz(k_RInfo, *failure_target); |
|
1419 |
// successful cast, fall through to profile or jump |
|
1420 |
} |
|
1421 |
} |
|
35127 | 1422 |
if (should_profile) { |
29184 | 1423 |
Register mdo = klass_RInfo, recv = k_RInfo; |
1424 |
__ bind(profile_cast_success); |
|
1425 |
__ mov_metadata(mdo, md->constant_encoding()); |
|
1426 |
__ load_klass(recv, obj); |
|
1427 |
Label update_done; |
|
1428 |
type_profile_helper(mdo, md, data, recv, success); |
|
1429 |
__ b(*success); |
|
1430 |
||
1431 |
__ bind(profile_cast_failure); |
|
1432 |
__ mov_metadata(mdo, md->constant_encoding()); |
|
1433 |
Address counter_addr |
|
1434 |
= __ form_address(rscratch2, mdo, |
|
1435 |
md->byte_offset_of_slot(data, CounterData::count_offset()), |
|
1436 |
LogBytesPerWord); |
|
1437 |
__ ldr(rscratch1, counter_addr); |
|
1438 |
__ sub(rscratch1, rscratch1, DataLayout::counter_increment); |
|
1439 |
__ str(rscratch1, counter_addr); |
|
1440 |
__ b(*failure); |
|
1441 |
} |
|
1442 |
__ b(*success); |
|
1443 |
} |
|
1444 |
||
1445 |
||
1446 |
void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { |
|
35127 | 1447 |
const bool should_profile = op->should_profile(); |
1448 |
||
29184 | 1449 |
LIR_Code code = op->code(); |
1450 |
if (code == lir_store_check) { |
|
1451 |
Register value = op->object()->as_register(); |
|
1452 |
Register array = op->array()->as_register(); |
|
1453 |
Register k_RInfo = op->tmp1()->as_register(); |
|
1454 |
Register klass_RInfo = op->tmp2()->as_register(); |
|
1455 |
Register Rtmp1 = op->tmp3()->as_register(); |
|
1456 |
||
1457 |
CodeStub* stub = op->stub(); |
|
1458 |
||
1459 |
// check if it needs to be profiled |
|
1460 |
ciMethodData* md; |
|
1461 |
ciProfileData* data; |
|
1462 |
||
35127 | 1463 |
if (should_profile) { |
29184 | 1464 |
ciMethod* method = op->profiled_method(); |
1465 |
assert(method != NULL, "Should have method"); |
|
1466 |
int bci = op->profiled_bci(); |
|
1467 |
md = method->method_data_or_null(); |
|
1468 |
assert(md != NULL, "Sanity"); |
|
1469 |
data = md->bci_to_data(bci); |
|
1470 |
assert(data != NULL, "need data for type check"); |
|
1471 |
assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check"); |
|
1472 |
} |
|
1473 |
Label profile_cast_success, profile_cast_failure, done; |
|
35127 | 1474 |
Label *success_target = should_profile ? &profile_cast_success : &done; |
1475 |
Label *failure_target = should_profile ? &profile_cast_failure : stub->entry(); |
|
1476 |
||
1477 |
if (should_profile) { |
|
29184 | 1478 |
Label not_null; |
1479 |
__ cbnz(value, not_null); |
|
1480 |
// Object is null; update MDO and exit |
|
1481 |
Register mdo = klass_RInfo; |
|
1482 |
__ mov_metadata(mdo, md->constant_encoding()); |
|
1483 |
Address data_addr |
|
1484 |
= __ form_address(rscratch2, mdo, |
|
1485 |
md->byte_offset_of_slot(data, DataLayout::header_offset()), |
|
1486 |
LogBytesPerInt); |
|
1487 |
int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant()); |
|
1488 |
__ ldrw(rscratch1, data_addr); |
|
1489 |
__ orrw(rscratch1, rscratch1, header_bits); |
|
1490 |
__ strw(rscratch1, data_addr); |
|
1491 |
__ b(done); |
|
1492 |
__ bind(not_null); |
|
1493 |
} else { |
|
1494 |
__ cbz(value, done); |
|
1495 |
} |
|
1496 |
||
1497 |
add_debug_info_for_null_check_here(op->info_for_exception()); |
|
1498 |
__ load_klass(k_RInfo, array); |
|
1499 |
__ load_klass(klass_RInfo, value); |
|
1500 |
||
1501 |
// get instance klass (it's already uncompressed) |
|
1502 |
__ ldr(k_RInfo, Address(k_RInfo, ObjArrayKlass::element_klass_offset())); |
|
1503 |
// perform the fast part of the checking logic |
|
1504 |
__ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL); |
|
1505 |
// call out-of-line instance of __ check_klass_subtype_slow_path(...): |
|
1506 |
__ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize))); |
|
1507 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); |
|
1508 |
__ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize))); |
|
1509 |
// result is a boolean |
|
1510 |
__ cbzw(k_RInfo, *failure_target); |
|
1511 |
// fall through to the success case |
|
1512 |
||
35127 | 1513 |
if (should_profile) { |
29184 | 1514 |
Register mdo = klass_RInfo, recv = k_RInfo; |
1515 |
__ bind(profile_cast_success); |
|
1516 |
__ mov_metadata(mdo, md->constant_encoding()); |
|
1517 |
__ load_klass(recv, value); |
|
1518 |
Label update_done; |
|
1519 |
type_profile_helper(mdo, md, data, recv, &done); |
|
1520 |
__ b(done); |
|
1521 |
||
1522 |
__ bind(profile_cast_failure); |
|
1523 |
__ mov_metadata(mdo, md->constant_encoding()); |
|
1524 |
Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset())); |
|
1525 |
__ lea(rscratch2, counter_addr); |
|
1526 |
__ ldr(rscratch1, Address(rscratch2)); |
|
1527 |
__ sub(rscratch1, rscratch1, DataLayout::counter_increment); |
|
1528 |
__ str(rscratch1, Address(rscratch2)); |
|
1529 |
__ b(*stub->entry()); |
|
1530 |
} |
|
1531 |
||
1532 |
__ bind(done); |
|
1533 |
} else if (code == lir_checkcast) { |
|
1534 |
Register obj = op->object()->as_register(); |
|
1535 |
Register dst = op->result_opr()->as_register(); |
|
1536 |
Label success; |
|
1537 |
emit_typecheck_helper(op, &success, op->stub()->entry(), &success); |
|
1538 |
__ bind(success); |
|
1539 |
if (dst != obj) { |
|
1540 |
__ mov(dst, obj); |
|
1541 |
} |
|
1542 |
} else if (code == lir_instanceof) { |
|
1543 |
Register obj = op->object()->as_register(); |
|
1544 |
Register dst = op->result_opr()->as_register(); |
|
1545 |
Label success, failure, done; |
|
1546 |
emit_typecheck_helper(op, &success, &failure, &failure); |
|
1547 |
__ bind(failure); |
|
1548 |
__ mov(dst, zr); |
|
1549 |
__ b(done); |
|
1550 |
__ bind(success); |
|
1551 |
__ mov(dst, 1); |
|
1552 |
__ bind(done); |
|
1553 |
} else { |
|
1554 |
ShouldNotReachHere(); |
|
1555 |
} |
|
1556 |
} |
|
1557 |
||
1558 |
void LIR_Assembler::casw(Register addr, Register newval, Register cmpval) { |
|
36562
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1559 |
if (UseLSE) { |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1560 |
__ mov(rscratch1, cmpval); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1561 |
__ casal(Assembler::word, rscratch1, newval, addr); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1562 |
__ cmpw(rscratch1, cmpval); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1563 |
__ cset(rscratch1, Assembler::NE); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1564 |
} else { |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1565 |
Label retry_load, nope; |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1566 |
// flush and load exclusive from the memory location |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1567 |
// and fail if it is not what we expect |
36565
8e38f7594806
8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents:
36562
diff
changeset
|
1568 |
__ prfm(Address(addr), PSTL1STRM); |
36562
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1569 |
__ bind(retry_load); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1570 |
__ ldaxrw(rscratch1, addr); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1571 |
__ cmpw(rscratch1, cmpval); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1572 |
__ cset(rscratch1, Assembler::NE); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1573 |
__ br(Assembler::NE, nope); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1574 |
// if we store+flush with no intervening write rscratch1 wil be zero |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1575 |
__ stlxrw(rscratch1, newval, addr); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1576 |
// retry so we only ever return after a load fails to compare |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1577 |
// ensures we don't return a stale value after a failed write. |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1578 |
__ cbnzw(rscratch1, retry_load); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1579 |
__ bind(nope); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1580 |
} |
29184 | 1581 |
__ membar(__ AnyAny); |
1582 |
} |
|
1583 |
||
1584 |
void LIR_Assembler::casl(Register addr, Register newval, Register cmpval) { |
|
36562
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1585 |
if (UseLSE) { |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1586 |
__ mov(rscratch1, cmpval); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1587 |
__ casal(Assembler::xword, rscratch1, newval, addr); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1588 |
__ cmp(rscratch1, cmpval); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1589 |
__ cset(rscratch1, Assembler::NE); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1590 |
} else { |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1591 |
Label retry_load, nope; |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1592 |
// flush and load exclusive from the memory location |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1593 |
// and fail if it is not what we expect |
36565
8e38f7594806
8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents:
36562
diff
changeset
|
1594 |
__ prfm(Address(addr), PSTL1STRM); |
36562
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1595 |
__ bind(retry_load); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1596 |
__ ldaxr(rscratch1, addr); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1597 |
__ cmp(rscratch1, cmpval); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1598 |
__ cset(rscratch1, Assembler::NE); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1599 |
__ br(Assembler::NE, nope); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1600 |
// if we store+flush with no intervening write rscratch1 wil be zero |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1601 |
__ stlxr(rscratch1, newval, addr); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1602 |
// retry so we only ever return after a load fails to compare |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1603 |
// ensures we don't return a stale value after a failed write. |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1604 |
__ cbnz(rscratch1, retry_load); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1605 |
__ bind(nope); |
4d1e93624d6a
8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents:
35584
diff
changeset
|
1606 |
} |
29184 | 1607 |
__ membar(__ AnyAny); |
1608 |
} |
|
1609 |
||
1610 |
||
1611 |
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) { |
|
1612 |
assert(VM_Version::supports_cx8(), "wrong machine"); |
|
1613 |
Register addr = as_reg(op->addr()); |
|
1614 |
Register newval = as_reg(op->new_value()); |
|
1615 |
Register cmpval = as_reg(op->cmp_value()); |
|
1616 |
Label succeed, fail, around; |
|
1617 |
||
1618 |
if (op->code() == lir_cas_obj) { |
|
1619 |
if (UseCompressedOops) { |
|
1620 |
Register t1 = op->tmp1()->as_register(); |
|
1621 |
assert(op->tmp1()->is_valid(), "must be"); |
|
1622 |
__ encode_heap_oop(t1, cmpval); |
|
1623 |
cmpval = t1; |
|
1624 |
__ encode_heap_oop(rscratch2, newval); |
|
1625 |
newval = rscratch2; |
|
1626 |
casw(addr, newval, cmpval); |
|
1627 |
} else { |
|
1628 |
casl(addr, newval, cmpval); |
|
1629 |
} |
|
1630 |
} else if (op->code() == lir_cas_int) { |
|
1631 |
casw(addr, newval, cmpval); |
|
1632 |
} else { |
|
1633 |
casl(addr, newval, cmpval); |
|
1634 |
} |
|
1635 |
} |
|
1636 |
||
1637 |
||
1638 |
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) { |
|
1639 |
||
1640 |
Assembler::Condition acond, ncond; |
|
1641 |
switch (condition) { |
|
1642 |
case lir_cond_equal: acond = Assembler::EQ; ncond = Assembler::NE; break; |
|
1643 |
case lir_cond_notEqual: acond = Assembler::NE; ncond = Assembler::EQ; break; |
|
1644 |
case lir_cond_less: acond = Assembler::LT; ncond = Assembler::GE; break; |
|
1645 |
case lir_cond_lessEqual: acond = Assembler::LE; ncond = Assembler::GT; break; |
|
1646 |
case lir_cond_greaterEqual: acond = Assembler::GE; ncond = Assembler::LT; break; |
|
1647 |
case lir_cond_greater: acond = Assembler::GT; ncond = Assembler::LE; break; |
|
35127 | 1648 |
case lir_cond_belowEqual: |
1649 |
case lir_cond_aboveEqual: |
|
29184 | 1650 |
default: ShouldNotReachHere(); |
35127 | 1651 |
acond = Assembler::EQ; ncond = Assembler::NE; // unreachable |
29184 | 1652 |
} |
1653 |
||
1654 |
assert(result->is_single_cpu() || result->is_double_cpu(), |
|
1655 |
"expect single register for result"); |
|
1656 |
if (opr1->is_constant() && opr2->is_constant() |
|
1657 |
&& opr1->type() == T_INT && opr2->type() == T_INT) { |
|
1658 |
jint val1 = opr1->as_jint(); |
|
1659 |
jint val2 = opr2->as_jint(); |
|
1660 |
if (val1 == 0 && val2 == 1) { |
|
1661 |
__ cset(result->as_register(), ncond); |
|
1662 |
return; |
|
1663 |
} else if (val1 == 1 && val2 == 0) { |
|
1664 |
__ cset(result->as_register(), acond); |
|
1665 |
return; |
|
1666 |
} |
|
1667 |
} |
|
1668 |
||
1669 |
if (opr1->is_constant() && opr2->is_constant() |
|
1670 |
&& opr1->type() == T_LONG && opr2->type() == T_LONG) { |
|
1671 |
jlong val1 = opr1->as_jlong(); |
|
1672 |
jlong val2 = opr2->as_jlong(); |
|
1673 |
if (val1 == 0 && val2 == 1) { |
|
1674 |
__ cset(result->as_register_lo(), ncond); |
|
1675 |
return; |
|
1676 |
} else if (val1 == 1 && val2 == 0) { |
|
1677 |
__ cset(result->as_register_lo(), acond); |
|
1678 |
return; |
|
1679 |
} |
|
1680 |
} |
|
1681 |
||
1682 |
if (opr1->is_stack()) { |
|
1683 |
stack2reg(opr1, FrameMap::rscratch1_opr, result->type()); |
|
1684 |
opr1 = FrameMap::rscratch1_opr; |
|
1685 |
} else if (opr1->is_constant()) { |
|
1686 |
LIR_Opr tmp |
|
1687 |
= opr1->type() == T_LONG ? FrameMap::rscratch1_long_opr : FrameMap::rscratch1_opr; |
|
1688 |
const2reg(opr1, tmp, lir_patch_none, NULL); |
|
1689 |
opr1 = tmp; |
|
1690 |
} |
|
1691 |
||
1692 |
if (opr2->is_stack()) { |
|
1693 |
stack2reg(opr2, FrameMap::rscratch2_opr, result->type()); |
|
1694 |
opr2 = FrameMap::rscratch2_opr; |
|
1695 |
} else if (opr2->is_constant()) { |
|
1696 |
LIR_Opr tmp |
|
1697 |
= opr2->type() == T_LONG ? FrameMap::rscratch2_long_opr : FrameMap::rscratch2_opr; |
|
1698 |
const2reg(opr2, tmp, lir_patch_none, NULL); |
|
1699 |
opr2 = tmp; |
|
1700 |
} |
|
1701 |
||
1702 |
if (result->type() == T_LONG) |
|
1703 |
__ csel(result->as_register_lo(), opr1->as_register_lo(), opr2->as_register_lo(), acond); |
|
1704 |
else |
|
1705 |
__ csel(result->as_register(), opr1->as_register(), opr2->as_register(), acond); |
|
1706 |
} |
|
1707 |
||
1708 |
void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack) { |
|
1709 |
assert(info == NULL, "should never be used, idiv/irem and ldiv/lrem not handled by this method"); |
|
1710 |
||
1711 |
if (left->is_single_cpu()) { |
|
1712 |
Register lreg = left->as_register(); |
|
1713 |
Register dreg = as_reg(dest); |
|
1714 |
||
1715 |
if (right->is_single_cpu()) { |
|
1716 |
// cpu register - cpu register |
|
1717 |
||
1718 |
assert(left->type() == T_INT && right->type() == T_INT && dest->type() == T_INT, |
|
1719 |
"should be"); |
|
1720 |
Register rreg = right->as_register(); |
|
1721 |
switch (code) { |
|
1722 |
case lir_add: __ addw (dest->as_register(), lreg, rreg); break; |
|
1723 |
case lir_sub: __ subw (dest->as_register(), lreg, rreg); break; |
|
1724 |
case lir_mul: __ mulw (dest->as_register(), lreg, rreg); break; |
|
1725 |
default: ShouldNotReachHere(); |
|
1726 |
} |
|
1727 |
||
1728 |
} else if (right->is_double_cpu()) { |
|
1729 |
Register rreg = right->as_register_lo(); |
|
1730 |
// single_cpu + double_cpu: can happen with obj+long |
|
1731 |
assert(code == lir_add || code == lir_sub, "mismatched arithmetic op"); |
|
1732 |
switch (code) { |
|
1733 |
case lir_add: __ add(dreg, lreg, rreg); break; |
|
1734 |
case lir_sub: __ sub(dreg, lreg, rreg); break; |
|
1735 |
default: ShouldNotReachHere(); |
|
1736 |
} |
|
1737 |
} else if (right->is_constant()) { |
|
1738 |
// cpu register - constant |
|
1739 |
jlong c; |
|
1740 |
||
1741 |
// FIXME. This is fugly: we really need to factor all this logic. |
|
1742 |
switch(right->type()) { |
|
1743 |
case T_LONG: |
|
1744 |
c = right->as_constant_ptr()->as_jlong(); |
|
1745 |
break; |
|
1746 |
case T_INT: |
|
1747 |
case T_ADDRESS: |
|
1748 |
c = right->as_constant_ptr()->as_jint(); |
|
1749 |
break; |
|
1750 |
default: |
|
1751 |
ShouldNotReachHere(); |
|
35127 | 1752 |
c = 0; // unreachable |
29184 | 1753 |
break; |
1754 |
} |
|
1755 |
||
1756 |
assert(code == lir_add || code == lir_sub, "mismatched arithmetic op"); |
|
1757 |
if (c == 0 && dreg == lreg) { |
|
1758 |
COMMENT("effective nop elided"); |
|
1759 |
return; |
|
1760 |
} |
|
1761 |
switch(left->type()) { |
|
1762 |
case T_INT: |
|
1763 |
switch (code) { |
|
1764 |
case lir_add: __ addw(dreg, lreg, c); break; |
|
1765 |
case lir_sub: __ subw(dreg, lreg, c); break; |
|
1766 |
default: ShouldNotReachHere(); |
|
1767 |
} |
|
1768 |
break; |
|
1769 |
case T_OBJECT: |
|
1770 |
case T_ADDRESS: |
|
1771 |
switch (code) { |
|
1772 |
case lir_add: __ add(dreg, lreg, c); break; |
|
1773 |
case lir_sub: __ sub(dreg, lreg, c); break; |
|
1774 |
default: ShouldNotReachHere(); |
|
1775 |
} |
|
1776 |
break; |
|
1777 |
ShouldNotReachHere(); |
|
1778 |
} |
|
1779 |
} else { |
|
1780 |
ShouldNotReachHere(); |
|
1781 |
} |
|
1782 |
||
1783 |
} else if (left->is_double_cpu()) { |
|
1784 |
Register lreg_lo = left->as_register_lo(); |
|
1785 |
||
1786 |
if (right->is_double_cpu()) { |
|
1787 |
// cpu register - cpu register |
|
1788 |
Register rreg_lo = right->as_register_lo(); |
|
1789 |
switch (code) { |
|
1790 |
case lir_add: __ add (dest->as_register_lo(), lreg_lo, rreg_lo); break; |
|
1791 |
case lir_sub: __ sub (dest->as_register_lo(), lreg_lo, rreg_lo); break; |
|
1792 |
case lir_mul: __ mul (dest->as_register_lo(), lreg_lo, rreg_lo); break; |
|
1793 |
case lir_div: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, false, rscratch1); break; |
|
1794 |
case lir_rem: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, true, rscratch1); break; |
|
1795 |
default: |
|
1796 |
ShouldNotReachHere(); |
|
1797 |
} |
|
1798 |
||
1799 |
} else if (right->is_constant()) { |
|
1800 |
jlong c = right->as_constant_ptr()->as_jlong_bits(); |
|
1801 |
Register dreg = as_reg(dest); |
|
1802 |
assert(code == lir_add || code == lir_sub, "mismatched arithmetic op"); |
|
1803 |
if (c == 0 && dreg == lreg_lo) { |
|
1804 |
COMMENT("effective nop elided"); |
|
1805 |
return; |
|
1806 |
} |
|
1807 |
switch (code) { |
|
1808 |
case lir_add: __ add(dreg, lreg_lo, c); break; |
|
1809 |
case lir_sub: __ sub(dreg, lreg_lo, c); break; |
|
1810 |
default: |
|
1811 |
ShouldNotReachHere(); |
|
1812 |
} |
|
1813 |
} else { |
|
1814 |
ShouldNotReachHere(); |
|
1815 |
} |
|
1816 |
} else if (left->is_single_fpu()) { |
|
1817 |
assert(right->is_single_fpu(), "right hand side of float arithmetics needs to be float register"); |
|
1818 |
switch (code) { |
|
1819 |
case lir_add: __ fadds (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break; |
|
1820 |
case lir_sub: __ fsubs (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break; |
|
1821 |
case lir_mul: __ fmuls (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break; |
|
1822 |
case lir_div: __ fdivs (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break; |
|
1823 |
default: |
|
1824 |
ShouldNotReachHere(); |
|
1825 |
} |
|
1826 |
} else if (left->is_double_fpu()) { |
|
1827 |
if (right->is_double_fpu()) { |
|
1828 |
// cpu register - cpu register |
|
1829 |
switch (code) { |
|
1830 |
case lir_add: __ faddd (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break; |
|
1831 |
case lir_sub: __ fsubd (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break; |
|
1832 |
case lir_mul: __ fmuld (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break; |
|
1833 |
case lir_div: __ fdivd (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break; |
|
1834 |
default: |
|
1835 |
ShouldNotReachHere(); |
|
1836 |
} |
|
1837 |
} else { |
|
1838 |
if (right->is_constant()) { |
|
1839 |
ShouldNotReachHere(); |
|
1840 |
} |
|
1841 |
ShouldNotReachHere(); |
|
1842 |
} |
|
1843 |
} else if (left->is_single_stack() || left->is_address()) { |
|
1844 |
assert(left == dest, "left and dest must be equal"); |
|
1845 |
ShouldNotReachHere(); |
|
1846 |
} else { |
|
1847 |
ShouldNotReachHere(); |
|
1848 |
} |
|
1849 |
} |
|
1850 |
||
1851 |
void LIR_Assembler::arith_fpu_implementation(LIR_Code code, int left_index, int right_index, int dest_index, bool pop_fpu_stack) { Unimplemented(); } |
|
1852 |
||
1853 |
||
1854 |
void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr unused, LIR_Opr dest, LIR_Op* op) { |
|
1855 |
switch(code) { |
|
1856 |
case lir_abs : __ fabsd(dest->as_double_reg(), value->as_double_reg()); break; |
|
1857 |
case lir_sqrt: __ fsqrtd(dest->as_double_reg(), value->as_double_reg()); break; |
|
1858 |
default : ShouldNotReachHere(); |
|
1859 |
} |
|
1860 |
} |
|
1861 |
||
1862 |
void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) { |
|
1863 |
||
1864 |
assert(left->is_single_cpu() || left->is_double_cpu(), "expect single or double register"); |
|
1865 |
Register Rleft = left->is_single_cpu() ? left->as_register() : |
|
1866 |
left->as_register_lo(); |
|
1867 |
if (dst->is_single_cpu()) { |
|
1868 |
Register Rdst = dst->as_register(); |
|
1869 |
if (right->is_constant()) { |
|
1870 |
switch (code) { |
|
1871 |
case lir_logic_and: __ andw (Rdst, Rleft, right->as_jint()); break; |
|
1872 |
case lir_logic_or: __ orrw (Rdst, Rleft, right->as_jint()); break; |
|
1873 |
case lir_logic_xor: __ eorw (Rdst, Rleft, right->as_jint()); break; |
|
1874 |
default: ShouldNotReachHere(); break; |
|
1875 |
} |
|
1876 |
} else { |
|
1877 |
Register Rright = right->is_single_cpu() ? right->as_register() : |
|
1878 |
right->as_register_lo(); |
|
1879 |
switch (code) { |
|
1880 |
case lir_logic_and: __ andw (Rdst, Rleft, Rright); break; |
|
1881 |
case lir_logic_or: __ orrw (Rdst, Rleft, Rright); break; |
|
1882 |
case lir_logic_xor: __ eorw (Rdst, Rleft, Rright); break; |
|
1883 |
default: ShouldNotReachHere(); break; |
|
1884 |
} |
|
1885 |
} |
|
1886 |
} else { |
|
1887 |
Register Rdst = dst->as_register_lo(); |
|
1888 |
if (right->is_constant()) { |
|
1889 |
switch (code) { |
|
1890 |
case lir_logic_and: __ andr (Rdst, Rleft, right->as_jlong()); break; |
|
1891 |
case lir_logic_or: __ orr (Rdst, Rleft, right->as_jlong()); break; |
|
1892 |
case lir_logic_xor: __ eor (Rdst, Rleft, right->as_jlong()); break; |
|
1893 |
default: ShouldNotReachHere(); break; |
|
1894 |
} |
|
1895 |
} else { |
|
1896 |
Register Rright = right->is_single_cpu() ? right->as_register() : |
|
1897 |
right->as_register_lo(); |
|
1898 |
switch (code) { |
|
1899 |
case lir_logic_and: __ andr (Rdst, Rleft, Rright); break; |
|
1900 |
case lir_logic_or: __ orr (Rdst, Rleft, Rright); break; |
|
1901 |
case lir_logic_xor: __ eor (Rdst, Rleft, Rright); break; |
|
1902 |
default: ShouldNotReachHere(); break; |
|
1903 |
} |
|
1904 |
} |
|
1905 |
} |
|
1906 |
} |
|
1907 |
||
1908 |
||
1909 |
||
1910 |
void LIR_Assembler::arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info) { Unimplemented(); } |
|
1911 |
||
1912 |
||
1913 |
void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) { |
|
1914 |
if (opr1->is_constant() && opr2->is_single_cpu()) { |
|
1915 |
// tableswitch |
|
1916 |
Register reg = as_reg(opr2); |
|
1917 |
struct tableswitch &table = switches[opr1->as_constant_ptr()->as_jint()]; |
|
1918 |
__ tableswitch(reg, table._first_key, table._last_key, table._branches, table._after); |
|
1919 |
} else if (opr1->is_single_cpu() || opr1->is_double_cpu()) { |
|
1920 |
Register reg1 = as_reg(opr1); |
|
1921 |
if (opr2->is_single_cpu()) { |
|
1922 |
// cpu register - cpu register |
|
1923 |
Register reg2 = opr2->as_register(); |
|
1924 |
if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) { |
|
1925 |
__ cmp(reg1, reg2); |
|
1926 |
} else { |
|
1927 |
assert(opr2->type() != T_OBJECT && opr2->type() != T_ARRAY, "cmp int, oop?"); |
|
1928 |
__ cmpw(reg1, reg2); |
|
1929 |
} |
|
1930 |
return; |
|
1931 |
} |
|
1932 |
if (opr2->is_double_cpu()) { |
|
1933 |
// cpu register - cpu register |
|
1934 |
Register reg2 = opr2->as_register_lo(); |
|
1935 |
__ cmp(reg1, reg2); |
|
1936 |
return; |
|
1937 |
} |
|
1938 |
||
1939 |
if (opr2->is_constant()) { |
|
1940 |
jlong imm; |
|
1941 |
switch(opr2->type()) { |
|
1942 |
case T_LONG: |
|
1943 |
imm = opr2->as_constant_ptr()->as_jlong(); |
|
1944 |
break; |
|
1945 |
case T_INT: |
|
1946 |
case T_ADDRESS: |
|
1947 |
imm = opr2->as_constant_ptr()->as_jint(); |
|
1948 |
break; |
|
1949 |
case T_OBJECT: |
|
1950 |
case T_ARRAY: |
|
1951 |
imm = jlong(opr2->as_constant_ptr()->as_jobject()); |
|
1952 |
break; |
|
1953 |
default: |
|
1954 |
ShouldNotReachHere(); |
|
35127 | 1955 |
imm = 0; // unreachable |
29184 | 1956 |
break; |
1957 |
} |
|
1958 |
||
1959 |
if (Assembler::operand_valid_for_add_sub_immediate(imm)) { |
|
1960 |
if (type2aelembytes(opr1->type()) <= 4) |
|
1961 |
__ cmpw(reg1, imm); |
|
1962 |
else |
|
1963 |
__ cmp(reg1, imm); |
|
1964 |
return; |
|
1965 |
} else { |
|
1966 |
__ mov(rscratch1, imm); |
|
1967 |
if (type2aelembytes(opr1->type()) <= 4) |
|
1968 |
__ cmpw(reg1, rscratch1); |
|
1969 |
else |
|
1970 |
__ cmp(reg1, rscratch1); |
|
1971 |
return; |
|
1972 |
} |
|
1973 |
} else |
|
1974 |
ShouldNotReachHere(); |
|
1975 |
} else if (opr1->is_single_fpu()) { |
|
1976 |
FloatRegister reg1 = opr1->as_float_reg(); |
|
1977 |
assert(opr2->is_single_fpu(), "expect single float register"); |
|
1978 |
FloatRegister reg2 = opr2->as_float_reg(); |
|
1979 |
__ fcmps(reg1, reg2); |
|
1980 |
} else if (opr1->is_double_fpu()) { |
|
1981 |
FloatRegister reg1 = opr1->as_double_reg(); |
|
1982 |
assert(opr2->is_double_fpu(), "expect double float register"); |
|
1983 |
FloatRegister reg2 = opr2->as_double_reg(); |
|
1984 |
__ fcmpd(reg1, reg2); |
|
1985 |
} else { |
|
1986 |
ShouldNotReachHere(); |
|
1987 |
} |
|
1988 |
} |
|
1989 |
||
1990 |
void LIR_Assembler::comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst, LIR_Op2* op){ |
|
1991 |
if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) { |
|
1992 |
bool is_unordered_less = (code == lir_ucmp_fd2i); |
|
1993 |
if (left->is_single_fpu()) { |
|
1994 |
__ float_cmp(true, is_unordered_less ? -1 : 1, left->as_float_reg(), right->as_float_reg(), dst->as_register()); |
|
1995 |
} else if (left->is_double_fpu()) { |
|
1996 |
__ float_cmp(false, is_unordered_less ? -1 : 1, left->as_double_reg(), right->as_double_reg(), dst->as_register()); |
|
1997 |
} else { |
|
1998 |
ShouldNotReachHere(); |
|
1999 |
} |
|
2000 |
} else if (code == lir_cmp_l2i) { |
|
2001 |
Label done; |
|
2002 |
__ cmp(left->as_register_lo(), right->as_register_lo()); |
|
2003 |
__ mov(dst->as_register(), (u_int64_t)-1L); |
|
2004 |
__ br(Assembler::LT, done); |
|
2005 |
__ csinc(dst->as_register(), zr, zr, Assembler::EQ); |
|
2006 |
__ bind(done); |
|
2007 |
} else { |
|
2008 |
ShouldNotReachHere(); |
|
2009 |
} |
|
2010 |
} |
|
2011 |
||
2012 |
||
2013 |
void LIR_Assembler::align_call(LIR_Code code) { } |
|
2014 |
||
2015 |
||
2016 |
void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) { |
|
32082
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2017 |
address call = __ trampoline_call(Address(op->addr(), rtype)); |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2018 |
if (call == NULL) { |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2019 |
bailout("trampoline stub overflow"); |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2020 |
return; |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2021 |
} |
29184 | 2022 |
add_call_info(code_offset(), op->info()); |
2023 |
} |
|
2024 |
||
2025 |
||
2026 |
void LIR_Assembler::ic_call(LIR_OpJavaCall* op) { |
|
32082
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2027 |
address call = __ ic_call(op->addr()); |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2028 |
if (call == NULL) { |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2029 |
bailout("trampoline stub overflow"); |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2030 |
return; |
2a3323e25de1
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents:
30764
diff
changeset
|
2031 |
} |
29184 | 2032 |
add_call_info(code_offset(), op->info()); |
2033 |
} |
|
2034 |
||
2035 |
||
2036 |
/* Currently, vtable-dispatch is only enabled for sparc platforms */ |
|
2037 |
void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) { |
|
2038 |
ShouldNotReachHere(); |
|
2039 |
} |
|
2040 |
||
2041 |
||
2042 |
void LIR_Assembler::emit_static_call_stub() { |
|
2043 |
address call_pc = __ pc(); |
|
2044 |
address stub = __ start_a_stub(call_stub_size); |
|
2045 |
if (stub == NULL) { |
|
2046 |
bailout("static call stub overflow"); |
|
2047 |
return; |
|
2048 |
} |
|
2049 |
||
2050 |
int start = __ offset(); |
|
2051 |
||
2052 |
__ relocate(static_stub_Relocation::spec(call_pc)); |
|
2053 |
__ mov_metadata(rmethod, (Metadata*)NULL); |
|
2054 |
__ movptr(rscratch1, 0); |
|
2055 |
__ br(rscratch1); |
|
2056 |
||
2057 |
assert(__ offset() - start <= call_stub_size, "stub too big"); |
|
2058 |
__ end_a_stub(); |
|
2059 |
} |
|
2060 |
||
2061 |
||
2062 |
void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) { |
|
2063 |
assert(exceptionOop->as_register() == r0, "must match"); |
|
2064 |
assert(exceptionPC->as_register() == r3, "must match"); |
|
2065 |
||
2066 |
// exception object is not added to oop map by LinearScan |
|
2067 |
// (LinearScan assumes that no oops are in fixed registers) |
|
2068 |
info->add_register_oop(exceptionOop); |
|
2069 |
Runtime1::StubID unwind_id; |
|
2070 |
||
2071 |
// get current pc information |
|
2072 |
// pc is only needed if the method has an exception handler, the unwind code does not need it. |
|
2073 |
int pc_for_athrow_offset = __ offset(); |
|
2074 |
InternalAddress pc_for_athrow(__ pc()); |
|
2075 |
__ adr(exceptionPC->as_register(), pc_for_athrow); |
|
2076 |
add_call_info(pc_for_athrow_offset, info); // for exception handler |
|
2077 |
||
2078 |
__ verify_not_null_oop(r0); |
|
2079 |
// search an exception handler (r0: exception oop, r3: throwing pc) |
|
2080 |
if (compilation()->has_fpu_code()) { |
|
2081 |
unwind_id = Runtime1::handle_exception_id; |
|
2082 |
} else { |
|
2083 |
unwind_id = Runtime1::handle_exception_nofpu_id; |
|
2084 |
} |
|
2085 |
__ far_call(RuntimeAddress(Runtime1::entry_for(unwind_id))); |
|
2086 |
||
2087 |
// FIXME: enough room for two byte trap ???? |
|
2088 |
__ nop(); |
|
2089 |
} |
|
2090 |
||
2091 |
||
2092 |
void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) { |
|
2093 |
assert(exceptionOop->as_register() == r0, "must match"); |
|
2094 |
||
2095 |
__ b(_unwind_handler_entry); |
|
2096 |
} |
|
2097 |
||
2098 |
||
2099 |
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) { |
|
2100 |
Register lreg = left->is_single_cpu() ? left->as_register() : left->as_register_lo(); |
|
2101 |
Register dreg = dest->is_single_cpu() ? dest->as_register() : dest->as_register_lo(); |
|
2102 |
||
2103 |
switch (left->type()) { |
|
2104 |
case T_INT: { |
|
2105 |
switch (code) { |
|
2106 |
case lir_shl: __ lslvw (dreg, lreg, count->as_register()); break; |
|
2107 |
case lir_shr: __ asrvw (dreg, lreg, count->as_register()); break; |
|
2108 |
case lir_ushr: __ lsrvw (dreg, lreg, count->as_register()); break; |
|
2109 |
default: |
|
2110 |
ShouldNotReachHere(); |
|
2111 |
break; |
|
2112 |
} |
|
2113 |
break; |
|
2114 |
case T_LONG: |
|
2115 |
case T_ADDRESS: |
|
2116 |
case T_OBJECT: |
|
2117 |
switch (code) { |
|
2118 |
case lir_shl: __ lslv (dreg, lreg, count->as_register()); break; |
|
2119 |
case lir_shr: __ asrv (dreg, lreg, count->as_register()); break; |
|
2120 |
case lir_ushr: __ lsrv (dreg, lreg, count->as_register()); break; |
|
2121 |
default: |
|
2122 |
ShouldNotReachHere(); |
|
2123 |
break; |
|
2124 |
} |
|
2125 |
break; |
|
2126 |
default: |
|
2127 |
ShouldNotReachHere(); |
|
2128 |
break; |
|
2129 |
} |
|
2130 |
} |
|
2131 |
} |
|
2132 |
||
2133 |
||
2134 |
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) { |
|
2135 |
Register dreg = dest->is_single_cpu() ? dest->as_register() : dest->as_register_lo(); |
|
2136 |
Register lreg = left->is_single_cpu() ? left->as_register() : left->as_register_lo(); |
|
2137 |
||
2138 |
switch (left->type()) { |
|
2139 |
case T_INT: { |
|
2140 |
switch (code) { |
|
2141 |
case lir_shl: __ lslw (dreg, lreg, count); break; |
|
2142 |
case lir_shr: __ asrw (dreg, lreg, count); break; |
|
2143 |
case lir_ushr: __ lsrw (dreg, lreg, count); break; |
|
2144 |
default: |
|
2145 |
ShouldNotReachHere(); |
|
2146 |
break; |
|
2147 |
} |
|
2148 |
break; |
|
2149 |
case T_LONG: |
|
2150 |
case T_ADDRESS: |
|
2151 |
case T_OBJECT: |
|
2152 |
switch (code) { |
|
2153 |
case lir_shl: __ lsl (dreg, lreg, count); break; |
|
2154 |
case lir_shr: __ asr (dreg, lreg, count); break; |
|
2155 |
case lir_ushr: __ lsr (dreg, lreg, count); break; |
|
2156 |
default: |
|
2157 |
ShouldNotReachHere(); |
|
2158 |
break; |
|
2159 |
} |
|
2160 |
break; |
|
2161 |
default: |
|
2162 |
ShouldNotReachHere(); |
|
2163 |
break; |
|
2164 |
} |
|
2165 |
} |
|
2166 |
} |
|
2167 |
||
2168 |
||
2169 |
void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) { |
|
2170 |
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp"); |
|
2171 |
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord; |
|
2172 |
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset"); |
|
2173 |
__ str (r, Address(sp, offset_from_rsp_in_bytes)); |
|
2174 |
} |
|
2175 |
||
2176 |
||
2177 |
void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) { |
|
2178 |
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp"); |
|
2179 |
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord; |
|
2180 |
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset"); |
|
2181 |
__ mov (rscratch1, c); |
|
2182 |
__ str (rscratch1, Address(sp, offset_from_rsp_in_bytes)); |
|
2183 |
} |
|
2184 |
||
2185 |
||
2186 |
void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) { |
|
2187 |
ShouldNotReachHere(); |
|
2188 |
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp"); |
|
2189 |
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord; |
|
2190 |
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset"); |
|
2191 |
__ lea(rscratch1, __ constant_oop_address(o)); |
|
2192 |
__ str(rscratch1, Address(sp, offset_from_rsp_in_bytes)); |
|
2193 |
} |
|
2194 |
||
2195 |
||
2196 |
// This code replaces a call to arraycopy; no exception may |
|
2197 |
// be thrown in this code, they must be thrown in the System.arraycopy |
|
2198 |
// activation frame; we could save some checks if this would not be the case |
|
2199 |
void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { |
|
2200 |
ciArrayKlass* default_type = op->expected_type(); |
|
2201 |
Register src = op->src()->as_register(); |
|
2202 |
Register dst = op->dst()->as_register(); |
|
2203 |
Register src_pos = op->src_pos()->as_register(); |
|
2204 |
Register dst_pos = op->dst_pos()->as_register(); |
|
2205 |
Register length = op->length()->as_register(); |
|
2206 |
Register tmp = op->tmp()->as_register(); |
|
2207 |
||
2208 |
CodeStub* stub = op->stub(); |
|
2209 |
int flags = op->flags(); |
|
2210 |
BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL; |
|
2211 |
if (basic_type == T_ARRAY) basic_type = T_OBJECT; |
|
2212 |
||
2213 |
// if we don't know anything, just go through the generic arraycopy |
|
2214 |
if (default_type == NULL // || basic_type == T_OBJECT |
|
2215 |
) { |
|
2216 |
Label done; |
|
2217 |
assert(src == r1 && src_pos == r2, "mismatch in calling convention"); |
|
2218 |
||
2219 |
// Save the arguments in case the generic arraycopy fails and we |
|
2220 |
// have to fall back to the JNI stub |
|
2221 |
__ stp(dst, dst_pos, Address(sp, 0*BytesPerWord)); |
|
2222 |
__ stp(length, src_pos, Address(sp, 2*BytesPerWord)); |
|
2223 |
__ str(src, Address(sp, 4*BytesPerWord)); |
|
2224 |
||
2225 |
address C_entry = CAST_FROM_FN_PTR(address, Runtime1::arraycopy); |
|
2226 |
address copyfunc_addr = StubRoutines::generic_arraycopy(); |
|
2227 |
||
2228 |
// The arguments are in java calling convention so we shift them |
|
2229 |
// to C convention |
|
2230 |
assert_different_registers(c_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4); |
|
2231 |
__ mov(c_rarg0, j_rarg0); |
|
2232 |
assert_different_registers(c_rarg1, j_rarg2, j_rarg3, j_rarg4); |
|
2233 |
__ mov(c_rarg1, j_rarg1); |
|
2234 |
assert_different_registers(c_rarg2, j_rarg3, j_rarg4); |
|
2235 |
__ mov(c_rarg2, j_rarg2); |
|
2236 |
assert_different_registers(c_rarg3, j_rarg4); |
|
2237 |
__ mov(c_rarg3, j_rarg3); |
|
2238 |
__ mov(c_rarg4, j_rarg4); |
|
2239 |
if (copyfunc_addr == NULL) { // Use C version if stub was not generated |
|
2240 |
__ mov(rscratch1, RuntimeAddress(C_entry)); |
|
2241 |
__ blrt(rscratch1, 5, 0, 1); |
|
2242 |
} else { |
|
2243 |
#ifndef PRODUCT |
|
2244 |
if (PrintC1Statistics) { |
|
2245 |
__ incrementw(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt)); |
|
2246 |
} |
|
2247 |
#endif |
|
2248 |
__ far_call(RuntimeAddress(copyfunc_addr)); |
|
2249 |
} |
|
2250 |
||
2251 |
__ cbz(r0, *stub->continuation()); |
|
2252 |
||
2253 |
// Reload values from the stack so they are where the stub |
|
2254 |
// expects them. |
|
2255 |
__ ldp(dst, dst_pos, Address(sp, 0*BytesPerWord)); |
|
2256 |
__ ldp(length, src_pos, Address(sp, 2*BytesPerWord)); |
|
2257 |
__ ldr(src, Address(sp, 4*BytesPerWord)); |
|
2258 |
||
2259 |
if (copyfunc_addr != NULL) { |
|
2260 |
// r0 is -1^K where K == partial copied count |
|
2261 |
__ eonw(rscratch1, r0, 0); |
|
2262 |
// adjust length down and src/end pos up by partial copied count |
|
2263 |
__ subw(length, length, rscratch1); |
|
2264 |
__ addw(src_pos, src_pos, rscratch1); |
|
2265 |
__ addw(dst_pos, dst_pos, rscratch1); |
|
2266 |
} |
|
2267 |
__ b(*stub->entry()); |
|
2268 |
||
2269 |
__ bind(*stub->continuation()); |
|
2270 |
return; |
|
2271 |
} |
|
2272 |
||
2273 |
assert(default_type != NULL && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point"); |
|
2274 |
||
2275 |
int elem_size = type2aelembytes(basic_type); |
|
2276 |
int shift_amount; |
|
2277 |
int scale = exact_log2(elem_size); |
|
2278 |
||
2279 |
Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes()); |
|
2280 |
Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes()); |
|
2281 |
Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes()); |
|
2282 |
Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes()); |
|
2283 |
||
2284 |
// test for NULL |
|
2285 |
if (flags & LIR_OpArrayCopy::src_null_check) { |
|
2286 |
__ cbz(src, *stub->entry()); |
|
2287 |
} |
|
2288 |
if (flags & LIR_OpArrayCopy::dst_null_check) { |
|
2289 |
__ cbz(dst, *stub->entry()); |
|
2290 |
} |
|
2291 |
||
2292 |
// check if negative |
|
2293 |
if (flags & LIR_OpArrayCopy::src_pos_positive_check) { |
|
2294 |
__ cmpw(src_pos, 0); |
|
2295 |
__ br(Assembler::LT, *stub->entry()); |
|
2296 |
} |
|
2297 |
if (flags & LIR_OpArrayCopy::dst_pos_positive_check) { |
|
2298 |
__ cmpw(dst_pos, 0); |
|
2299 |
__ br(Assembler::LT, *stub->entry()); |
|
2300 |
} |
|
2301 |
||
2302 |
if (flags & LIR_OpArrayCopy::length_positive_check) { |
|
2303 |
__ cmpw(length, 0); |
|
2304 |
__ br(Assembler::LT, *stub->entry()); |
|
2305 |
} |
|
2306 |
||
2307 |
if (flags & LIR_OpArrayCopy::src_range_check) { |
|
2308 |
__ addw(tmp, src_pos, length); |
|
2309 |
__ ldrw(rscratch1, src_length_addr); |
|
2310 |
__ cmpw(tmp, rscratch1); |
|
2311 |
__ br(Assembler::HI, *stub->entry()); |
|
2312 |
} |
|
2313 |
if (flags & LIR_OpArrayCopy::dst_range_check) { |
|
2314 |
__ addw(tmp, dst_pos, length); |
|
2315 |
__ ldrw(rscratch1, dst_length_addr); |
|
2316 |
__ cmpw(tmp, rscratch1); |
|
2317 |
__ br(Assembler::HI, *stub->entry()); |
|
2318 |
} |
|
2319 |
||
2320 |
// FIXME: The logic in LIRGenerator::arraycopy_helper clears |
|
2321 |
// length_positive_check if the source of our length operand is an |
|
2322 |
// arraylength. However, that arraylength might be zero, and the |
|
2323 |
// stub that we're about to call contains an assertion that count != |
|
2324 |
// 0 . So we make this check purely in order not to trigger an |
|
2325 |
// assertion failure. |
|
2326 |
__ cbzw(length, *stub->continuation()); |
|
2327 |
||
2328 |
if (flags & LIR_OpArrayCopy::type_check) { |
|
2329 |
// We don't know the array types are compatible |
|
2330 |
if (basic_type != T_OBJECT) { |
|
2331 |
// Simple test for basic type arrays |
|
2332 |
if (UseCompressedClassPointers) { |
|
2333 |
__ ldrw(tmp, src_klass_addr); |
|
2334 |
__ ldrw(rscratch1, dst_klass_addr); |
|
2335 |
__ cmpw(tmp, rscratch1); |
|
2336 |
} else { |
|
2337 |
__ ldr(tmp, src_klass_addr); |
|
2338 |
__ ldr(rscratch1, dst_klass_addr); |
|
2339 |
__ cmp(tmp, rscratch1); |
|
2340 |
} |
|
2341 |
__ br(Assembler::NE, *stub->entry()); |
|
2342 |
} else { |
|
2343 |
// For object arrays, if src is a sub class of dst then we can |
|
2344 |
// safely do the copy. |
|
2345 |
Label cont, slow; |
|
2346 |
||
2347 |
#define PUSH(r1, r2) \ |
|
2348 |
stp(r1, r2, __ pre(sp, -2 * wordSize)); |
|
2349 |
||
2350 |
#define POP(r1, r2) \ |
|
2351 |
ldp(r1, r2, __ post(sp, 2 * wordSize)); |
|
2352 |
||
2353 |
__ PUSH(src, dst); |
|
2354 |
||
2355 |
__ load_klass(src, src); |
|
2356 |
__ load_klass(dst, dst); |
|
2357 |
||
2358 |
__ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL); |
|
2359 |
||
2360 |
__ PUSH(src, dst); |
|
2361 |
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); |
|
2362 |
__ POP(src, dst); |
|
2363 |
||
2364 |
__ cbnz(src, cont); |
|
2365 |
||
2366 |
__ bind(slow); |
|
2367 |
__ POP(src, dst); |
|
2368 |
||
2369 |
address copyfunc_addr = StubRoutines::checkcast_arraycopy(); |
|
2370 |
if (copyfunc_addr != NULL) { // use stub if available |
|
2371 |
// src is not a sub class of dst so we have to do a |
|
2372 |
// per-element check. |
|
2373 |
||
2374 |
int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray; |
|
2375 |
if ((flags & mask) != mask) { |
|
2376 |
// Check that at least both of them object arrays. |
|
2377 |
assert(flags & mask, "one of the two should be known to be an object array"); |
|
2378 |
||
2379 |
if (!(flags & LIR_OpArrayCopy::src_objarray)) { |
|
2380 |
__ load_klass(tmp, src); |
|
2381 |
} else if (!(flags & LIR_OpArrayCopy::dst_objarray)) { |
|
2382 |
__ load_klass(tmp, dst); |
|
2383 |
} |
|
2384 |
int lh_offset = in_bytes(Klass::layout_helper_offset()); |
|
2385 |
Address klass_lh_addr(tmp, lh_offset); |
|
2386 |
jint objArray_lh = Klass::array_layout_helper(T_OBJECT); |
|
2387 |
__ ldrw(rscratch1, klass_lh_addr); |
|
2388 |
__ mov(rscratch2, objArray_lh); |
|
2389 |
__ eorw(rscratch1, rscratch1, rscratch2); |
|
2390 |
__ cbnzw(rscratch1, *stub->entry()); |
|
2391 |
} |
|
2392 |
||
2393 |
// Spill because stubs can use any register they like and it's |
|
2394 |
// easier to restore just those that we care about. |
|
2395 |
__ stp(dst, dst_pos, Address(sp, 0*BytesPerWord)); |
|
2396 |
__ stp(length, src_pos, Address(sp, 2*BytesPerWord)); |
|
2397 |
__ str(src, Address(sp, 4*BytesPerWord)); |
|
2398 |
||
2399 |
__ lea(c_rarg0, Address(src, src_pos, Address::uxtw(scale))); |
|
2400 |
__ add(c_rarg0, c_rarg0, arrayOopDesc::base_offset_in_bytes(basic_type)); |
|
2401 |
assert_different_registers(c_rarg0, dst, dst_pos, length); |
|
2402 |
__ lea(c_rarg1, Address(dst, dst_pos, Address::uxtw(scale))); |
|
2403 |
__ add(c_rarg1, c_rarg1, arrayOopDesc::base_offset_in_bytes(basic_type)); |
|
2404 |
assert_different_registers(c_rarg1, dst, length); |
|
2405 |
__ uxtw(c_rarg2, length); |
|
2406 |
assert_different_registers(c_rarg2, dst); |
|
2407 |
||
2408 |
__ load_klass(c_rarg4, dst); |
|
2409 |
__ ldr(c_rarg4, Address(c_rarg4, ObjArrayKlass::element_klass_offset())); |
|
2410 |
__ ldrw(c_rarg3, Address(c_rarg4, Klass::super_check_offset_offset())); |
|
2411 |
__ far_call(RuntimeAddress(copyfunc_addr)); |
|
2412 |
||
2413 |
#ifndef PRODUCT |
|
2414 |
if (PrintC1Statistics) { |
|
2415 |
Label failed; |
|
2416 |
__ cbnz(r0, failed); |
|
2417 |
__ incrementw(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_cnt)); |
|
2418 |
__ bind(failed); |
|
2419 |
} |
|
2420 |
#endif |
|
2421 |
||
2422 |
__ cbz(r0, *stub->continuation()); |
|
2423 |
||
2424 |
#ifndef PRODUCT |
|
2425 |
if (PrintC1Statistics) { |
|
2426 |
__ incrementw(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_attempt_cnt)); |
|
2427 |
} |
|
2428 |
#endif |
|
2429 |
assert_different_registers(dst, dst_pos, length, src_pos, src, r0, rscratch1); |
|
2430 |
||
2431 |
// Restore previously spilled arguments |
|
2432 |
__ ldp(dst, dst_pos, Address(sp, 0*BytesPerWord)); |
|
2433 |
__ ldp(length, src_pos, Address(sp, 2*BytesPerWord)); |
|
2434 |
__ ldr(src, Address(sp, 4*BytesPerWord)); |
|
2435 |
||
2436 |
// return value is -1^K where K is partial copied count |
|
2437 |
__ eonw(rscratch1, r0, zr); |
|
2438 |
// adjust length down and src/end pos up by partial copied count |
|
2439 |
__ subw(length, length, rscratch1); |
|
2440 |
__ addw(src_pos, src_pos, rscratch1); |
|
2441 |
__ addw(dst_pos, dst_pos, rscratch1); |
|
2442 |
} |
|
2443 |
||
2444 |
__ b(*stub->entry()); |
|
2445 |
||
2446 |
__ bind(cont); |
|
2447 |
__ POP(src, dst); |
|
2448 |
} |
|
2449 |
} |
|
2450 |
||
2451 |
#ifdef ASSERT |
|
2452 |
if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) { |
|
2453 |
// Sanity check the known type with the incoming class. For the |
|
2454 |
// primitive case the types must match exactly with src.klass and |
|
2455 |
// dst.klass each exactly matching the default type. For the |
|
2456 |
// object array case, if no type check is needed then either the |
|
2457 |
// dst type is exactly the expected type and the src type is a |
|
2458 |
// subtype which we can't check or src is the same array as dst |
|
2459 |
// but not necessarily exactly of type default_type. |
|
2460 |
Label known_ok, halt; |
|
2461 |
__ mov_metadata(tmp, default_type->constant_encoding()); |
|
2462 |
if (UseCompressedClassPointers) { |
|
2463 |
__ encode_klass_not_null(tmp); |
|
2464 |
} |
|
2465 |
||
2466 |
if (basic_type != T_OBJECT) { |
|
2467 |
||
2468 |
if (UseCompressedClassPointers) { |
|
2469 |
__ ldrw(rscratch1, dst_klass_addr); |
|
2470 |
__ cmpw(tmp, rscratch1); |
|
2471 |
} else { |
|
2472 |
__ ldr(rscratch1, dst_klass_addr); |
|
2473 |
__ cmp(tmp, rscratch1); |
|
2474 |
} |
|
2475 |
__ br(Assembler::NE, halt); |
|
2476 |
if (UseCompressedClassPointers) { |
|
2477 |
__ ldrw(rscratch1, src_klass_addr); |
|
2478 |
__ cmpw(tmp, rscratch1); |
|
2479 |
} else { |
|
2480 |
__ ldr(rscratch1, src_klass_addr); |
|
2481 |
__ cmp(tmp, rscratch1); |
|
2482 |
} |
|
2483 |
__ br(Assembler::EQ, known_ok); |
|
2484 |
} else { |
|
2485 |
if (UseCompressedClassPointers) { |
|
2486 |
__ ldrw(rscratch1, dst_klass_addr); |
|
2487 |
__ cmpw(tmp, rscratch1); |
|
2488 |
} else { |
|
2489 |
__ ldr(rscratch1, dst_klass_addr); |
|
2490 |
__ cmp(tmp, rscratch1); |
|
2491 |
} |
|
2492 |
__ br(Assembler::EQ, known_ok); |
|
2493 |
__ cmp(src, dst); |
|
2494 |
__ br(Assembler::EQ, known_ok); |
|
2495 |
} |
|
2496 |
__ bind(halt); |
|
2497 |
__ stop("incorrect type information in arraycopy"); |
|
2498 |
__ bind(known_ok); |
|
2499 |
} |
|
2500 |
#endif |
|
2501 |
||
2502 |
#ifndef PRODUCT |
|
2503 |
if (PrintC1Statistics) { |
|
2504 |
__ incrementw(ExternalAddress(Runtime1::arraycopy_count_address(basic_type))); |
|
2505 |
} |
|
2506 |
#endif |
|
2507 |
||
2508 |
__ lea(c_rarg0, Address(src, src_pos, Address::uxtw(scale))); |
|
2509 |
__ add(c_rarg0, c_rarg0, arrayOopDesc::base_offset_in_bytes(basic_type)); |
|
2510 |
assert_different_registers(c_rarg0, dst, dst_pos, length); |
|
2511 |
__ lea(c_rarg1, Address(dst, dst_pos, Address::uxtw(scale))); |
|
2512 |
__ add(c_rarg1, c_rarg1, arrayOopDesc::base_offset_in_bytes(basic_type)); |
|
2513 |
assert_different_registers(c_rarg1, dst, length); |
|
2514 |
__ uxtw(c_rarg2, length); |
|
2515 |
assert_different_registers(c_rarg2, dst); |
|
2516 |
||
2517 |
bool disjoint = (flags & LIR_OpArrayCopy::overlapping) == 0; |
|
2518 |
bool aligned = (flags & LIR_OpArrayCopy::unaligned) == 0; |
|
2519 |
const char *name; |
|
2520 |
address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false); |
|
2521 |
||
2522 |
CodeBlob *cb = CodeCache::find_blob(entry); |
|
2523 |
if (cb) { |
|
2524 |
__ far_call(RuntimeAddress(entry)); |
|
2525 |
} else { |
|
2526 |
__ call_VM_leaf(entry, 3); |
|
2527 |
} |
|
2528 |
||
2529 |
__ bind(*stub->continuation()); |
|
2530 |
} |
|
2531 |
||
2532 |
||
2533 |
||
2534 |
||
2535 |
void LIR_Assembler::emit_lock(LIR_OpLock* op) { |
|
2536 |
Register obj = op->obj_opr()->as_register(); // may not be an oop |
|
2537 |
Register hdr = op->hdr_opr()->as_register(); |
|
2538 |
Register lock = op->lock_opr()->as_register(); |
|
2539 |
if (!UseFastLocking) { |
|
2540 |
__ b(*op->stub()->entry()); |
|
2541 |
} else if (op->code() == lir_lock) { |
|
2542 |
Register scratch = noreg; |
|
2543 |
if (UseBiasedLocking) { |
|
2544 |
scratch = op->scratch_opr()->as_register(); |
|
2545 |
} |
|
2546 |
assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); |
|
2547 |
// add debug info for NullPointerException only if one is possible |
|
2548 |
int null_check_offset = __ lock_object(hdr, obj, lock, scratch, *op->stub()->entry()); |
|
2549 |
if (op->info() != NULL) { |
|
2550 |
add_debug_info_for_null_check(null_check_offset, op->info()); |
|
2551 |
} |
|
2552 |
// done |
|
2553 |
} else if (op->code() == lir_unlock) { |
|
2554 |
assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); |
|
2555 |
__ unlock_object(hdr, obj, lock, *op->stub()->entry()); |
|
2556 |
} else { |
|
2557 |
Unimplemented(); |
|
2558 |
} |
|
2559 |
__ bind(*op->stub()->continuation()); |
|
2560 |
} |
|
2561 |
||
2562 |
||
2563 |
void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) { |
|
2564 |
ciMethod* method = op->profiled_method(); |
|
2565 |
int bci = op->profiled_bci(); |
|
2566 |
ciMethod* callee = op->profiled_callee(); |
|
2567 |
||
2568 |
// Update counter for all call types |
|
2569 |
ciMethodData* md = method->method_data_or_null(); |
|
2570 |
assert(md != NULL, "Sanity"); |
|
2571 |
ciProfileData* data = md->bci_to_data(bci); |
|
2572 |
assert(data->is_CounterData(), "need CounterData for calls"); |
|
2573 |
assert(op->mdo()->is_single_cpu(), "mdo must be allocated"); |
|
2574 |
Register mdo = op->mdo()->as_register(); |
|
2575 |
__ mov_metadata(mdo, md->constant_encoding()); |
|
2576 |
Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset())); |
|
2577 |
Bytecodes::Code bc = method->java_code_at_bci(bci); |
|
2578 |
const bool callee_is_static = callee->is_loaded() && callee->is_static(); |
|
2579 |
// Perform additional virtual call profiling for invokevirtual and |
|
2580 |
// invokeinterface bytecodes |
|
2581 |
if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && |
|
2582 |
!callee_is_static && // required for optimized MH invokes |
|
2583 |
C1ProfileVirtualCalls) { |
|
2584 |
assert(op->recv()->is_single_cpu(), "recv must be allocated"); |
|
2585 |
Register recv = op->recv()->as_register(); |
|
2586 |
assert_different_registers(mdo, recv); |
|
2587 |
assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls"); |
|
2588 |
ciKlass* known_klass = op->known_holder(); |
|
2589 |
if (C1OptimizeVirtualCallProfiling && known_klass != NULL) { |
|
2590 |
// We know the type that will be seen at this call site; we can |
|
2591 |
// statically update the MethodData* rather than needing to do |
|
2592 |
// dynamic tests on the receiver type |
|
2593 |
||
2594 |
// NOTE: we should probably put a lock around this search to |
|
2595 |
// avoid collisions by concurrent compilations |
|
2596 |
ciVirtualCallData* vc_data = (ciVirtualCallData*) data; |
|
2597 |
uint i; |
|
2598 |
for (i = 0; i < VirtualCallData::row_limit(); i++) { |
|
2599 |
ciKlass* receiver = vc_data->receiver(i); |
|
2600 |
if (known_klass->equals(receiver)) { |
|
2601 |
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))); |
|
2602 |
__ addptr(data_addr, DataLayout::counter_increment); |
|
2603 |
return; |
|
2604 |
} |
|
2605 |
} |
|
2606 |
||
2607 |
// Receiver type not found in profile data; select an empty slot |
|
2608 |
||
2609 |
// Note that this is less efficient than it should be because it |
|
2610 |
// always does a write to the receiver part of the |
|
2611 |
// VirtualCallData rather than just the first time |
|
2612 |
for (i = 0; i < VirtualCallData::row_limit(); i++) { |
|
2613 |
ciKlass* receiver = vc_data->receiver(i); |
|
2614 |
if (receiver == NULL) { |
|
2615 |
Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i))); |
|
2616 |
__ mov_metadata(rscratch1, known_klass->constant_encoding()); |
|
2617 |
__ lea(rscratch2, recv_addr); |
|
2618 |
__ str(rscratch1, Address(rscratch2)); |
|
2619 |
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))); |
|
2620 |
__ addptr(data_addr, DataLayout::counter_increment); |
|
2621 |
return; |
|
2622 |
} |
|
2623 |
} |
|
2624 |
} else { |
|
2625 |
__ load_klass(recv, recv); |
|
2626 |
Label update_done; |
|
2627 |
type_profile_helper(mdo, md, data, recv, &update_done); |
|
2628 |
// Receiver did not match any saved receiver and there is no empty row for it. |
|
2629 |
// Increment total counter to indicate polymorphic case. |
|
2630 |
__ addptr(counter_addr, DataLayout::counter_increment); |
|
2631 |
||
2632 |
__ bind(update_done); |
|
2633 |
} |
|
2634 |
} else { |
|
2635 |
// Static call |
|
2636 |
__ addptr(counter_addr, DataLayout::counter_increment); |
|
2637 |
} |
|
2638 |
} |
|
2639 |
||
2640 |
||
2641 |
void LIR_Assembler::emit_delay(LIR_OpDelay*) { |
|
2642 |
Unimplemented(); |
|
2643 |
} |
|
2644 |
||
2645 |
||
2646 |
void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) { |
|
2647 |
__ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no)); |
|
2648 |
} |
|
2649 |
||
2650 |
void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) { |
|
2651 |
assert(op->crc()->is_single_cpu(), "crc must be register"); |
|
2652 |
assert(op->val()->is_single_cpu(), "byte value must be register"); |
|
2653 |
assert(op->result_opr()->is_single_cpu(), "result must be register"); |
|
2654 |
Register crc = op->crc()->as_register(); |
|
2655 |
Register val = op->val()->as_register(); |
|
2656 |
Register res = op->result_opr()->as_register(); |
|
2657 |
||
2658 |
assert_different_registers(val, crc, res); |
|
2659 |
unsigned long offset; |
|
2660 |
__ adrp(res, ExternalAddress(StubRoutines::crc_table_addr()), offset); |
|
2661 |
if (offset) __ add(res, res, offset); |
|
2662 |
||
2663 |
__ ornw(crc, zr, crc); // ~crc |
|
2664 |
__ update_byte_crc32(crc, val, res); |
|
2665 |
__ ornw(res, zr, crc); // ~crc |
|
2666 |
} |
|
2667 |
||
2668 |
void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) { |
|
2669 |
COMMENT("emit_profile_type {"); |
|
2670 |
Register obj = op->obj()->as_register(); |
|
2671 |
Register tmp = op->tmp()->as_pointer_register(); |
|
2672 |
Address mdo_addr = as_Address(op->mdp()->as_address_ptr()); |
|
2673 |
ciKlass* exact_klass = op->exact_klass(); |
|
2674 |
intptr_t current_klass = op->current_klass(); |
|
2675 |
bool not_null = op->not_null(); |
|
2676 |
bool no_conflict = op->no_conflict(); |
|
2677 |
||
2678 |
Label update, next, none; |
|
2679 |
||
2680 |
bool do_null = !not_null; |
|
2681 |
bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass; |
|
2682 |
bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set; |
|
2683 |
||
2684 |
assert(do_null || do_update, "why are we here?"); |
|
2685 |
assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?"); |
|
2686 |
assert(mdo_addr.base() != rscratch1, "wrong register"); |
|
2687 |
||
2688 |
__ verify_oop(obj); |
|
2689 |
||
2690 |
if (tmp != obj) { |
|
2691 |
__ mov(tmp, obj); |
|
2692 |
} |
|
2693 |
if (do_null) { |
|
2694 |
__ cbnz(tmp, update); |
|
2695 |
if (!TypeEntries::was_null_seen(current_klass)) { |
|
2696 |
__ ldr(rscratch2, mdo_addr); |
|
2697 |
__ orr(rscratch2, rscratch2, TypeEntries::null_seen); |
|
2698 |
__ str(rscratch2, mdo_addr); |
|
2699 |
} |
|
2700 |
if (do_update) { |
|
2701 |
#ifndef ASSERT |
|
2702 |
__ b(next); |
|
2703 |
} |
|
2704 |
#else |
|
2705 |
__ b(next); |
|
2706 |
} |
|
2707 |
} else { |
|
2708 |
__ cbnz(tmp, update); |
|
2709 |
__ stop("unexpected null obj"); |
|
2710 |
#endif |
|
2711 |
} |
|
2712 |
||
2713 |
__ bind(update); |
|
2714 |
||
2715 |
if (do_update) { |
|
2716 |
#ifdef ASSERT |
|
2717 |
if (exact_klass != NULL) { |
|
2718 |
Label ok; |
|
2719 |
__ load_klass(tmp, tmp); |
|
2720 |
__ mov_metadata(rscratch1, exact_klass->constant_encoding()); |
|
2721 |
__ eor(rscratch1, tmp, rscratch1); |
|
2722 |
__ cbz(rscratch1, ok); |
|
2723 |
__ stop("exact klass and actual klass differ"); |
|
2724 |
__ bind(ok); |
|
2725 |
} |
|
2726 |
#endif |
|
2727 |
if (!no_conflict) { |
|
2728 |
if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) { |
|
2729 |
if (exact_klass != NULL) { |
|
2730 |
__ mov_metadata(tmp, exact_klass->constant_encoding()); |
|
2731 |
} else { |
|
2732 |
__ load_klass(tmp, tmp); |
|
2733 |
} |
|
2734 |
||
2735 |
__ ldr(rscratch2, mdo_addr); |
|
2736 |
__ eor(tmp, tmp, rscratch2); |
|
2737 |
__ andr(rscratch1, tmp, TypeEntries::type_klass_mask); |
|
2738 |
// klass seen before, nothing to do. The unknown bit may have been |
|
2739 |
// set already but no need to check. |
|
2740 |
__ cbz(rscratch1, next); |
|
2741 |
||
2742 |
__ andr(rscratch1, tmp, TypeEntries::type_unknown); |
|
2743 |
__ cbnz(rscratch1, next); // already unknown. Nothing to do anymore. |
|
2744 |
||
2745 |
if (TypeEntries::is_type_none(current_klass)) { |
|
2746 |
__ cbz(rscratch2, none); |
|
2747 |
__ cmp(rscratch2, TypeEntries::null_seen); |
|
2748 |
__ br(Assembler::EQ, none); |
|
2749 |
// There is a chance that the checks above (re-reading profiling |
|
2750 |
// data from memory) fail if another thread has just set the |
|
2751 |
// profiling to this obj's klass |
|
2752 |
__ dmb(Assembler::ISHLD); |
|
2753 |
__ ldr(rscratch2, mdo_addr); |
|
2754 |
__ eor(tmp, tmp, rscratch2); |
|
2755 |
__ andr(rscratch1, tmp, TypeEntries::type_klass_mask); |
|
2756 |
__ cbz(rscratch1, next); |
|
2757 |
} |
|
2758 |
} else { |
|
2759 |
assert(ciTypeEntries::valid_ciklass(current_klass) != NULL && |
|
2760 |
ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only"); |
|
2761 |
||
2762 |
__ ldr(tmp, mdo_addr); |
|
2763 |
__ andr(rscratch1, tmp, TypeEntries::type_unknown); |
|
2764 |
__ cbnz(rscratch1, next); // already unknown. Nothing to do anymore. |
|
2765 |
} |
|
2766 |
||
2767 |
// different than before. Cannot keep accurate profile. |
|
2768 |
__ ldr(rscratch2, mdo_addr); |
|
2769 |
__ orr(rscratch2, rscratch2, TypeEntries::type_unknown); |
|
2770 |
__ str(rscratch2, mdo_addr); |
|
2771 |
||
2772 |
if (TypeEntries::is_type_none(current_klass)) { |
|
2773 |
__ b(next); |
|
2774 |
||
2775 |
__ bind(none); |
|
2776 |
// first time here. Set profile type. |
|
2777 |
__ str(tmp, mdo_addr); |
|
2778 |
} |
|
2779 |
} else { |
|
2780 |
// There's a single possible klass at this profile point |
|
2781 |
assert(exact_klass != NULL, "should be"); |
|
2782 |
if (TypeEntries::is_type_none(current_klass)) { |
|
2783 |
__ mov_metadata(tmp, exact_klass->constant_encoding()); |
|
2784 |
__ ldr(rscratch2, mdo_addr); |
|
2785 |
__ eor(tmp, tmp, rscratch2); |
|
2786 |
__ andr(rscratch1, tmp, TypeEntries::type_klass_mask); |
|
2787 |
__ cbz(rscratch1, next); |
|
2788 |
#ifdef ASSERT |
|
2789 |
{ |
|
2790 |
Label ok; |
|
2791 |
__ ldr(rscratch1, mdo_addr); |
|
2792 |
__ cbz(rscratch1, ok); |
|
2793 |
__ cmp(rscratch1, TypeEntries::null_seen); |
|
2794 |
__ br(Assembler::EQ, ok); |
|
2795 |
// may have been set by another thread |
|
2796 |
__ dmb(Assembler::ISHLD); |
|
2797 |
__ mov_metadata(rscratch1, exact_klass->constant_encoding()); |
|
2798 |
__ ldr(rscratch2, mdo_addr); |
|
2799 |
__ eor(rscratch2, rscratch1, rscratch2); |
|
2800 |
__ andr(rscratch2, rscratch2, TypeEntries::type_mask); |
|
2801 |
__ cbz(rscratch2, ok); |
|
2802 |
||
2803 |
__ stop("unexpected profiling mismatch"); |
|
2804 |
__ bind(ok); |
|
2805 |
} |
|
2806 |
#endif |
|
2807 |
// first time here. Set profile type. |
|
2808 |
__ ldr(tmp, mdo_addr); |
|
2809 |
} else { |
|
2810 |
assert(ciTypeEntries::valid_ciklass(current_klass) != NULL && |
|
2811 |
ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent"); |
|
2812 |
||
2813 |
__ ldr(tmp, mdo_addr); |
|
2814 |
__ andr(rscratch1, tmp, TypeEntries::type_unknown); |
|
2815 |
__ cbnz(rscratch1, next); // already unknown. Nothing to do anymore. |
|
2816 |
||
2817 |
__ orr(tmp, tmp, TypeEntries::type_unknown); |
|
2818 |
__ str(tmp, mdo_addr); |
|
2819 |
// FIXME: Write barrier needed here? |
|
2820 |
} |
|
2821 |
} |
|
2822 |
||
2823 |
__ bind(next); |
|
2824 |
} |
|
2825 |
COMMENT("} emit_profile_type"); |
|
2826 |
} |
|
2827 |
||
2828 |
||
2829 |
void LIR_Assembler::align_backward_branch_target() { |
|
2830 |
} |
|
2831 |
||
2832 |
||
2833 |
void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) { |
|
2834 |
if (left->is_single_cpu()) { |
|
2835 |
assert(dest->is_single_cpu(), "expect single result reg"); |
|
2836 |
__ negw(dest->as_register(), left->as_register()); |
|
2837 |
} else if (left->is_double_cpu()) { |
|
2838 |
assert(dest->is_double_cpu(), "expect double result reg"); |
|
2839 |
__ neg(dest->as_register_lo(), left->as_register_lo()); |
|
2840 |
} else if (left->is_single_fpu()) { |
|
2841 |
assert(dest->is_single_fpu(), "expect single float result reg"); |
|
2842 |
__ fnegs(dest->as_float_reg(), left->as_float_reg()); |
|
2843 |
} else { |
|
2844 |
assert(left->is_double_fpu(), "expect double float operand reg"); |
|
2845 |
assert(dest->is_double_fpu(), "expect double float result reg"); |
|
2846 |
__ fnegd(dest->as_double_reg(), left->as_double_reg()); |
|
2847 |
} |
|
2848 |
} |
|
2849 |
||
2850 |
||
2851 |
void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest) { |
|
2852 |
__ lea(dest->as_register_lo(), as_Address(addr->as_address_ptr())); |
|
2853 |
} |
|
2854 |
||
2855 |
||
2856 |
void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) { |
|
2857 |
assert(!tmp->is_valid(), "don't need temporary"); |
|
2858 |
||
2859 |
CodeBlob *cb = CodeCache::find_blob(dest); |
|
2860 |
if (cb) { |
|
2861 |
__ far_call(RuntimeAddress(dest)); |
|
2862 |
} else { |
|
2863 |
__ mov(rscratch1, RuntimeAddress(dest)); |
|
2864 |
int len = args->length(); |
|
2865 |
int type = 0; |
|
2866 |
if (! result->is_illegal()) { |
|
2867 |
switch (result->type()) { |
|
2868 |
case T_VOID: |
|
2869 |
type = 0; |
|
2870 |
break; |
|
2871 |
case T_INT: |
|
2872 |
case T_LONG: |
|
2873 |
case T_OBJECT: |
|
2874 |
type = 1; |
|
2875 |
break; |
|
2876 |
case T_FLOAT: |
|
2877 |
type = 2; |
|
2878 |
break; |
|
2879 |
case T_DOUBLE: |
|
2880 |
type = 3; |
|
2881 |
break; |
|
2882 |
default: |
|
2883 |
ShouldNotReachHere(); |
|
2884 |
break; |
|
2885 |
} |
|
2886 |
} |
|
2887 |
int num_gpargs = 0; |
|
2888 |
int num_fpargs = 0; |
|
2889 |
for (int i = 0; i < args->length(); i++) { |
|
2890 |
LIR_Opr arg = args->at(i); |
|
2891 |
if (arg->type() == T_FLOAT || arg->type() == T_DOUBLE) { |
|
2892 |
num_fpargs++; |
|
2893 |
} else { |
|
2894 |
num_gpargs++; |
|
2895 |
} |
|
2896 |
} |
|
2897 |
__ blrt(rscratch1, num_gpargs, num_fpargs, type); |
|
2898 |
} |
|
2899 |
||
2900 |
if (info != NULL) { |
|
2901 |
add_call_info_here(info); |
|
2902 |
} |
|
2903 |
__ maybe_isb(); |
|
2904 |
} |
|
2905 |
||
2906 |
void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) { |
|
2907 |
if (dest->is_address() || src->is_address()) { |
|
2908 |
move_op(src, dest, type, lir_patch_none, info, |
|
2909 |
/*pop_fpu_stack*/false, /*unaligned*/false, /*wide*/false); |
|
2910 |
} else { |
|
2911 |
ShouldNotReachHere(); |
|
2912 |
} |
|
2913 |
} |
|
2914 |
||
2915 |
#ifdef ASSERT |
|
2916 |
// emit run-time assertion |
|
2917 |
void LIR_Assembler::emit_assert(LIR_OpAssert* op) { |
|
2918 |
assert(op->code() == lir_assert, "must be"); |
|
2919 |
||
2920 |
if (op->in_opr1()->is_valid()) { |
|
2921 |
assert(op->in_opr2()->is_valid(), "both operands must be valid"); |
|
2922 |
comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); |
|
2923 |
} else { |
|
2924 |
assert(op->in_opr2()->is_illegal(), "both operands must be illegal"); |
|
2925 |
assert(op->condition() == lir_cond_always, "no other conditions allowed"); |
|
2926 |
} |
|
2927 |
||
2928 |
Label ok; |
|
2929 |
if (op->condition() != lir_cond_always) { |
|
2930 |
Assembler::Condition acond = Assembler::AL; |
|
2931 |
switch (op->condition()) { |
|
2932 |
case lir_cond_equal: acond = Assembler::EQ; break; |
|
2933 |
case lir_cond_notEqual: acond = Assembler::NE; break; |
|
2934 |
case lir_cond_less: acond = Assembler::LT; break; |
|
2935 |
case lir_cond_lessEqual: acond = Assembler::LE; break; |
|
2936 |
case lir_cond_greaterEqual: acond = Assembler::GE; break; |
|
2937 |
case lir_cond_greater: acond = Assembler::GT; break; |
|
2938 |
case lir_cond_belowEqual: acond = Assembler::LS; break; |
|
2939 |
case lir_cond_aboveEqual: acond = Assembler::HS; break; |
|
2940 |
default: ShouldNotReachHere(); |
|
2941 |
} |
|
2942 |
__ br(acond, ok); |
|
2943 |
} |
|
2944 |
if (op->halt()) { |
|
2945 |
const char* str = __ code_string(op->msg()); |
|
2946 |
__ stop(str); |
|
2947 |
} else { |
|
2948 |
breakpoint(); |
|
2949 |
} |
|
2950 |
__ bind(ok); |
|
2951 |
} |
|
2952 |
#endif |
|
2953 |
||
2954 |
#ifndef PRODUCT |
|
2955 |
#define COMMENT(x) do { __ block_comment(x); } while (0) |
|
2956 |
#else |
|
2957 |
#define COMMENT(x) |
|
2958 |
#endif |
|
2959 |
||
2960 |
void LIR_Assembler::membar() { |
|
2961 |
COMMENT("membar"); |
|
2962 |
__ membar(MacroAssembler::AnyAny); |
|
2963 |
} |
|
2964 |
||
2965 |
void LIR_Assembler::membar_acquire() { |
|
2966 |
__ membar(Assembler::LoadLoad|Assembler::LoadStore); |
|
2967 |
} |
|
2968 |
||
2969 |
void LIR_Assembler::membar_release() { |
|
2970 |
__ membar(Assembler::LoadStore|Assembler::StoreStore); |
|
2971 |
} |
|
2972 |
||
2973 |
void LIR_Assembler::membar_loadload() { |
|
2974 |
__ membar(Assembler::LoadLoad); |
|
2975 |
} |
|
2976 |
||
2977 |
void LIR_Assembler::membar_storestore() { |
|
2978 |
__ membar(MacroAssembler::StoreStore); |
|
2979 |
} |
|
2980 |
||
2981 |
void LIR_Assembler::membar_loadstore() { __ membar(MacroAssembler::LoadStore); } |
|
2982 |
||
2983 |
void LIR_Assembler::membar_storeload() { __ membar(MacroAssembler::StoreLoad); } |
|
2984 |
||
2985 |
void LIR_Assembler::get_thread(LIR_Opr result_reg) { |
|
2986 |
__ mov(result_reg->as_register(), rthread); |
|
2987 |
} |
|
2988 |
||
2989 |
||
2990 |
void LIR_Assembler::peephole(LIR_List *lir) { |
|
2991 |
#if 0 |
|
2992 |
if (tableswitch_count >= max_tableswitches) |
|
2993 |
return; |
|
2994 |
||
2995 |
/* |
|
2996 |
This finite-state automaton recognizes sequences of compare-and- |
|
2997 |
branch instructions. We will turn them into a tableswitch. You |
|
2998 |
could argue that C1 really shouldn't be doing this sort of |
|
2999 |
optimization, but without it the code is really horrible. |
|
3000 |
*/ |
|
3001 |
||
3002 |
enum { start_s, cmp1_s, beq_s, cmp_s } state; |
|
3003 |
int first_key, last_key = -2147483648; |
|
3004 |
int next_key = 0; |
|
3005 |
int start_insn = -1; |
|
3006 |
int last_insn = -1; |
|
3007 |
Register reg = noreg; |
|
3008 |
LIR_Opr reg_opr; |
|
3009 |
state = start_s; |
|
3010 |
||
3011 |
LIR_OpList* inst = lir->instructions_list(); |
|
3012 |
for (int i = 0; i < inst->length(); i++) { |
|
3013 |
LIR_Op* op = inst->at(i); |
|
3014 |
switch (state) { |
|
3015 |
case start_s: |
|
3016 |
first_key = -1; |
|
3017 |
start_insn = i; |
|
3018 |
switch (op->code()) { |
|
3019 |
case lir_cmp: |
|
3020 |
LIR_Opr opr1 = op->as_Op2()->in_opr1(); |
|
3021 |
LIR_Opr opr2 = op->as_Op2()->in_opr2(); |
|
3022 |
if (opr1->is_cpu_register() && opr1->is_single_cpu() |
|
3023 |
&& opr2->is_constant() |
|
3024 |
&& opr2->type() == T_INT) { |
|
3025 |
reg_opr = opr1; |
|
3026 |
reg = opr1->as_register(); |
|
3027 |
first_key = opr2->as_constant_ptr()->as_jint(); |
|
3028 |
next_key = first_key + 1; |
|
3029 |
state = cmp_s; |
|
3030 |
goto next_state; |
|
3031 |
} |
|
3032 |
break; |
|
3033 |
} |
|
3034 |
break; |
|
3035 |
case cmp_s: |
|
3036 |
switch (op->code()) { |
|
3037 |
case lir_branch: |
|
3038 |
if (op->as_OpBranch()->cond() == lir_cond_equal) { |
|
3039 |
state = beq_s; |
|
3040 |
last_insn = i; |
|
3041 |
goto next_state; |
|
3042 |
} |
|
3043 |
} |
|
3044 |
state = start_s; |
|
3045 |
break; |
|
3046 |
case beq_s: |
|
3047 |
switch (op->code()) { |
|
3048 |
case lir_cmp: { |
|
3049 |
LIR_Opr opr1 = op->as_Op2()->in_opr1(); |
|
3050 |
LIR_Opr opr2 = op->as_Op2()->in_opr2(); |
|
3051 |
if (opr1->is_cpu_register() && opr1->is_single_cpu() |
|
3052 |
&& opr1->as_register() == reg |
|
3053 |
&& opr2->is_constant() |
|
3054 |
&& opr2->type() == T_INT |
|
3055 |
&& opr2->as_constant_ptr()->as_jint() == next_key) { |
|
3056 |
last_key = next_key; |
|
3057 |
next_key++; |
|
3058 |
state = cmp_s; |
|
3059 |
goto next_state; |
|
3060 |
} |
|
3061 |
} |
|
3062 |
} |
|
3063 |
last_key = next_key; |
|
3064 |
state = start_s; |
|
3065 |
break; |
|
3066 |
default: |
|
3067 |
assert(false, "impossible state"); |
|
3068 |
} |
|
3069 |
if (state == start_s) { |
|
3070 |
if (first_key < last_key - 5L && reg != noreg) { |
|
3071 |
{ |
|
3072 |
// printf("found run register %d starting at insn %d low value %d high value %d\n", |
|
3073 |
// reg->encoding(), |
|
3074 |
// start_insn, first_key, last_key); |
|
3075 |
// for (int i = 0; i < inst->length(); i++) { |
|
3076 |
// inst->at(i)->print(); |
|
3077 |
// tty->print("\n"); |
|
3078 |
// } |
|
3079 |
// tty->print("\n"); |
|
3080 |
} |
|
3081 |
||
3082 |
struct tableswitch *sw = &switches[tableswitch_count]; |
|
3083 |
sw->_insn_index = start_insn, sw->_first_key = first_key, |
|
3084 |
sw->_last_key = last_key, sw->_reg = reg; |
|
3085 |
inst->insert_before(last_insn + 1, new LIR_OpLabel(&sw->_after)); |
|
3086 |
{ |
|
3087 |
// Insert the new table of branches |
|
3088 |
int offset = last_insn; |
|
3089 |
for (int n = first_key; n < last_key; n++) { |
|
3090 |
inst->insert_before |
|
3091 |
(last_insn + 1, |
|
3092 |
new LIR_OpBranch(lir_cond_always, T_ILLEGAL, |
|
3093 |
inst->at(offset)->as_OpBranch()->label())); |
|
3094 |
offset -= 2, i++; |
|
3095 |
} |
|
3096 |
} |
|
3097 |
// Delete all the old compare-and-branch instructions |
|
3098 |
for (int n = first_key; n < last_key; n++) { |
|
3099 |
inst->remove_at(start_insn); |
|
3100 |
inst->remove_at(start_insn); |
|
3101 |
} |
|
3102 |
// Insert the tableswitch instruction |
|
3103 |
inst->insert_before(start_insn, |
|
3104 |
new LIR_Op2(lir_cmp, lir_cond_always, |
|
3105 |
LIR_OprFact::intConst(tableswitch_count), |
|
3106 |
reg_opr)); |
|
3107 |
inst->insert_before(start_insn + 1, new LIR_OpLabel(&sw->_branches)); |
|
3108 |
tableswitch_count++; |
|
3109 |
} |
|
3110 |
reg = noreg; |
|
3111 |
last_key = -2147483648; |
|
3112 |
} |
|
3113 |
next_state: |
|
3114 |
; |
|
3115 |
} |
|
3116 |
#endif |
|
3117 |
} |
|
3118 |
||
3119 |
void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr dest, LIR_Opr tmp_op) { |
|
3120 |
Address addr = as_Address(src->as_address_ptr(), noreg); |
|
3121 |
BasicType type = src->type(); |
|
3122 |
bool is_oop = type == T_OBJECT || type == T_ARRAY; |
|
3123 |
||
3124 |
void (MacroAssembler::* lda)(Register Rd, Register Ra); |
|
3125 |
void (MacroAssembler::* add)(Register Rd, Register Rn, RegisterOrConstant increment); |
|
3126 |
void (MacroAssembler::* stl)(Register Rs, Register Rt, Register Rn); |
|
3127 |
||
3128 |
switch(type) { |
|
3129 |
case T_INT: |
|
3130 |
lda = &MacroAssembler::ldaxrw; |
|
3131 |
add = &MacroAssembler::addw; |
|
3132 |
stl = &MacroAssembler::stlxrw; |
|
3133 |
break; |
|
3134 |
case T_LONG: |
|
3135 |
lda = &MacroAssembler::ldaxr; |
|
3136 |
add = &MacroAssembler::add; |
|
3137 |
stl = &MacroAssembler::stlxr; |
|
3138 |
break; |
|
3139 |
case T_OBJECT: |
|
3140 |
case T_ARRAY: |
|
3141 |
if (UseCompressedOops) { |
|
3142 |
lda = &MacroAssembler::ldaxrw; |
|
3143 |
add = &MacroAssembler::addw; |
|
3144 |
stl = &MacroAssembler::stlxrw; |
|
3145 |
} else { |
|
3146 |
lda = &MacroAssembler::ldaxr; |
|
3147 |
add = &MacroAssembler::add; |
|
3148 |
stl = &MacroAssembler::stlxr; |
|
3149 |
} |
|
3150 |
break; |
|
3151 |
default: |
|
3152 |
ShouldNotReachHere(); |
|
35127 | 3153 |
lda = &MacroAssembler::ldaxr; |
3154 |
add = &MacroAssembler::add; |
|
3155 |
stl = &MacroAssembler::stlxr; // unreachable |
|
29184 | 3156 |
} |
3157 |
||
3158 |
switch (code) { |
|
3159 |
case lir_xadd: |
|
3160 |
{ |
|
3161 |
RegisterOrConstant inc; |
|
3162 |
Register tmp = as_reg(tmp_op); |
|
3163 |
Register dst = as_reg(dest); |
|
3164 |
if (data->is_constant()) { |
|
3165 |
inc = RegisterOrConstant(as_long(data)); |
|
3166 |
assert_different_registers(dst, addr.base(), tmp, |
|
3167 |
rscratch1, rscratch2); |
|
3168 |
} else { |
|
3169 |
inc = RegisterOrConstant(as_reg(data)); |
|
3170 |
assert_different_registers(inc.as_register(), dst, addr.base(), tmp, |
|
3171 |
rscratch1, rscratch2); |
|
3172 |
} |
|
3173 |
Label again; |
|
3174 |
__ lea(tmp, addr); |
|
36565
8e38f7594806
8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents:
36562
diff
changeset
|
3175 |
__ prfm(Address(tmp), PSTL1STRM); |
29184 | 3176 |
__ bind(again); |
3177 |
(_masm->*lda)(dst, tmp); |
|
3178 |
(_masm->*add)(rscratch1, dst, inc); |
|
3179 |
(_masm->*stl)(rscratch2, rscratch1, tmp); |
|
3180 |
__ cbnzw(rscratch2, again); |
|
3181 |
break; |
|
3182 |
} |
|
3183 |
case lir_xchg: |
|
3184 |
{ |
|
3185 |
Register tmp = tmp_op->as_register(); |
|
3186 |
Register obj = as_reg(data); |
|
3187 |
Register dst = as_reg(dest); |
|
3188 |
if (is_oop && UseCompressedOops) { |
|
35584
bd3f4749a19c
8147805: aarch64: C1 segmentation fault due to inline Unsafe.getAndSetObject
hshi
parents:
35127
diff
changeset
|
3189 |
__ encode_heap_oop(rscratch1, obj); |
bd3f4749a19c
8147805: aarch64: C1 segmentation fault due to inline Unsafe.getAndSetObject
hshi
parents:
35127
diff
changeset
|
3190 |
obj = rscratch1; |
29184 | 3191 |
} |
3192 |
assert_different_registers(obj, addr.base(), tmp, rscratch2, dst); |
|
3193 |
Label again; |
|
3194 |
__ lea(tmp, addr); |
|
36565
8e38f7594806
8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents:
36562
diff
changeset
|
3195 |
__ prfm(Address(tmp), PSTL1STRM); |
29184 | 3196 |
__ bind(again); |
3197 |
(_masm->*lda)(dst, tmp); |
|
3198 |
(_masm->*stl)(rscratch2, obj, tmp); |
|
3199 |
__ cbnzw(rscratch2, again); |
|
3200 |
if (is_oop && UseCompressedOops) { |
|
3201 |
__ decode_heap_oop(dst); |
|
3202 |
} |
|
3203 |
} |
|
3204 |
break; |
|
3205 |
default: |
|
3206 |
ShouldNotReachHere(); |
|
3207 |
} |
|
3208 |
__ membar(__ AnyAny); |
|
3209 |
} |
|
3210 |
||
3211 |
#undef __ |