author | rkennke |
Sun, 06 May 2018 00:42:59 +0200 | |
changeset 50024 | 7238cb613dc5 |
parent 49933 | c63bdf53a1a7 |
child 50153 | 9010b580d8a9 |
permissions | -rw-r--r-- |
29184 | 1 |
/* |
49906 | 2 |
* Copyright (c) 2005, 2018, 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 "c1/c1_Compilation.hpp" |
|
28 |
#include "c1/c1_FrameMap.hpp" |
|
29 |
#include "c1/c1_Instruction.hpp" |
|
30 |
#include "c1/c1_LIRAssembler.hpp" |
|
31 |
#include "c1/c1_LIRGenerator.hpp" |
|
32 |
#include "c1/c1_Runtime1.hpp" |
|
33 |
#include "c1/c1_ValueStack.hpp" |
|
34 |
#include "ci/ciArray.hpp" |
|
35 |
#include "ci/ciObjArrayKlass.hpp" |
|
36 |
#include "ci/ciTypeArrayKlass.hpp" |
|
37 |
#include "runtime/sharedRuntime.hpp" |
|
38 |
#include "runtime/stubRoutines.hpp" |
|
39 |
#include "vmreg_aarch64.inline.hpp" |
|
40 |
||
41 |
#ifdef ASSERT |
|
42 |
#define __ gen()->lir(__FILE__, __LINE__)-> |
|
43 |
#else |
|
44 |
#define __ gen()->lir()-> |
|
45 |
#endif |
|
46 |
||
47 |
// Item will be loaded into a byte register; Intel only |
|
48 |
void LIRItem::load_byte_item() { |
|
49 |
load_item(); |
|
50 |
} |
|
51 |
||
52 |
||
53 |
void LIRItem::load_nonconstant() { |
|
54 |
LIR_Opr r = value()->operand(); |
|
55 |
if (r->is_constant()) { |
|
56 |
_result = r; |
|
57 |
} else { |
|
58 |
load_item(); |
|
59 |
} |
|
60 |
} |
|
61 |
||
62 |
//-------------------------------------------------------------- |
|
63 |
// LIRGenerator |
|
64 |
//-------------------------------------------------------------- |
|
65 |
||
66 |
||
67 |
LIR_Opr LIRGenerator::exceptionOopOpr() { return FrameMap::r0_oop_opr; } |
|
68 |
LIR_Opr LIRGenerator::exceptionPcOpr() { return FrameMap::r3_opr; } |
|
69 |
LIR_Opr LIRGenerator::divInOpr() { Unimplemented(); return LIR_OprFact::illegalOpr; } |
|
70 |
LIR_Opr LIRGenerator::divOutOpr() { Unimplemented(); return LIR_OprFact::illegalOpr; } |
|
71 |
LIR_Opr LIRGenerator::remOutOpr() { Unimplemented(); return LIR_OprFact::illegalOpr; } |
|
72 |
LIR_Opr LIRGenerator::shiftCountOpr() { Unimplemented(); return LIR_OprFact::illegalOpr; } |
|
34201
2de6f3566659
8138895: C1: PPC64 Port needs special register for Locks in synchronization code
mdoerr
parents:
29184
diff
changeset
|
73 |
LIR_Opr LIRGenerator::syncLockOpr() { return new_register(T_INT); } |
29184 | 74 |
LIR_Opr LIRGenerator::syncTempOpr() { return FrameMap::r0_opr; } |
75 |
LIR_Opr LIRGenerator::getThreadTemp() { return LIR_OprFact::illegalOpr; } |
|
76 |
||
77 |
||
78 |
LIR_Opr LIRGenerator::result_register_for(ValueType* type, bool callee) { |
|
79 |
LIR_Opr opr; |
|
80 |
switch (type->tag()) { |
|
81 |
case intTag: opr = FrameMap::r0_opr; break; |
|
82 |
case objectTag: opr = FrameMap::r0_oop_opr; break; |
|
83 |
case longTag: opr = FrameMap::long0_opr; break; |
|
84 |
case floatTag: opr = FrameMap::fpu0_float_opr; break; |
|
85 |
case doubleTag: opr = FrameMap::fpu0_double_opr; break; |
|
86 |
||
87 |
case addressTag: |
|
88 |
default: ShouldNotReachHere(); return LIR_OprFact::illegalOpr; |
|
89 |
} |
|
90 |
||
91 |
assert(opr->type_field() == as_OprType(as_BasicType(type)), "type mismatch"); |
|
92 |
return opr; |
|
93 |
} |
|
94 |
||
95 |
||
96 |
LIR_Opr LIRGenerator::rlock_byte(BasicType type) { |
|
97 |
LIR_Opr reg = new_register(T_INT); |
|
98 |
set_vreg_flag(reg, LIRGenerator::byte_reg); |
|
99 |
return reg; |
|
100 |
} |
|
101 |
||
102 |
||
103 |
//--------- loading items into registers -------------------------------- |
|
104 |
||
105 |
||
106 |
bool LIRGenerator::can_store_as_constant(Value v, BasicType type) const { |
|
107 |
if (v->type()->as_IntConstant() != NULL) { |
|
108 |
return v->type()->as_IntConstant()->value() == 0L; |
|
109 |
} else if (v->type()->as_LongConstant() != NULL) { |
|
110 |
return v->type()->as_LongConstant()->value() == 0L; |
|
111 |
} else if (v->type()->as_ObjectConstant() != NULL) { |
|
112 |
return v->type()->as_ObjectConstant()->value()->is_null_object(); |
|
113 |
} else { |
|
114 |
return false; |
|
115 |
} |
|
116 |
} |
|
117 |
||
118 |
bool LIRGenerator::can_inline_as_constant(Value v) const { |
|
119 |
// FIXME: Just a guess |
|
120 |
if (v->type()->as_IntConstant() != NULL) { |
|
121 |
return Assembler::operand_valid_for_add_sub_immediate(v->type()->as_IntConstant()->value()); |
|
122 |
} else if (v->type()->as_LongConstant() != NULL) { |
|
123 |
return v->type()->as_LongConstant()->value() == 0L; |
|
124 |
} else if (v->type()->as_ObjectConstant() != NULL) { |
|
125 |
return v->type()->as_ObjectConstant()->value()->is_null_object(); |
|
126 |
} else { |
|
127 |
return false; |
|
128 |
} |
|
129 |
} |
|
130 |
||
131 |
||
132 |
bool LIRGenerator::can_inline_as_constant(LIR_Const* c) const { return false; } |
|
133 |
||
134 |
||
135 |
LIR_Opr LIRGenerator::safepoint_poll_register() { |
|
136 |
return LIR_OprFact::illegalOpr; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index, |
|
141 |
int shift, int disp, BasicType type) { |
|
142 |
assert(base->is_register(), "must be"); |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
143 |
intx large_disp = disp; |
29184 | 144 |
|
145 |
// accumulate fixed displacements |
|
146 |
if (index->is_constant()) { |
|
49906 | 147 |
LIR_Const *constant = index->as_constant_ptr(); |
148 |
if (constant->type() == T_INT) { |
|
149 |
large_disp += index->as_jint() << shift; |
|
150 |
} else { |
|
151 |
assert(constant->type() == T_LONG, "should be"); |
|
152 |
jlong c = index->as_jlong() << shift; |
|
153 |
if ((jlong)((jint)c) == c) { |
|
154 |
large_disp += c; |
|
155 |
index = LIR_OprFact::illegalOpr; |
|
156 |
} else { |
|
157 |
LIR_Opr tmp = new_register(T_LONG); |
|
158 |
__ move(index, tmp); |
|
159 |
index = tmp; |
|
160 |
// apply shift and displacement below |
|
161 |
} |
|
162 |
} |
|
29184 | 163 |
} |
164 |
||
165 |
if (index->is_register()) { |
|
166 |
// apply the shift and accumulate the displacement |
|
167 |
if (shift > 0) { |
|
168 |
LIR_Opr tmp = new_pointer_register(); |
|
169 |
__ shift_left(index, shift, tmp); |
|
170 |
index = tmp; |
|
171 |
} |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
172 |
if (large_disp != 0) { |
29184 | 173 |
LIR_Opr tmp = new_pointer_register(); |
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
174 |
if (Assembler::operand_valid_for_add_sub_immediate(large_disp)) { |
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
175 |
__ add(tmp, tmp, LIR_OprFact::intptrConst(large_disp)); |
29184 | 176 |
index = tmp; |
177 |
} else { |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
178 |
__ move(tmp, LIR_OprFact::intptrConst(large_disp)); |
29184 | 179 |
__ add(tmp, index, tmp); |
180 |
index = tmp; |
|
181 |
} |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
182 |
large_disp = 0; |
29184 | 183 |
} |
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
184 |
} else if (large_disp != 0 && !Address::offset_ok_for_immed(large_disp, shift)) { |
29184 | 185 |
// index is illegal so replace it with the displacement loaded into a register |
186 |
index = new_pointer_register(); |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
187 |
__ move(LIR_OprFact::intptrConst(large_disp), index); |
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
188 |
large_disp = 0; |
29184 | 189 |
} |
190 |
||
191 |
// at this point we either have base + index or base + displacement |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
192 |
if (large_disp == 0) { |
29184 | 193 |
return new LIR_Address(base, index, type); |
194 |
} else { |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
195 |
assert(Address::offset_ok_for_immed(large_disp, 0), "must be"); |
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
196 |
return new LIR_Address(base, large_disp, type); |
29184 | 197 |
} |
198 |
} |
|
199 |
||
200 |
LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, |
|
49906 | 201 |
BasicType type) { |
29184 | 202 |
int offset_in_bytes = arrayOopDesc::base_offset_in_bytes(type); |
203 |
int elem_size = type2aelembytes(type); |
|
204 |
int shift = exact_log2(elem_size); |
|
205 |
||
206 |
LIR_Address* addr; |
|
207 |
if (index_opr->is_constant()) { |
|
208 |
addr = new LIR_Address(array_opr, |
|
41337
4493ad6de04d
8166140: C1: Possible integer overflow in LIRGenerator::generate_address on several platforms
mdoerr
parents:
41323
diff
changeset
|
209 |
offset_in_bytes + (intx)(index_opr->as_jint()) * elem_size, type); |
29184 | 210 |
} else { |
211 |
if (offset_in_bytes) { |
|
212 |
LIR_Opr tmp = new_pointer_register(); |
|
213 |
__ add(array_opr, LIR_OprFact::intConst(offset_in_bytes), tmp); |
|
214 |
array_opr = tmp; |
|
215 |
offset_in_bytes = 0; |
|
216 |
} |
|
217 |
addr = new LIR_Address(array_opr, |
|
218 |
index_opr, |
|
219 |
LIR_Address::scale(type), |
|
220 |
offset_in_bytes, type); |
|
221 |
} |
|
49906 | 222 |
return addr; |
29184 | 223 |
} |
224 |
||
225 |
LIR_Opr LIRGenerator::load_immediate(int x, BasicType type) { |
|
226 |
LIR_Opr r; |
|
227 |
if (type == T_LONG) { |
|
228 |
r = LIR_OprFact::longConst(x); |
|
229 |
if (!Assembler::operand_valid_for_logical_immediate(false, x)) { |
|
230 |
LIR_Opr tmp = new_register(type); |
|
231 |
__ move(r, tmp); |
|
232 |
return tmp; |
|
233 |
} |
|
234 |
} else if (type == T_INT) { |
|
235 |
r = LIR_OprFact::intConst(x); |
|
236 |
if (!Assembler::operand_valid_for_logical_immediate(true, x)) { |
|
237 |
// This is all rather nasty. We don't know whether our constant |
|
238 |
// is required for a logical or an arithmetic operation, wo we |
|
239 |
// don't know what the range of valid values is!! |
|
240 |
LIR_Opr tmp = new_register(type); |
|
241 |
__ move(r, tmp); |
|
242 |
return tmp; |
|
243 |
} |
|
244 |
} else { |
|
245 |
ShouldNotReachHere(); |
|
35127 | 246 |
r = NULL; // unreachable |
29184 | 247 |
} |
248 |
return r; |
|
249 |
} |
|
250 |
||
251 |
||
252 |
||
253 |
void LIRGenerator::increment_counter(address counter, BasicType type, int step) { |
|
254 |
LIR_Opr pointer = new_pointer_register(); |
|
255 |
__ move(LIR_OprFact::intptrConst(counter), pointer); |
|
256 |
LIR_Address* addr = new LIR_Address(pointer, type); |
|
257 |
increment_counter(addr, step); |
|
258 |
} |
|
259 |
||
260 |
||
261 |
void LIRGenerator::increment_counter(LIR_Address* addr, int step) { |
|
262 |
LIR_Opr imm = NULL; |
|
263 |
switch(addr->type()) { |
|
264 |
case T_INT: |
|
265 |
imm = LIR_OprFact::intConst(step); |
|
266 |
break; |
|
267 |
case T_LONG: |
|
268 |
imm = LIR_OprFact::longConst(step); |
|
269 |
break; |
|
270 |
default: |
|
271 |
ShouldNotReachHere(); |
|
272 |
} |
|
273 |
LIR_Opr reg = new_register(addr->type()); |
|
274 |
__ load(addr, reg); |
|
275 |
__ add(reg, imm, reg); |
|
276 |
__ store(reg, addr); |
|
277 |
} |
|
278 |
||
279 |
void LIRGenerator::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) { |
|
280 |
LIR_Opr reg = new_register(T_INT); |
|
281 |
__ load(generate_address(base, disp, T_INT), reg, info); |
|
282 |
__ cmp(condition, reg, LIR_OprFact::intConst(c)); |
|
283 |
} |
|
284 |
||
285 |
void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info) { |
|
286 |
LIR_Opr reg1 = new_register(T_INT); |
|
287 |
__ load(generate_address(base, disp, type), reg1, info); |
|
288 |
__ cmp(condition, reg, reg1); |
|
289 |
} |
|
290 |
||
291 |
||
292 |
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) { |
|
293 |
||
294 |
if (is_power_of_2(c - 1)) { |
|
295 |
__ shift_left(left, exact_log2(c - 1), tmp); |
|
296 |
__ add(tmp, left, result); |
|
297 |
return true; |
|
298 |
} else if (is_power_of_2(c + 1)) { |
|
299 |
__ shift_left(left, exact_log2(c + 1), tmp); |
|
300 |
__ sub(tmp, left, result); |
|
301 |
return true; |
|
302 |
} else { |
|
303 |
return false; |
|
304 |
} |
|
305 |
} |
|
306 |
||
307 |
void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) { |
|
308 |
BasicType type = item->type(); |
|
309 |
__ store(item, new LIR_Address(FrameMap::sp_opr, in_bytes(offset_from_sp), type)); |
|
310 |
} |
|
311 |
||
49906 | 312 |
void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) { |
313 |
LIR_Opr tmp1 = new_register(objectType); |
|
314 |
LIR_Opr tmp2 = new_register(objectType); |
|
315 |
LIR_Opr tmp3 = new_register(objectType); |
|
316 |
__ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci); |
|
317 |
} |
|
318 |
||
29184 | 319 |
//---------------------------------------------------------------------- |
320 |
// visitor functions |
|
321 |
//---------------------------------------------------------------------- |
|
322 |
||
323 |
void LIRGenerator::do_MonitorEnter(MonitorEnter* x) { |
|
324 |
assert(x->is_pinned(),""); |
|
325 |
LIRItem obj(x->obj(), this); |
|
326 |
obj.load_item(); |
|
327 |
||
328 |
set_no_result(x); |
|
329 |
||
330 |
// "lock" stores the address of the monitor stack slot, so this is not an oop |
|
331 |
LIR_Opr lock = new_register(T_INT); |
|
332 |
// Need a scratch register for biased locking |
|
333 |
LIR_Opr scratch = LIR_OprFact::illegalOpr; |
|
334 |
if (UseBiasedLocking) { |
|
335 |
scratch = new_register(T_INT); |
|
336 |
} |
|
337 |
||
338 |
CodeEmitInfo* info_for_exception = NULL; |
|
339 |
if (x->needs_null_check()) { |
|
340 |
info_for_exception = state_for(x); |
|
341 |
} |
|
342 |
// this CodeEmitInfo must not have the xhandlers because here the |
|
343 |
// object is already locked (xhandlers expect object to be unlocked) |
|
344 |
CodeEmitInfo* info = state_for(x, x->state(), true); |
|
345 |
monitor_enter(obj.result(), lock, syncTempOpr(), scratch, |
|
346 |
x->monitor_no(), info_for_exception, info); |
|
347 |
} |
|
348 |
||
349 |
||
350 |
void LIRGenerator::do_MonitorExit(MonitorExit* x) { |
|
351 |
assert(x->is_pinned(),""); |
|
352 |
||
353 |
LIRItem obj(x->obj(), this); |
|
354 |
obj.dont_load_item(); |
|
355 |
||
356 |
LIR_Opr lock = new_register(T_INT); |
|
357 |
LIR_Opr obj_temp = new_register(T_INT); |
|
358 |
set_no_result(x); |
|
359 |
monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no()); |
|
360 |
} |
|
361 |
||
362 |
||
363 |
void LIRGenerator::do_NegateOp(NegateOp* x) { |
|
364 |
||
365 |
LIRItem from(x->x(), this); |
|
366 |
from.load_item(); |
|
367 |
LIR_Opr result = rlock_result(x); |
|
368 |
__ negate (from.result(), result); |
|
369 |
||
370 |
} |
|
371 |
||
372 |
// for _fadd, _fmul, _fsub, _fdiv, _frem |
|
373 |
// _dadd, _dmul, _dsub, _ddiv, _drem |
|
374 |
void LIRGenerator::do_ArithmeticOp_FPU(ArithmeticOp* x) { |
|
375 |
||
376 |
if (x->op() == Bytecodes::_frem || x->op() == Bytecodes::_drem) { |
|
377 |
// float remainder is implemented as a direct call into the runtime |
|
378 |
LIRItem right(x->x(), this); |
|
379 |
LIRItem left(x->y(), this); |
|
380 |
||
381 |
BasicTypeList signature(2); |
|
382 |
if (x->op() == Bytecodes::_frem) { |
|
383 |
signature.append(T_FLOAT); |
|
384 |
signature.append(T_FLOAT); |
|
385 |
} else { |
|
386 |
signature.append(T_DOUBLE); |
|
387 |
signature.append(T_DOUBLE); |
|
388 |
} |
|
389 |
CallingConvention* cc = frame_map()->c_calling_convention(&signature); |
|
390 |
||
391 |
const LIR_Opr result_reg = result_register_for(x->type()); |
|
392 |
left.load_item_force(cc->at(1)); |
|
393 |
right.load_item(); |
|
394 |
||
395 |
__ move(right.result(), cc->at(0)); |
|
396 |
||
397 |
address entry; |
|
398 |
if (x->op() == Bytecodes::_frem) { |
|
399 |
entry = CAST_FROM_FN_PTR(address, SharedRuntime::frem); |
|
400 |
} else { |
|
401 |
entry = CAST_FROM_FN_PTR(address, SharedRuntime::drem); |
|
402 |
} |
|
403 |
||
404 |
LIR_Opr result = rlock_result(x); |
|
405 |
__ call_runtime_leaf(entry, getThreadTemp(), result_reg, cc->args()); |
|
406 |
__ move(result_reg, result); |
|
407 |
||
408 |
return; |
|
409 |
} |
|
410 |
||
411 |
LIRItem left(x->x(), this); |
|
412 |
LIRItem right(x->y(), this); |
|
413 |
LIRItem* left_arg = &left; |
|
414 |
LIRItem* right_arg = &right; |
|
415 |
||
416 |
// Always load right hand side. |
|
417 |
right.load_item(); |
|
418 |
||
419 |
if (!left.is_register()) |
|
420 |
left.load_item(); |
|
421 |
||
422 |
LIR_Opr reg = rlock(x); |
|
423 |
LIR_Opr tmp = LIR_OprFact::illegalOpr; |
|
424 |
if (x->is_strictfp() && (x->op() == Bytecodes::_dmul || x->op() == Bytecodes::_ddiv)) { |
|
425 |
tmp = new_register(T_DOUBLE); |
|
426 |
} |
|
427 |
||
428 |
arithmetic_op_fpu(x->op(), reg, left.result(), right.result(), NULL); |
|
429 |
||
430 |
set_result(x, round_item(reg)); |
|
431 |
} |
|
432 |
||
433 |
// for _ladd, _lmul, _lsub, _ldiv, _lrem |
|
434 |
void LIRGenerator::do_ArithmeticOp_Long(ArithmeticOp* x) { |
|
435 |
||
436 |
// missing test if instr is commutative and if we should swap |
|
437 |
LIRItem left(x->x(), this); |
|
438 |
LIRItem right(x->y(), this); |
|
439 |
||
440 |
if (x->op() == Bytecodes::_ldiv || x->op() == Bytecodes::_lrem) { |
|
441 |
||
442 |
// the check for division by zero destroys the right operand |
|
443 |
right.set_destroys_register(); |
|
444 |
||
445 |
// check for division by zero (destroys registers of right operand!) |
|
446 |
CodeEmitInfo* info = state_for(x); |
|
447 |
||
448 |
left.load_item(); |
|
449 |
right.load_item(); |
|
450 |
||
451 |
__ cmp(lir_cond_equal, right.result(), LIR_OprFact::longConst(0)); |
|
452 |
__ branch(lir_cond_equal, T_LONG, new DivByZeroStub(info)); |
|
453 |
||
454 |
rlock_result(x); |
|
455 |
switch (x->op()) { |
|
456 |
case Bytecodes::_lrem: |
|
457 |
__ rem (left.result(), right.result(), x->operand()); |
|
458 |
break; |
|
459 |
case Bytecodes::_ldiv: |
|
460 |
__ div (left.result(), right.result(), x->operand()); |
|
461 |
break; |
|
462 |
default: |
|
463 |
ShouldNotReachHere(); |
|
464 |
break; |
|
465 |
} |
|
466 |
||
467 |
||
468 |
} else { |
|
469 |
assert (x->op() == Bytecodes::_lmul || x->op() == Bytecodes::_ladd || x->op() == Bytecodes::_lsub, |
|
470 |
"expect lmul, ladd or lsub"); |
|
471 |
// add, sub, mul |
|
472 |
left.load_item(); |
|
473 |
if (! right.is_register()) { |
|
474 |
if (x->op() == Bytecodes::_lmul |
|
475 |
|| ! right.is_constant() |
|
476 |
|| ! Assembler::operand_valid_for_add_sub_immediate(right.get_jlong_constant())) { |
|
477 |
right.load_item(); |
|
478 |
} else { // add, sub |
|
479 |
assert (x->op() == Bytecodes::_ladd || x->op() == Bytecodes::_lsub, "expect ladd or lsub"); |
|
480 |
// don't load constants to save register |
|
481 |
right.load_nonconstant(); |
|
482 |
} |
|
483 |
} |
|
484 |
rlock_result(x); |
|
485 |
arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL); |
|
486 |
} |
|
487 |
} |
|
488 |
||
489 |
// for: _iadd, _imul, _isub, _idiv, _irem |
|
490 |
void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) { |
|
491 |
||
492 |
// Test if instr is commutative and if we should swap |
|
493 |
LIRItem left(x->x(), this); |
|
494 |
LIRItem right(x->y(), this); |
|
495 |
LIRItem* left_arg = &left; |
|
496 |
LIRItem* right_arg = &right; |
|
497 |
if (x->is_commutative() && left.is_stack() && right.is_register()) { |
|
498 |
// swap them if left is real stack (or cached) and right is real register(not cached) |
|
499 |
left_arg = &right; |
|
500 |
right_arg = &left; |
|
501 |
} |
|
502 |
||
503 |
left_arg->load_item(); |
|
504 |
||
505 |
// do not need to load right, as we can handle stack and constants |
|
506 |
if (x->op() == Bytecodes::_idiv || x->op() == Bytecodes::_irem) { |
|
507 |
||
508 |
right_arg->load_item(); |
|
509 |
rlock_result(x); |
|
510 |
||
511 |
CodeEmitInfo* info = state_for(x); |
|
512 |
LIR_Opr tmp = new_register(T_INT); |
|
513 |
__ cmp(lir_cond_equal, right_arg->result(), LIR_OprFact::longConst(0)); |
|
514 |
__ branch(lir_cond_equal, T_INT, new DivByZeroStub(info)); |
|
515 |
info = state_for(x); |
|
516 |
||
517 |
if (x->op() == Bytecodes::_irem) { |
|
518 |
__ irem(left_arg->result(), right_arg->result(), x->operand(), tmp, NULL); |
|
519 |
} else if (x->op() == Bytecodes::_idiv) { |
|
520 |
__ idiv(left_arg->result(), right_arg->result(), x->operand(), tmp, NULL); |
|
521 |
} |
|
522 |
||
523 |
} else if (x->op() == Bytecodes::_iadd || x->op() == Bytecodes::_isub) { |
|
524 |
if (right.is_constant() |
|
525 |
&& Assembler::operand_valid_for_add_sub_immediate(right.get_jint_constant())) { |
|
526 |
right.load_nonconstant(); |
|
527 |
} else { |
|
528 |
right.load_item(); |
|
529 |
} |
|
530 |
rlock_result(x); |
|
531 |
arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), LIR_OprFact::illegalOpr); |
|
532 |
} else { |
|
533 |
assert (x->op() == Bytecodes::_imul, "expect imul"); |
|
534 |
if (right.is_constant()) { |
|
45632
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
45115
diff
changeset
|
535 |
jint c = right.get_jint_constant(); |
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
45115
diff
changeset
|
536 |
if (c > 0 && c < max_jint && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) { |
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
45115
diff
changeset
|
537 |
right_arg->dont_load_item(); |
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
45115
diff
changeset
|
538 |
} else { |
29184 | 539 |
// Cannot use constant op. |
45632
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
45115
diff
changeset
|
540 |
right_arg->load_item(); |
29184 | 541 |
} |
542 |
} else { |
|
543 |
right.load_item(); |
|
544 |
} |
|
545 |
rlock_result(x); |
|
546 |
arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), new_register(T_INT)); |
|
547 |
} |
|
548 |
} |
|
549 |
||
550 |
void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) { |
|
551 |
// when an operand with use count 1 is the left operand, then it is |
|
552 |
// likely that no move for 2-operand-LIR-form is necessary |
|
553 |
if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) { |
|
554 |
x->swap_operands(); |
|
555 |
} |
|
556 |
||
557 |
ValueTag tag = x->type()->tag(); |
|
558 |
assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters"); |
|
559 |
switch (tag) { |
|
560 |
case floatTag: |
|
561 |
case doubleTag: do_ArithmeticOp_FPU(x); return; |
|
562 |
case longTag: do_ArithmeticOp_Long(x); return; |
|
563 |
case intTag: do_ArithmeticOp_Int(x); return; |
|
564 |
} |
|
565 |
ShouldNotReachHere(); |
|
566 |
} |
|
567 |
||
568 |
// _ishl, _lshl, _ishr, _lshr, _iushr, _lushr |
|
569 |
void LIRGenerator::do_ShiftOp(ShiftOp* x) { |
|
570 |
||
571 |
LIRItem left(x->x(), this); |
|
572 |
LIRItem right(x->y(), this); |
|
573 |
||
574 |
left.load_item(); |
|
575 |
||
576 |
rlock_result(x); |
|
577 |
if (right.is_constant()) { |
|
578 |
right.dont_load_item(); |
|
579 |
||
580 |
switch (x->op()) { |
|
581 |
case Bytecodes::_ishl: { |
|
582 |
int c = right.get_jint_constant() & 0x1f; |
|
583 |
__ shift_left(left.result(), c, x->operand()); |
|
584 |
break; |
|
585 |
} |
|
586 |
case Bytecodes::_ishr: { |
|
587 |
int c = right.get_jint_constant() & 0x1f; |
|
588 |
__ shift_right(left.result(), c, x->operand()); |
|
589 |
break; |
|
590 |
} |
|
591 |
case Bytecodes::_iushr: { |
|
592 |
int c = right.get_jint_constant() & 0x1f; |
|
593 |
__ unsigned_shift_right(left.result(), c, x->operand()); |
|
594 |
break; |
|
595 |
} |
|
596 |
case Bytecodes::_lshl: { |
|
597 |
int c = right.get_jint_constant() & 0x3f; |
|
598 |
__ shift_left(left.result(), c, x->operand()); |
|
599 |
break; |
|
600 |
} |
|
601 |
case Bytecodes::_lshr: { |
|
602 |
int c = right.get_jint_constant() & 0x3f; |
|
603 |
__ shift_right(left.result(), c, x->operand()); |
|
604 |
break; |
|
605 |
} |
|
606 |
case Bytecodes::_lushr: { |
|
607 |
int c = right.get_jint_constant() & 0x3f; |
|
608 |
__ unsigned_shift_right(left.result(), c, x->operand()); |
|
609 |
break; |
|
610 |
} |
|
611 |
default: |
|
612 |
ShouldNotReachHere(); |
|
613 |
} |
|
614 |
} else { |
|
615 |
right.load_item(); |
|
616 |
LIR_Opr tmp = new_register(T_INT); |
|
617 |
switch (x->op()) { |
|
618 |
case Bytecodes::_ishl: { |
|
619 |
__ logical_and(right.result(), LIR_OprFact::intConst(0x1f), tmp); |
|
620 |
__ shift_left(left.result(), tmp, x->operand(), tmp); |
|
621 |
break; |
|
622 |
} |
|
623 |
case Bytecodes::_ishr: { |
|
624 |
__ logical_and(right.result(), LIR_OprFact::intConst(0x1f), tmp); |
|
625 |
__ shift_right(left.result(), tmp, x->operand(), tmp); |
|
626 |
break; |
|
627 |
} |
|
628 |
case Bytecodes::_iushr: { |
|
629 |
__ logical_and(right.result(), LIR_OprFact::intConst(0x1f), tmp); |
|
630 |
__ unsigned_shift_right(left.result(), tmp, x->operand(), tmp); |
|
631 |
break; |
|
632 |
} |
|
633 |
case Bytecodes::_lshl: { |
|
634 |
__ logical_and(right.result(), LIR_OprFact::intConst(0x3f), tmp); |
|
635 |
__ shift_left(left.result(), tmp, x->operand(), tmp); |
|
636 |
break; |
|
637 |
} |
|
638 |
case Bytecodes::_lshr: { |
|
639 |
__ logical_and(right.result(), LIR_OprFact::intConst(0x3f), tmp); |
|
640 |
__ shift_right(left.result(), tmp, x->operand(), tmp); |
|
641 |
break; |
|
642 |
} |
|
643 |
case Bytecodes::_lushr: { |
|
644 |
__ logical_and(right.result(), LIR_OprFact::intConst(0x3f), tmp); |
|
645 |
__ unsigned_shift_right(left.result(), tmp, x->operand(), tmp); |
|
646 |
break; |
|
647 |
} |
|
648 |
default: |
|
649 |
ShouldNotReachHere(); |
|
650 |
} |
|
651 |
} |
|
652 |
} |
|
653 |
||
654 |
// _iand, _land, _ior, _lor, _ixor, _lxor |
|
655 |
void LIRGenerator::do_LogicOp(LogicOp* x) { |
|
656 |
||
657 |
LIRItem left(x->x(), this); |
|
658 |
LIRItem right(x->y(), this); |
|
659 |
||
660 |
left.load_item(); |
|
661 |
||
662 |
rlock_result(x); |
|
663 |
if (right.is_constant() |
|
664 |
&& ((right.type()->tag() == intTag |
|
665 |
&& Assembler::operand_valid_for_logical_immediate(true, right.get_jint_constant())) |
|
666 |
|| (right.type()->tag() == longTag |
|
667 |
&& Assembler::operand_valid_for_logical_immediate(false, right.get_jlong_constant())))) { |
|
668 |
right.dont_load_item(); |
|
669 |
} else { |
|
670 |
right.load_item(); |
|
671 |
} |
|
672 |
switch (x->op()) { |
|
673 |
case Bytecodes::_iand: |
|
674 |
case Bytecodes::_land: |
|
675 |
__ logical_and(left.result(), right.result(), x->operand()); break; |
|
676 |
case Bytecodes::_ior: |
|
677 |
case Bytecodes::_lor: |
|
678 |
__ logical_or (left.result(), right.result(), x->operand()); break; |
|
679 |
case Bytecodes::_ixor: |
|
680 |
case Bytecodes::_lxor: |
|
681 |
__ logical_xor(left.result(), right.result(), x->operand()); break; |
|
682 |
default: Unimplemented(); |
|
683 |
} |
|
684 |
} |
|
685 |
||
686 |
// _lcmp, _fcmpl, _fcmpg, _dcmpl, _dcmpg |
|
687 |
void LIRGenerator::do_CompareOp(CompareOp* x) { |
|
688 |
LIRItem left(x->x(), this); |
|
689 |
LIRItem right(x->y(), this); |
|
690 |
ValueTag tag = x->x()->type()->tag(); |
|
691 |
if (tag == longTag) { |
|
692 |
left.set_destroys_register(); |
|
693 |
} |
|
694 |
left.load_item(); |
|
695 |
right.load_item(); |
|
696 |
LIR_Opr reg = rlock_result(x); |
|
697 |
||
698 |
if (x->x()->type()->is_float_kind()) { |
|
699 |
Bytecodes::Code code = x->op(); |
|
700 |
__ fcmp2int(left.result(), right.result(), reg, (code == Bytecodes::_fcmpl || code == Bytecodes::_dcmpl)); |
|
701 |
} else if (x->x()->type()->tag() == longTag) { |
|
702 |
__ lcmp2int(left.result(), right.result(), reg); |
|
703 |
} else { |
|
704 |
Unimplemented(); |
|
705 |
} |
|
706 |
} |
|
707 |
||
49906 | 708 |
LIR_Opr LIRGenerator::atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value) { |
709 |
LIR_Opr ill = LIR_OprFact::illegalOpr; // for convenience |
|
710 |
new_value.load_item(); |
|
711 |
cmp_value.load_item(); |
|
712 |
LIR_Opr result = new_register(T_INT); |
|
713 |
if (type == T_OBJECT || type == T_ARRAY) { |
|
714 |
__ cas_obj(addr, cmp_value.result(), new_value.result(), new_register(T_INT), new_register(T_INT), result); |
|
715 |
} else if (type == T_INT) { |
|
716 |
__ cas_int(addr->as_address_ptr()->base(), cmp_value.result(), new_value.result(), ill, ill); |
|
717 |
} else if (type == T_LONG) { |
|
718 |
__ cas_long(addr->as_address_ptr()->base(), cmp_value.result(), new_value.result(), ill, ill); |
|
719 |
} else { |
|
720 |
ShouldNotReachHere(); |
|
721 |
Unimplemented(); |
|
722 |
} |
|
723 |
__ logical_xor(FrameMap::r8_opr, LIR_OprFact::intConst(1), result); |
|
724 |
return result; |
|
725 |
} |
|
29184 | 726 |
|
49906 | 727 |
LIR_Opr LIRGenerator::atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& value) { |
728 |
bool is_oop = type == T_OBJECT || type == T_ARRAY; |
|
729 |
LIR_Opr result = new_register(type); |
|
730 |
value.load_item(); |
|
731 |
assert(type == T_INT || is_oop LP64_ONLY( || type == T_LONG ), "unexpected type"); |
|
732 |
LIR_Opr tmp = new_register(T_INT); |
|
733 |
__ xchg(addr, value.result(), result, tmp); |
|
734 |
return result; |
|
735 |
} |
|
29184 | 736 |
|
49906 | 737 |
LIR_Opr LIRGenerator::atomic_add(BasicType type, LIR_Opr addr, LIRItem& value) { |
738 |
LIR_Opr result = new_register(type); |
|
739 |
value.load_item(); |
|
740 |
assert(type == T_INT LP64_ONLY( || type == T_LONG ), "unexpected type"); |
|
741 |
LIR_Opr tmp = new_register(T_INT); |
|
742 |
__ xadd(addr, value.result(), result, tmp); |
|
743 |
return result; |
|
29184 | 744 |
} |
745 |
||
746 |
void LIRGenerator::do_MathIntrinsic(Intrinsic* x) { |
|
747 |
switch (x->id()) { |
|
748 |
case vmIntrinsics::_dabs: |
|
749 |
case vmIntrinsics::_dsqrt: { |
|
750 |
assert(x->number_of_arguments() == 1, "wrong type"); |
|
751 |
LIRItem value(x->argument_at(0), this); |
|
752 |
value.load_item(); |
|
753 |
LIR_Opr dst = rlock_result(x); |
|
754 |
||
755 |
switch (x->id()) { |
|
756 |
case vmIntrinsics::_dsqrt: { |
|
757 |
__ sqrt(value.result(), dst, LIR_OprFact::illegalOpr); |
|
758 |
break; |
|
759 |
} |
|
760 |
case vmIntrinsics::_dabs: { |
|
761 |
__ abs(value.result(), dst, LIR_OprFact::illegalOpr); |
|
762 |
break; |
|
763 |
} |
|
764 |
} |
|
765 |
break; |
|
766 |
} |
|
767 |
case vmIntrinsics::_dlog10: // fall through |
|
768 |
case vmIntrinsics::_dlog: // fall through |
|
769 |
case vmIntrinsics::_dsin: // fall through |
|
770 |
case vmIntrinsics::_dtan: // fall through |
|
771 |
case vmIntrinsics::_dcos: // fall through |
|
772 |
case vmIntrinsics::_dexp: { |
|
773 |
assert(x->number_of_arguments() == 1, "wrong type"); |
|
774 |
||
775 |
address runtime_entry = NULL; |
|
776 |
switch (x->id()) { |
|
777 |
case vmIntrinsics::_dsin: |
|
778 |
runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin); |
|
779 |
break; |
|
780 |
case vmIntrinsics::_dcos: |
|
781 |
runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos); |
|
782 |
break; |
|
783 |
case vmIntrinsics::_dtan: |
|
784 |
runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan); |
|
785 |
break; |
|
786 |
case vmIntrinsics::_dlog: |
|
787 |
runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog); |
|
788 |
break; |
|
789 |
case vmIntrinsics::_dlog10: |
|
790 |
runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10); |
|
791 |
break; |
|
792 |
case vmIntrinsics::_dexp: |
|
793 |
runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dexp); |
|
794 |
break; |
|
795 |
default: |
|
796 |
ShouldNotReachHere(); |
|
797 |
} |
|
798 |
||
799 |
LIR_Opr result = call_runtime(x->argument_at(0), runtime_entry, x->type(), NULL); |
|
800 |
set_result(x, result); |
|
801 |
break; |
|
802 |
} |
|
803 |
case vmIntrinsics::_dpow: { |
|
804 |
assert(x->number_of_arguments() == 2, "wrong type"); |
|
805 |
address runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dpow); |
|
806 |
LIR_Opr result = call_runtime(x->argument_at(0), x->argument_at(1), runtime_entry, x->type(), NULL); |
|
807 |
set_result(x, result); |
|
808 |
break; |
|
809 |
} |
|
810 |
} |
|
811 |
} |
|
812 |
||
813 |
||
814 |
void LIRGenerator::do_ArrayCopy(Intrinsic* x) { |
|
815 |
assert(x->number_of_arguments() == 5, "wrong type"); |
|
816 |
||
817 |
// Make all state_for calls early since they can emit code |
|
818 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
819 |
||
820 |
LIRItem src(x->argument_at(0), this); |
|
821 |
LIRItem src_pos(x->argument_at(1), this); |
|
822 |
LIRItem dst(x->argument_at(2), this); |
|
823 |
LIRItem dst_pos(x->argument_at(3), this); |
|
824 |
LIRItem length(x->argument_at(4), this); |
|
825 |
||
826 |
// operands for arraycopy must use fixed registers, otherwise |
|
827 |
// LinearScan will fail allocation (because arraycopy always needs a |
|
828 |
// call) |
|
829 |
||
830 |
// The java calling convention will give us enough registers |
|
831 |
// so that on the stub side the args will be perfect already. |
|
832 |
// On the other slow/special case side we call C and the arg |
|
833 |
// positions are not similar enough to pick one as the best. |
|
834 |
// Also because the java calling convention is a "shifted" version |
|
835 |
// of the C convention we can process the java args trivially into C |
|
836 |
// args without worry of overwriting during the xfer |
|
837 |
||
838 |
src.load_item_force (FrameMap::as_oop_opr(j_rarg0)); |
|
839 |
src_pos.load_item_force (FrameMap::as_opr(j_rarg1)); |
|
840 |
dst.load_item_force (FrameMap::as_oop_opr(j_rarg2)); |
|
841 |
dst_pos.load_item_force (FrameMap::as_opr(j_rarg3)); |
|
842 |
length.load_item_force (FrameMap::as_opr(j_rarg4)); |
|
843 |
||
844 |
LIR_Opr tmp = FrameMap::as_opr(j_rarg5); |
|
845 |
||
846 |
set_no_result(x); |
|
847 |
||
848 |
int flags; |
|
849 |
ciArrayKlass* expected_type; |
|
850 |
arraycopy_helper(x, &flags, &expected_type); |
|
851 |
||
852 |
__ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, expected_type, flags, info); // does add_safepoint |
|
853 |
} |
|
854 |
||
855 |
void LIRGenerator::do_update_CRC32(Intrinsic* x) { |
|
856 |
assert(UseCRC32Intrinsics, "why are we here?"); |
|
857 |
// Make all state_for calls early since they can emit code |
|
858 |
LIR_Opr result = rlock_result(x); |
|
859 |
int flags = 0; |
|
860 |
switch (x->id()) { |
|
861 |
case vmIntrinsics::_updateCRC32: { |
|
862 |
LIRItem crc(x->argument_at(0), this); |
|
863 |
LIRItem val(x->argument_at(1), this); |
|
864 |
// val is destroyed by update_crc32 |
|
865 |
val.set_destroys_register(); |
|
866 |
crc.load_item(); |
|
867 |
val.load_item(); |
|
868 |
__ update_crc32(crc.result(), val.result(), result); |
|
869 |
break; |
|
870 |
} |
|
871 |
case vmIntrinsics::_updateBytesCRC32: |
|
872 |
case vmIntrinsics::_updateByteBufferCRC32: { |
|
873 |
bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32); |
|
874 |
||
875 |
LIRItem crc(x->argument_at(0), this); |
|
876 |
LIRItem buf(x->argument_at(1), this); |
|
877 |
LIRItem off(x->argument_at(2), this); |
|
878 |
LIRItem len(x->argument_at(3), this); |
|
879 |
buf.load_item(); |
|
880 |
off.load_nonconstant(); |
|
881 |
||
882 |
LIR_Opr index = off.result(); |
|
883 |
int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0; |
|
884 |
if(off.result()->is_constant()) { |
|
885 |
index = LIR_OprFact::illegalOpr; |
|
886 |
offset += off.result()->as_jint(); |
|
887 |
} |
|
888 |
LIR_Opr base_op = buf.result(); |
|
889 |
||
890 |
if (index->is_valid()) { |
|
891 |
LIR_Opr tmp = new_register(T_LONG); |
|
892 |
__ convert(Bytecodes::_i2l, index, tmp); |
|
893 |
index = tmp; |
|
894 |
} |
|
895 |
||
896 |
if (offset) { |
|
897 |
LIR_Opr tmp = new_pointer_register(); |
|
898 |
__ add(base_op, LIR_OprFact::intConst(offset), tmp); |
|
899 |
base_op = tmp; |
|
900 |
offset = 0; |
|
901 |
} |
|
902 |
||
903 |
LIR_Address* a = new LIR_Address(base_op, |
|
904 |
index, |
|
905 |
offset, |
|
906 |
T_BYTE); |
|
907 |
BasicTypeList signature(3); |
|
908 |
signature.append(T_INT); |
|
909 |
signature.append(T_ADDRESS); |
|
910 |
signature.append(T_INT); |
|
911 |
CallingConvention* cc = frame_map()->c_calling_convention(&signature); |
|
912 |
const LIR_Opr result_reg = result_register_for(x->type()); |
|
913 |
||
914 |
LIR_Opr addr = new_pointer_register(); |
|
915 |
__ leal(LIR_OprFact::address(a), addr); |
|
916 |
||
917 |
crc.load_item_force(cc->at(0)); |
|
918 |
__ move(addr, cc->at(1)); |
|
919 |
len.load_item_force(cc->at(2)); |
|
920 |
||
921 |
__ call_runtime_leaf(StubRoutines::updateBytesCRC32(), getThreadTemp(), result_reg, cc->args()); |
|
922 |
__ move(result_reg, result); |
|
923 |
||
924 |
break; |
|
925 |
} |
|
926 |
default: { |
|
927 |
ShouldNotReachHere(); |
|
928 |
} |
|
929 |
} |
|
930 |
} |
|
931 |
||
38237
d972e3a2df53
8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents:
38031
diff
changeset
|
932 |
void LIRGenerator::do_update_CRC32C(Intrinsic* x) { |
47767
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
933 |
assert(UseCRC32CIntrinsics, "why are we here?"); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
934 |
// Make all state_for calls early since they can emit code |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
935 |
LIR_Opr result = rlock_result(x); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
936 |
int flags = 0; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
937 |
switch (x->id()) { |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
938 |
case vmIntrinsics::_updateBytesCRC32C: |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
939 |
case vmIntrinsics::_updateDirectByteBufferCRC32C: { |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
940 |
bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32C); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
941 |
int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
942 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
943 |
LIRItem crc(x->argument_at(0), this); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
944 |
LIRItem buf(x->argument_at(1), this); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
945 |
LIRItem off(x->argument_at(2), this); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
946 |
LIRItem end(x->argument_at(3), this); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
947 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
948 |
buf.load_item(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
949 |
off.load_nonconstant(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
950 |
end.load_nonconstant(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
951 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
952 |
// len = end - off |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
953 |
LIR_Opr len = end.result(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
954 |
LIR_Opr tmpA = new_register(T_INT); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
955 |
LIR_Opr tmpB = new_register(T_INT); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
956 |
__ move(end.result(), tmpA); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
957 |
__ move(off.result(), tmpB); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
958 |
__ sub(tmpA, tmpB, tmpA); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
959 |
len = tmpA; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
960 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
961 |
LIR_Opr index = off.result(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
962 |
if(off.result()->is_constant()) { |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
963 |
index = LIR_OprFact::illegalOpr; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
964 |
offset += off.result()->as_jint(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
965 |
} |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
966 |
LIR_Opr base_op = buf.result(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
967 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
968 |
if (index->is_valid()) { |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
969 |
LIR_Opr tmp = new_register(T_LONG); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
970 |
__ convert(Bytecodes::_i2l, index, tmp); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
971 |
index = tmp; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
972 |
} |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
973 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
974 |
if (offset) { |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
975 |
LIR_Opr tmp = new_pointer_register(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
976 |
__ add(base_op, LIR_OprFact::intConst(offset), tmp); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
977 |
base_op = tmp; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
978 |
offset = 0; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
979 |
} |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
980 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
981 |
LIR_Address* a = new LIR_Address(base_op, |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
982 |
index, |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
983 |
offset, |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
984 |
T_BYTE); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
985 |
BasicTypeList signature(3); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
986 |
signature.append(T_INT); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
987 |
signature.append(T_ADDRESS); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
988 |
signature.append(T_INT); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
989 |
CallingConvention* cc = frame_map()->c_calling_convention(&signature); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
990 |
const LIR_Opr result_reg = result_register_for(x->type()); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
991 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
992 |
LIR_Opr addr = new_pointer_register(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
993 |
__ leal(LIR_OprFact::address(a), addr); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
994 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
995 |
crc.load_item_force(cc->at(0)); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
996 |
__ move(addr, cc->at(1)); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
997 |
__ move(len, cc->at(2)); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
998 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
999 |
__ call_runtime_leaf(StubRoutines::updateBytesCRC32C(), getThreadTemp(), result_reg, cc->args()); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1000 |
__ move(result_reg, result); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1001 |
|
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1002 |
break; |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1003 |
} |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1004 |
default: { |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1005 |
ShouldNotReachHere(); |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1006 |
} |
107622f2695c
8189745: AARCH64: Use CRC32C intrinsic code in interpreter and C1
dchuyko
parents:
47216
diff
changeset
|
1007 |
} |
38237
d972e3a2df53
8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents:
38031
diff
changeset
|
1008 |
} |
d972e3a2df53
8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents:
38031
diff
changeset
|
1009 |
|
41323 | 1010 |
void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) { |
42653 | 1011 |
assert(x->number_of_arguments() == 3, "wrong type"); |
1012 |
assert(UseFMA, "Needs FMA instructions support."); |
|
1013 |
LIRItem value(x->argument_at(0), this); |
|
1014 |
LIRItem value1(x->argument_at(1), this); |
|
1015 |
LIRItem value2(x->argument_at(2), this); |
|
1016 |
||
1017 |
value.load_item(); |
|
1018 |
value1.load_item(); |
|
1019 |
value2.load_item(); |
|
1020 |
||
1021 |
LIR_Opr calc_input = value.result(); |
|
1022 |
LIR_Opr calc_input1 = value1.result(); |
|
1023 |
LIR_Opr calc_input2 = value2.result(); |
|
1024 |
LIR_Opr calc_result = rlock_result(x); |
|
1025 |
||
1026 |
switch (x->id()) { |
|
1027 |
case vmIntrinsics::_fmaD: __ fmad(calc_input, calc_input1, calc_input2, calc_result); break; |
|
1028 |
case vmIntrinsics::_fmaF: __ fmaf(calc_input, calc_input1, calc_input2, calc_result); break; |
|
1029 |
default: ShouldNotReachHere(); |
|
1030 |
} |
|
41323 | 1031 |
} |
1032 |
||
38238
1bbcc430c78d
8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents:
38237
diff
changeset
|
1033 |
void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { |
1bbcc430c78d
8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents:
38237
diff
changeset
|
1034 |
fatal("vectorizedMismatch intrinsic is not implemented on this platform"); |
1bbcc430c78d
8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents:
38237
diff
changeset
|
1035 |
} |
1bbcc430c78d
8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents:
38237
diff
changeset
|
1036 |
|
29184 | 1037 |
// _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f |
1038 |
// _i2b, _i2c, _i2s |
|
1039 |
void LIRGenerator::do_Convert(Convert* x) { |
|
1040 |
LIRItem value(x->value(), this); |
|
1041 |
value.load_item(); |
|
1042 |
LIR_Opr input = value.result(); |
|
1043 |
LIR_Opr result = rlock(x); |
|
1044 |
||
1045 |
// arguments of lir_convert |
|
1046 |
LIR_Opr conv_input = input; |
|
1047 |
LIR_Opr conv_result = result; |
|
1048 |
ConversionStub* stub = NULL; |
|
1049 |
||
1050 |
__ convert(x->op(), conv_input, conv_result); |
|
1051 |
||
1052 |
assert(result->is_virtual(), "result must be virtual register"); |
|
1053 |
set_result(x, result); |
|
1054 |
} |
|
1055 |
||
1056 |
void LIRGenerator::do_NewInstance(NewInstance* x) { |
|
1057 |
#ifndef PRODUCT |
|
1058 |
if (PrintNotLoaded && !x->klass()->is_loaded()) { |
|
1059 |
tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci()); |
|
1060 |
} |
|
1061 |
#endif |
|
1062 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1063 |
LIR_Opr reg = result_register_for(x->type()); |
|
1064 |
new_instance(reg, x->klass(), x->is_unresolved(), |
|
1065 |
FrameMap::r2_oop_opr, |
|
1066 |
FrameMap::r5_oop_opr, |
|
1067 |
FrameMap::r4_oop_opr, |
|
1068 |
LIR_OprFact::illegalOpr, |
|
1069 |
FrameMap::r3_metadata_opr, info); |
|
1070 |
LIR_Opr result = rlock_result(x); |
|
1071 |
__ move(reg, result); |
|
1072 |
} |
|
1073 |
||
1074 |
void LIRGenerator::do_NewTypeArray(NewTypeArray* x) { |
|
1075 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1076 |
||
1077 |
LIRItem length(x->length(), this); |
|
1078 |
length.load_item_force(FrameMap::r19_opr); |
|
1079 |
||
1080 |
LIR_Opr reg = result_register_for(x->type()); |
|
1081 |
LIR_Opr tmp1 = FrameMap::r2_oop_opr; |
|
1082 |
LIR_Opr tmp2 = FrameMap::r4_oop_opr; |
|
1083 |
LIR_Opr tmp3 = FrameMap::r5_oop_opr; |
|
1084 |
LIR_Opr tmp4 = reg; |
|
1085 |
LIR_Opr klass_reg = FrameMap::r3_metadata_opr; |
|
1086 |
LIR_Opr len = length.result(); |
|
1087 |
BasicType elem_type = x->elt_type(); |
|
1088 |
||
1089 |
__ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); |
|
1090 |
||
1091 |
CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info); |
|
1092 |
__ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path); |
|
1093 |
||
1094 |
LIR_Opr result = rlock_result(x); |
|
1095 |
__ move(reg, result); |
|
1096 |
} |
|
1097 |
||
1098 |
void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { |
|
1099 |
LIRItem length(x->length(), this); |
|
1100 |
// in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction |
|
1101 |
// and therefore provide the state before the parameters have been consumed |
|
1102 |
CodeEmitInfo* patching_info = NULL; |
|
1103 |
if (!x->klass()->is_loaded() || PatchALot) { |
|
1104 |
patching_info = state_for(x, x->state_before()); |
|
1105 |
} |
|
1106 |
||
1107 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1108 |
||
1109 |
LIR_Opr reg = result_register_for(x->type()); |
|
1110 |
LIR_Opr tmp1 = FrameMap::r2_oop_opr; |
|
1111 |
LIR_Opr tmp2 = FrameMap::r4_oop_opr; |
|
1112 |
LIR_Opr tmp3 = FrameMap::r5_oop_opr; |
|
1113 |
LIR_Opr tmp4 = reg; |
|
1114 |
LIR_Opr klass_reg = FrameMap::r3_metadata_opr; |
|
1115 |
||
1116 |
length.load_item_force(FrameMap::r19_opr); |
|
1117 |
LIR_Opr len = length.result(); |
|
1118 |
||
1119 |
CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info); |
|
1120 |
ciKlass* obj = (ciKlass*) ciObjArrayKlass::make(x->klass()); |
|
1121 |
if (obj == ciEnv::unloaded_ciobjarrayklass()) { |
|
1122 |
BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error"); |
|
1123 |
} |
|
1124 |
klass2reg_with_patching(klass_reg, obj, patching_info); |
|
1125 |
__ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path); |
|
1126 |
||
1127 |
LIR_Opr result = rlock_result(x); |
|
1128 |
__ move(reg, result); |
|
1129 |
} |
|
1130 |
||
1131 |
||
1132 |
void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { |
|
1133 |
Values* dims = x->dims(); |
|
1134 |
int i = dims->length(); |
|
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
35127
diff
changeset
|
1135 |
LIRItemList* items = new LIRItemList(i, i, NULL); |
29184 | 1136 |
while (i-- > 0) { |
1137 |
LIRItem* size = new LIRItem(dims->at(i), this); |
|
1138 |
items->at_put(i, size); |
|
1139 |
} |
|
1140 |
||
1141 |
// Evaluate state_for early since it may emit code. |
|
1142 |
CodeEmitInfo* patching_info = NULL; |
|
1143 |
if (!x->klass()->is_loaded() || PatchALot) { |
|
1144 |
patching_info = state_for(x, x->state_before()); |
|
1145 |
||
1146 |
// Cannot re-use same xhandlers for multiple CodeEmitInfos, so |
|
1147 |
// clone all handlers (NOTE: Usually this is handled transparently |
|
1148 |
// by the CodeEmitInfo cloning logic in CodeStub constructors but |
|
1149 |
// is done explicitly here because a stub isn't being used). |
|
1150 |
x->set_exception_handlers(new XHandlers(x->exception_handlers())); |
|
1151 |
} |
|
1152 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1153 |
||
1154 |
i = dims->length(); |
|
1155 |
while (i-- > 0) { |
|
1156 |
LIRItem* size = items->at(i); |
|
1157 |
size->load_item(); |
|
1158 |
||
1159 |
store_stack_parameter(size->result(), in_ByteSize(i*4)); |
|
1160 |
} |
|
1161 |
||
1162 |
LIR_Opr klass_reg = FrameMap::r0_metadata_opr; |
|
1163 |
klass2reg_with_patching(klass_reg, x->klass(), patching_info); |
|
1164 |
||
1165 |
LIR_Opr rank = FrameMap::r19_opr; |
|
1166 |
__ move(LIR_OprFact::intConst(x->rank()), rank); |
|
1167 |
LIR_Opr varargs = FrameMap::r2_opr; |
|
1168 |
__ move(FrameMap::sp_opr, varargs); |
|
1169 |
LIR_OprList* args = new LIR_OprList(3); |
|
1170 |
args->append(klass_reg); |
|
1171 |
args->append(rank); |
|
1172 |
args->append(varargs); |
|
1173 |
LIR_Opr reg = result_register_for(x->type()); |
|
1174 |
__ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), |
|
1175 |
LIR_OprFact::illegalOpr, |
|
1176 |
reg, args, info); |
|
1177 |
||
1178 |
LIR_Opr result = rlock_result(x); |
|
1179 |
__ move(reg, result); |
|
1180 |
} |
|
1181 |
||
1182 |
void LIRGenerator::do_BlockBegin(BlockBegin* x) { |
|
1183 |
// nothing to do for now |
|
1184 |
} |
|
1185 |
||
1186 |
void LIRGenerator::do_CheckCast(CheckCast* x) { |
|
1187 |
LIRItem obj(x->obj(), this); |
|
1188 |
||
1189 |
CodeEmitInfo* patching_info = NULL; |
|
49933
c63bdf53a1a7
8202399: [C1] LIRGenerator::do_CheckCast needs to exclude is_invokespecial_receiver_check() when using PatchAlot
dholmes
parents:
49906
diff
changeset
|
1190 |
if (!x->klass()->is_loaded() || (PatchALot && !x->is_incompatible_class_change_check() && !x->is_invokespecial_receiver_check())) { |
29184 | 1191 |
// must do this before locking the destination register as an oop register, |
1192 |
// and before the obj is loaded (the latter is for deoptimization) |
|
1193 |
patching_info = state_for(x, x->state_before()); |
|
1194 |
} |
|
1195 |
obj.load_item(); |
|
1196 |
||
1197 |
// info for exceptions |
|
44738 | 1198 |
CodeEmitInfo* info_for_exception = |
1199 |
(x->needs_exception_state() ? state_for(x) : |
|
1200 |
state_for(x, x->state_before(), true /*ignore_xhandler*/)); |
|
29184 | 1201 |
|
1202 |
CodeStub* stub; |
|
1203 |
if (x->is_incompatible_class_change_check()) { |
|
1204 |
assert(patching_info == NULL, "can't patch this"); |
|
1205 |
stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); |
|
44738 | 1206 |
} else if (x->is_invokespecial_receiver_check()) { |
1207 |
assert(patching_info == NULL, "can't patch this"); |
|
1208 |
stub = new DeoptimizeStub(info_for_exception, |
|
1209 |
Deoptimization::Reason_class_check, |
|
1210 |
Deoptimization::Action_none); |
|
29184 | 1211 |
} else { |
1212 |
stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); |
|
1213 |
} |
|
1214 |
LIR_Opr reg = rlock_result(x); |
|
1215 |
LIR_Opr tmp3 = LIR_OprFact::illegalOpr; |
|
1216 |
if (!x->klass()->is_loaded() || UseCompressedClassPointers) { |
|
1217 |
tmp3 = new_register(objectType); |
|
1218 |
} |
|
1219 |
__ checkcast(reg, obj.result(), x->klass(), |
|
1220 |
new_register(objectType), new_register(objectType), tmp3, |
|
1221 |
x->direct_compare(), info_for_exception, patching_info, stub, |
|
1222 |
x->profiled_method(), x->profiled_bci()); |
|
1223 |
} |
|
1224 |
||
1225 |
void LIRGenerator::do_InstanceOf(InstanceOf* x) { |
|
1226 |
LIRItem obj(x->obj(), this); |
|
1227 |
||
1228 |
// result and test object may not be in same register |
|
1229 |
LIR_Opr reg = rlock_result(x); |
|
1230 |
CodeEmitInfo* patching_info = NULL; |
|
1231 |
if ((!x->klass()->is_loaded() || PatchALot)) { |
|
1232 |
// must do this before locking the destination register as an oop register |
|
1233 |
patching_info = state_for(x, x->state_before()); |
|
1234 |
} |
|
1235 |
obj.load_item(); |
|
1236 |
LIR_Opr tmp3 = LIR_OprFact::illegalOpr; |
|
1237 |
if (!x->klass()->is_loaded() || UseCompressedClassPointers) { |
|
1238 |
tmp3 = new_register(objectType); |
|
1239 |
} |
|
1240 |
__ instanceof(reg, obj.result(), x->klass(), |
|
1241 |
new_register(objectType), new_register(objectType), tmp3, |
|
1242 |
x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci()); |
|
1243 |
} |
|
1244 |
||
1245 |
void LIRGenerator::do_If(If* x) { |
|
1246 |
assert(x->number_of_sux() == 2, "inconsistency"); |
|
1247 |
ValueTag tag = x->x()->type()->tag(); |
|
1248 |
bool is_safepoint = x->is_safepoint(); |
|
1249 |
||
1250 |
If::Condition cond = x->cond(); |
|
1251 |
||
1252 |
LIRItem xitem(x->x(), this); |
|
1253 |
LIRItem yitem(x->y(), this); |
|
1254 |
LIRItem* xin = &xitem; |
|
1255 |
LIRItem* yin = &yitem; |
|
1256 |
||
1257 |
if (tag == longTag) { |
|
1258 |
// for longs, only conditions "eql", "neq", "lss", "geq" are valid; |
|
1259 |
// mirror for other conditions |
|
1260 |
if (cond == If::gtr || cond == If::leq) { |
|
1261 |
cond = Instruction::mirror(cond); |
|
1262 |
xin = &yitem; |
|
1263 |
yin = &xitem; |
|
1264 |
} |
|
1265 |
xin->set_destroys_register(); |
|
1266 |
} |
|
1267 |
xin->load_item(); |
|
1268 |
||
1269 |
if (tag == longTag) { |
|
1270 |
if (yin->is_constant() |
|
1271 |
&& Assembler::operand_valid_for_add_sub_immediate(yin->get_jlong_constant())) { |
|
1272 |
yin->dont_load_item(); |
|
1273 |
} else { |
|
1274 |
yin->load_item(); |
|
1275 |
} |
|
1276 |
} else if (tag == intTag) { |
|
1277 |
if (yin->is_constant() |
|
1278 |
&& Assembler::operand_valid_for_add_sub_immediate(yin->get_jint_constant())) { |
|
1279 |
yin->dont_load_item(); |
|
1280 |
} else { |
|
1281 |
yin->load_item(); |
|
1282 |
} |
|
1283 |
} else { |
|
1284 |
yin->load_item(); |
|
1285 |
} |
|
1286 |
||
1287 |
// add safepoint before generating condition code so it can be recomputed |
|
1288 |
if (x->is_safepoint()) { |
|
1289 |
// increment backedge counter if needed |
|
1290 |
increment_backedge_counter(state_for(x, x->state_before()), x->profiled_bci()); |
|
1291 |
__ safepoint(LIR_OprFact::illegalOpr, state_for(x, x->state_before())); |
|
1292 |
} |
|
1293 |
set_no_result(x); |
|
1294 |
||
1295 |
LIR_Opr left = xin->result(); |
|
1296 |
LIR_Opr right = yin->result(); |
|
1297 |
||
1298 |
__ cmp(lir_cond(cond), left, right); |
|
1299 |
// Generate branch profiling. Profiling code doesn't kill flags. |
|
1300 |
profile_branch(x, cond); |
|
1301 |
move_to_phi(x->state()); |
|
1302 |
if (x->x()->type()->is_float_kind()) { |
|
1303 |
__ branch(lir_cond(cond), right->type(), x->tsux(), x->usux()); |
|
1304 |
} else { |
|
1305 |
__ branch(lir_cond(cond), right->type(), x->tsux()); |
|
1306 |
} |
|
1307 |
assert(x->default_sux() == x->fsux(), "wrong destination above"); |
|
1308 |
__ jump(x->default_sux()); |
|
1309 |
} |
|
1310 |
||
1311 |
LIR_Opr LIRGenerator::getThreadPointer() { |
|
1312 |
return FrameMap::as_pointer_opr(rthread); |
|
1313 |
} |
|
1314 |
||
1315 |
void LIRGenerator::trace_block_entry(BlockBegin* block) { Unimplemented(); } |
|
1316 |
||
1317 |
void LIRGenerator::volatile_field_store(LIR_Opr value, LIR_Address* address, |
|
1318 |
CodeEmitInfo* info) { |
|
1319 |
__ volatile_store_mem_reg(value, address, info); |
|
1320 |
} |
|
1321 |
||
1322 |
void LIRGenerator::volatile_field_load(LIR_Address* address, LIR_Opr result, |
|
1323 |
CodeEmitInfo* info) { |
|
45115
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1324 |
// 8179954: We need to make sure that the code generated for |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1325 |
// volatile accesses forms a sequentially-consistent set of |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1326 |
// operations when combined with STLR and LDAR. Without a leading |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1327 |
// membar it's possible for a simple Dekker test to fail if loads |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1328 |
// use LD;DMB but stores use STLR. This can happen if C2 compiles |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1329 |
// the stores in one method and C1 compiles the loads in another. |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1330 |
if (! UseBarriersForVolatile) { |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1331 |
__ membar(); |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1332 |
} |
e3a622b2b7db
8179954: AArch64: C1 and C2 volatile accesses are not sequentially consistent
aph
parents:
44738
diff
changeset
|
1333 |
|
29184 | 1334 |
__ volatile_load_mem_reg(address, result, info); |
1335 |
} |