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