author | iveresov |
Wed, 16 May 2018 15:19:28 -0700 | |
changeset 50153 | 9010b580d8a9 |
parent 49951 | 65b13c206495 |
child 50380 | bec342339138 |
permissions | -rw-r--r-- |
42664 | 1 |
/* |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
42664 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "c1/c1_Compilation.hpp" |
|
27 |
#include "c1/c1_FrameMap.hpp" |
|
28 |
#include "c1/c1_Instruction.hpp" |
|
29 |
#include "c1/c1_LIRAssembler.hpp" |
|
30 |
#include "c1/c1_LIRGenerator.hpp" |
|
31 |
#include "c1/c1_Runtime1.hpp" |
|
32 |
#include "c1/c1_ValueStack.hpp" |
|
33 |
#include "ci/ciArray.hpp" |
|
34 |
#include "ci/ciObjArrayKlass.hpp" |
|
35 |
#include "ci/ciTypeArrayKlass.hpp" |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
36 |
#include "ci/ciUtilities.hpp" |
49906 | 37 |
#include "gc/shared/c1/barrierSetC1.hpp" |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
38 |
#include "gc/shared/cardTable.hpp" |
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49164
diff
changeset
|
39 |
#include "gc/shared/cardTableBarrierSet.hpp" |
42664 | 40 |
#include "runtime/sharedRuntime.hpp" |
41 |
#include "runtime/stubRoutines.hpp" |
|
42 |
#include "vmreg_arm.inline.hpp" |
|
43 |
||
44 |
#ifdef ASSERT |
|
45 |
#define __ gen()->lir(__FILE__, __LINE__)-> |
|
46 |
#else |
|
47 |
#define __ gen()->lir()-> |
|
48 |
#endif |
|
49 |
||
50 |
void LIRItem::load_byte_item() { |
|
51 |
load_item(); |
|
52 |
} |
|
53 |
||
54 |
void LIRItem::load_nonconstant() { |
|
55 |
LIR_Opr r = value()->operand(); |
|
56 |
if (_gen->can_inline_as_constant(value())) { |
|
57 |
if (!r->is_constant()) { |
|
58 |
r = LIR_OprFact::value_type(value()->type()); |
|
59 |
} |
|
60 |
_result = r; |
|
61 |
} else { |
|
62 |
load_item(); |
|
63 |
} |
|
64 |
} |
|
65 |
||
66 |
//-------------------------------------------------------------- |
|
67 |
// LIRGenerator |
|
68 |
//-------------------------------------------------------------- |
|
69 |
||
70 |
||
71 |
LIR_Opr LIRGenerator::exceptionOopOpr() { |
|
72 |
return FrameMap::Exception_oop_opr; |
|
73 |
} |
|
74 |
||
75 |
LIR_Opr LIRGenerator::exceptionPcOpr() { |
|
76 |
return FrameMap::Exception_pc_opr; |
|
77 |
} |
|
78 |
||
79 |
LIR_Opr LIRGenerator::syncLockOpr() { |
|
80 |
return new_register(T_INT); |
|
81 |
} |
|
82 |
||
83 |
LIR_Opr LIRGenerator::syncTempOpr() { |
|
84 |
return new_register(T_OBJECT); |
|
85 |
} |
|
86 |
||
87 |
LIR_Opr LIRGenerator::getThreadTemp() { |
|
88 |
return LIR_OprFact::illegalOpr; |
|
89 |
} |
|
90 |
||
91 |
LIR_Opr LIRGenerator::atomicLockOpr() { |
|
92 |
return LIR_OprFact::illegalOpr; |
|
93 |
} |
|
94 |
||
95 |
LIR_Opr LIRGenerator::result_register_for(ValueType* type, bool callee) { |
|
96 |
LIR_Opr opr; |
|
97 |
switch (type->tag()) { |
|
98 |
case intTag: opr = FrameMap::Int_result_opr; break; |
|
99 |
case objectTag: opr = FrameMap::Object_result_opr; break; |
|
100 |
case longTag: opr = FrameMap::Long_result_opr; break; |
|
101 |
case floatTag: opr = FrameMap::Float_result_opr; break; |
|
102 |
case doubleTag: opr = FrameMap::Double_result_opr; break; |
|
103 |
case addressTag: |
|
104 |
default: ShouldNotReachHere(); return LIR_OprFact::illegalOpr; |
|
105 |
} |
|
106 |
assert(opr->type_field() == as_OprType(as_BasicType(type)), "type mismatch"); |
|
107 |
return opr; |
|
108 |
} |
|
109 |
||
110 |
||
111 |
LIR_Opr LIRGenerator::rlock_byte(BasicType type) { |
|
112 |
return new_register(T_INT); |
|
113 |
} |
|
114 |
||
115 |
||
116 |
//--------- loading items into registers -------------------------------- |
|
117 |
||
118 |
||
119 |
bool LIRGenerator::can_store_as_constant(Value v, BasicType type) const { |
|
120 |
#ifdef AARCH64 |
|
121 |
if (v->type()->as_IntConstant() != NULL) { |
|
122 |
return v->type()->as_IntConstant()->value() == 0; |
|
123 |
} else if (v->type()->as_LongConstant() != NULL) { |
|
124 |
return v->type()->as_LongConstant()->value() == 0; |
|
125 |
} else if (v->type()->as_ObjectConstant() != NULL) { |
|
126 |
return v->type()->as_ObjectConstant()->value()->is_null_object(); |
|
127 |
} else if (v->type()->as_FloatConstant() != NULL) { |
|
128 |
return jint_cast(v->type()->as_FloatConstant()->value()) == 0; |
|
129 |
} else if (v->type()->as_DoubleConstant() != NULL) { |
|
130 |
return jlong_cast(v->type()->as_DoubleConstant()->value()) == 0; |
|
131 |
} |
|
132 |
#endif // AARCH64 |
|
133 |
return false; |
|
134 |
} |
|
135 |
||
136 |
||
137 |
bool LIRGenerator::can_inline_as_constant(Value v) const { |
|
138 |
if (v->type()->as_IntConstant() != NULL) { |
|
139 |
return Assembler::is_arith_imm_in_range(v->type()->as_IntConstant()->value()); |
|
140 |
} else if (v->type()->as_ObjectConstant() != NULL) { |
|
141 |
return v->type()->as_ObjectConstant()->value()->is_null_object(); |
|
142 |
#ifdef AARCH64 |
|
143 |
} else if (v->type()->as_LongConstant() != NULL) { |
|
144 |
return Assembler::is_arith_imm_in_range(v->type()->as_LongConstant()->value()); |
|
145 |
#else |
|
146 |
} else if (v->type()->as_FloatConstant() != NULL) { |
|
147 |
return v->type()->as_FloatConstant()->value() == 0.0f; |
|
148 |
} else if (v->type()->as_DoubleConstant() != NULL) { |
|
149 |
return v->type()->as_DoubleConstant()->value() == 0.0; |
|
150 |
#endif // AARCH64 |
|
151 |
} |
|
152 |
return false; |
|
153 |
} |
|
154 |
||
155 |
||
156 |
bool LIRGenerator::can_inline_as_constant(LIR_Const* c) const { |
|
157 |
ShouldNotCallThis(); // Not used on ARM |
|
158 |
return false; |
|
159 |
} |
|
160 |
||
161 |
||
162 |
#ifdef AARCH64 |
|
163 |
||
164 |
static bool can_inline_as_constant_in_cmp(Value v) { |
|
165 |
jlong constant; |
|
166 |
if (v->type()->as_IntConstant() != NULL) { |
|
167 |
constant = v->type()->as_IntConstant()->value(); |
|
168 |
} else if (v->type()->as_LongConstant() != NULL) { |
|
169 |
constant = v->type()->as_LongConstant()->value(); |
|
170 |
} else if (v->type()->as_ObjectConstant() != NULL) { |
|
171 |
return v->type()->as_ObjectConstant()->value()->is_null_object(); |
|
172 |
} else if (v->type()->as_FloatConstant() != NULL) { |
|
173 |
return v->type()->as_FloatConstant()->value() == 0.0f; |
|
174 |
} else if (v->type()->as_DoubleConstant() != NULL) { |
|
175 |
return v->type()->as_DoubleConstant()->value() == 0.0; |
|
176 |
} else { |
|
177 |
return false; |
|
178 |
} |
|
179 |
||
180 |
return Assembler::is_arith_imm_in_range(constant) || Assembler::is_arith_imm_in_range(-constant); |
|
181 |
} |
|
182 |
||
183 |
||
184 |
static bool can_inline_as_constant_in_logic(Value v) { |
|
185 |
if (v->type()->as_IntConstant() != NULL) { |
|
186 |
return Assembler::LogicalImmediate(v->type()->as_IntConstant()->value(), true).is_encoded(); |
|
187 |
} else if (v->type()->as_LongConstant() != NULL) { |
|
188 |
return Assembler::LogicalImmediate(v->type()->as_LongConstant()->value(), false).is_encoded(); |
|
189 |
} |
|
190 |
return false; |
|
191 |
} |
|
192 |
||
193 |
||
194 |
#endif // AARCH64 |
|
195 |
||
196 |
||
197 |
LIR_Opr LIRGenerator::safepoint_poll_register() { |
|
198 |
return LIR_OprFact::illegalOpr; |
|
199 |
} |
|
200 |
||
201 |
||
202 |
static LIR_Opr make_constant(BasicType type, jlong c) { |
|
203 |
switch (type) { |
|
204 |
case T_ADDRESS: |
|
205 |
case T_OBJECT: return LIR_OprFact::intptrConst(c); |
|
206 |
case T_LONG: return LIR_OprFact::longConst(c); |
|
207 |
case T_INT: return LIR_OprFact::intConst(c); |
|
208 |
default: ShouldNotReachHere(); |
|
209 |
return LIR_OprFact::intConst(-1); |
|
210 |
} |
|
211 |
} |
|
212 |
||
213 |
#ifdef AARCH64 |
|
214 |
||
215 |
void LIRGenerator::add_constant(LIR_Opr src, jlong c, LIR_Opr dest) { |
|
216 |
if (c == 0) { |
|
217 |
__ move(src, dest); |
|
218 |
return; |
|
219 |
} |
|
220 |
||
221 |
BasicType type = src->type(); |
|
222 |
bool is_neg = (c < 0); |
|
223 |
c = ABS(c); |
|
224 |
||
225 |
if ((c >> 24) == 0) { |
|
226 |
for (int shift = 0; shift <= 12; shift += 12) { |
|
227 |
int part = ((int)c) & (right_n_bits(12) << shift); |
|
228 |
if (part != 0) { |
|
229 |
if (is_neg) { |
|
230 |
__ sub(src, make_constant(type, part), dest); |
|
231 |
} else { |
|
232 |
__ add(src, make_constant(type, part), dest); |
|
233 |
} |
|
234 |
src = dest; |
|
235 |
} |
|
236 |
} |
|
237 |
} else { |
|
238 |
__ move(make_constant(type, c), dest); |
|
239 |
if (is_neg) { |
|
240 |
__ sub(src, dest, dest); |
|
241 |
} else { |
|
242 |
__ add(src, dest, dest); |
|
243 |
} |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
#endif // AARCH64 |
|
248 |
||
249 |
||
250 |
void LIRGenerator::add_large_constant(LIR_Opr src, int c, LIR_Opr dest) { |
|
251 |
assert(c != 0, "must be"); |
|
252 |
#ifdef AARCH64 |
|
253 |
add_constant(src, c, dest); |
|
254 |
#else |
|
255 |
// Find first non-zero bit |
|
256 |
int shift = 0; |
|
257 |
while ((c & (3 << shift)) == 0) { |
|
258 |
shift += 2; |
|
259 |
} |
|
260 |
// Add the least significant part of the constant |
|
261 |
int mask = 0xff << shift; |
|
262 |
__ add(src, LIR_OprFact::intConst(c & mask), dest); |
|
263 |
// Add up to 3 other parts of the constant; |
|
264 |
// each of them can be represented as rotated_imm |
|
265 |
if (c & (mask << 8)) { |
|
266 |
__ add(dest, LIR_OprFact::intConst(c & (mask << 8)), dest); |
|
267 |
} |
|
268 |
if (c & (mask << 16)) { |
|
269 |
__ add(dest, LIR_OprFact::intConst(c & (mask << 16)), dest); |
|
270 |
} |
|
271 |
if (c & (mask << 24)) { |
|
272 |
__ add(dest, LIR_OprFact::intConst(c & (mask << 24)), dest); |
|
273 |
} |
|
274 |
#endif // AARCH64 |
|
275 |
} |
|
276 |
||
277 |
static LIR_Address* make_address(LIR_Opr base, LIR_Opr index, LIR_Address::Scale scale, BasicType type) { |
|
278 |
return new LIR_Address(base, index, scale, 0, type); |
|
279 |
} |
|
280 |
||
281 |
LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index, |
|
282 |
int shift, int disp, BasicType type) { |
|
283 |
assert(base->is_register(), "must be"); |
|
284 |
||
285 |
if (index->is_constant()) { |
|
286 |
disp += index->as_constant_ptr()->as_jint() << shift; |
|
287 |
index = LIR_OprFact::illegalOpr; |
|
288 |
} |
|
289 |
||
290 |
#ifndef AARCH64 |
|
291 |
if (base->type() == T_LONG) { |
|
292 |
LIR_Opr tmp = new_register(T_INT); |
|
293 |
__ convert(Bytecodes::_l2i, base, tmp); |
|
294 |
base = tmp; |
|
295 |
} |
|
296 |
if (index != LIR_OprFact::illegalOpr && index->type() == T_LONG) { |
|
297 |
LIR_Opr tmp = new_register(T_INT); |
|
298 |
__ convert(Bytecodes::_l2i, index, tmp); |
|
299 |
index = tmp; |
|
300 |
} |
|
301 |
// At this point base and index should be all ints and not constants |
|
302 |
assert(base->is_single_cpu() && !base->is_constant(), "base should be an non-constant int"); |
|
303 |
assert(index->is_illegal() || (index->type() == T_INT && !index->is_constant()), "index should be an non-constant int"); |
|
304 |
#endif |
|
305 |
||
306 |
int max_disp; |
|
307 |
bool disp_is_in_range; |
|
308 |
bool embedded_shift; |
|
309 |
||
310 |
#ifdef AARCH64 |
|
311 |
int align = exact_log2(type2aelembytes(type, true)); |
|
312 |
assert((disp & right_n_bits(align)) == 0, "displacement is not aligned"); |
|
313 |
assert(shift == 0 || shift == align, "shift should be zero or equal to embedded align"); |
|
314 |
max_disp = (1 << 12) << align; |
|
315 |
||
316 |
if (disp >= 0) { |
|
317 |
disp_is_in_range = Assembler::is_unsigned_imm_in_range(disp, 12, align); |
|
318 |
} else { |
|
319 |
disp_is_in_range = Assembler::is_imm_in_range(disp, 9, 0); |
|
320 |
} |
|
321 |
||
322 |
embedded_shift = true; |
|
323 |
#else |
|
324 |
switch (type) { |
|
325 |
case T_BYTE: |
|
326 |
case T_SHORT: |
|
327 |
case T_CHAR: |
|
328 |
max_disp = 256; // ldrh, ldrsb encoding has 8-bit offset |
|
329 |
embedded_shift = false; |
|
330 |
break; |
|
331 |
case T_FLOAT: |
|
332 |
case T_DOUBLE: |
|
333 |
max_disp = 1024; // flds, fldd have 8-bit offset multiplied by 4 |
|
334 |
embedded_shift = false; |
|
335 |
break; |
|
336 |
case T_LONG: |
|
337 |
max_disp = 4096; |
|
338 |
embedded_shift = false; |
|
339 |
break; |
|
340 |
default: |
|
341 |
max_disp = 4096; // ldr, ldrb allow 12-bit offset |
|
342 |
embedded_shift = true; |
|
343 |
} |
|
344 |
||
345 |
disp_is_in_range = (-max_disp < disp && disp < max_disp); |
|
346 |
#endif // !AARCH64 |
|
347 |
||
348 |
if (index->is_register()) { |
|
349 |
LIR_Opr tmp = new_pointer_register(); |
|
350 |
if (!disp_is_in_range) { |
|
351 |
add_large_constant(base, disp, tmp); |
|
352 |
base = tmp; |
|
353 |
disp = 0; |
|
354 |
} |
|
355 |
LIR_Address* addr = make_address(base, index, (LIR_Address::Scale)shift, type); |
|
356 |
if (disp == 0 && embedded_shift) { |
|
357 |
// can use ldr/str instruction with register index |
|
358 |
return addr; |
|
359 |
} else { |
|
360 |
LIR_Opr tmp = new_pointer_register(); |
|
361 |
__ add(base, LIR_OprFact::address(addr), tmp); // add with shifted/extended register |
|
362 |
return new LIR_Address(tmp, disp, type); |
|
363 |
} |
|
364 |
} |
|
365 |
||
366 |
// If the displacement is too large to be inlined into LDR instruction, |
|
367 |
// generate large constant with additional sequence of ADD instructions |
|
368 |
int excess_disp = disp & ~(max_disp - 1); |
|
369 |
if (excess_disp != 0) { |
|
370 |
LIR_Opr tmp = new_pointer_register(); |
|
371 |
add_large_constant(base, excess_disp, tmp); |
|
372 |
base = tmp; |
|
373 |
} |
|
374 |
return new LIR_Address(base, disp & (max_disp - 1), type); |
|
375 |
} |
|
376 |
||
377 |
||
49938
2c2a722a2c0c
8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents:
49933
diff
changeset
|
378 |
LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type) { |
42664 | 379 |
int base_offset = arrayOopDesc::base_offset_in_bytes(type); |
380 |
int elem_size = type2aelembytes(type); |
|
381 |
||
382 |
if (index_opr->is_constant()) { |
|
383 |
int offset = base_offset + index_opr->as_constant_ptr()->as_jint() * elem_size; |
|
49938
2c2a722a2c0c
8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents:
49933
diff
changeset
|
384 |
return generate_address(array_opr, offset, type); |
42664 | 385 |
} else { |
386 |
assert(index_opr->is_register(), "must be"); |
|
387 |
int scale = exact_log2(elem_size); |
|
49938
2c2a722a2c0c
8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents:
49933
diff
changeset
|
388 |
return generate_address(array_opr, index_opr, scale, base_offset, type); |
42664 | 389 |
} |
390 |
} |
|
391 |
||
392 |
||
393 |
LIR_Opr LIRGenerator::load_immediate(int x, BasicType type) { |
|
394 |
assert(type == T_LONG || type == T_INT, "should be"); |
|
395 |
LIR_Opr r = make_constant(type, x); |
|
396 |
#ifdef AARCH64 |
|
397 |
bool imm_in_range = Assembler::LogicalImmediate(x, type == T_INT).is_encoded(); |
|
398 |
#else |
|
399 |
bool imm_in_range = AsmOperand::is_rotated_imm(x); |
|
400 |
#endif // AARCH64 |
|
401 |
if (!imm_in_range) { |
|
402 |
LIR_Opr tmp = new_register(type); |
|
403 |
__ move(r, tmp); |
|
404 |
return tmp; |
|
405 |
} |
|
406 |
return r; |
|
407 |
} |
|
408 |
||
409 |
||
410 |
void LIRGenerator::increment_counter(address counter, BasicType type, int step) { |
|
411 |
LIR_Opr pointer = new_pointer_register(); |
|
412 |
__ move(LIR_OprFact::intptrConst(counter), pointer); |
|
413 |
LIR_Address* addr = new LIR_Address(pointer, type); |
|
414 |
increment_counter(addr, step); |
|
415 |
} |
|
416 |
||
417 |
||
418 |
void LIRGenerator::increment_counter(LIR_Address* addr, int step) { |
|
419 |
LIR_Opr temp = new_register(addr->type()); |
|
420 |
__ move(addr, temp); |
|
421 |
__ add(temp, make_constant(addr->type(), step), temp); |
|
422 |
__ move(temp, addr); |
|
423 |
} |
|
424 |
||
425 |
||
426 |
void LIRGenerator::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) { |
|
427 |
__ load(new LIR_Address(base, disp, T_INT), FrameMap::LR_opr, info); |
|
428 |
__ cmp(condition, FrameMap::LR_opr, c); |
|
429 |
} |
|
430 |
||
431 |
||
432 |
void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info) { |
|
433 |
__ load(new LIR_Address(base, disp, type), FrameMap::LR_opr, info); |
|
434 |
__ cmp(condition, reg, FrameMap::LR_opr); |
|
435 |
} |
|
436 |
||
437 |
||
438 |
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) { |
|
439 |
assert(left != result, "should be different registers"); |
|
440 |
if (is_power_of_2(c + 1)) { |
|
441 |
#ifdef AARCH64 |
|
442 |
__ shift_left(left, log2_intptr(c + 1), result); |
|
443 |
__ sub(result, left, result); |
|
444 |
#else |
|
445 |
LIR_Address::Scale scale = (LIR_Address::Scale) log2_intptr(c + 1); |
|
446 |
LIR_Address* addr = new LIR_Address(left, left, scale, 0, T_INT); |
|
447 |
__ sub(LIR_OprFact::address(addr), left, result); // rsb with shifted register |
|
448 |
#endif // AARCH64 |
|
449 |
return true; |
|
450 |
} else if (is_power_of_2(c - 1)) { |
|
451 |
LIR_Address::Scale scale = (LIR_Address::Scale) log2_intptr(c - 1); |
|
452 |
LIR_Address* addr = new LIR_Address(left, left, scale, 0, T_INT); |
|
453 |
__ add(left, LIR_OprFact::address(addr), result); // add with shifted register |
|
454 |
return true; |
|
455 |
} |
|
456 |
return false; |
|
457 |
} |
|
458 |
||
459 |
||
460 |
void LIRGenerator::store_stack_parameter(LIR_Opr item, ByteSize offset_from_sp) { |
|
461 |
assert(item->type() == T_INT, "other types are not expected"); |
|
462 |
__ store(item, new LIR_Address(FrameMap::SP_opr, in_bytes(offset_from_sp), item->type())); |
|
463 |
} |
|
464 |
||
465 |
void LIRGenerator::set_card(LIR_Opr value, LIR_Address* card_addr) { |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
466 |
assert(CardTable::dirty_card_val() == 0, |
42664 | 467 |
"Cannot use ZR register (aarch64) or the register containing the card table base address directly (aarch32) otherwise"); |
468 |
#ifdef AARCH64 |
|
469 |
// AARCH64 has a register that is constant zero. We can use that one to set the |
|
470 |
// value in the card table to dirty. |
|
471 |
__ move(FrameMap::ZR_opr, card_addr); |
|
472 |
#else // AARCH64 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
473 |
if((ci_card_table_address_as<intx>() & 0xff) == 0) { |
42664 | 474 |
// If the card table base address is aligned to 256 bytes, we can use the register |
475 |
// that contains the card_table_base_address. |
|
476 |
__ move(value, card_addr); |
|
477 |
} else { |
|
478 |
// Otherwise we need to create a register containing that value. |
|
479 |
LIR_Opr tmp_zero = new_register(T_INT); |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
480 |
__ move(LIR_OprFact::intConst(CardTable::dirty_card_val()), tmp_zero); |
42664 | 481 |
__ move(tmp_zero, card_addr); |
482 |
} |
|
483 |
#endif // AARCH64 |
|
484 |
} |
|
485 |
||
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49164
diff
changeset
|
486 |
void LIRGenerator::CardTableBarrierSet_post_barrier_helper(LIR_OprDesc* addr, LIR_Const* card_table_base) { |
42664 | 487 |
assert(addr->is_register(), "must be a register at this point"); |
488 |
||
49951
65b13c206495
8202418: Remove explicit CMS checks in CardTableBarrierSetAssembler: ARM32 leftovers
shade
parents:
49938
diff
changeset
|
489 |
CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set()); |
65b13c206495
8202418: Remove explicit CMS checks in CardTableBarrierSetAssembler: ARM32 leftovers
shade
parents:
49938
diff
changeset
|
490 |
CardTable* ct = ctbs->card_table(); |
65b13c206495
8202418: Remove explicit CMS checks in CardTableBarrierSetAssembler: ARM32 leftovers
shade
parents:
49938
diff
changeset
|
491 |
|
42664 | 492 |
LIR_Opr tmp = FrameMap::LR_ptr_opr; |
493 |
||
494 |
// TODO-AARCH64: check performance |
|
495 |
bool load_card_table_base_const = AARCH64_ONLY(false) NOT_AARCH64(VM_Version::supports_movw()); |
|
496 |
if (load_card_table_base_const) { |
|
497 |
__ move((LIR_Opr)card_table_base, tmp); |
|
498 |
} else { |
|
499 |
__ move(new LIR_Address(FrameMap::Rthread_opr, in_bytes(JavaThread::card_table_base_offset()), T_ADDRESS), tmp); |
|
500 |
} |
|
501 |
||
502 |
#ifdef AARCH64 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
503 |
LIR_Address* shifted_reg_operand = new LIR_Address(tmp, addr, (LIR_Address::Scale) -CardTable::card_shift, 0, T_BYTE); |
42664 | 504 |
LIR_Opr tmp2 = tmp; |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
505 |
__ add(tmp, LIR_OprFact::address(shifted_reg_operand), tmp2); // tmp2 = tmp + (addr >> CardTable::card_shift) |
42664 | 506 |
LIR_Address* card_addr = new LIR_Address(tmp2, T_BYTE); |
507 |
#else |
|
508 |
// Use unsigned type T_BOOLEAN here rather than (signed) T_BYTE since signed load |
|
509 |
// byte instruction does not support the addressing mode we need. |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
510 |
LIR_Address* card_addr = new LIR_Address(tmp, addr, (LIR_Address::Scale) -CardTable::card_shift, 0, T_BOOLEAN); |
42664 | 511 |
#endif |
512 |
if (UseCondCardMark) { |
|
49951
65b13c206495
8202418: Remove explicit CMS checks in CardTableBarrierSetAssembler: ARM32 leftovers
shade
parents:
49938
diff
changeset
|
513 |
if (ct->scanned_concurrently()) { |
42664 | 514 |
__ membar_storeload(); |
515 |
} |
|
516 |
LIR_Opr cur_value = new_register(T_INT); |
|
517 |
__ move(card_addr, cur_value); |
|
518 |
||
519 |
LabelObj* L_already_dirty = new LabelObj(); |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
520 |
__ cmp(lir_cond_equal, cur_value, LIR_OprFact::intConst(CardTable::dirty_card_val())); |
42664 | 521 |
__ branch(lir_cond_equal, T_BYTE, L_already_dirty->label()); |
522 |
set_card(tmp, card_addr); |
|
523 |
__ branch_destination(L_already_dirty->label()); |
|
524 |
} else { |
|
49951
65b13c206495
8202418: Remove explicit CMS checks in CardTableBarrierSetAssembler: ARM32 leftovers
shade
parents:
49938
diff
changeset
|
525 |
if (ct->scanned_concurrently()) { |
42664 | 526 |
__ membar_storestore(); |
527 |
} |
|
528 |
set_card(tmp, card_addr); |
|
529 |
} |
|
530 |
} |
|
531 |
||
49906 | 532 |
void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) { |
533 |
LIR_Opr tmp1 = FrameMap::R0_oop_opr; |
|
534 |
LIR_Opr tmp2 = FrameMap::R1_oop_opr; |
|
535 |
LIR_Opr tmp3 = LIR_OprFact::illegalOpr; |
|
536 |
__ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci); |
|
537 |
} |
|
538 |
||
42664 | 539 |
//---------------------------------------------------------------------- |
540 |
// visitor functions |
|
541 |
//---------------------------------------------------------------------- |
|
542 |
||
543 |
void LIRGenerator::do_MonitorEnter(MonitorEnter* x) { |
|
544 |
assert(x->is_pinned(),""); |
|
545 |
LIRItem obj(x->obj(), this); |
|
546 |
obj.load_item(); |
|
547 |
set_no_result(x); |
|
548 |
||
549 |
LIR_Opr lock = new_pointer_register(); |
|
550 |
LIR_Opr hdr = new_pointer_register(); |
|
551 |
||
552 |
// Need a scratch register for biased locking on arm |
|
553 |
LIR_Opr scratch = LIR_OprFact::illegalOpr; |
|
554 |
if(UseBiasedLocking) { |
|
555 |
scratch = new_pointer_register(); |
|
556 |
} else { |
|
557 |
scratch = atomicLockOpr(); |
|
558 |
} |
|
559 |
||
560 |
CodeEmitInfo* info_for_exception = NULL; |
|
561 |
if (x->needs_null_check()) { |
|
562 |
info_for_exception = state_for(x); |
|
563 |
} |
|
564 |
||
565 |
CodeEmitInfo* info = state_for(x, x->state(), true); |
|
566 |
monitor_enter(obj.result(), lock, hdr, scratch, |
|
567 |
x->monitor_no(), info_for_exception, info); |
|
568 |
} |
|
569 |
||
570 |
||
571 |
void LIRGenerator::do_MonitorExit(MonitorExit* x) { |
|
572 |
assert(x->is_pinned(),""); |
|
573 |
LIRItem obj(x->obj(), this); |
|
574 |
obj.dont_load_item(); |
|
575 |
set_no_result(x); |
|
576 |
||
577 |
LIR_Opr obj_temp = new_pointer_register(); |
|
578 |
LIR_Opr lock = new_pointer_register(); |
|
579 |
LIR_Opr hdr = new_pointer_register(); |
|
580 |
||
581 |
monitor_exit(obj_temp, lock, hdr, atomicLockOpr(), x->monitor_no()); |
|
582 |
} |
|
583 |
||
584 |
||
585 |
// _ineg, _lneg, _fneg, _dneg |
|
586 |
void LIRGenerator::do_NegateOp(NegateOp* x) { |
|
587 |
#ifdef __SOFTFP__ |
|
588 |
address runtime_func = NULL; |
|
589 |
ValueTag tag = x->type()->tag(); |
|
590 |
if (tag == floatTag) { |
|
591 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::fneg); |
|
592 |
} else if (tag == doubleTag) { |
|
593 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dneg); |
|
594 |
} |
|
595 |
if (runtime_func != NULL) { |
|
596 |
set_result(x, call_runtime(x->x(), runtime_func, x->type(), NULL)); |
|
597 |
return; |
|
598 |
} |
|
599 |
#endif // __SOFTFP__ |
|
600 |
LIRItem value(x->x(), this); |
|
601 |
value.load_item(); |
|
602 |
LIR_Opr reg = rlock_result(x); |
|
603 |
__ negate(value.result(), reg); |
|
604 |
} |
|
605 |
||
606 |
||
607 |
// for _fadd, _fmul, _fsub, _fdiv, _frem |
|
608 |
// _dadd, _dmul, _dsub, _ddiv, _drem |
|
609 |
void LIRGenerator::do_ArithmeticOp_FPU(ArithmeticOp* x) { |
|
610 |
address runtime_func; |
|
611 |
switch (x->op()) { |
|
612 |
case Bytecodes::_frem: |
|
613 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::frem); |
|
614 |
break; |
|
615 |
case Bytecodes::_drem: |
|
616 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::drem); |
|
617 |
break; |
|
618 |
#ifdef __SOFTFP__ |
|
619 |
// Call function compiled with -msoft-float. |
|
620 |
||
621 |
// __aeabi_XXXX_glibc: Imported code from glibc soft-fp bundle for calculation accuracy improvement. See CR 6757269. |
|
622 |
||
623 |
case Bytecodes::_fadd: |
|
624 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fadd_glibc); |
|
625 |
break; |
|
626 |
case Bytecodes::_fmul: |
|
627 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fmul); |
|
628 |
break; |
|
629 |
case Bytecodes::_fsub: |
|
630 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fsub_glibc); |
|
631 |
break; |
|
632 |
case Bytecodes::_fdiv: |
|
633 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_fdiv); |
|
634 |
break; |
|
635 |
case Bytecodes::_dadd: |
|
636 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dadd_glibc); |
|
637 |
break; |
|
638 |
case Bytecodes::_dmul: |
|
639 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dmul); |
|
640 |
break; |
|
641 |
case Bytecodes::_dsub: |
|
642 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_dsub_glibc); |
|
643 |
break; |
|
644 |
case Bytecodes::_ddiv: |
|
645 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_ddiv); |
|
646 |
break; |
|
647 |
default: |
|
648 |
ShouldNotReachHere(); |
|
649 |
#else // __SOFTFP__ |
|
650 |
default: { |
|
651 |
LIRItem left(x->x(), this); |
|
652 |
LIRItem right(x->y(), this); |
|
653 |
left.load_item(); |
|
654 |
right.load_item(); |
|
655 |
rlock_result(x); |
|
656 |
arithmetic_op_fpu(x->op(), x->operand(), left.result(), right.result(), x->is_strictfp()); |
|
657 |
return; |
|
658 |
} |
|
659 |
#endif // __SOFTFP__ |
|
660 |
} |
|
661 |
||
662 |
LIR_Opr result = call_runtime(x->x(), x->y(), runtime_func, x->type(), NULL); |
|
663 |
set_result(x, result); |
|
664 |
} |
|
665 |
||
666 |
||
667 |
void LIRGenerator::make_div_by_zero_check(LIR_Opr right_arg, BasicType type, CodeEmitInfo* info) { |
|
668 |
assert(right_arg->is_register(), "must be"); |
|
669 |
__ cmp(lir_cond_equal, right_arg, make_constant(type, 0)); |
|
670 |
__ branch(lir_cond_equal, type, new DivByZeroStub(info)); |
|
671 |
} |
|
672 |
||
673 |
||
674 |
// for _ladd, _lmul, _lsub, _ldiv, _lrem |
|
675 |
void LIRGenerator::do_ArithmeticOp_Long(ArithmeticOp* x) { |
|
676 |
CodeEmitInfo* info = NULL; |
|
677 |
if (x->op() == Bytecodes::_ldiv || x->op() == Bytecodes::_lrem) { |
|
678 |
info = state_for(x); |
|
679 |
} |
|
680 |
||
681 |
#ifdef AARCH64 |
|
682 |
LIRItem left(x->x(), this); |
|
683 |
LIRItem right(x->y(), this); |
|
684 |
LIRItem* left_arg = &left; |
|
685 |
LIRItem* right_arg = &right; |
|
686 |
||
687 |
// Test if instr is commutative and if we should swap |
|
688 |
if (x->is_commutative() && left.is_constant()) { |
|
689 |
left_arg = &right; |
|
690 |
right_arg = &left; |
|
691 |
} |
|
692 |
||
693 |
left_arg->load_item(); |
|
694 |
switch (x->op()) { |
|
695 |
case Bytecodes::_ldiv: |
|
696 |
right_arg->load_item(); |
|
697 |
make_div_by_zero_check(right_arg->result(), T_LONG, info); |
|
698 |
__ idiv(left_arg->result(), right_arg->result(), rlock_result(x), LIR_OprFact::illegalOpr, NULL); |
|
699 |
break; |
|
700 |
||
701 |
case Bytecodes::_lrem: { |
|
702 |
right_arg->load_item(); |
|
703 |
make_div_by_zero_check(right_arg->result(), T_LONG, info); |
|
704 |
// a % b is implemented with 2 instructions: |
|
705 |
// tmp = a/b (sdiv) |
|
706 |
// res = a - b*tmp (msub) |
|
707 |
LIR_Opr tmp = FrameMap::as_long_opr(Rtemp); |
|
708 |
__ irem(left_arg->result(), right_arg->result(), rlock_result(x), tmp, NULL); |
|
709 |
break; |
|
710 |
} |
|
711 |
||
712 |
case Bytecodes::_lmul: |
|
713 |
if (right_arg->is_constant() && is_power_of_2_long(right_arg->get_jlong_constant())) { |
|
714 |
right_arg->dont_load_item(); |
|
715 |
__ shift_left(left_arg->result(), exact_log2_long(right_arg->get_jlong_constant()), rlock_result(x)); |
|
716 |
} else { |
|
717 |
right_arg->load_item(); |
|
718 |
__ mul(left_arg->result(), right_arg->result(), rlock_result(x)); |
|
719 |
} |
|
720 |
break; |
|
721 |
||
722 |
case Bytecodes::_ladd: |
|
723 |
case Bytecodes::_lsub: |
|
724 |
if (right_arg->is_constant()) { |
|
725 |
jlong c = right_arg->get_jlong_constant(); |
|
726 |
add_constant(left_arg->result(), (x->op() == Bytecodes::_ladd) ? c : -c, rlock_result(x)); |
|
727 |
} else { |
|
728 |
right_arg->load_item(); |
|
729 |
arithmetic_op_long(x->op(), rlock_result(x), left_arg->result(), right_arg->result(), NULL); |
|
730 |
} |
|
731 |
break; |
|
732 |
||
733 |
default: |
|
734 |
ShouldNotReachHere(); |
|
735 |
} |
|
736 |
#else |
|
737 |
switch (x->op()) { |
|
738 |
case Bytecodes::_ldiv: |
|
739 |
case Bytecodes::_lrem: { |
|
740 |
LIRItem right(x->y(), this); |
|
741 |
right.load_item(); |
|
742 |
make_div_by_zero_check(right.result(), T_LONG, info); |
|
743 |
} |
|
744 |
// Fall through |
|
745 |
case Bytecodes::_lmul: { |
|
746 |
address entry; |
|
747 |
switch (x->op()) { |
|
748 |
case Bytecodes::_lrem: |
|
749 |
entry = CAST_FROM_FN_PTR(address, SharedRuntime::lrem); |
|
750 |
break; |
|
751 |
case Bytecodes::_ldiv: |
|
752 |
entry = CAST_FROM_FN_PTR(address, SharedRuntime::ldiv); |
|
753 |
break; |
|
754 |
case Bytecodes::_lmul: |
|
755 |
entry = CAST_FROM_FN_PTR(address, SharedRuntime::lmul); |
|
756 |
break; |
|
757 |
default: |
|
758 |
ShouldNotReachHere(); |
|
759 |
} |
|
760 |
LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL); |
|
761 |
set_result(x, result); |
|
762 |
break; |
|
763 |
} |
|
764 |
case Bytecodes::_ladd: |
|
765 |
case Bytecodes::_lsub: { |
|
766 |
LIRItem left(x->x(), this); |
|
767 |
LIRItem right(x->y(), this); |
|
768 |
left.load_item(); |
|
769 |
right.load_item(); |
|
770 |
rlock_result(x); |
|
771 |
arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL); |
|
772 |
break; |
|
773 |
} |
|
774 |
default: |
|
775 |
ShouldNotReachHere(); |
|
776 |
} |
|
777 |
#endif // AARCH64 |
|
778 |
} |
|
779 |
||
780 |
||
781 |
// for: _iadd, _imul, _isub, _idiv, _irem |
|
782 |
void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) { |
|
783 |
bool is_div_rem = x->op() == Bytecodes::_idiv || x->op() == Bytecodes::_irem; |
|
784 |
LIRItem left(x->x(), this); |
|
785 |
LIRItem right(x->y(), this); |
|
786 |
LIRItem* left_arg = &left; |
|
787 |
LIRItem* right_arg = &right; |
|
788 |
||
789 |
// Test if instr is commutative and if we should swap |
|
790 |
if (x->is_commutative() && left.is_constant()) { |
|
791 |
left_arg = &right; |
|
792 |
right_arg = &left; |
|
793 |
} |
|
794 |
||
795 |
if (is_div_rem) { |
|
796 |
CodeEmitInfo* info = state_for(x); |
|
797 |
if (x->op() == Bytecodes::_idiv && right_arg->is_constant() && is_power_of_2(right_arg->get_jint_constant())) { |
|
798 |
left_arg->load_item(); |
|
799 |
right_arg->dont_load_item(); |
|
800 |
LIR_Opr tmp = LIR_OprFact::illegalOpr; |
|
801 |
LIR_Opr result = rlock_result(x); |
|
802 |
__ idiv(left_arg->result(), right_arg->result(), result, tmp, info); |
|
803 |
} else { |
|
804 |
#ifdef AARCH64 |
|
805 |
left_arg->load_item(); |
|
806 |
right_arg->load_item(); |
|
807 |
make_div_by_zero_check(right_arg->result(), T_INT, info); |
|
808 |
if (x->op() == Bytecodes::_idiv) { |
|
809 |
__ idiv(left_arg->result(), right_arg->result(), rlock_result(x), LIR_OprFact::illegalOpr, NULL); |
|
810 |
} else { |
|
811 |
// a % b is implemented with 2 instructions: |
|
812 |
// tmp = a/b (sdiv) |
|
813 |
// res = a - b*tmp (msub) |
|
814 |
LIR_Opr tmp = FrameMap::as_opr(Rtemp); |
|
815 |
__ irem(left_arg->result(), right_arg->result(), rlock_result(x), tmp, NULL); |
|
816 |
} |
|
817 |
#else |
|
818 |
left_arg->load_item_force(FrameMap::R0_opr); |
|
819 |
right_arg->load_item_force(FrameMap::R2_opr); |
|
820 |
LIR_Opr tmp = FrameMap::R1_opr; |
|
821 |
LIR_Opr result = rlock_result(x); |
|
822 |
LIR_Opr out_reg; |
|
823 |
if (x->op() == Bytecodes::_irem) { |
|
824 |
out_reg = FrameMap::R0_opr; |
|
825 |
__ irem(left_arg->result(), right_arg->result(), out_reg, tmp, info); |
|
826 |
} else if (x->op() == Bytecodes::_idiv) { |
|
827 |
out_reg = FrameMap::R1_opr; |
|
828 |
__ idiv(left_arg->result(), right_arg->result(), out_reg, tmp, info); |
|
829 |
} |
|
830 |
__ move(out_reg, result); |
|
831 |
#endif // AARCH64 |
|
832 |
} |
|
833 |
||
834 |
#ifdef AARCH64 |
|
835 |
} else if (((x->op() == Bytecodes::_iadd) || (x->op() == Bytecodes::_isub)) && right_arg->is_constant()) { |
|
836 |
left_arg->load_item(); |
|
837 |
jint c = right_arg->get_jint_constant(); |
|
838 |
right_arg->dont_load_item(); |
|
839 |
add_constant(left_arg->result(), (x->op() == Bytecodes::_iadd) ? c : -c, rlock_result(x)); |
|
840 |
#endif // AARCH64 |
|
841 |
||
842 |
} else { |
|
843 |
left_arg->load_item(); |
|
844 |
if (x->op() == Bytecodes::_imul && right_arg->is_constant()) { |
|
45632
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
44738
diff
changeset
|
845 |
jint c = right_arg->get_jint_constant(); |
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
44738
diff
changeset
|
846 |
if (c > 0 && c < max_jint && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) { |
42664 | 847 |
right_arg->dont_load_item(); |
848 |
} else { |
|
849 |
right_arg->load_item(); |
|
850 |
} |
|
851 |
} else { |
|
852 |
AARCH64_ONLY(assert(!right_arg->is_constant(), "constant right_arg is already handled by this moment");) |
|
853 |
right_arg->load_nonconstant(); |
|
854 |
} |
|
855 |
rlock_result(x); |
|
856 |
assert(right_arg->is_constant() || right_arg->is_register(), "wrong state of right"); |
|
857 |
arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), NULL); |
|
858 |
} |
|
859 |
} |
|
860 |
||
861 |
||
862 |
void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) { |
|
863 |
ValueTag tag = x->type()->tag(); |
|
864 |
assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters"); |
|
865 |
switch (tag) { |
|
866 |
case floatTag: |
|
867 |
case doubleTag: do_ArithmeticOp_FPU(x); return; |
|
868 |
case longTag: do_ArithmeticOp_Long(x); return; |
|
869 |
case intTag: do_ArithmeticOp_Int(x); return; |
|
870 |
} |
|
871 |
ShouldNotReachHere(); |
|
872 |
} |
|
873 |
||
874 |
||
875 |
// _ishl, _lshl, _ishr, _lshr, _iushr, _lushr |
|
876 |
void LIRGenerator::do_ShiftOp(ShiftOp* x) { |
|
877 |
LIRItem value(x->x(), this); |
|
878 |
LIRItem count(x->y(), this); |
|
879 |
||
880 |
#ifndef AARCH64 |
|
881 |
if (value.type()->is_long()) { |
|
882 |
count.set_destroys_register(); |
|
883 |
} |
|
884 |
#endif // !AARCH64 |
|
885 |
||
886 |
if (count.is_constant()) { |
|
887 |
assert(count.type()->as_IntConstant() != NULL, "should be"); |
|
888 |
count.dont_load_item(); |
|
889 |
} else { |
|
890 |
count.load_item(); |
|
891 |
} |
|
892 |
value.load_item(); |
|
893 |
||
894 |
LIR_Opr res = rlock_result(x); |
|
895 |
shift_op(x->op(), res, value.result(), count.result(), LIR_OprFact::illegalOpr); |
|
896 |
} |
|
897 |
||
898 |
||
899 |
// _iand, _land, _ior, _lor, _ixor, _lxor |
|
900 |
void LIRGenerator::do_LogicOp(LogicOp* x) { |
|
901 |
LIRItem left(x->x(), this); |
|
902 |
LIRItem right(x->y(), this); |
|
903 |
||
904 |
left.load_item(); |
|
905 |
||
906 |
#ifdef AARCH64 |
|
907 |
if (right.is_constant() && can_inline_as_constant_in_logic(right.value())) { |
|
908 |
right.dont_load_item(); |
|
909 |
} else { |
|
910 |
right.load_item(); |
|
911 |
} |
|
912 |
#else |
|
913 |
right.load_nonconstant(); |
|
914 |
#endif // AARCH64 |
|
915 |
||
916 |
logic_op(x->op(), rlock_result(x), left.result(), right.result()); |
|
917 |
} |
|
918 |
||
919 |
||
920 |
// _lcmp, _fcmpl, _fcmpg, _dcmpl, _dcmpg |
|
921 |
void LIRGenerator::do_CompareOp(CompareOp* x) { |
|
922 |
#ifdef __SOFTFP__ |
|
923 |
address runtime_func; |
|
924 |
switch (x->op()) { |
|
925 |
case Bytecodes::_fcmpl: |
|
926 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::fcmpl); |
|
927 |
break; |
|
928 |
case Bytecodes::_fcmpg: |
|
929 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::fcmpg); |
|
930 |
break; |
|
931 |
case Bytecodes::_dcmpl: |
|
932 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dcmpl); |
|
933 |
break; |
|
934 |
case Bytecodes::_dcmpg: |
|
935 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dcmpg); |
|
936 |
break; |
|
937 |
case Bytecodes::_lcmp: { |
|
938 |
LIRItem left(x->x(), this); |
|
939 |
LIRItem right(x->y(), this); |
|
940 |
left.load_item(); |
|
941 |
right.load_nonconstant(); |
|
942 |
LIR_Opr reg = rlock_result(x); |
|
943 |
__ lcmp2int(left.result(), right.result(), reg); |
|
944 |
return; |
|
945 |
} |
|
946 |
default: |
|
947 |
ShouldNotReachHere(); |
|
948 |
} |
|
949 |
LIR_Opr result = call_runtime(x->x(), x->y(), runtime_func, x->type(), NULL); |
|
950 |
set_result(x, result); |
|
951 |
#else // __SOFTFP__ |
|
952 |
LIRItem left(x->x(), this); |
|
953 |
LIRItem right(x->y(), this); |
|
954 |
left.load_item(); |
|
955 |
||
956 |
#ifdef AARCH64 |
|
957 |
if (right.is_constant() && can_inline_as_constant_in_cmp(right.value())) { |
|
958 |
right.dont_load_item(); |
|
959 |
} else { |
|
960 |
right.load_item(); |
|
961 |
} |
|
962 |
#else |
|
963 |
right.load_nonconstant(); |
|
964 |
#endif // AARCH64 |
|
965 |
||
966 |
LIR_Opr reg = rlock_result(x); |
|
967 |
||
968 |
if (x->x()->type()->is_float_kind()) { |
|
969 |
Bytecodes::Code code = x->op(); |
|
970 |
__ fcmp2int(left.result(), right.result(), reg, (code == Bytecodes::_fcmpl || code == Bytecodes::_dcmpl)); |
|
971 |
} else if (x->x()->type()->tag() == longTag) { |
|
972 |
__ lcmp2int(left.result(), right.result(), reg); |
|
973 |
} else { |
|
974 |
ShouldNotReachHere(); |
|
975 |
} |
|
976 |
#endif // __SOFTFP__ |
|
977 |
} |
|
978 |
||
49906 | 979 |
LIR_Opr LIRGenerator::atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value) { |
980 |
LIR_Opr ill = LIR_OprFact::illegalOpr; // for convenience |
|
42664 | 981 |
LIR_Opr tmp1 = LIR_OprFact::illegalOpr; |
982 |
LIR_Opr tmp2 = LIR_OprFact::illegalOpr; |
|
49906 | 983 |
new_value.load_item(); |
984 |
cmp_value.load_item(); |
|
985 |
LIR_Opr result = new_register(T_INT); |
|
986 |
if (type == T_OBJECT || type == T_ARRAY) { |
|
42664 | 987 |
#ifdef AARCH64 |
988 |
if (UseCompressedOops) { |
|
989 |
tmp1 = new_pointer_register(); |
|
990 |
tmp2 = new_pointer_register(); |
|
991 |
} |
|
49906 | 992 |
#endif |
993 |
__ cas_obj(addr, cmp_value.result(), new_value.result(), new_register(T_INT), new_register(T_INT), result); |
|
994 |
} else if (type == T_INT) { |
|
995 |
__ cas_int(addr->as_address_ptr()->base(), cmp_value.result(), new_value.result(), tmp1, tmp1, result); |
|
996 |
} else if (type == T_LONG) { |
|
42664 | 997 |
#ifndef AARCH64 |
998 |
tmp1 = new_register(T_LONG); |
|
999 |
#endif // !AARCH64 |
|
49906 | 1000 |
__ cas_long(addr->as_address_ptr()->base(), cmp_value.result(), new_value.result(), tmp1, tmp2, result); |
1001 |
} else { |
|
42664 | 1002 |
ShouldNotReachHere(); |
1003 |
} |
|
49906 | 1004 |
return result; |
42664 | 1005 |
} |
1006 |
||
49906 | 1007 |
LIR_Opr LIRGenerator::atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& value) { |
1008 |
bool is_oop = type == T_OBJECT || type == T_ARRAY; |
|
1009 |
LIR_Opr result = new_register(type); |
|
1010 |
value.load_item(); |
|
1011 |
assert(type == T_INT || is_oop LP64_ONLY( || type == T_LONG ), "unexpected type"); |
|
1012 |
LIR_Opr tmp = (UseCompressedOops && is_oop) ? new_pointer_register() : LIR_OprFact::illegalOpr; |
|
49938
2c2a722a2c0c
8202379: ARM32 is broken after JDK-8201543 (Modularize C1 GC barriers)
shade
parents:
49933
diff
changeset
|
1013 |
__ xchg(addr, value.result(), result, tmp); |
49906 | 1014 |
return result; |
1015 |
} |
|
1016 |
||
1017 |
LIR_Opr LIRGenerator::atomic_add(BasicType type, LIR_Opr addr, LIRItem& value) { |
|
1018 |
LIR_Opr result = new_register(type); |
|
1019 |
value.load_item(); |
|
1020 |
assert(type == T_INT LP64_ONLY( || type == T_LONG), "unexpected type"); |
|
1021 |
LIR_Opr tmp = new_register(type); |
|
1022 |
__ xadd(addr, value.result(), result, tmp); |
|
1023 |
return result; |
|
1024 |
} |
|
42664 | 1025 |
|
1026 |
void LIRGenerator::do_MathIntrinsic(Intrinsic* x) { |
|
1027 |
address runtime_func; |
|
1028 |
switch (x->id()) { |
|
1029 |
case vmIntrinsics::_dabs: { |
|
1030 |
#ifdef __SOFTFP__ |
|
1031 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dabs); |
|
1032 |
break; |
|
1033 |
#else |
|
1034 |
assert(x->number_of_arguments() == 1, "wrong type"); |
|
1035 |
LIRItem value(x->argument_at(0), this); |
|
1036 |
value.load_item(); |
|
1037 |
__ abs(value.result(), rlock_result(x), LIR_OprFact::illegalOpr); |
|
1038 |
return; |
|
1039 |
#endif // __SOFTFP__ |
|
1040 |
} |
|
1041 |
case vmIntrinsics::_dsqrt: { |
|
1042 |
#ifdef __SOFTFP__ |
|
1043 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dsqrt); |
|
1044 |
break; |
|
1045 |
#else |
|
1046 |
assert(x->number_of_arguments() == 1, "wrong type"); |
|
1047 |
LIRItem value(x->argument_at(0), this); |
|
1048 |
value.load_item(); |
|
1049 |
__ sqrt(value.result(), rlock_result(x), LIR_OprFact::illegalOpr); |
|
1050 |
return; |
|
1051 |
#endif // __SOFTFP__ |
|
1052 |
} |
|
1053 |
case vmIntrinsics::_dsin: |
|
1054 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dsin); |
|
1055 |
break; |
|
1056 |
case vmIntrinsics::_dcos: |
|
1057 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dcos); |
|
1058 |
break; |
|
1059 |
case vmIntrinsics::_dtan: |
|
1060 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dtan); |
|
1061 |
break; |
|
1062 |
case vmIntrinsics::_dlog: |
|
1063 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dlog); |
|
1064 |
break; |
|
1065 |
case vmIntrinsics::_dlog10: |
|
1066 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10); |
|
1067 |
break; |
|
1068 |
case vmIntrinsics::_dexp: |
|
1069 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dexp); |
|
1070 |
break; |
|
1071 |
case vmIntrinsics::_dpow: |
|
1072 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::dpow); |
|
1073 |
break; |
|
1074 |
default: |
|
1075 |
ShouldNotReachHere(); |
|
1076 |
return; |
|
1077 |
} |
|
1078 |
||
1079 |
LIR_Opr result; |
|
1080 |
if (x->number_of_arguments() == 1) { |
|
1081 |
result = call_runtime(x->argument_at(0), runtime_func, x->type(), NULL); |
|
1082 |
} else { |
|
1083 |
assert(x->number_of_arguments() == 2 && x->id() == vmIntrinsics::_dpow, "unexpected intrinsic"); |
|
1084 |
result = call_runtime(x->argument_at(0), x->argument_at(1), runtime_func, x->type(), NULL); |
|
1085 |
} |
|
1086 |
set_result(x, result); |
|
1087 |
} |
|
1088 |
||
1089 |
void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) { |
|
1090 |
fatal("FMA intrinsic is not implemented on this platform"); |
|
1091 |
} |
|
1092 |
||
1093 |
void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { |
|
1094 |
fatal("vectorizedMismatch intrinsic is not implemented on this platform"); |
|
1095 |
} |
|
1096 |
||
1097 |
void LIRGenerator::do_ArrayCopy(Intrinsic* x) { |
|
1098 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1099 |
assert(x->number_of_arguments() == 5, "wrong type"); |
|
1100 |
LIRItem src(x->argument_at(0), this); |
|
1101 |
LIRItem src_pos(x->argument_at(1), this); |
|
1102 |
LIRItem dst(x->argument_at(2), this); |
|
1103 |
LIRItem dst_pos(x->argument_at(3), this); |
|
1104 |
LIRItem length(x->argument_at(4), this); |
|
1105 |
||
1106 |
// We put arguments into the same registers which are used for a Java call. |
|
1107 |
// Note: we used fixed registers for all arguments because all registers |
|
1108 |
// are caller-saved, so register allocator treats them all as used. |
|
1109 |
src.load_item_force (FrameMap::R0_oop_opr); |
|
1110 |
src_pos.load_item_force(FrameMap::R1_opr); |
|
1111 |
dst.load_item_force (FrameMap::R2_oop_opr); |
|
1112 |
dst_pos.load_item_force(FrameMap::R3_opr); |
|
1113 |
length.load_item_force (FrameMap::R4_opr); |
|
1114 |
LIR_Opr tmp = (FrameMap::R5_opr); |
|
1115 |
set_no_result(x); |
|
1116 |
||
1117 |
int flags; |
|
1118 |
ciArrayKlass* expected_type; |
|
1119 |
arraycopy_helper(x, &flags, &expected_type); |
|
1120 |
__ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), |
|
1121 |
tmp, expected_type, flags, info); |
|
1122 |
} |
|
1123 |
||
1124 |
void LIRGenerator::do_update_CRC32(Intrinsic* x) { |
|
1125 |
fatal("CRC32 intrinsic is not implemented on this platform"); |
|
1126 |
} |
|
1127 |
||
1128 |
void LIRGenerator::do_update_CRC32C(Intrinsic* x) { |
|
1129 |
Unimplemented(); |
|
1130 |
} |
|
1131 |
||
1132 |
void LIRGenerator::do_Convert(Convert* x) { |
|
1133 |
address runtime_func; |
|
1134 |
switch (x->op()) { |
|
1135 |
#ifndef AARCH64 |
|
1136 |
case Bytecodes::_l2f: |
|
1137 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::l2f); |
|
1138 |
break; |
|
1139 |
case Bytecodes::_l2d: |
|
1140 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::l2d); |
|
1141 |
break; |
|
1142 |
case Bytecodes::_f2l: |
|
1143 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::f2l); |
|
1144 |
break; |
|
1145 |
case Bytecodes::_d2l: |
|
1146 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::d2l); |
|
1147 |
break; |
|
1148 |
#ifdef __SOFTFP__ |
|
1149 |
case Bytecodes::_f2d: |
|
1150 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_f2d); |
|
1151 |
break; |
|
1152 |
case Bytecodes::_d2f: |
|
1153 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_d2f); |
|
1154 |
break; |
|
1155 |
case Bytecodes::_i2f: |
|
1156 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_i2f); |
|
1157 |
break; |
|
1158 |
case Bytecodes::_i2d: |
|
1159 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_i2d); |
|
1160 |
break; |
|
1161 |
case Bytecodes::_f2i: |
|
1162 |
runtime_func = CAST_FROM_FN_PTR(address, __aeabi_f2iz); |
|
1163 |
break; |
|
1164 |
case Bytecodes::_d2i: |
|
1165 |
// This is implemented in hard float in assembler on arm but a call |
|
1166 |
// on other platforms. |
|
1167 |
runtime_func = CAST_FROM_FN_PTR(address, SharedRuntime::d2i); |
|
1168 |
break; |
|
1169 |
#endif // __SOFTFP__ |
|
1170 |
#endif // !AARCH64 |
|
1171 |
default: { |
|
1172 |
LIRItem value(x->value(), this); |
|
1173 |
value.load_item(); |
|
1174 |
LIR_Opr reg = rlock_result(x); |
|
1175 |
__ convert(x->op(), value.result(), reg, NULL); |
|
1176 |
return; |
|
1177 |
} |
|
1178 |
} |
|
1179 |
||
1180 |
LIR_Opr result = call_runtime(x->value(), runtime_func, x->type(), NULL); |
|
1181 |
set_result(x, result); |
|
1182 |
} |
|
1183 |
||
1184 |
||
1185 |
void LIRGenerator::do_NewInstance(NewInstance* x) { |
|
1186 |
print_if_not_loaded(x); |
|
1187 |
||
1188 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1189 |
LIR_Opr reg = result_register_for(x->type()); // R0 is required by runtime call in NewInstanceStub::emit_code |
|
1190 |
LIR_Opr klass_reg = FrameMap::R1_metadata_opr; // R1 is required by runtime call in NewInstanceStub::emit_code |
|
1191 |
LIR_Opr tmp1 = new_register(objectType); |
|
1192 |
LIR_Opr tmp2 = new_register(objectType); |
|
1193 |
LIR_Opr tmp3 = FrameMap::LR_oop_opr; |
|
1194 |
||
1195 |
new_instance(reg, x->klass(), x->is_unresolved(), tmp1, tmp2, tmp3, |
|
1196 |
LIR_OprFact::illegalOpr, klass_reg, info); |
|
1197 |
||
1198 |
LIR_Opr result = rlock_result(x); |
|
1199 |
__ move(reg, result); |
|
1200 |
} |
|
1201 |
||
1202 |
||
1203 |
void LIRGenerator::do_NewTypeArray(NewTypeArray* x) { |
|
1204 |
// Evaluate state_for() first, because it can emit code |
|
1205 |
// with the same fixed registers that are used here (R1, R2) |
|
1206 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1207 |
LIRItem length(x->length(), this); |
|
1208 |
||
1209 |
length.load_item_force(FrameMap::R2_opr); // R2 is required by runtime call in NewTypeArrayStub::emit_code |
|
1210 |
LIR_Opr len = length.result(); |
|
1211 |
||
1212 |
LIR_Opr reg = result_register_for(x->type()); // R0 is required by runtime call in NewTypeArrayStub::emit_code |
|
1213 |
LIR_Opr klass_reg = FrameMap::R1_metadata_opr; // R1 is required by runtime call in NewTypeArrayStub::emit_code |
|
1214 |
||
1215 |
LIR_Opr tmp1 = new_register(objectType); |
|
1216 |
LIR_Opr tmp2 = new_register(objectType); |
|
1217 |
LIR_Opr tmp3 = FrameMap::LR_oop_opr; |
|
1218 |
LIR_Opr tmp4 = LIR_OprFact::illegalOpr; |
|
1219 |
||
1220 |
BasicType elem_type = x->elt_type(); |
|
1221 |
__ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); |
|
1222 |
||
1223 |
CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info); |
|
1224 |
__ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path); |
|
1225 |
||
1226 |
LIR_Opr result = rlock_result(x); |
|
1227 |
__ move(reg, result); |
|
1228 |
} |
|
1229 |
||
1230 |
||
1231 |
void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { |
|
1232 |
// Evaluate state_for() first, because it can emit code |
|
1233 |
// with the same fixed registers that are used here (R1, R2) |
|
1234 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1235 |
LIRItem length(x->length(), this); |
|
1236 |
||
1237 |
length.load_item_force(FrameMap::R2_opr); // R2 is required by runtime call in NewObjectArrayStub::emit_code |
|
1238 |
LIR_Opr len = length.result(); |
|
1239 |
||
1240 |
CodeEmitInfo* patching_info = NULL; |
|
1241 |
if (!x->klass()->is_loaded() || PatchALot) { |
|
1242 |
patching_info = state_for(x, x->state_before()); |
|
1243 |
} |
|
1244 |
||
1245 |
LIR_Opr reg = result_register_for(x->type()); // R0 is required by runtime call in NewObjectArrayStub::emit_code |
|
1246 |
LIR_Opr klass_reg = FrameMap::R1_metadata_opr; // R1 is required by runtime call in NewObjectArrayStub::emit_code |
|
1247 |
||
1248 |
LIR_Opr tmp1 = new_register(objectType); |
|
1249 |
LIR_Opr tmp2 = new_register(objectType); |
|
1250 |
LIR_Opr tmp3 = FrameMap::LR_oop_opr; |
|
1251 |
LIR_Opr tmp4 = LIR_OprFact::illegalOpr; |
|
1252 |
||
1253 |
CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info); |
|
1254 |
ciMetadata* obj = ciObjArrayKlass::make(x->klass()); |
|
1255 |
if (obj == ciEnv::unloaded_ciobjarrayklass()) { |
|
1256 |
BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error"); |
|
1257 |
} |
|
1258 |
klass2reg_with_patching(klass_reg, obj, patching_info); |
|
1259 |
__ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path); |
|
1260 |
||
1261 |
LIR_Opr result = rlock_result(x); |
|
1262 |
__ move(reg, result); |
|
1263 |
} |
|
1264 |
||
1265 |
||
1266 |
void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { |
|
1267 |
Values* dims = x->dims(); |
|
1268 |
int i = dims->length(); |
|
1269 |
LIRItemList* items = new LIRItemList(i, i, NULL); |
|
1270 |
while (i-- > 0) { |
|
1271 |
LIRItem* size = new LIRItem(dims->at(i), this); |
|
1272 |
items->at_put(i, size); |
|
1273 |
} |
|
1274 |
||
1275 |
// Need to get the info before, as the items may become invalid through item_free |
|
1276 |
CodeEmitInfo* patching_info = NULL; |
|
1277 |
if (!x->klass()->is_loaded() || PatchALot) { |
|
1278 |
patching_info = state_for(x, x->state_before()); |
|
1279 |
||
1280 |
// Cannot re-use same xhandlers for multiple CodeEmitInfos, so |
|
1281 |
// clone all handlers (NOTE: Usually this is handled transparently |
|
1282 |
// by the CodeEmitInfo cloning logic in CodeStub constructors but |
|
1283 |
// is done explicitly here because a stub isn't being used). |
|
1284 |
x->set_exception_handlers(new XHandlers(x->exception_handlers())); |
|
1285 |
} |
|
1286 |
||
1287 |
i = dims->length(); |
|
1288 |
while (i-- > 0) { |
|
1289 |
LIRItem* size = items->at(i); |
|
1290 |
size->load_item(); |
|
1291 |
LIR_Opr sz = size->result(); |
|
1292 |
assert(sz->type() == T_INT, "should be"); |
|
1293 |
store_stack_parameter(sz, in_ByteSize(i * BytesPerInt)); |
|
1294 |
} |
|
1295 |
||
1296 |
CodeEmitInfo* info = state_for(x, x->state()); |
|
1297 |
LIR_Opr klass_reg = FrameMap::R0_metadata_opr; |
|
1298 |
klass2reg_with_patching(klass_reg, x->klass(), patching_info); |
|
1299 |
||
1300 |
LIR_Opr rank = FrameMap::R2_opr; |
|
1301 |
__ move(LIR_OprFact::intConst(x->rank()), rank); |
|
1302 |
LIR_Opr varargs = FrameMap::SP_opr; |
|
1303 |
LIR_OprList* args = new LIR_OprList(3); |
|
1304 |
args->append(klass_reg); |
|
1305 |
args->append(rank); |
|
1306 |
args->append(varargs); |
|
1307 |
LIR_Opr reg = result_register_for(x->type()); |
|
1308 |
__ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), |
|
1309 |
LIR_OprFact::illegalOpr, reg, args, info); |
|
1310 |
||
1311 |
LIR_Opr result = rlock_result(x); |
|
1312 |
__ move(reg, result); |
|
1313 |
} |
|
1314 |
||
1315 |
||
1316 |
void LIRGenerator::do_BlockBegin(BlockBegin* x) { |
|
1317 |
// nothing to do for now |
|
1318 |
} |
|
1319 |
||
1320 |
||
1321 |
void LIRGenerator::do_CheckCast(CheckCast* x) { |
|
1322 |
LIRItem obj(x->obj(), this); |
|
1323 |
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
|
1324 |
if (!x->klass()->is_loaded() || (PatchALot && !x->is_incompatible_class_change_check() && !x->is_invokespecial_receiver_check())) { |
42664 | 1325 |
patching_info = state_for(x, x->state_before()); |
1326 |
} |
|
1327 |
||
1328 |
obj.load_item(); |
|
1329 |
||
44738 | 1330 |
CodeEmitInfo* info_for_exception = |
1331 |
(x->needs_exception_state() ? state_for(x) : |
|
1332 |
state_for(x, x->state_before(), true /*ignore_xhandler*/)); |
|
1333 |
||
42664 | 1334 |
CodeStub* stub; |
1335 |
if (x->is_incompatible_class_change_check()) { |
|
1336 |
assert(patching_info == NULL, "can't patch this"); |
|
1337 |
stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, |
|
1338 |
LIR_OprFact::illegalOpr, info_for_exception); |
|
44738 | 1339 |
} else if (x->is_invokespecial_receiver_check()) { |
1340 |
assert(patching_info == NULL, "can't patch this"); |
|
1341 |
stub = new DeoptimizeStub(info_for_exception, |
|
1342 |
Deoptimization::Reason_class_check, |
|
1343 |
Deoptimization::Action_none); |
|
42664 | 1344 |
} else { |
1345 |
stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, |
|
1346 |
LIR_OprFact::illegalOpr, info_for_exception); |
|
1347 |
} |
|
1348 |
||
1349 |
LIR_Opr out_reg = rlock_result(x); |
|
1350 |
LIR_Opr tmp1 = FrameMap::R0_oop_opr; |
|
1351 |
LIR_Opr tmp2 = FrameMap::R1_oop_opr; |
|
1352 |
LIR_Opr tmp3 = LIR_OprFact::illegalOpr; |
|
1353 |
||
1354 |
__ checkcast(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3, x->direct_compare(), |
|
1355 |
info_for_exception, patching_info, stub, x->profiled_method(), x->profiled_bci()); |
|
1356 |
} |
|
1357 |
||
1358 |
||
1359 |
void LIRGenerator::do_InstanceOf(InstanceOf* x) { |
|
1360 |
LIRItem obj(x->obj(), this); |
|
1361 |
CodeEmitInfo* patching_info = NULL; |
|
1362 |
if (!x->klass()->is_loaded() || PatchALot) { |
|
1363 |
patching_info = state_for(x, x->state_before()); |
|
1364 |
} |
|
1365 |
||
1366 |
obj.load_item(); |
|
1367 |
LIR_Opr out_reg = rlock_result(x); |
|
1368 |
LIR_Opr tmp1 = FrameMap::R0_oop_opr; |
|
1369 |
LIR_Opr tmp2 = FrameMap::R1_oop_opr; |
|
1370 |
LIR_Opr tmp3 = LIR_OprFact::illegalOpr; |
|
1371 |
||
1372 |
__ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3, |
|
1373 |
x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci()); |
|
1374 |
} |
|
1375 |
||
1376 |
||
1377 |
#ifdef __SOFTFP__ |
|
1378 |
// Turn operator if (f <op> g) into runtime call: |
|
1379 |
// call _aeabi_fcmp<op>(f, g) |
|
1380 |
// cmp(eq, 1) |
|
1381 |
// branch(eq, true path). |
|
1382 |
void LIRGenerator::do_soft_float_compare(If* x) { |
|
1383 |
assert(x->number_of_sux() == 2, "inconsistency"); |
|
1384 |
ValueTag tag = x->x()->type()->tag(); |
|
1385 |
If::Condition cond = x->cond(); |
|
1386 |
address runtime_func; |
|
1387 |
// unordered comparison gets the wrong answer because aeabi functions |
|
1388 |
// return false. |
|
1389 |
bool unordered_is_true = x->unordered_is_true(); |
|
1390 |
// reverse of condition for ne |
|
1391 |
bool compare_to_zero = false; |
|
1392 |
switch (lir_cond(cond)) { |
|
1393 |
case lir_cond_notEqual: |
|
1394 |
compare_to_zero = true; // fall through |
|
1395 |
case lir_cond_equal: |
|
1396 |
runtime_func = tag == floatTag ? |
|
1397 |
CAST_FROM_FN_PTR(address, __aeabi_fcmpeq): |
|
1398 |
CAST_FROM_FN_PTR(address, __aeabi_dcmpeq); |
|
1399 |
break; |
|
1400 |
case lir_cond_less: |
|
1401 |
if (unordered_is_true) { |
|
1402 |
runtime_func = tag == floatTag ? |
|
1403 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_fcmplt): |
|
1404 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_dcmplt); |
|
1405 |
} else { |
|
1406 |
runtime_func = tag == floatTag ? |
|
1407 |
CAST_FROM_FN_PTR(address, __aeabi_fcmplt): |
|
1408 |
CAST_FROM_FN_PTR(address, __aeabi_dcmplt); |
|
1409 |
} |
|
1410 |
break; |
|
1411 |
case lir_cond_lessEqual: |
|
1412 |
if (unordered_is_true) { |
|
1413 |
runtime_func = tag == floatTag ? |
|
1414 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_fcmple): |
|
1415 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_dcmple); |
|
1416 |
} else { |
|
1417 |
runtime_func = tag == floatTag ? |
|
1418 |
CAST_FROM_FN_PTR(address, __aeabi_fcmple): |
|
1419 |
CAST_FROM_FN_PTR(address, __aeabi_dcmple); |
|
1420 |
} |
|
1421 |
break; |
|
1422 |
case lir_cond_greaterEqual: |
|
1423 |
if (unordered_is_true) { |
|
1424 |
runtime_func = tag == floatTag ? |
|
1425 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_fcmpge): |
|
1426 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_dcmpge); |
|
1427 |
} else { |
|
1428 |
runtime_func = tag == floatTag ? |
|
1429 |
CAST_FROM_FN_PTR(address, __aeabi_fcmpge): |
|
1430 |
CAST_FROM_FN_PTR(address, __aeabi_dcmpge); |
|
1431 |
} |
|
1432 |
break; |
|
1433 |
case lir_cond_greater: |
|
1434 |
if (unordered_is_true) { |
|
1435 |
runtime_func = tag == floatTag ? |
|
1436 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_fcmpgt): |
|
1437 |
CAST_FROM_FN_PTR(address, SharedRuntime::unordered_dcmpgt); |
|
1438 |
} else { |
|
1439 |
runtime_func = tag == floatTag ? |
|
1440 |
CAST_FROM_FN_PTR(address, __aeabi_fcmpgt): |
|
1441 |
CAST_FROM_FN_PTR(address, __aeabi_dcmpgt); |
|
1442 |
} |
|
1443 |
break; |
|
1444 |
case lir_cond_aboveEqual: |
|
1445 |
case lir_cond_belowEqual: |
|
1446 |
ShouldNotReachHere(); // We're not going to get these. |
|
1447 |
default: |
|
1448 |
assert(lir_cond(cond) == lir_cond_always, "must be"); |
|
1449 |
ShouldNotReachHere(); |
|
1450 |
} |
|
1451 |
set_no_result(x); |
|
1452 |
||
1453 |
// add safepoint before generating condition code so it can be recomputed |
|
1454 |
if (x->is_safepoint()) { |
|
1455 |
increment_backedge_counter(state_for(x, x->state_before()), x->profiled_bci()); |
|
1456 |
__ safepoint(LIR_OprFact::illegalOpr, state_for(x, x->state_before())); |
|
1457 |
} |
|
1458 |
// Call float compare function, returns (1,0) if true or false. |
|
1459 |
LIR_Opr result = call_runtime(x->x(), x->y(), runtime_func, intType, NULL); |
|
1460 |
__ cmp(lir_cond_equal, result, |
|
1461 |
compare_to_zero ? |
|
1462 |
LIR_OprFact::intConst(0) : LIR_OprFact::intConst(1)); |
|
1463 |
profile_branch(x, cond); |
|
1464 |
move_to_phi(x->state()); |
|
1465 |
__ branch(lir_cond_equal, T_INT, x->tsux()); |
|
1466 |
} |
|
1467 |
#endif // __SOFTFP__ |
|
1468 |
||
1469 |
void LIRGenerator::do_If(If* x) { |
|
1470 |
assert(x->number_of_sux() == 2, "inconsistency"); |
|
1471 |
ValueTag tag = x->x()->type()->tag(); |
|
1472 |
||
1473 |
#ifdef __SOFTFP__ |
|
1474 |
if (tag == floatTag || tag == doubleTag) { |
|
1475 |
do_soft_float_compare(x); |
|
1476 |
assert(x->default_sux() == x->fsux(), "wrong destination above"); |
|
1477 |
__ jump(x->default_sux()); |
|
1478 |
return; |
|
1479 |
} |
|
1480 |
#endif // __SOFTFP__ |
|
1481 |
||
1482 |
LIRItem xitem(x->x(), this); |
|
1483 |
LIRItem yitem(x->y(), this); |
|
1484 |
LIRItem* xin = &xitem; |
|
1485 |
LIRItem* yin = &yitem; |
|
1486 |
If::Condition cond = x->cond(); |
|
1487 |
||
1488 |
#ifndef AARCH64 |
|
1489 |
if (tag == longTag) { |
|
1490 |
if (cond == If::gtr || cond == If::leq) { |
|
1491 |
cond = Instruction::mirror(cond); |
|
1492 |
xin = &yitem; |
|
1493 |
yin = &xitem; |
|
1494 |
} |
|
1495 |
xin->set_destroys_register(); |
|
1496 |
} |
|
1497 |
#endif // !AARCH64 |
|
1498 |
||
1499 |
xin->load_item(); |
|
1500 |
LIR_Opr left = xin->result(); |
|
1501 |
LIR_Opr right; |
|
1502 |
||
1503 |
#ifdef AARCH64 |
|
1504 |
if (yin->is_constant() && can_inline_as_constant_in_cmp(yin->value())) { |
|
1505 |
yin->dont_load_item(); |
|
1506 |
} else { |
|
1507 |
yin->load_item(); |
|
1508 |
} |
|
1509 |
right = yin->result(); |
|
1510 |
#else |
|
1511 |
if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && |
|
1512 |
(cond == If::eql || cond == If::neq)) { |
|
1513 |
// inline long zero |
|
1514 |
right = LIR_OprFact::value_type(yin->value()->type()); |
|
1515 |
} else { |
|
1516 |
yin->load_nonconstant(); |
|
1517 |
right = yin->result(); |
|
1518 |
} |
|
1519 |
#endif // AARCH64 |
|
1520 |
||
1521 |
set_no_result(x); |
|
1522 |
||
1523 |
// add safepoint before generating condition code so it can be recomputed |
|
1524 |
if (x->is_safepoint()) { |
|
50153 | 1525 |
increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()), |
1526 |
x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci()); |
|
42664 | 1527 |
__ safepoint(LIR_OprFact::illegalOpr, state_for(x, x->state_before())); |
1528 |
} |
|
1529 |
||
1530 |
__ cmp(lir_cond(cond), left, right); |
|
1531 |
profile_branch(x, cond); |
|
1532 |
move_to_phi(x->state()); |
|
1533 |
if (x->x()->type()->is_float_kind()) { |
|
1534 |
__ branch(lir_cond(cond), right->type(), x->tsux(), x->usux()); |
|
1535 |
} else { |
|
1536 |
__ branch(lir_cond(cond), right->type(), x->tsux()); |
|
1537 |
} |
|
1538 |
assert(x->default_sux() == x->fsux(), "wrong destination above"); |
|
1539 |
__ jump(x->default_sux()); |
|
1540 |
} |
|
1541 |
||
1542 |
||
1543 |
LIR_Opr LIRGenerator::getThreadPointer() { |
|
1544 |
return FrameMap::Rthread_opr; |
|
1545 |
} |
|
1546 |
||
1547 |
void LIRGenerator::trace_block_entry(BlockBegin* block) { |
|
1548 |
__ move(LIR_OprFact::intConst(block->block_id()), FrameMap::R0_opr); |
|
1549 |
LIR_OprList* args = new LIR_OprList(1); |
|
1550 |
args->append(FrameMap::R0_opr); |
|
1551 |
address func = CAST_FROM_FN_PTR(address, Runtime1::trace_block_entry); |
|
1552 |
__ call_runtime_leaf(func, getThreadTemp(), LIR_OprFact::illegalOpr, args); |
|
1553 |
} |
|
1554 |
||
1555 |
||
1556 |
void LIRGenerator::volatile_field_store(LIR_Opr value, LIR_Address* address, |
|
1557 |
CodeEmitInfo* info) { |
|
1558 |
#ifndef AARCH64 |
|
1559 |
if (value->is_double_cpu()) { |
|
1560 |
assert(address->index()->is_illegal(), "should have a constant displacement"); |
|
1561 |
LIR_Opr tmp = new_pointer_register(); |
|
1562 |
add_large_constant(address->base(), address->disp(), tmp); |
|
1563 |
__ volatile_store_mem_reg(value, new LIR_Address(tmp, (intx)0, address->type()), info); |
|
1564 |
return; |
|
1565 |
} |
|
1566 |
#endif // !AARCH64 |
|
1567 |
// TODO-AARCH64 implement with stlr instruction |
|
1568 |
__ store(value, address, info, lir_patch_none); |
|
1569 |
} |
|
1570 |
||
1571 |
void LIRGenerator::volatile_field_load(LIR_Address* address, LIR_Opr result, |
|
1572 |
CodeEmitInfo* info) { |
|
1573 |
#ifndef AARCH64 |
|
1574 |
if (result->is_double_cpu()) { |
|
1575 |
assert(address->index()->is_illegal(), "should have a constant displacement"); |
|
1576 |
LIR_Opr tmp = new_pointer_register(); |
|
1577 |
add_large_constant(address->base(), address->disp(), tmp); |
|
1578 |
__ volatile_load_mem_reg(new LIR_Address(tmp, (intx)0, address->type()), result, info); |
|
1579 |
return; |
|
1580 |
} |
|
1581 |
#endif // !AARCH64 |
|
1582 |
// TODO-AARCH64 implement with ldar instruction |
|
1583 |
__ load(address, result, info, lir_patch_none); |
|
1584 |
} |