29183
|
1 |
/*
|
|
2 |
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
|
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
5 |
*
|
|
6 |
* This code is free software; you can redistribute it and/or modify it
|
|
7 |
* under the terms of the GNU General Public License version 2 only, as
|
|
8 |
* published by the Free Software Foundation.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
#include "precompiled.hpp"
|
|
27 |
#include "asm/macroAssembler.hpp"
|
|
28 |
#include "interpreter/interpreter.hpp"
|
|
29 |
#include "interpreter/interpreterRuntime.hpp"
|
|
30 |
#include "interpreter/interp_masm.hpp"
|
|
31 |
#include "interpreter/templateTable.hpp"
|
|
32 |
#include "memory/universe.inline.hpp"
|
|
33 |
#include "oops/methodData.hpp"
|
|
34 |
#include "oops/method.hpp"
|
|
35 |
#include "oops/objArrayKlass.hpp"
|
|
36 |
#include "oops/oop.inline.hpp"
|
|
37 |
#include "prims/methodHandles.hpp"
|
|
38 |
#include "runtime/sharedRuntime.hpp"
|
|
39 |
#include "runtime/stubRoutines.hpp"
|
|
40 |
#include "runtime/synchronizer.hpp"
|
|
41 |
|
|
42 |
#ifndef CC_INTERP
|
|
43 |
|
|
44 |
#define __ _masm->
|
|
45 |
|
|
46 |
// Platform-dependent initialization
|
|
47 |
|
|
48 |
void TemplateTable::pd_initialize() {
|
|
49 |
// No aarch64 specific initialization
|
|
50 |
}
|
|
51 |
|
|
52 |
// Address computation: local variables
|
|
53 |
|
|
54 |
static inline Address iaddress(int n) {
|
|
55 |
return Address(rlocals, Interpreter::local_offset_in_bytes(n));
|
|
56 |
}
|
|
57 |
|
|
58 |
static inline Address laddress(int n) {
|
|
59 |
return iaddress(n + 1);
|
|
60 |
}
|
|
61 |
|
|
62 |
static inline Address faddress(int n) {
|
|
63 |
return iaddress(n);
|
|
64 |
}
|
|
65 |
|
|
66 |
static inline Address daddress(int n) {
|
|
67 |
return laddress(n);
|
|
68 |
}
|
|
69 |
|
|
70 |
static inline Address aaddress(int n) {
|
|
71 |
return iaddress(n);
|
|
72 |
}
|
|
73 |
|
|
74 |
static inline Address iaddress(Register r) {
|
|
75 |
return Address(rlocals, r, Address::lsl(3));
|
|
76 |
}
|
|
77 |
|
|
78 |
static inline Address laddress(Register r, Register scratch,
|
|
79 |
InterpreterMacroAssembler* _masm) {
|
|
80 |
__ lea(scratch, Address(rlocals, r, Address::lsl(3)));
|
|
81 |
return Address(scratch, Interpreter::local_offset_in_bytes(1));
|
|
82 |
}
|
|
83 |
|
|
84 |
static inline Address faddress(Register r) {
|
|
85 |
return iaddress(r);
|
|
86 |
}
|
|
87 |
|
|
88 |
static inline Address daddress(Register r, Register scratch,
|
|
89 |
InterpreterMacroAssembler* _masm) {
|
|
90 |
return laddress(r, scratch, _masm);
|
|
91 |
}
|
|
92 |
|
|
93 |
static inline Address aaddress(Register r) {
|
|
94 |
return iaddress(r);
|
|
95 |
}
|
|
96 |
|
|
97 |
static inline Address at_rsp() {
|
|
98 |
return Address(esp, 0);
|
|
99 |
}
|
|
100 |
|
|
101 |
// At top of Java expression stack which may be different than esp(). It
|
|
102 |
// isn't for category 1 objects.
|
|
103 |
static inline Address at_tos () {
|
|
104 |
return Address(esp, Interpreter::expr_offset_in_bytes(0));
|
|
105 |
}
|
|
106 |
|
|
107 |
static inline Address at_tos_p1() {
|
|
108 |
return Address(esp, Interpreter::expr_offset_in_bytes(1));
|
|
109 |
}
|
|
110 |
|
|
111 |
static inline Address at_tos_p2() {
|
|
112 |
return Address(esp, Interpreter::expr_offset_in_bytes(2));
|
|
113 |
}
|
|
114 |
|
|
115 |
static inline Address at_tos_p3() {
|
|
116 |
return Address(esp, Interpreter::expr_offset_in_bytes(3));
|
|
117 |
}
|
|
118 |
|
|
119 |
static inline Address at_tos_p4() {
|
|
120 |
return Address(esp, Interpreter::expr_offset_in_bytes(4));
|
|
121 |
}
|
|
122 |
|
|
123 |
static inline Address at_tos_p5() {
|
|
124 |
return Address(esp, Interpreter::expr_offset_in_bytes(5));
|
|
125 |
}
|
|
126 |
|
|
127 |
// Condition conversion
|
|
128 |
static Assembler::Condition j_not(TemplateTable::Condition cc) {
|
|
129 |
switch (cc) {
|
|
130 |
case TemplateTable::equal : return Assembler::NE;
|
|
131 |
case TemplateTable::not_equal : return Assembler::EQ;
|
|
132 |
case TemplateTable::less : return Assembler::GE;
|
|
133 |
case TemplateTable::less_equal : return Assembler::GT;
|
|
134 |
case TemplateTable::greater : return Assembler::LE;
|
|
135 |
case TemplateTable::greater_equal: return Assembler::LT;
|
|
136 |
}
|
|
137 |
ShouldNotReachHere();
|
|
138 |
return Assembler::EQ;
|
|
139 |
}
|
|
140 |
|
|
141 |
|
|
142 |
// Miscelaneous helper routines
|
|
143 |
// Store an oop (or NULL) at the Address described by obj.
|
|
144 |
// If val == noreg this means store a NULL
|
|
145 |
static void do_oop_store(InterpreterMacroAssembler* _masm,
|
|
146 |
Address obj,
|
|
147 |
Register val,
|
|
148 |
BarrierSet::Name barrier,
|
|
149 |
bool precise) {
|
|
150 |
assert(val == noreg || val == r0, "parameter is just for looks");
|
|
151 |
switch (barrier) {
|
|
152 |
#if INCLUDE_ALL_GCS
|
|
153 |
case BarrierSet::G1SATBCT:
|
|
154 |
case BarrierSet::G1SATBCTLogging:
|
|
155 |
{
|
|
156 |
// flatten object address if needed
|
|
157 |
if (obj.index() == noreg && obj.offset() == 0) {
|
|
158 |
if (obj.base() != r3) {
|
|
159 |
__ mov(r3, obj.base());
|
|
160 |
}
|
|
161 |
} else {
|
|
162 |
__ lea(r3, obj);
|
|
163 |
}
|
|
164 |
__ g1_write_barrier_pre(r3 /* obj */,
|
|
165 |
r1 /* pre_val */,
|
|
166 |
rthread /* thread */,
|
|
167 |
r10 /* tmp */,
|
|
168 |
val != noreg /* tosca_live */,
|
|
169 |
false /* expand_call */);
|
|
170 |
if (val == noreg) {
|
|
171 |
__ store_heap_oop_null(Address(r3, 0));
|
|
172 |
} else {
|
|
173 |
// G1 barrier needs uncompressed oop for region cross check.
|
|
174 |
Register new_val = val;
|
|
175 |
if (UseCompressedOops) {
|
|
176 |
new_val = rscratch1;
|
|
177 |
__ mov(new_val, val);
|
|
178 |
}
|
|
179 |
__ store_heap_oop(Address(r3, 0), val);
|
|
180 |
__ g1_write_barrier_post(r3 /* store_adr */,
|
|
181 |
new_val /* new_val */,
|
|
182 |
rthread /* thread */,
|
|
183 |
r10 /* tmp */,
|
|
184 |
r1 /* tmp2 */);
|
|
185 |
}
|
|
186 |
|
|
187 |
}
|
|
188 |
break;
|
|
189 |
#endif // INCLUDE_ALL_GCS
|
|
190 |
case BarrierSet::CardTableModRef:
|
|
191 |
case BarrierSet::CardTableExtension:
|
|
192 |
{
|
|
193 |
if (val == noreg) {
|
|
194 |
__ store_heap_oop_null(obj);
|
|
195 |
} else {
|
|
196 |
__ store_heap_oop(obj, val);
|
|
197 |
// flatten object address if needed
|
|
198 |
if (!precise || (obj.index() == noreg && obj.offset() == 0)) {
|
|
199 |
__ store_check(obj.base());
|
|
200 |
} else {
|
|
201 |
__ lea(r3, obj);
|
|
202 |
__ store_check(r3);
|
|
203 |
}
|
|
204 |
}
|
|
205 |
}
|
|
206 |
break;
|
|
207 |
case BarrierSet::ModRef:
|
|
208 |
case BarrierSet::Other:
|
|
209 |
if (val == noreg) {
|
|
210 |
__ store_heap_oop_null(obj);
|
|
211 |
} else {
|
|
212 |
__ store_heap_oop(obj, val);
|
|
213 |
}
|
|
214 |
break;
|
|
215 |
default :
|
|
216 |
ShouldNotReachHere();
|
|
217 |
|
|
218 |
}
|
|
219 |
}
|
|
220 |
|
|
221 |
Address TemplateTable::at_bcp(int offset) {
|
|
222 |
assert(_desc->uses_bcp(), "inconsistent uses_bcp information");
|
|
223 |
return Address(rbcp, offset);
|
|
224 |
}
|
|
225 |
|
|
226 |
void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
|
|
227 |
Register temp_reg, bool load_bc_into_bc_reg/*=true*/,
|
|
228 |
int byte_no)
|
|
229 |
{
|
|
230 |
if (!RewriteBytecodes) return;
|
|
231 |
Label L_patch_done;
|
|
232 |
|
|
233 |
switch (bc) {
|
|
234 |
case Bytecodes::_fast_aputfield:
|
|
235 |
case Bytecodes::_fast_bputfield:
|
|
236 |
case Bytecodes::_fast_cputfield:
|
|
237 |
case Bytecodes::_fast_dputfield:
|
|
238 |
case Bytecodes::_fast_fputfield:
|
|
239 |
case Bytecodes::_fast_iputfield:
|
|
240 |
case Bytecodes::_fast_lputfield:
|
|
241 |
case Bytecodes::_fast_sputfield:
|
|
242 |
{
|
|
243 |
// We skip bytecode quickening for putfield instructions when
|
|
244 |
// the put_code written to the constant pool cache is zero.
|
|
245 |
// This is required so that every execution of this instruction
|
|
246 |
// calls out to InterpreterRuntime::resolve_get_put to do
|
|
247 |
// additional, required work.
|
|
248 |
assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
|
|
249 |
assert(load_bc_into_bc_reg, "we use bc_reg as temp");
|
|
250 |
__ get_cache_and_index_and_bytecode_at_bcp(temp_reg, bc_reg, temp_reg, byte_no, 1);
|
|
251 |
__ movw(bc_reg, bc);
|
|
252 |
__ cmpw(temp_reg, (unsigned) 0);
|
|
253 |
__ br(Assembler::EQ, L_patch_done); // don't patch
|
|
254 |
}
|
|
255 |
break;
|
|
256 |
default:
|
|
257 |
assert(byte_no == -1, "sanity");
|
|
258 |
// the pair bytecodes have already done the load.
|
|
259 |
if (load_bc_into_bc_reg) {
|
|
260 |
__ movw(bc_reg, bc);
|
|
261 |
}
|
|
262 |
}
|
|
263 |
|
|
264 |
if (JvmtiExport::can_post_breakpoint()) {
|
|
265 |
Label L_fast_patch;
|
|
266 |
// if a breakpoint is present we can't rewrite the stream directly
|
|
267 |
__ load_unsigned_byte(temp_reg, at_bcp(0));
|
|
268 |
__ cmpw(temp_reg, Bytecodes::_breakpoint);
|
|
269 |
__ br(Assembler::NE, L_fast_patch);
|
|
270 |
// Let breakpoint table handling rewrite to quicker bytecode
|
|
271 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), rmethod, rbcp, bc_reg);
|
|
272 |
__ b(L_patch_done);
|
|
273 |
__ bind(L_fast_patch);
|
|
274 |
}
|
|
275 |
|
|
276 |
#ifdef ASSERT
|
|
277 |
Label L_okay;
|
|
278 |
__ load_unsigned_byte(temp_reg, at_bcp(0));
|
|
279 |
__ cmpw(temp_reg, (int) Bytecodes::java_code(bc));
|
|
280 |
__ br(Assembler::EQ, L_okay);
|
|
281 |
__ cmpw(temp_reg, bc_reg);
|
|
282 |
__ br(Assembler::EQ, L_okay);
|
|
283 |
__ stop("patching the wrong bytecode");
|
|
284 |
__ bind(L_okay);
|
|
285 |
#endif
|
|
286 |
|
|
287 |
// patch bytecode
|
|
288 |
__ strb(bc_reg, at_bcp(0));
|
|
289 |
__ bind(L_patch_done);
|
|
290 |
}
|
|
291 |
|
|
292 |
|
|
293 |
// Individual instructions
|
|
294 |
|
|
295 |
void TemplateTable::nop() {
|
|
296 |
transition(vtos, vtos);
|
|
297 |
// nothing to do
|
|
298 |
}
|
|
299 |
|
|
300 |
void TemplateTable::shouldnotreachhere() {
|
|
301 |
transition(vtos, vtos);
|
|
302 |
__ stop("shouldnotreachhere bytecode");
|
|
303 |
}
|
|
304 |
|
|
305 |
void TemplateTable::aconst_null()
|
|
306 |
{
|
|
307 |
transition(vtos, atos);
|
|
308 |
__ mov(r0, 0);
|
|
309 |
}
|
|
310 |
|
|
311 |
void TemplateTable::iconst(int value)
|
|
312 |
{
|
|
313 |
transition(vtos, itos);
|
|
314 |
__ mov(r0, value);
|
|
315 |
}
|
|
316 |
|
|
317 |
void TemplateTable::lconst(int value)
|
|
318 |
{
|
|
319 |
__ mov(r0, value);
|
|
320 |
}
|
|
321 |
|
|
322 |
void TemplateTable::fconst(int value)
|
|
323 |
{
|
|
324 |
transition(vtos, ftos);
|
|
325 |
switch (value) {
|
|
326 |
case 0:
|
|
327 |
__ fmovs(v0, zr);
|
|
328 |
break;
|
|
329 |
case 1:
|
|
330 |
__ fmovs(v0, 1.0);
|
|
331 |
break;
|
|
332 |
case 2:
|
|
333 |
__ fmovs(v0, 2.0);
|
|
334 |
break;
|
|
335 |
default:
|
|
336 |
ShouldNotReachHere();
|
|
337 |
break;
|
|
338 |
}
|
|
339 |
}
|
|
340 |
|
|
341 |
void TemplateTable::dconst(int value)
|
|
342 |
{
|
|
343 |
transition(vtos, dtos);
|
|
344 |
switch (value) {
|
|
345 |
case 0:
|
|
346 |
__ fmovd(v0, zr);
|
|
347 |
break;
|
|
348 |
case 1:
|
|
349 |
__ fmovd(v0, 1.0);
|
|
350 |
break;
|
|
351 |
case 2:
|
|
352 |
__ fmovd(v0, 2.0);
|
|
353 |
break;
|
|
354 |
default:
|
|
355 |
ShouldNotReachHere();
|
|
356 |
break;
|
|
357 |
}
|
|
358 |
}
|
|
359 |
|
|
360 |
void TemplateTable::bipush()
|
|
361 |
{
|
|
362 |
transition(vtos, itos);
|
|
363 |
__ load_signed_byte32(r0, at_bcp(1));
|
|
364 |
}
|
|
365 |
|
|
366 |
void TemplateTable::sipush()
|
|
367 |
{
|
|
368 |
transition(vtos, itos);
|
|
369 |
__ load_unsigned_short(r0, at_bcp(1));
|
|
370 |
__ revw(r0, r0);
|
|
371 |
__ asrw(r0, r0, 16);
|
|
372 |
}
|
|
373 |
|
|
374 |
void TemplateTable::ldc(bool wide)
|
|
375 |
{
|
|
376 |
transition(vtos, vtos);
|
|
377 |
Label call_ldc, notFloat, notClass, Done;
|
|
378 |
|
|
379 |
if (wide) {
|
|
380 |
__ get_unsigned_2_byte_index_at_bcp(r1, 1);
|
|
381 |
} else {
|
|
382 |
__ load_unsigned_byte(r1, at_bcp(1));
|
|
383 |
}
|
|
384 |
__ get_cpool_and_tags(r2, r0);
|
|
385 |
|
|
386 |
const int base_offset = ConstantPool::header_size() * wordSize;
|
|
387 |
const int tags_offset = Array<u1>::base_offset_in_bytes();
|
|
388 |
|
|
389 |
// get type
|
|
390 |
__ add(r3, r1, tags_offset);
|
|
391 |
__ ldrb(r3, Address(r0, r3));
|
|
392 |
|
|
393 |
// unresolved class - get the resolved class
|
|
394 |
__ cmp(r3, JVM_CONSTANT_UnresolvedClass);
|
|
395 |
__ br(Assembler::EQ, call_ldc);
|
|
396 |
|
|
397 |
// unresolved class in error state - call into runtime to throw the error
|
|
398 |
// from the first resolution attempt
|
|
399 |
__ cmp(r3, JVM_CONSTANT_UnresolvedClassInError);
|
|
400 |
__ br(Assembler::EQ, call_ldc);
|
|
401 |
|
|
402 |
// resolved class - need to call vm to get java mirror of the class
|
|
403 |
__ cmp(r3, JVM_CONSTANT_Class);
|
|
404 |
__ br(Assembler::NE, notClass);
|
|
405 |
|
|
406 |
__ bind(call_ldc);
|
|
407 |
__ mov(c_rarg1, wide);
|
|
408 |
call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1);
|
|
409 |
__ push_ptr(r0);
|
|
410 |
__ verify_oop(r0);
|
|
411 |
__ b(Done);
|
|
412 |
|
|
413 |
__ bind(notClass);
|
|
414 |
__ cmp(r3, JVM_CONSTANT_Float);
|
|
415 |
__ br(Assembler::NE, notFloat);
|
|
416 |
// ftos
|
|
417 |
__ adds(r1, r2, r1, Assembler::LSL, 3);
|
|
418 |
__ ldrs(v0, Address(r1, base_offset));
|
|
419 |
__ push_f();
|
|
420 |
__ b(Done);
|
|
421 |
|
|
422 |
__ bind(notFloat);
|
|
423 |
#ifdef ASSERT
|
|
424 |
{
|
|
425 |
Label L;
|
|
426 |
__ cmp(r3, JVM_CONSTANT_Integer);
|
|
427 |
__ br(Assembler::EQ, L);
|
|
428 |
// String and Object are rewritten to fast_aldc
|
|
429 |
__ stop("unexpected tag type in ldc");
|
|
430 |
__ bind(L);
|
|
431 |
}
|
|
432 |
#endif
|
|
433 |
// itos JVM_CONSTANT_Integer only
|
|
434 |
__ adds(r1, r2, r1, Assembler::LSL, 3);
|
|
435 |
__ ldrw(r0, Address(r1, base_offset));
|
|
436 |
__ push_i(r0);
|
|
437 |
__ bind(Done);
|
|
438 |
}
|
|
439 |
|
|
440 |
// Fast path for caching oop constants.
|
|
441 |
void TemplateTable::fast_aldc(bool wide)
|
|
442 |
{
|
|
443 |
transition(vtos, atos);
|
|
444 |
|
|
445 |
Register result = r0;
|
|
446 |
Register tmp = r1;
|
|
447 |
int index_size = wide ? sizeof(u2) : sizeof(u1);
|
|
448 |
|
|
449 |
Label resolved;
|
|
450 |
|
|
451 |
// We are resolved if the resolved reference cache entry contains a
|
|
452 |
// non-null object (String, MethodType, etc.)
|
|
453 |
assert_different_registers(result, tmp);
|
|
454 |
__ get_cache_index_at_bcp(tmp, 1, index_size);
|
|
455 |
__ load_resolved_reference_at_index(result, tmp);
|
|
456 |
__ cbnz(result, resolved);
|
|
457 |
|
|
458 |
address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
|
|
459 |
|
|
460 |
// first time invocation - must resolve first
|
|
461 |
__ mov(tmp, (int)bytecode());
|
|
462 |
__ call_VM(result, entry, tmp);
|
|
463 |
|
|
464 |
__ bind(resolved);
|
|
465 |
|
|
466 |
if (VerifyOops) {
|
|
467 |
__ verify_oop(result);
|
|
468 |
}
|
|
469 |
}
|
|
470 |
|
|
471 |
void TemplateTable::ldc2_w()
|
|
472 |
{
|
|
473 |
transition(vtos, vtos);
|
|
474 |
Label Long, Done;
|
|
475 |
__ get_unsigned_2_byte_index_at_bcp(r0, 1);
|
|
476 |
|
|
477 |
__ get_cpool_and_tags(r1, r2);
|
|
478 |
const int base_offset = ConstantPool::header_size() * wordSize;
|
|
479 |
const int tags_offset = Array<u1>::base_offset_in_bytes();
|
|
480 |
|
|
481 |
// get type
|
|
482 |
__ lea(r2, Address(r2, r0, Address::lsl(0)));
|
|
483 |
__ load_unsigned_byte(r2, Address(r2, tags_offset));
|
|
484 |
__ cmpw(r2, (int)JVM_CONSTANT_Double);
|
|
485 |
__ br(Assembler::NE, Long);
|
|
486 |
// dtos
|
|
487 |
__ lea (r2, Address(r1, r0, Address::lsl(3)));
|
|
488 |
__ ldrd(v0, Address(r2, base_offset));
|
|
489 |
__ push_d();
|
|
490 |
__ b(Done);
|
|
491 |
|
|
492 |
__ bind(Long);
|
|
493 |
// ltos
|
|
494 |
__ lea(r0, Address(r1, r0, Address::lsl(3)));
|
|
495 |
__ ldr(r0, Address(r0, base_offset));
|
|
496 |
__ push_l();
|
|
497 |
|
|
498 |
__ bind(Done);
|
|
499 |
}
|
|
500 |
|
|
501 |
void TemplateTable::locals_index(Register reg, int offset)
|
|
502 |
{
|
|
503 |
__ ldrb(reg, at_bcp(offset));
|
|
504 |
__ neg(reg, reg);
|
|
505 |
}
|
|
506 |
|
|
507 |
void TemplateTable::iload()
|
|
508 |
{
|
|
509 |
transition(vtos, itos);
|
|
510 |
if (RewriteFrequentPairs) {
|
|
511 |
// TODO : check x86 code for what to do here
|
|
512 |
__ call_Unimplemented();
|
|
513 |
} else {
|
|
514 |
locals_index(r1);
|
|
515 |
__ ldr(r0, iaddress(r1));
|
|
516 |
}
|
|
517 |
|
|
518 |
}
|
|
519 |
|
|
520 |
void TemplateTable::fast_iload2()
|
|
521 |
{
|
|
522 |
__ call_Unimplemented();
|
|
523 |
}
|
|
524 |
|
|
525 |
void TemplateTable::fast_iload()
|
|
526 |
{
|
|
527 |
__ call_Unimplemented();
|
|
528 |
}
|
|
529 |
|
|
530 |
void TemplateTable::lload()
|
|
531 |
{
|
|
532 |
transition(vtos, ltos);
|
|
533 |
__ ldrb(r1, at_bcp(1));
|
|
534 |
__ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord);
|
|
535 |
__ ldr(r0, Address(r1, Interpreter::local_offset_in_bytes(1)));
|
|
536 |
}
|
|
537 |
|
|
538 |
void TemplateTable::fload()
|
|
539 |
{
|
|
540 |
transition(vtos, ftos);
|
|
541 |
locals_index(r1);
|
|
542 |
// n.b. we use ldrd here because this is a 64 bit slot
|
|
543 |
// this is comparable to the iload case
|
|
544 |
__ ldrd(v0, faddress(r1));
|
|
545 |
}
|
|
546 |
|
|
547 |
void TemplateTable::dload()
|
|
548 |
{
|
|
549 |
transition(vtos, dtos);
|
|
550 |
__ ldrb(r1, at_bcp(1));
|
|
551 |
__ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord);
|
|
552 |
__ ldrd(v0, Address(r1, Interpreter::local_offset_in_bytes(1)));
|
|
553 |
}
|
|
554 |
|
|
555 |
void TemplateTable::aload()
|
|
556 |
{
|
|
557 |
transition(vtos, atos);
|
|
558 |
locals_index(r1);
|
|
559 |
__ ldr(r0, iaddress(r1));
|
|
560 |
}
|
|
561 |
|
|
562 |
void TemplateTable::locals_index_wide(Register reg) {
|
|
563 |
__ ldrh(reg, at_bcp(2));
|
|
564 |
__ rev16w(reg, reg);
|
|
565 |
__ neg(reg, reg);
|
|
566 |
}
|
|
567 |
|
|
568 |
void TemplateTable::wide_iload() {
|
|
569 |
transition(vtos, itos);
|
|
570 |
locals_index_wide(r1);
|
|
571 |
__ ldr(r0, iaddress(r1));
|
|
572 |
}
|
|
573 |
|
|
574 |
void TemplateTable::wide_lload()
|
|
575 |
{
|
|
576 |
transition(vtos, ltos);
|
|
577 |
__ ldrh(r1, at_bcp(2));
|
|
578 |
__ rev16w(r1, r1);
|
|
579 |
__ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord);
|
|
580 |
__ ldr(r0, Address(r1, Interpreter::local_offset_in_bytes(1)));
|
|
581 |
}
|
|
582 |
|
|
583 |
void TemplateTable::wide_fload()
|
|
584 |
{
|
|
585 |
transition(vtos, ftos);
|
|
586 |
locals_index_wide(r1);
|
|
587 |
// n.b. we use ldrd here because this is a 64 bit slot
|
|
588 |
// this is comparable to the iload case
|
|
589 |
__ ldrd(v0, faddress(r1));
|
|
590 |
}
|
|
591 |
|
|
592 |
void TemplateTable::wide_dload()
|
|
593 |
{
|
|
594 |
transition(vtos, dtos);
|
|
595 |
__ ldrh(r1, at_bcp(2));
|
|
596 |
__ rev16w(r1, r1);
|
|
597 |
__ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord);
|
|
598 |
__ ldrd(v0, Address(r1, Interpreter::local_offset_in_bytes(1)));
|
|
599 |
}
|
|
600 |
|
|
601 |
void TemplateTable::wide_aload()
|
|
602 |
{
|
|
603 |
transition(vtos, atos);
|
|
604 |
locals_index_wide(r1);
|
|
605 |
__ ldr(r0, aaddress(r1));
|
|
606 |
}
|
|
607 |
|
|
608 |
void TemplateTable::index_check(Register array, Register index)
|
|
609 |
{
|
|
610 |
// destroys r1, rscratch1
|
|
611 |
// check array
|
|
612 |
__ null_check(array, arrayOopDesc::length_offset_in_bytes());
|
|
613 |
// sign extend index for use by indexed load
|
|
614 |
// __ movl2ptr(index, index);
|
|
615 |
// check index
|
|
616 |
Register length = rscratch1;
|
|
617 |
__ ldrw(length, Address(array, arrayOopDesc::length_offset_in_bytes()));
|
|
618 |
__ cmpw(index, length);
|
|
619 |
if (index != r1) {
|
|
620 |
// ??? convention: move aberrant index into r1 for exception message
|
|
621 |
assert(r1 != array, "different registers");
|
|
622 |
__ mov(r1, index);
|
|
623 |
}
|
|
624 |
Label ok;
|
|
625 |
__ br(Assembler::LO, ok);
|
|
626 |
__ mov(rscratch1, Interpreter::_throw_ArrayIndexOutOfBoundsException_entry);
|
|
627 |
__ br(rscratch1);
|
|
628 |
__ bind(ok);
|
|
629 |
}
|
|
630 |
|
|
631 |
void TemplateTable::iaload()
|
|
632 |
{
|
|
633 |
transition(itos, itos);
|
|
634 |
__ mov(r1, r0);
|
|
635 |
__ pop_ptr(r0);
|
|
636 |
// r0: array
|
|
637 |
// r1: index
|
|
638 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
639 |
__ lea(r1, Address(r0, r1, Address::uxtw(2)));
|
|
640 |
__ ldrw(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_INT)));
|
|
641 |
}
|
|
642 |
|
|
643 |
void TemplateTable::laload()
|
|
644 |
{
|
|
645 |
transition(itos, ltos);
|
|
646 |
__ mov(r1, r0);
|
|
647 |
__ pop_ptr(r0);
|
|
648 |
// r0: array
|
|
649 |
// r1: index
|
|
650 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
651 |
__ lea(r1, Address(r0, r1, Address::uxtw(3)));
|
|
652 |
__ ldr(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_LONG)));
|
|
653 |
}
|
|
654 |
|
|
655 |
void TemplateTable::faload()
|
|
656 |
{
|
|
657 |
transition(itos, ftos);
|
|
658 |
__ mov(r1, r0);
|
|
659 |
__ pop_ptr(r0);
|
|
660 |
// r0: array
|
|
661 |
// r1: index
|
|
662 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
663 |
__ lea(r1, Address(r0, r1, Address::uxtw(2)));
|
|
664 |
__ ldrs(v0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_FLOAT)));
|
|
665 |
}
|
|
666 |
|
|
667 |
void TemplateTable::daload()
|
|
668 |
{
|
|
669 |
transition(itos, dtos);
|
|
670 |
__ mov(r1, r0);
|
|
671 |
__ pop_ptr(r0);
|
|
672 |
// r0: array
|
|
673 |
// r1: index
|
|
674 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
675 |
__ lea(r1, Address(r0, r1, Address::uxtw(3)));
|
|
676 |
__ ldrd(v0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_DOUBLE)));
|
|
677 |
}
|
|
678 |
|
|
679 |
void TemplateTable::aaload()
|
|
680 |
{
|
|
681 |
transition(itos, atos);
|
|
682 |
__ mov(r1, r0);
|
|
683 |
__ pop_ptr(r0);
|
|
684 |
// r0: array
|
|
685 |
// r1: index
|
|
686 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
687 |
int s = (UseCompressedOops ? 2 : 3);
|
|
688 |
__ lea(r1, Address(r0, r1, Address::uxtw(s)));
|
|
689 |
__ load_heap_oop(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
|
|
690 |
}
|
|
691 |
|
|
692 |
void TemplateTable::baload()
|
|
693 |
{
|
|
694 |
transition(itos, itos);
|
|
695 |
__ mov(r1, r0);
|
|
696 |
__ pop_ptr(r0);
|
|
697 |
// r0: array
|
|
698 |
// r1: index
|
|
699 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
700 |
__ lea(r1, Address(r0, r1, Address::uxtw(0)));
|
|
701 |
__ load_signed_byte(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_BYTE)));
|
|
702 |
}
|
|
703 |
|
|
704 |
void TemplateTable::caload()
|
|
705 |
{
|
|
706 |
transition(itos, itos);
|
|
707 |
__ mov(r1, r0);
|
|
708 |
__ pop_ptr(r0);
|
|
709 |
// r0: array
|
|
710 |
// r1: index
|
|
711 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
712 |
__ lea(r1, Address(r0, r1, Address::uxtw(1)));
|
|
713 |
__ load_unsigned_short(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
|
|
714 |
}
|
|
715 |
|
|
716 |
// iload followed by caload frequent pair
|
|
717 |
void TemplateTable::fast_icaload()
|
|
718 |
{
|
|
719 |
__ call_Unimplemented();
|
|
720 |
}
|
|
721 |
|
|
722 |
void TemplateTable::saload()
|
|
723 |
{
|
|
724 |
transition(itos, itos);
|
|
725 |
__ mov(r1, r0);
|
|
726 |
__ pop_ptr(r0);
|
|
727 |
// r0: array
|
|
728 |
// r1: index
|
|
729 |
index_check(r0, r1); // leaves index in r1, kills rscratch1
|
|
730 |
__ lea(r1, Address(r0, r1, Address::uxtw(1)));
|
|
731 |
__ load_signed_short(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_SHORT)));
|
|
732 |
}
|
|
733 |
|
|
734 |
void TemplateTable::iload(int n)
|
|
735 |
{
|
|
736 |
transition(vtos, itos);
|
|
737 |
__ ldr(r0, iaddress(n));
|
|
738 |
}
|
|
739 |
|
|
740 |
void TemplateTable::lload(int n)
|
|
741 |
{
|
|
742 |
transition(vtos, ltos);
|
|
743 |
__ ldr(r0, laddress(n));
|
|
744 |
}
|
|
745 |
|
|
746 |
void TemplateTable::fload(int n)
|
|
747 |
{
|
|
748 |
transition(vtos, ftos);
|
|
749 |
__ ldrs(v0, faddress(n));
|
|
750 |
}
|
|
751 |
|
|
752 |
void TemplateTable::dload(int n)
|
|
753 |
{
|
|
754 |
transition(vtos, dtos);
|
|
755 |
__ ldrd(v0, daddress(n));
|
|
756 |
}
|
|
757 |
|
|
758 |
void TemplateTable::aload(int n)
|
|
759 |
{
|
|
760 |
transition(vtos, atos);
|
|
761 |
__ ldr(r0, iaddress(n));
|
|
762 |
}
|
|
763 |
|
|
764 |
void TemplateTable::aload_0()
|
|
765 |
{
|
|
766 |
// According to bytecode histograms, the pairs:
|
|
767 |
//
|
|
768 |
// _aload_0, _fast_igetfield
|
|
769 |
// _aload_0, _fast_agetfield
|
|
770 |
// _aload_0, _fast_fgetfield
|
|
771 |
//
|
|
772 |
// occur frequently. If RewriteFrequentPairs is set, the (slow)
|
|
773 |
// _aload_0 bytecode checks if the next bytecode is either
|
|
774 |
// _fast_igetfield, _fast_agetfield or _fast_fgetfield and then
|
|
775 |
// rewrites the current bytecode into a pair bytecode; otherwise it
|
|
776 |
// rewrites the current bytecode into _fast_aload_0 that doesn't do
|
|
777 |
// the pair check anymore.
|
|
778 |
//
|
|
779 |
// Note: If the next bytecode is _getfield, the rewrite must be
|
|
780 |
// delayed, otherwise we may miss an opportunity for a pair.
|
|
781 |
//
|
|
782 |
// Also rewrite frequent pairs
|
|
783 |
// aload_0, aload_1
|
|
784 |
// aload_0, iload_1
|
|
785 |
// These bytecodes with a small amount of code are most profitable
|
|
786 |
// to rewrite
|
|
787 |
if (RewriteFrequentPairs) {
|
|
788 |
__ call_Unimplemented();
|
|
789 |
} else {
|
|
790 |
aload(0);
|
|
791 |
}
|
|
792 |
}
|
|
793 |
|
|
794 |
void TemplateTable::istore()
|
|
795 |
{
|
|
796 |
transition(itos, vtos);
|
|
797 |
locals_index(r1);
|
|
798 |
// FIXME: We're being very pernickerty here storing a jint in a
|
|
799 |
// local with strw, which costs an extra instruction over what we'd
|
|
800 |
// be able to do with a simple str. We should just store the whole
|
|
801 |
// word.
|
|
802 |
__ lea(rscratch1, iaddress(r1));
|
|
803 |
__ strw(r0, Address(rscratch1));
|
|
804 |
}
|
|
805 |
|
|
806 |
void TemplateTable::lstore()
|
|
807 |
{
|
|
808 |
transition(ltos, vtos);
|
|
809 |
locals_index(r1);
|
|
810 |
__ str(r0, laddress(r1, rscratch1, _masm));
|
|
811 |
}
|
|
812 |
|
|
813 |
void TemplateTable::fstore() {
|
|
814 |
transition(ftos, vtos);
|
|
815 |
locals_index(r1);
|
|
816 |
__ lea(rscratch1, iaddress(r1));
|
|
817 |
__ strs(v0, Address(rscratch1));
|
|
818 |
}
|
|
819 |
|
|
820 |
void TemplateTable::dstore() {
|
|
821 |
transition(dtos, vtos);
|
|
822 |
locals_index(r1);
|
|
823 |
__ strd(v0, daddress(r1, rscratch1, _masm));
|
|
824 |
}
|
|
825 |
|
|
826 |
void TemplateTable::astore()
|
|
827 |
{
|
|
828 |
transition(vtos, vtos);
|
|
829 |
__ pop_ptr(r0);
|
|
830 |
locals_index(r1);
|
|
831 |
__ str(r0, aaddress(r1));
|
|
832 |
}
|
|
833 |
|
|
834 |
void TemplateTable::wide_istore() {
|
|
835 |
transition(vtos, vtos);
|
|
836 |
__ pop_i();
|
|
837 |
locals_index_wide(r1);
|
|
838 |
__ lea(rscratch1, iaddress(r1));
|
|
839 |
__ strw(r0, Address(rscratch1));
|
|
840 |
}
|
|
841 |
|
|
842 |
void TemplateTable::wide_lstore() {
|
|
843 |
transition(vtos, vtos);
|
|
844 |
__ pop_l();
|
|
845 |
locals_index_wide(r1);
|
|
846 |
__ str(r0, laddress(r1, rscratch1, _masm));
|
|
847 |
}
|
|
848 |
|
|
849 |
void TemplateTable::wide_fstore() {
|
|
850 |
transition(vtos, vtos);
|
|
851 |
__ pop_f();
|
|
852 |
locals_index_wide(r1);
|
|
853 |
__ lea(rscratch1, faddress(r1));
|
|
854 |
__ strs(v0, rscratch1);
|
|
855 |
}
|
|
856 |
|
|
857 |
void TemplateTable::wide_dstore() {
|
|
858 |
transition(vtos, vtos);
|
|
859 |
__ pop_d();
|
|
860 |
locals_index_wide(r1);
|
|
861 |
__ strd(v0, daddress(r1, rscratch1, _masm));
|
|
862 |
}
|
|
863 |
|
|
864 |
void TemplateTable::wide_astore() {
|
|
865 |
transition(vtos, vtos);
|
|
866 |
__ pop_ptr(r0);
|
|
867 |
locals_index_wide(r1);
|
|
868 |
__ str(r0, aaddress(r1));
|
|
869 |
}
|
|
870 |
|
|
871 |
void TemplateTable::iastore() {
|
|
872 |
transition(itos, vtos);
|
|
873 |
__ pop_i(r1);
|
|
874 |
__ pop_ptr(r3);
|
|
875 |
// r0: value
|
|
876 |
// r1: index
|
|
877 |
// r3: array
|
|
878 |
index_check(r3, r1); // prefer index in r1
|
|
879 |
__ lea(rscratch1, Address(r3, r1, Address::uxtw(2)));
|
|
880 |
__ strw(r0, Address(rscratch1,
|
|
881 |
arrayOopDesc::base_offset_in_bytes(T_INT)));
|
|
882 |
}
|
|
883 |
|
|
884 |
void TemplateTable::lastore() {
|
|
885 |
transition(ltos, vtos);
|
|
886 |
__ pop_i(r1);
|
|
887 |
__ pop_ptr(r3);
|
|
888 |
// r0: value
|
|
889 |
// r1: index
|
|
890 |
// r3: array
|
|
891 |
index_check(r3, r1); // prefer index in r1
|
|
892 |
__ lea(rscratch1, Address(r3, r1, Address::uxtw(3)));
|
|
893 |
__ str(r0, Address(rscratch1,
|
|
894 |
arrayOopDesc::base_offset_in_bytes(T_LONG)));
|
|
895 |
}
|
|
896 |
|
|
897 |
void TemplateTable::fastore() {
|
|
898 |
transition(ftos, vtos);
|
|
899 |
__ pop_i(r1);
|
|
900 |
__ pop_ptr(r3);
|
|
901 |
// v0: value
|
|
902 |
// r1: index
|
|
903 |
// r3: array
|
|
904 |
index_check(r3, r1); // prefer index in r1
|
|
905 |
__ lea(rscratch1, Address(r3, r1, Address::uxtw(2)));
|
|
906 |
__ strs(v0, Address(rscratch1,
|
|
907 |
arrayOopDesc::base_offset_in_bytes(T_FLOAT)));
|
|
908 |
}
|
|
909 |
|
|
910 |
void TemplateTable::dastore() {
|
|
911 |
transition(dtos, vtos);
|
|
912 |
__ pop_i(r1);
|
|
913 |
__ pop_ptr(r3);
|
|
914 |
// v0: value
|
|
915 |
// r1: index
|
|
916 |
// r3: array
|
|
917 |
index_check(r3, r1); // prefer index in r1
|
|
918 |
__ lea(rscratch1, Address(r3, r1, Address::uxtw(3)));
|
|
919 |
__ strd(v0, Address(rscratch1,
|
|
920 |
arrayOopDesc::base_offset_in_bytes(T_DOUBLE)));
|
|
921 |
}
|
|
922 |
|
|
923 |
void TemplateTable::aastore() {
|
|
924 |
Label is_null, ok_is_subtype, done;
|
|
925 |
transition(vtos, vtos);
|
|
926 |
// stack: ..., array, index, value
|
|
927 |
__ ldr(r0, at_tos()); // value
|
|
928 |
__ ldr(r2, at_tos_p1()); // index
|
|
929 |
__ ldr(r3, at_tos_p2()); // array
|
|
930 |
|
|
931 |
Address element_address(r4, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
|
|
932 |
|
|
933 |
index_check(r3, r2); // kills r1
|
|
934 |
__ lea(r4, Address(r3, r2, Address::uxtw(UseCompressedOops? 2 : 3)));
|
|
935 |
|
|
936 |
// do array store check - check for NULL value first
|
|
937 |
__ cbz(r0, is_null);
|
|
938 |
|
|
939 |
// Move subklass into r1
|
|
940 |
__ load_klass(r1, r0);
|
|
941 |
// Move superklass into r0
|
|
942 |
__ load_klass(r0, r3);
|
|
943 |
__ ldr(r0, Address(r0,
|
|
944 |
ObjArrayKlass::element_klass_offset()));
|
|
945 |
// Compress array + index*oopSize + 12 into a single register. Frees r2.
|
|
946 |
|
|
947 |
// Generate subtype check. Blows r2, r5
|
|
948 |
// Superklass in r0. Subklass in r1.
|
|
949 |
__ gen_subtype_check(r1, ok_is_subtype);
|
|
950 |
|
|
951 |
// Come here on failure
|
|
952 |
// object is at TOS
|
|
953 |
__ b(Interpreter::_throw_ArrayStoreException_entry);
|
|
954 |
|
|
955 |
// Come here on success
|
|
956 |
__ bind(ok_is_subtype);
|
|
957 |
|
|
958 |
// Get the value we will store
|
|
959 |
__ ldr(r0, at_tos());
|
|
960 |
// Now store using the appropriate barrier
|
|
961 |
do_oop_store(_masm, element_address, r0, _bs->kind(), true);
|
|
962 |
__ b(done);
|
|
963 |
|
|
964 |
// Have a NULL in r0, r3=array, r2=index. Store NULL at ary[idx]
|
|
965 |
__ bind(is_null);
|
|
966 |
__ profile_null_seen(r2);
|
|
967 |
|
|
968 |
// Store a NULL
|
|
969 |
do_oop_store(_masm, element_address, noreg, _bs->kind(), true);
|
|
970 |
|
|
971 |
// Pop stack arguments
|
|
972 |
__ bind(done);
|
|
973 |
__ add(esp, esp, 3 * Interpreter::stackElementSize);
|
|
974 |
}
|
|
975 |
|
|
976 |
void TemplateTable::bastore()
|
|
977 |
{
|
|
978 |
transition(itos, vtos);
|
|
979 |
__ pop_i(r1);
|
|
980 |
__ pop_ptr(r3);
|
|
981 |
// r0: value
|
|
982 |
// r1: index
|
|
983 |
// r3: array
|
|
984 |
index_check(r3, r1); // prefer index in r1
|
|
985 |
__ lea(rscratch1, Address(r3, r1, Address::uxtw(0)));
|
|
986 |
__ strb(r0, Address(rscratch1,
|
|
987 |
arrayOopDesc::base_offset_in_bytes(T_BYTE)));
|
|
988 |
}
|
|
989 |
|
|
990 |
void TemplateTable::castore()
|
|
991 |
{
|
|
992 |
transition(itos, vtos);
|
|
993 |
__ pop_i(r1);
|
|
994 |
__ pop_ptr(r3);
|
|
995 |
// r0: value
|
|
996 |
// r1: index
|
|
997 |
// r3: array
|
|
998 |
index_check(r3, r1); // prefer index in r1
|
|
999 |
__ lea(rscratch1, Address(r3, r1, Address::uxtw(1)));
|
|
1000 |
__ strh(r0, Address(rscratch1,
|
|
1001 |
arrayOopDesc::base_offset_in_bytes(T_CHAR)));
|
|
1002 |
}
|
|
1003 |
|
|
1004 |
void TemplateTable::sastore()
|
|
1005 |
{
|
|
1006 |
castore();
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
void TemplateTable::istore(int n)
|
|
1010 |
{
|
|
1011 |
transition(itos, vtos);
|
|
1012 |
__ str(r0, iaddress(n));
|
|
1013 |
}
|
|
1014 |
|
|
1015 |
void TemplateTable::lstore(int n)
|
|
1016 |
{
|
|
1017 |
transition(ltos, vtos);
|
|
1018 |
__ str(r0, laddress(n));
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
void TemplateTable::fstore(int n)
|
|
1022 |
{
|
|
1023 |
transition(ftos, vtos);
|
|
1024 |
__ strs(v0, faddress(n));
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
void TemplateTable::dstore(int n)
|
|
1028 |
{
|
|
1029 |
transition(dtos, vtos);
|
|
1030 |
__ strd(v0, daddress(n));
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
void TemplateTable::astore(int n)
|
|
1034 |
{
|
|
1035 |
transition(vtos, vtos);
|
|
1036 |
__ pop_ptr(r0);
|
|
1037 |
__ str(r0, iaddress(n));
|
|
1038 |
}
|
|
1039 |
|
|
1040 |
void TemplateTable::pop()
|
|
1041 |
{
|
|
1042 |
transition(vtos, vtos);
|
|
1043 |
__ add(esp, esp, Interpreter::stackElementSize);
|
|
1044 |
}
|
|
1045 |
|
|
1046 |
void TemplateTable::pop2()
|
|
1047 |
{
|
|
1048 |
transition(vtos, vtos);
|
|
1049 |
__ add(esp, esp, 2 * Interpreter::stackElementSize);
|
|
1050 |
}
|
|
1051 |
|
|
1052 |
void TemplateTable::dup()
|
|
1053 |
{
|
|
1054 |
transition(vtos, vtos);
|
|
1055 |
__ ldr(r0, Address(esp, 0));
|
|
1056 |
__ push(r0);
|
|
1057 |
// stack: ..., a, a
|
|
1058 |
}
|
|
1059 |
|
|
1060 |
void TemplateTable::dup_x1()
|
|
1061 |
{
|
|
1062 |
transition(vtos, vtos);
|
|
1063 |
// stack: ..., a, b
|
|
1064 |
__ ldr(r0, at_tos()); // load b
|
|
1065 |
__ ldr(r2, at_tos_p1()); // load a
|
|
1066 |
__ str(r0, at_tos_p1()); // store b
|
|
1067 |
__ str(r2, at_tos()); // store a
|
|
1068 |
__ push(r0); // push b
|
|
1069 |
// stack: ..., b, a, b
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
void TemplateTable::dup_x2()
|
|
1073 |
{
|
|
1074 |
transition(vtos, vtos);
|
|
1075 |
// stack: ..., a, b, c
|
|
1076 |
__ ldr(r0, at_tos()); // load c
|
|
1077 |
__ ldr(r2, at_tos_p2()); // load a
|
|
1078 |
__ str(r0, at_tos_p2()); // store c in a
|
|
1079 |
__ push(r0); // push c
|
|
1080 |
// stack: ..., c, b, c, c
|
|
1081 |
__ ldr(r0, at_tos_p2()); // load b
|
|
1082 |
__ str(r2, at_tos_p2()); // store a in b
|
|
1083 |
// stack: ..., c, a, c, c
|
|
1084 |
__ str(r0, at_tos_p1()); // store b in c
|
|
1085 |
// stack: ..., c, a, b, c
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
void TemplateTable::dup2()
|
|
1089 |
{
|
|
1090 |
transition(vtos, vtos);
|
|
1091 |
// stack: ..., a, b
|
|
1092 |
__ ldr(r0, at_tos_p1()); // load a
|
|
1093 |
__ push(r0); // push a
|
|
1094 |
__ ldr(r0, at_tos_p1()); // load b
|
|
1095 |
__ push(r0); // push b
|
|
1096 |
// stack: ..., a, b, a, b
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
void TemplateTable::dup2_x1()
|
|
1100 |
{
|
|
1101 |
transition(vtos, vtos);
|
|
1102 |
// stack: ..., a, b, c
|
|
1103 |
__ ldr(r2, at_tos()); // load c
|
|
1104 |
__ ldr(r0, at_tos_p1()); // load b
|
|
1105 |
__ push(r0); // push b
|
|
1106 |
__ push(r2); // push c
|
|
1107 |
// stack: ..., a, b, c, b, c
|
|
1108 |
__ str(r2, at_tos_p3()); // store c in b
|
|
1109 |
// stack: ..., a, c, c, b, c
|
|
1110 |
__ ldr(r2, at_tos_p4()); // load a
|
|
1111 |
__ str(r2, at_tos_p2()); // store a in 2nd c
|
|
1112 |
// stack: ..., a, c, a, b, c
|
|
1113 |
__ str(r0, at_tos_p4()); // store b in a
|
|
1114 |
// stack: ..., b, c, a, b, c
|
|
1115 |
}
|
|
1116 |
|
|
1117 |
void TemplateTable::dup2_x2()
|
|
1118 |
{
|
|
1119 |
transition(vtos, vtos);
|
|
1120 |
// stack: ..., a, b, c, d
|
|
1121 |
__ ldr(r2, at_tos()); // load d
|
|
1122 |
__ ldr(r0, at_tos_p1()); // load c
|
|
1123 |
__ push(r0) ; // push c
|
|
1124 |
__ push(r2); // push d
|
|
1125 |
// stack: ..., a, b, c, d, c, d
|
|
1126 |
__ ldr(r0, at_tos_p4()); // load b
|
|
1127 |
__ str(r0, at_tos_p2()); // store b in d
|
|
1128 |
__ str(r2, at_tos_p4()); // store d in b
|
|
1129 |
// stack: ..., a, d, c, b, c, d
|
|
1130 |
__ ldr(r2, at_tos_p5()); // load a
|
|
1131 |
__ ldr(r0, at_tos_p3()); // load c
|
|
1132 |
__ str(r2, at_tos_p3()); // store a in c
|
|
1133 |
__ str(r0, at_tos_p5()); // store c in a
|
|
1134 |
// stack: ..., c, d, a, b, c, d
|
|
1135 |
}
|
|
1136 |
|
|
1137 |
void TemplateTable::swap()
|
|
1138 |
{
|
|
1139 |
transition(vtos, vtos);
|
|
1140 |
// stack: ..., a, b
|
|
1141 |
__ ldr(r2, at_tos_p1()); // load a
|
|
1142 |
__ ldr(r0, at_tos()); // load b
|
|
1143 |
__ str(r2, at_tos()); // store a in b
|
|
1144 |
__ str(r0, at_tos_p1()); // store b in a
|
|
1145 |
// stack: ..., b, a
|
|
1146 |
}
|
|
1147 |
|
|
1148 |
void TemplateTable::iop2(Operation op)
|
|
1149 |
{
|
|
1150 |
transition(itos, itos);
|
|
1151 |
// r0 <== r1 op r0
|
|
1152 |
__ pop_i(r1);
|
|
1153 |
switch (op) {
|
|
1154 |
case add : __ addw(r0, r1, r0); break;
|
|
1155 |
case sub : __ subw(r0, r1, r0); break;
|
|
1156 |
case mul : __ mulw(r0, r1, r0); break;
|
|
1157 |
case _and : __ andw(r0, r1, r0); break;
|
|
1158 |
case _or : __ orrw(r0, r1, r0); break;
|
|
1159 |
case _xor : __ eorw(r0, r1, r0); break;
|
|
1160 |
case shl : __ lslvw(r0, r1, r0); break;
|
|
1161 |
case shr : __ asrvw(r0, r1, r0); break;
|
|
1162 |
case ushr : __ lsrvw(r0, r1, r0);break;
|
|
1163 |
default : ShouldNotReachHere();
|
|
1164 |
}
|
|
1165 |
}
|
|
1166 |
|
|
1167 |
void TemplateTable::lop2(Operation op)
|
|
1168 |
{
|
|
1169 |
transition(ltos, ltos);
|
|
1170 |
// r0 <== r1 op r0
|
|
1171 |
__ pop_l(r1);
|
|
1172 |
switch (op) {
|
|
1173 |
case add : __ add(r0, r1, r0); break;
|
|
1174 |
case sub : __ sub(r0, r1, r0); break;
|
|
1175 |
case mul : __ mul(r0, r1, r0); break;
|
|
1176 |
case _and : __ andr(r0, r1, r0); break;
|
|
1177 |
case _or : __ orr(r0, r1, r0); break;
|
|
1178 |
case _xor : __ eor(r0, r1, r0); break;
|
|
1179 |
default : ShouldNotReachHere();
|
|
1180 |
}
|
|
1181 |
}
|
|
1182 |
|
|
1183 |
void TemplateTable::idiv()
|
|
1184 |
{
|
|
1185 |
transition(itos, itos);
|
|
1186 |
// explicitly check for div0
|
|
1187 |
Label no_div0;
|
|
1188 |
__ cbnzw(r0, no_div0);
|
|
1189 |
__ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry);
|
|
1190 |
__ br(rscratch1);
|
|
1191 |
__ bind(no_div0);
|
|
1192 |
__ pop_i(r1);
|
|
1193 |
// r0 <== r1 idiv r0
|
|
1194 |
__ corrected_idivl(r0, r1, r0, /* want_remainder */ false);
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
void TemplateTable::irem()
|
|
1198 |
{
|
|
1199 |
transition(itos, itos);
|
|
1200 |
// explicitly check for div0
|
|
1201 |
Label no_div0;
|
|
1202 |
__ cbnzw(r0, no_div0);
|
|
1203 |
__ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry);
|
|
1204 |
__ br(rscratch1);
|
|
1205 |
__ bind(no_div0);
|
|
1206 |
__ pop_i(r1);
|
|
1207 |
// r0 <== r1 irem r0
|
|
1208 |
__ corrected_idivl(r0, r1, r0, /* want_remainder */ true);
|
|
1209 |
}
|
|
1210 |
|
|
1211 |
void TemplateTable::lmul()
|
|
1212 |
{
|
|
1213 |
transition(ltos, ltos);
|
|
1214 |
__ pop_l(r1);
|
|
1215 |
__ mul(r0, r0, r1);
|
|
1216 |
}
|
|
1217 |
|
|
1218 |
void TemplateTable::ldiv()
|
|
1219 |
{
|
|
1220 |
transition(ltos, ltos);
|
|
1221 |
// explicitly check for div0
|
|
1222 |
Label no_div0;
|
|
1223 |
__ cbnz(r0, no_div0);
|
|
1224 |
__ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry);
|
|
1225 |
__ br(rscratch1);
|
|
1226 |
__ bind(no_div0);
|
|
1227 |
__ pop_l(r1);
|
|
1228 |
// r0 <== r1 ldiv r0
|
|
1229 |
__ corrected_idivq(r0, r1, r0, /* want_remainder */ false);
|
|
1230 |
}
|
|
1231 |
|
|
1232 |
void TemplateTable::lrem()
|
|
1233 |
{
|
|
1234 |
transition(ltos, ltos);
|
|
1235 |
// explicitly check for div0
|
|
1236 |
Label no_div0;
|
|
1237 |
__ cbnz(r0, no_div0);
|
|
1238 |
__ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry);
|
|
1239 |
__ br(rscratch1);
|
|
1240 |
__ bind(no_div0);
|
|
1241 |
__ pop_l(r1);
|
|
1242 |
// r0 <== r1 lrem r0
|
|
1243 |
__ corrected_idivq(r0, r1, r0, /* want_remainder */ true);
|
|
1244 |
}
|
|
1245 |
|
|
1246 |
void TemplateTable::lshl()
|
|
1247 |
{
|
|
1248 |
transition(itos, ltos);
|
|
1249 |
// shift count is in r0
|
|
1250 |
__ pop_l(r1);
|
|
1251 |
__ lslv(r0, r1, r0);
|
|
1252 |
}
|
|
1253 |
|
|
1254 |
void TemplateTable::lshr()
|
|
1255 |
{
|
|
1256 |
transition(itos, ltos);
|
|
1257 |
// shift count is in r0
|
|
1258 |
__ pop_l(r1);
|
|
1259 |
__ asrv(r0, r1, r0);
|
|
1260 |
}
|
|
1261 |
|
|
1262 |
void TemplateTable::lushr()
|
|
1263 |
{
|
|
1264 |
transition(itos, ltos);
|
|
1265 |
// shift count is in r0
|
|
1266 |
__ pop_l(r1);
|
|
1267 |
__ lsrv(r0, r1, r0);
|
|
1268 |
}
|
|
1269 |
|
|
1270 |
void TemplateTable::fop2(Operation op)
|
|
1271 |
{
|
|
1272 |
transition(ftos, ftos);
|
|
1273 |
switch (op) {
|
|
1274 |
case add:
|
|
1275 |
// n.b. use ldrd because this is a 64 bit slot
|
|
1276 |
__ pop_f(v1);
|
|
1277 |
__ fadds(v0, v1, v0);
|
|
1278 |
break;
|
|
1279 |
case sub:
|
|
1280 |
__ pop_f(v1);
|
|
1281 |
__ fsubs(v0, v1, v0);
|
|
1282 |
break;
|
|
1283 |
case mul:
|
|
1284 |
__ pop_f(v1);
|
|
1285 |
__ fmuls(v0, v1, v0);
|
|
1286 |
break;
|
|
1287 |
case div:
|
|
1288 |
__ pop_f(v1);
|
|
1289 |
__ fdivs(v0, v1, v0);
|
|
1290 |
break;
|
|
1291 |
case rem:
|
|
1292 |
__ fmovs(v1, v0);
|
|
1293 |
__ pop_f(v0);
|
|
1294 |
__ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::frem),
|
|
1295 |
0, 2, MacroAssembler::ret_type_float);
|
|
1296 |
break;
|
|
1297 |
default:
|
|
1298 |
ShouldNotReachHere();
|
|
1299 |
break;
|
|
1300 |
}
|
|
1301 |
}
|
|
1302 |
|
|
1303 |
void TemplateTable::dop2(Operation op)
|
|
1304 |
{
|
|
1305 |
transition(dtos, dtos);
|
|
1306 |
switch (op) {
|
|
1307 |
case add:
|
|
1308 |
// n.b. use ldrd because this is a 64 bit slot
|
|
1309 |
__ pop_d(v1);
|
|
1310 |
__ faddd(v0, v1, v0);
|
|
1311 |
break;
|
|
1312 |
case sub:
|
|
1313 |
__ pop_d(v1);
|
|
1314 |
__ fsubd(v0, v1, v0);
|
|
1315 |
break;
|
|
1316 |
case mul:
|
|
1317 |
__ pop_d(v1);
|
|
1318 |
__ fmuld(v0, v1, v0);
|
|
1319 |
break;
|
|
1320 |
case div:
|
|
1321 |
__ pop_d(v1);
|
|
1322 |
__ fdivd(v0, v1, v0);
|
|
1323 |
break;
|
|
1324 |
case rem:
|
|
1325 |
__ fmovd(v1, v0);
|
|
1326 |
__ pop_d(v0);
|
|
1327 |
__ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::drem),
|
|
1328 |
0, 2, MacroAssembler::ret_type_double);
|
|
1329 |
break;
|
|
1330 |
default:
|
|
1331 |
ShouldNotReachHere();
|
|
1332 |
break;
|
|
1333 |
}
|
|
1334 |
}
|
|
1335 |
|
|
1336 |
void TemplateTable::ineg()
|
|
1337 |
{
|
|
1338 |
transition(itos, itos);
|
|
1339 |
__ negw(r0, r0);
|
|
1340 |
|
|
1341 |
}
|
|
1342 |
|
|
1343 |
void TemplateTable::lneg()
|
|
1344 |
{
|
|
1345 |
transition(ltos, ltos);
|
|
1346 |
__ neg(r0, r0);
|
|
1347 |
}
|
|
1348 |
|
|
1349 |
void TemplateTable::fneg()
|
|
1350 |
{
|
|
1351 |
transition(ftos, ftos);
|
|
1352 |
__ fnegs(v0, v0);
|
|
1353 |
}
|
|
1354 |
|
|
1355 |
void TemplateTable::dneg()
|
|
1356 |
{
|
|
1357 |
transition(dtos, dtos);
|
|
1358 |
__ fnegd(v0, v0);
|
|
1359 |
}
|
|
1360 |
|
|
1361 |
void TemplateTable::iinc()
|
|
1362 |
{
|
|
1363 |
transition(vtos, vtos);
|
|
1364 |
__ load_signed_byte(r1, at_bcp(2)); // get constant
|
|
1365 |
locals_index(r2);
|
|
1366 |
__ ldr(r0, iaddress(r2));
|
|
1367 |
__ addw(r0, r0, r1);
|
|
1368 |
__ str(r0, iaddress(r2));
|
|
1369 |
}
|
|
1370 |
|
|
1371 |
void TemplateTable::wide_iinc()
|
|
1372 |
{
|
|
1373 |
transition(vtos, vtos);
|
|
1374 |
// __ mov(r1, zr);
|
|
1375 |
__ ldrw(r1, at_bcp(2)); // get constant and index
|
|
1376 |
__ rev16(r1, r1);
|
|
1377 |
__ ubfx(r2, r1, 0, 16);
|
|
1378 |
__ neg(r2, r2);
|
|
1379 |
__ sbfx(r1, r1, 16, 16);
|
|
1380 |
__ ldr(r0, iaddress(r2));
|
|
1381 |
__ addw(r0, r0, r1);
|
|
1382 |
__ str(r0, iaddress(r2));
|
|
1383 |
}
|
|
1384 |
|
|
1385 |
void TemplateTable::convert()
|
|
1386 |
{
|
|
1387 |
// Checking
|
|
1388 |
#ifdef ASSERT
|
|
1389 |
{
|
|
1390 |
TosState tos_in = ilgl;
|
|
1391 |
TosState tos_out = ilgl;
|
|
1392 |
switch (bytecode()) {
|
|
1393 |
case Bytecodes::_i2l: // fall through
|
|
1394 |
case Bytecodes::_i2f: // fall through
|
|
1395 |
case Bytecodes::_i2d: // fall through
|
|
1396 |
case Bytecodes::_i2b: // fall through
|
|
1397 |
case Bytecodes::_i2c: // fall through
|
|
1398 |
case Bytecodes::_i2s: tos_in = itos; break;
|
|
1399 |
case Bytecodes::_l2i: // fall through
|
|
1400 |
case Bytecodes::_l2f: // fall through
|
|
1401 |
case Bytecodes::_l2d: tos_in = ltos; break;
|
|
1402 |
case Bytecodes::_f2i: // fall through
|
|
1403 |
case Bytecodes::_f2l: // fall through
|
|
1404 |
case Bytecodes::_f2d: tos_in = ftos; break;
|
|
1405 |
case Bytecodes::_d2i: // fall through
|
|
1406 |
case Bytecodes::_d2l: // fall through
|
|
1407 |
case Bytecodes::_d2f: tos_in = dtos; break;
|
|
1408 |
default : ShouldNotReachHere();
|
|
1409 |
}
|
|
1410 |
switch (bytecode()) {
|
|
1411 |
case Bytecodes::_l2i: // fall through
|
|
1412 |
case Bytecodes::_f2i: // fall through
|
|
1413 |
case Bytecodes::_d2i: // fall through
|
|
1414 |
case Bytecodes::_i2b: // fall through
|
|
1415 |
case Bytecodes::_i2c: // fall through
|
|
1416 |
case Bytecodes::_i2s: tos_out = itos; break;
|
|
1417 |
case Bytecodes::_i2l: // fall through
|
|
1418 |
case Bytecodes::_f2l: // fall through
|
|
1419 |
case Bytecodes::_d2l: tos_out = ltos; break;
|
|
1420 |
case Bytecodes::_i2f: // fall through
|
|
1421 |
case Bytecodes::_l2f: // fall through
|
|
1422 |
case Bytecodes::_d2f: tos_out = ftos; break;
|
|
1423 |
case Bytecodes::_i2d: // fall through
|
|
1424 |
case Bytecodes::_l2d: // fall through
|
|
1425 |
case Bytecodes::_f2d: tos_out = dtos; break;
|
|
1426 |
default : ShouldNotReachHere();
|
|
1427 |
}
|
|
1428 |
transition(tos_in, tos_out);
|
|
1429 |
}
|
|
1430 |
#endif // ASSERT
|
|
1431 |
// static const int64_t is_nan = 0x8000000000000000L;
|
|
1432 |
|
|
1433 |
// Conversion
|
|
1434 |
switch (bytecode()) {
|
|
1435 |
case Bytecodes::_i2l:
|
|
1436 |
__ sxtw(r0, r0);
|
|
1437 |
break;
|
|
1438 |
case Bytecodes::_i2f:
|
|
1439 |
__ scvtfws(v0, r0);
|
|
1440 |
break;
|
|
1441 |
case Bytecodes::_i2d:
|
|
1442 |
__ scvtfwd(v0, r0);
|
|
1443 |
break;
|
|
1444 |
case Bytecodes::_i2b:
|
|
1445 |
__ sxtbw(r0, r0);
|
|
1446 |
break;
|
|
1447 |
case Bytecodes::_i2c:
|
|
1448 |
__ uxthw(r0, r0);
|
|
1449 |
break;
|
|
1450 |
case Bytecodes::_i2s:
|
|
1451 |
__ sxthw(r0, r0);
|
|
1452 |
break;
|
|
1453 |
case Bytecodes::_l2i:
|
|
1454 |
__ uxtw(r0, r0);
|
|
1455 |
break;
|
|
1456 |
case Bytecodes::_l2f:
|
|
1457 |
__ scvtfs(v0, r0);
|
|
1458 |
break;
|
|
1459 |
case Bytecodes::_l2d:
|
|
1460 |
__ scvtfd(v0, r0);
|
|
1461 |
break;
|
|
1462 |
case Bytecodes::_f2i:
|
|
1463 |
{
|
|
1464 |
Label L_Okay;
|
|
1465 |
__ clear_fpsr();
|
|
1466 |
__ fcvtzsw(r0, v0);
|
|
1467 |
__ get_fpsr(r1);
|
|
1468 |
__ cbzw(r1, L_Okay);
|
|
1469 |
__ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::f2i),
|
|
1470 |
0, 1, MacroAssembler::ret_type_integral);
|
|
1471 |
__ bind(L_Okay);
|
|
1472 |
}
|
|
1473 |
break;
|
|
1474 |
case Bytecodes::_f2l:
|
|
1475 |
{
|
|
1476 |
Label L_Okay;
|
|
1477 |
__ clear_fpsr();
|
|
1478 |
__ fcvtzs(r0, v0);
|
|
1479 |
__ get_fpsr(r1);
|
|
1480 |
__ cbzw(r1, L_Okay);
|
|
1481 |
__ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::f2l),
|
|
1482 |
0, 1, MacroAssembler::ret_type_integral);
|
|
1483 |
__ bind(L_Okay);
|
|
1484 |
}
|
|
1485 |
break;
|
|
1486 |
case Bytecodes::_f2d:
|
|
1487 |
__ fcvts(v0, v0);
|
|
1488 |
break;
|
|
1489 |
case Bytecodes::_d2i:
|
|
1490 |
{
|
|
1491 |
Label L_Okay;
|
|
1492 |
__ clear_fpsr();
|
|
1493 |
__ fcvtzdw(r0, v0);
|
|
1494 |
__ get_fpsr(r1);
|
|
1495 |
__ cbzw(r1, L_Okay);
|
|
1496 |
__ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::d2i),
|
|
1497 |
0, 1, MacroAssembler::ret_type_integral);
|
|
1498 |
__ bind(L_Okay);
|
|
1499 |
}
|
|
1500 |
break;
|
|
1501 |
case Bytecodes::_d2l:
|
|
1502 |
{
|
|
1503 |
Label L_Okay;
|
|
1504 |
__ clear_fpsr();
|
|
1505 |
__ fcvtzd(r0, v0);
|
|
1506 |
__ get_fpsr(r1);
|
|
1507 |
__ cbzw(r1, L_Okay);
|
|
1508 |
__ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::d2l),
|
|
1509 |
0, 1, MacroAssembler::ret_type_integral);
|
|
1510 |
__ bind(L_Okay);
|
|
1511 |
}
|
|
1512 |
break;
|
|
1513 |
case Bytecodes::_d2f:
|
|
1514 |
__ fcvtd(v0, v0);
|
|
1515 |
break;
|
|
1516 |
default:
|
|
1517 |
ShouldNotReachHere();
|
|
1518 |
}
|
|
1519 |
}
|
|
1520 |
|
|
1521 |
void TemplateTable::lcmp()
|
|
1522 |
{
|
|
1523 |
transition(ltos, itos);
|
|
1524 |
Label done;
|
|
1525 |
__ pop_l(r1);
|
|
1526 |
__ cmp(r1, r0);
|
|
1527 |
__ mov(r0, (u_int64_t)-1L);
|
|
1528 |
__ br(Assembler::LT, done);
|
|
1529 |
// __ mov(r0, 1UL);
|
|
1530 |
// __ csel(r0, r0, zr, Assembler::NE);
|
|
1531 |
// and here is a faster way
|
|
1532 |
__ csinc(r0, zr, zr, Assembler::EQ);
|
|
1533 |
__ bind(done);
|
|
1534 |
}
|
|
1535 |
|
|
1536 |
void TemplateTable::float_cmp(bool is_float, int unordered_result)
|
|
1537 |
{
|
|
1538 |
Label done;
|
|
1539 |
if (is_float) {
|
|
1540 |
// XXX get rid of pop here, use ... reg, mem32
|
|
1541 |
__ pop_f(v1);
|
|
1542 |
__ fcmps(v1, v0);
|
|
1543 |
} else {
|
|
1544 |
// XXX get rid of pop here, use ... reg, mem64
|
|
1545 |
__ pop_d(v1);
|
|
1546 |
__ fcmpd(v1, v0);
|
|
1547 |
}
|
|
1548 |
if (unordered_result < 0) {
|
|
1549 |
// we want -1 for unordered or less than, 0 for equal and 1 for
|
|
1550 |
// greater than.
|
|
1551 |
__ mov(r0, (u_int64_t)-1L);
|
|
1552 |
// for FP LT tests less than or unordered
|
|
1553 |
__ br(Assembler::LT, done);
|
|
1554 |
// install 0 for EQ otherwise 1
|
|
1555 |
__ csinc(r0, zr, zr, Assembler::EQ);
|
|
1556 |
} else {
|
|
1557 |
// we want -1 for less than, 0 for equal and 1 for unordered or
|
|
1558 |
// greater than.
|
|
1559 |
__ mov(r0, 1L);
|
|
1560 |
// for FP HI tests greater than or unordered
|
|
1561 |
__ br(Assembler::HI, done);
|
|
1562 |
// install 0 for EQ otherwise ~0
|
|
1563 |
__ csinv(r0, zr, zr, Assembler::EQ);
|
|
1564 |
|
|
1565 |
}
|
|
1566 |
__ bind(done);
|
|
1567 |
}
|
|
1568 |
|
|
1569 |
void TemplateTable::branch(bool is_jsr, bool is_wide)
|
|
1570 |
{
|
|
1571 |
// We might be moving to a safepoint. The thread which calls
|
|
1572 |
// Interpreter::notice_safepoints() will effectively flush its cache
|
|
1573 |
// when it makes a system call, but we need to do something to
|
|
1574 |
// ensure that we see the changed dispatch table.
|
|
1575 |
__ membar(MacroAssembler::LoadLoad);
|
|
1576 |
|
|
1577 |
__ profile_taken_branch(r0, r1);
|
|
1578 |
const ByteSize be_offset = MethodCounters::backedge_counter_offset() +
|
|
1579 |
InvocationCounter::counter_offset();
|
|
1580 |
const ByteSize inv_offset = MethodCounters::invocation_counter_offset() +
|
|
1581 |
InvocationCounter::counter_offset();
|
|
1582 |
|
|
1583 |
// load branch displacement
|
|
1584 |
if (!is_wide) {
|
|
1585 |
__ ldrh(r2, at_bcp(1));
|
|
1586 |
__ rev16(r2, r2);
|
|
1587 |
// sign extend the 16 bit value in r2
|
|
1588 |
__ sbfm(r2, r2, 0, 15);
|
|
1589 |
} else {
|
|
1590 |
__ ldrw(r2, at_bcp(1));
|
|
1591 |
__ revw(r2, r2);
|
|
1592 |
// sign extend the 32 bit value in r2
|
|
1593 |
__ sbfm(r2, r2, 0, 31);
|
|
1594 |
}
|
|
1595 |
|
|
1596 |
// Handle all the JSR stuff here, then exit.
|
|
1597 |
// It's much shorter and cleaner than intermingling with the non-JSR
|
|
1598 |
// normal-branch stuff occurring below.
|
|
1599 |
|
|
1600 |
if (is_jsr) {
|
|
1601 |
// Pre-load the next target bytecode into rscratch1
|
|
1602 |
__ load_unsigned_byte(rscratch1, Address(rbcp, r2));
|
|
1603 |
// compute return address as bci
|
|
1604 |
__ ldr(rscratch2, Address(rmethod, Method::const_offset()));
|
|
1605 |
__ add(rscratch2, rscratch2,
|
|
1606 |
in_bytes(ConstMethod::codes_offset()) - (is_wide ? 5 : 3));
|
|
1607 |
__ sub(r1, rbcp, rscratch2);
|
|
1608 |
__ push_i(r1);
|
|
1609 |
// Adjust the bcp by the 16-bit displacement in r2
|
|
1610 |
__ add(rbcp, rbcp, r2);
|
|
1611 |
__ dispatch_only(vtos);
|
|
1612 |
return;
|
|
1613 |
}
|
|
1614 |
|
|
1615 |
// Normal (non-jsr) branch handling
|
|
1616 |
|
|
1617 |
// Adjust the bcp by the displacement in r2
|
|
1618 |
__ add(rbcp, rbcp, r2);
|
|
1619 |
|
|
1620 |
assert(UseLoopCounter || !UseOnStackReplacement,
|
|
1621 |
"on-stack-replacement requires loop counters");
|
|
1622 |
Label backedge_counter_overflow;
|
|
1623 |
Label profile_method;
|
|
1624 |
Label dispatch;
|
|
1625 |
if (UseLoopCounter) {
|
|
1626 |
// increment backedge counter for backward branches
|
|
1627 |
// r0: MDO
|
|
1628 |
// w1: MDO bumped taken-count
|
|
1629 |
// r2: target offset
|
|
1630 |
__ cmp(r2, zr);
|
|
1631 |
__ br(Assembler::GT, dispatch); // count only if backward branch
|
|
1632 |
|
|
1633 |
// ECN: FIXME: This code smells
|
|
1634 |
// check if MethodCounters exists
|
|
1635 |
Label has_counters;
|
|
1636 |
__ ldr(rscratch1, Address(rmethod, Method::method_counters_offset()));
|
|
1637 |
__ cbnz(rscratch1, has_counters);
|
|
1638 |
__ push(r0);
|
|
1639 |
__ push(r1);
|
|
1640 |
__ push(r2);
|
|
1641 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address,
|
|
1642 |
InterpreterRuntime::build_method_counters), rmethod);
|
|
1643 |
__ pop(r2);
|
|
1644 |
__ pop(r1);
|
|
1645 |
__ pop(r0);
|
|
1646 |
__ ldr(rscratch1, Address(rmethod, Method::method_counters_offset()));
|
|
1647 |
__ cbz(rscratch1, dispatch); // No MethodCounters allocated, OutOfMemory
|
|
1648 |
__ bind(has_counters);
|
|
1649 |
|
|
1650 |
if (TieredCompilation) {
|
|
1651 |
Label no_mdo;
|
|
1652 |
int increment = InvocationCounter::count_increment;
|
|
1653 |
int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
|
|
1654 |
if (ProfileInterpreter) {
|
|
1655 |
// Are we profiling?
|
|
1656 |
__ ldr(r1, Address(rmethod, in_bytes(Method::method_data_offset())));
|
|
1657 |
__ cbz(r1, no_mdo);
|
|
1658 |
// Increment the MDO backedge counter
|
|
1659 |
const Address mdo_backedge_counter(r1, in_bytes(MethodData::backedge_counter_offset()) +
|
|
1660 |
in_bytes(InvocationCounter::counter_offset()));
|
|
1661 |
__ increment_mask_and_jump(mdo_backedge_counter, increment, mask,
|
|
1662 |
r0, false, Assembler::EQ, &backedge_counter_overflow);
|
|
1663 |
__ b(dispatch);
|
|
1664 |
}
|
|
1665 |
__ bind(no_mdo);
|
|
1666 |
// Increment backedge counter in MethodCounters*
|
|
1667 |
__ ldr(rscratch1, Address(rmethod, Method::method_counters_offset()));
|
|
1668 |
__ increment_mask_and_jump(Address(rscratch1, be_offset), increment, mask,
|
|
1669 |
r0, false, Assembler::EQ, &backedge_counter_overflow);
|
|
1670 |
} else {
|
|
1671 |
// increment counter
|
|
1672 |
__ ldr(rscratch2, Address(rmethod, Method::method_counters_offset()));
|
|
1673 |
__ ldrw(r0, Address(rscratch2, be_offset)); // load backedge counter
|
|
1674 |
__ addw(rscratch1, r0, InvocationCounter::count_increment); // increment counter
|
|
1675 |
__ strw(rscratch1, Address(rscratch2, be_offset)); // store counter
|
|
1676 |
|
|
1677 |
__ ldrw(r0, Address(rscratch2, inv_offset)); // load invocation counter
|
|
1678 |
__ andw(r0, r0, (unsigned)InvocationCounter::count_mask_value); // and the status bits
|
|
1679 |
__ addw(r0, r0, rscratch1); // add both counters
|
|
1680 |
|
|
1681 |
if (ProfileInterpreter) {
|
|
1682 |
// Test to see if we should create a method data oop
|
|
1683 |
__ lea(rscratch1, ExternalAddress((address) &InvocationCounter::InterpreterProfileLimit));
|
|
1684 |
__ ldrw(rscratch1, rscratch1);
|
|
1685 |
__ cmpw(r0, rscratch1);
|
|
1686 |
__ br(Assembler::LT, dispatch);
|
|
1687 |
|
|
1688 |
// if no method data exists, go to profile method
|
|
1689 |
__ test_method_data_pointer(r0, profile_method);
|
|
1690 |
|
|
1691 |
if (UseOnStackReplacement) {
|
|
1692 |
// check for overflow against w1 which is the MDO taken count
|
|
1693 |
__ lea(rscratch1, ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit));
|
|
1694 |
__ ldrw(rscratch1, rscratch1);
|
|
1695 |
__ cmpw(r1, rscratch1);
|
|
1696 |
__ br(Assembler::LO, dispatch); // Intel == Assembler::below
|
|
1697 |
|
|
1698 |
// When ProfileInterpreter is on, the backedge_count comes
|
|
1699 |
// from the MethodData*, which value does not get reset on
|
|
1700 |
// the call to frequency_counter_overflow(). To avoid
|
|
1701 |
// excessive calls to the overflow routine while the method is
|
|
1702 |
// being compiled, add a second test to make sure the overflow
|
|
1703 |
// function is called only once every overflow_frequency.
|
|
1704 |
const int overflow_frequency = 1024;
|
|
1705 |
__ andsw(r1, r1, overflow_frequency - 1);
|
|
1706 |
__ br(Assembler::EQ, backedge_counter_overflow);
|
|
1707 |
|
|
1708 |
}
|
|
1709 |
} else {
|
|
1710 |
if (UseOnStackReplacement) {
|
|
1711 |
// check for overflow against w0, which is the sum of the
|
|
1712 |
// counters
|
|
1713 |
__ lea(rscratch1, ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit));
|
|
1714 |
__ ldrw(rscratch1, rscratch1);
|
|
1715 |
__ cmpw(r0, rscratch1);
|
|
1716 |
__ br(Assembler::HS, backedge_counter_overflow); // Intel == Assembler::aboveEqual
|
|
1717 |
}
|
|
1718 |
}
|
|
1719 |
}
|
|
1720 |
}
|
|
1721 |
__ bind(dispatch);
|
|
1722 |
|
|
1723 |
// Pre-load the next target bytecode into rscratch1
|
|
1724 |
__ load_unsigned_byte(rscratch1, Address(rbcp, 0));
|
|
1725 |
|
|
1726 |
// continue with the bytecode @ target
|
|
1727 |
// rscratch1: target bytecode
|
|
1728 |
// rbcp: target bcp
|
|
1729 |
__ dispatch_only(vtos);
|
|
1730 |
|
|
1731 |
if (UseLoopCounter) {
|
|
1732 |
if (ProfileInterpreter) {
|
|
1733 |
// Out-of-line code to allocate method data oop.
|
|
1734 |
__ bind(profile_method);
|
|
1735 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method));
|
|
1736 |
__ load_unsigned_byte(r1, Address(rbcp, 0)); // restore target bytecode
|
|
1737 |
__ set_method_data_pointer_for_bcp();
|
|
1738 |
__ b(dispatch);
|
|
1739 |
}
|
|
1740 |
|
|
1741 |
if (TieredCompilation || UseOnStackReplacement) {
|
|
1742 |
// invocation counter overflow
|
|
1743 |
__ bind(backedge_counter_overflow);
|
|
1744 |
__ neg(r2, r2);
|
|
1745 |
__ add(r2, r2, rbcp); // branch bcp
|
|
1746 |
// IcoResult frequency_counter_overflow([JavaThread*], address branch_bcp)
|
|
1747 |
__ call_VM(noreg,
|
|
1748 |
CAST_FROM_FN_PTR(address,
|
|
1749 |
InterpreterRuntime::frequency_counter_overflow),
|
|
1750 |
r2);
|
|
1751 |
if (!UseOnStackReplacement)
|
|
1752 |
__ b(dispatch);
|
|
1753 |
}
|
|
1754 |
|
|
1755 |
if (UseOnStackReplacement) {
|
|
1756 |
__ load_unsigned_byte(r1, Address(rbcp, 0)); // restore target bytecode
|
|
1757 |
|
|
1758 |
// r0: osr nmethod (osr ok) or NULL (osr not possible)
|
|
1759 |
// w1: target bytecode
|
|
1760 |
// r2: scratch
|
|
1761 |
__ cbz(r0, dispatch); // test result -- no osr if null
|
|
1762 |
// nmethod may have been invalidated (VM may block upon call_VM return)
|
|
1763 |
__ ldrb(r2, Address(r0, nmethod::state_offset()));
|
|
1764 |
if (nmethod::in_use != 0)
|
|
1765 |
__ sub(r2, r2, nmethod::in_use);
|
|
1766 |
__ cbnz(r2, dispatch);
|
|
1767 |
|
|
1768 |
// We have the address of an on stack replacement routine in r0
|
|
1769 |
// We need to prepare to execute the OSR method. First we must
|
|
1770 |
// migrate the locals and monitors off of the stack.
|
|
1771 |
|
|
1772 |
__ mov(r19, r0); // save the nmethod
|
|
1773 |
|
|
1774 |
call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin));
|
|
1775 |
|
|
1776 |
// r0 is OSR buffer, move it to expected parameter location
|
|
1777 |
__ mov(j_rarg0, r0);
|
|
1778 |
|
|
1779 |
// remove activation
|
|
1780 |
// get sender esp
|
|
1781 |
__ ldr(esp,
|
|
1782 |
Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize));
|
|
1783 |
// remove frame anchor
|
|
1784 |
__ leave();
|
|
1785 |
// Ensure compiled code always sees stack at proper alignment
|
|
1786 |
__ andr(sp, esp, -16);
|
|
1787 |
|
|
1788 |
// and begin the OSR nmethod
|
|
1789 |
__ ldr(rscratch1, Address(r19, nmethod::osr_entry_point_offset()));
|
|
1790 |
__ br(rscratch1);
|
|
1791 |
}
|
|
1792 |
}
|
|
1793 |
}
|
|
1794 |
|
|
1795 |
|
|
1796 |
void TemplateTable::if_0cmp(Condition cc)
|
|
1797 |
{
|
|
1798 |
transition(itos, vtos);
|
|
1799 |
// assume branch is more often taken than not (loops use backward branches)
|
|
1800 |
Label not_taken;
|
|
1801 |
if (cc == equal)
|
|
1802 |
__ cbnzw(r0, not_taken);
|
|
1803 |
else if (cc == not_equal)
|
|
1804 |
__ cbzw(r0, not_taken);
|
|
1805 |
else {
|
|
1806 |
__ andsw(zr, r0, r0);
|
|
1807 |
__ br(j_not(cc), not_taken);
|
|
1808 |
}
|
|
1809 |
|
|
1810 |
branch(false, false);
|
|
1811 |
__ bind(not_taken);
|
|
1812 |
__ profile_not_taken_branch(r0);
|
|
1813 |
}
|
|
1814 |
|
|
1815 |
void TemplateTable::if_icmp(Condition cc)
|
|
1816 |
{
|
|
1817 |
transition(itos, vtos);
|
|
1818 |
// assume branch is more often taken than not (loops use backward branches)
|
|
1819 |
Label not_taken;
|
|
1820 |
__ pop_i(r1);
|
|
1821 |
__ cmpw(r1, r0, Assembler::LSL);
|
|
1822 |
__ br(j_not(cc), not_taken);
|
|
1823 |
branch(false, false);
|
|
1824 |
__ bind(not_taken);
|
|
1825 |
__ profile_not_taken_branch(r0);
|
|
1826 |
}
|
|
1827 |
|
|
1828 |
void TemplateTable::if_nullcmp(Condition cc)
|
|
1829 |
{
|
|
1830 |
transition(atos, vtos);
|
|
1831 |
// assume branch is more often taken than not (loops use backward branches)
|
|
1832 |
Label not_taken;
|
|
1833 |
if (cc == equal)
|
|
1834 |
__ cbnz(r0, not_taken);
|
|
1835 |
else
|
|
1836 |
__ cbz(r0, not_taken);
|
|
1837 |
branch(false, false);
|
|
1838 |
__ bind(not_taken);
|
|
1839 |
__ profile_not_taken_branch(r0);
|
|
1840 |
}
|
|
1841 |
|
|
1842 |
void TemplateTable::if_acmp(Condition cc)
|
|
1843 |
{
|
|
1844 |
transition(atos, vtos);
|
|
1845 |
// assume branch is more often taken than not (loops use backward branches)
|
|
1846 |
Label not_taken;
|
|
1847 |
__ pop_ptr(r1);
|
|
1848 |
__ cmp(r1, r0);
|
|
1849 |
__ br(j_not(cc), not_taken);
|
|
1850 |
branch(false, false);
|
|
1851 |
__ bind(not_taken);
|
|
1852 |
__ profile_not_taken_branch(r0);
|
|
1853 |
}
|
|
1854 |
|
|
1855 |
void TemplateTable::ret() {
|
|
1856 |
transition(vtos, vtos);
|
|
1857 |
// We might be moving to a safepoint. The thread which calls
|
|
1858 |
// Interpreter::notice_safepoints() will effectively flush its cache
|
|
1859 |
// when it makes a system call, but we need to do something to
|
|
1860 |
// ensure that we see the changed dispatch table.
|
|
1861 |
__ membar(MacroAssembler::LoadLoad);
|
|
1862 |
|
|
1863 |
locals_index(r1);
|
|
1864 |
__ ldr(r1, aaddress(r1)); // get return bci, compute return bcp
|
|
1865 |
__ profile_ret(r1, r2);
|
|
1866 |
__ ldr(rbcp, Address(rmethod, Method::const_offset()));
|
|
1867 |
__ lea(rbcp, Address(rbcp, r1));
|
|
1868 |
__ add(rbcp, rbcp, in_bytes(ConstMethod::codes_offset()));
|
|
1869 |
__ dispatch_next(vtos);
|
|
1870 |
}
|
|
1871 |
|
|
1872 |
void TemplateTable::wide_ret() {
|
|
1873 |
transition(vtos, vtos);
|
|
1874 |
locals_index_wide(r1);
|
|
1875 |
__ ldr(r1, aaddress(r1)); // get return bci, compute return bcp
|
|
1876 |
__ profile_ret(r1, r2);
|
|
1877 |
__ ldr(rbcp, Address(rmethod, Method::const_offset()));
|
|
1878 |
__ lea(rbcp, Address(rbcp, r1));
|
|
1879 |
__ add(rbcp, rbcp, in_bytes(ConstMethod::codes_offset()));
|
|
1880 |
__ dispatch_next(vtos);
|
|
1881 |
}
|
|
1882 |
|
|
1883 |
|
|
1884 |
void TemplateTable::tableswitch() {
|
|
1885 |
Label default_case, continue_execution;
|
|
1886 |
transition(itos, vtos);
|
|
1887 |
// align rbcp
|
|
1888 |
__ lea(r1, at_bcp(BytesPerInt));
|
|
1889 |
__ andr(r1, r1, -BytesPerInt);
|
|
1890 |
// load lo & hi
|
|
1891 |
__ ldrw(r2, Address(r1, BytesPerInt));
|
|
1892 |
__ ldrw(r3, Address(r1, 2 * BytesPerInt));
|
|
1893 |
__ rev32(r2, r2);
|
|
1894 |
__ rev32(r3, r3);
|
|
1895 |
// check against lo & hi
|
|
1896 |
__ cmpw(r0, r2);
|
|
1897 |
__ br(Assembler::LT, default_case);
|
|
1898 |
__ cmpw(r0, r3);
|
|
1899 |
__ br(Assembler::GT, default_case);
|
|
1900 |
// lookup dispatch offset
|
|
1901 |
__ subw(r0, r0, r2);
|
|
1902 |
__ lea(r3, Address(r1, r0, Address::uxtw(2)));
|
|
1903 |
__ ldrw(r3, Address(r3, 3 * BytesPerInt));
|
|
1904 |
__ profile_switch_case(r0, r1, r2);
|
|
1905 |
// continue execution
|
|
1906 |
__ bind(continue_execution);
|
|
1907 |
__ rev32(r3, r3);
|
|
1908 |
__ load_unsigned_byte(rscratch1, Address(rbcp, r3, Address::sxtw(0)));
|
|
1909 |
__ add(rbcp, rbcp, r3, ext::sxtw);
|
|
1910 |
__ dispatch_only(vtos);
|
|
1911 |
// handle default
|
|
1912 |
__ bind(default_case);
|
|
1913 |
__ profile_switch_default(r0);
|
|
1914 |
__ ldrw(r3, Address(r1, 0));
|
|
1915 |
__ b(continue_execution);
|
|
1916 |
}
|
|
1917 |
|
|
1918 |
void TemplateTable::lookupswitch() {
|
|
1919 |
transition(itos, itos);
|
|
1920 |
__ stop("lookupswitch bytecode should have been rewritten");
|
|
1921 |
}
|
|
1922 |
|
|
1923 |
void TemplateTable::fast_linearswitch() {
|
|
1924 |
transition(itos, vtos);
|
|
1925 |
Label loop_entry, loop, found, continue_execution;
|
|
1926 |
// bswap r0 so we can avoid bswapping the table entries
|
|
1927 |
__ rev32(r0, r0);
|
|
1928 |
// align rbcp
|
|
1929 |
__ lea(r19, at_bcp(BytesPerInt)); // btw: should be able to get rid of
|
|
1930 |
// this instruction (change offsets
|
|
1931 |
// below)
|
|
1932 |
__ andr(r19, r19, -BytesPerInt);
|
|
1933 |
// set counter
|
|
1934 |
__ ldrw(r1, Address(r19, BytesPerInt));
|
|
1935 |
__ rev32(r1, r1);
|
|
1936 |
__ b(loop_entry);
|
|
1937 |
// table search
|
|
1938 |
__ bind(loop);
|
|
1939 |
__ lea(rscratch1, Address(r19, r1, Address::lsl(3)));
|
|
1940 |
__ ldrw(rscratch1, Address(rscratch1, 2 * BytesPerInt));
|
|
1941 |
__ cmpw(r0, rscratch1);
|
|
1942 |
__ br(Assembler::EQ, found);
|
|
1943 |
__ bind(loop_entry);
|
|
1944 |
__ subs(r1, r1, 1);
|
|
1945 |
__ br(Assembler::PL, loop);
|
|
1946 |
// default case
|
|
1947 |
__ profile_switch_default(r0);
|
|
1948 |
__ ldrw(r3, Address(r19, 0));
|
|
1949 |
__ b(continue_execution);
|
|
1950 |
// entry found -> get offset
|
|
1951 |
__ bind(found);
|
|
1952 |
__ lea(rscratch1, Address(r19, r1, Address::lsl(3)));
|
|
1953 |
__ ldrw(r3, Address(rscratch1, 3 * BytesPerInt));
|
|
1954 |
__ profile_switch_case(r1, r0, r19);
|
|
1955 |
// continue execution
|
|
1956 |
__ bind(continue_execution);
|
|
1957 |
__ rev32(r3, r3);
|
|
1958 |
__ add(rbcp, rbcp, r3, ext::sxtw);
|
|
1959 |
__ ldrb(rscratch1, Address(rbcp, 0));
|
|
1960 |
__ dispatch_only(vtos);
|
|
1961 |
}
|
|
1962 |
|
|
1963 |
void TemplateTable::fast_binaryswitch() {
|
|
1964 |
transition(itos, vtos);
|
|
1965 |
// Implementation using the following core algorithm:
|
|
1966 |
//
|
|
1967 |
// int binary_search(int key, LookupswitchPair* array, int n) {
|
|
1968 |
// // Binary search according to "Methodik des Programmierens" by
|
|
1969 |
// // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985.
|
|
1970 |
// int i = 0;
|
|
1971 |
// int j = n;
|
|
1972 |
// while (i+1 < j) {
|
|
1973 |
// // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q)
|
|
1974 |
// // with Q: for all i: 0 <= i < n: key < a[i]
|
|
1975 |
// // where a stands for the array and assuming that the (inexisting)
|
|
1976 |
// // element a[n] is infinitely big.
|
|
1977 |
// int h = (i + j) >> 1;
|
|
1978 |
// // i < h < j
|
|
1979 |
// if (key < array[h].fast_match()) {
|
|
1980 |
// j = h;
|
|
1981 |
// } else {
|
|
1982 |
// i = h;
|
|
1983 |
// }
|
|
1984 |
// }
|
|
1985 |
// // R: a[i] <= key < a[i+1] or Q
|
|
1986 |
// // (i.e., if key is within array, i is the correct index)
|
|
1987 |
// return i;
|
|
1988 |
// }
|
|
1989 |
|
|
1990 |
// Register allocation
|
|
1991 |
const Register key = r0; // already set (tosca)
|
|
1992 |
const Register array = r1;
|
|
1993 |
const Register i = r2;
|
|
1994 |
const Register j = r3;
|
|
1995 |
const Register h = rscratch1;
|
|
1996 |
const Register temp = rscratch2;
|
|
1997 |
|
|
1998 |
// Find array start
|
|
1999 |
__ lea(array, at_bcp(3 * BytesPerInt)); // btw: should be able to
|
|
2000 |
// get rid of this
|
|
2001 |
// instruction (change
|
|
2002 |
// offsets below)
|
|
2003 |
__ andr(array, array, -BytesPerInt);
|
|
2004 |
|
|
2005 |
// Initialize i & j
|
|
2006 |
__ mov(i, 0); // i = 0;
|
|
2007 |
__ ldrw(j, Address(array, -BytesPerInt)); // j = length(array);
|
|
2008 |
|
|
2009 |
// Convert j into native byteordering
|
|
2010 |
__ rev32(j, j);
|
|
2011 |
|
|
2012 |
// And start
|
|
2013 |
Label entry;
|
|
2014 |
__ b(entry);
|
|
2015 |
|
|
2016 |
// binary search loop
|
|
2017 |
{
|
|
2018 |
Label loop;
|
|
2019 |
__ bind(loop);
|
|
2020 |
// int h = (i + j) >> 1;
|
|
2021 |
__ addw(h, i, j); // h = i + j;
|
|
2022 |
__ lsrw(h, h, 1); // h = (i + j) >> 1;
|
|
2023 |
// if (key < array[h].fast_match()) {
|
|
2024 |
// j = h;
|
|
2025 |
// } else {
|
|
2026 |
// i = h;
|
|
2027 |
// }
|
|
2028 |
// Convert array[h].match to native byte-ordering before compare
|
|
2029 |
__ ldr(temp, Address(array, h, Address::lsl(3)));
|
|
2030 |
__ rev32(temp, temp);
|
|
2031 |
__ cmpw(key, temp);
|
|
2032 |
// j = h if (key < array[h].fast_match())
|
|
2033 |
__ csel(j, h, j, Assembler::LT);
|
|
2034 |
// i = h if (key >= array[h].fast_match())
|
|
2035 |
__ csel(i, h, i, Assembler::GE);
|
|
2036 |
// while (i+1 < j)
|
|
2037 |
__ bind(entry);
|
|
2038 |
__ addw(h, i, 1); // i+1
|
|
2039 |
__ cmpw(h, j); // i+1 < j
|
|
2040 |
__ br(Assembler::LT, loop);
|
|
2041 |
}
|
|
2042 |
|
|
2043 |
// end of binary search, result index is i (must check again!)
|
|
2044 |
Label default_case;
|
|
2045 |
// Convert array[i].match to native byte-ordering before compare
|
|
2046 |
__ ldr(temp, Address(array, i, Address::lsl(3)));
|
|
2047 |
__ rev32(temp, temp);
|
|
2048 |
__ cmpw(key, temp);
|
|
2049 |
__ br(Assembler::NE, default_case);
|
|
2050 |
|
|
2051 |
// entry found -> j = offset
|
|
2052 |
__ add(j, array, i, ext::uxtx, 3);
|
|
2053 |
__ ldrw(j, Address(j, BytesPerInt));
|
|
2054 |
__ profile_switch_case(i, key, array);
|
|
2055 |
__ rev32(j, j);
|
|
2056 |
__ load_unsigned_byte(rscratch1, Address(rbcp, j, Address::sxtw(0)));
|
|
2057 |
__ lea(rbcp, Address(rbcp, j, Address::sxtw(0)));
|
|
2058 |
__ dispatch_only(vtos);
|
|
2059 |
|
|
2060 |
// default case -> j = default offset
|
|
2061 |
__ bind(default_case);
|
|
2062 |
__ profile_switch_default(i);
|
|
2063 |
__ ldrw(j, Address(array, -2 * BytesPerInt));
|
|
2064 |
__ rev32(j, j);
|
|
2065 |
__ load_unsigned_byte(rscratch1, Address(rbcp, j, Address::sxtw(0)));
|
|
2066 |
__ lea(rbcp, Address(rbcp, j, Address::sxtw(0)));
|
|
2067 |
__ dispatch_only(vtos);
|
|
2068 |
}
|
|
2069 |
|
|
2070 |
|
|
2071 |
void TemplateTable::_return(TosState state)
|
|
2072 |
{
|
|
2073 |
transition(state, state);
|
|
2074 |
assert(_desc->calls_vm(),
|
|
2075 |
"inconsistent calls_vm information"); // call in remove_activation
|
|
2076 |
|
|
2077 |
if (_desc->bytecode() == Bytecodes::_return_register_finalizer) {
|
|
2078 |
assert(state == vtos, "only valid state");
|
|
2079 |
|
|
2080 |
__ ldr(c_rarg1, aaddress(0));
|
|
2081 |
__ load_klass(r3, c_rarg1);
|
|
2082 |
__ ldrw(r3, Address(r3, Klass::access_flags_offset()));
|
|
2083 |
__ tst(r3, JVM_ACC_HAS_FINALIZER);
|
|
2084 |
Label skip_register_finalizer;
|
|
2085 |
__ br(Assembler::EQ, skip_register_finalizer);
|
|
2086 |
|
|
2087 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1);
|
|
2088 |
|
|
2089 |
__ bind(skip_register_finalizer);
|
|
2090 |
}
|
|
2091 |
|
|
2092 |
// Issue a StoreStore barrier after all stores but before return
|
|
2093 |
// from any constructor for any class with a final field. We don't
|
|
2094 |
// know if this is a finalizer, so we always do so.
|
|
2095 |
if (_desc->bytecode() == Bytecodes::_return)
|
|
2096 |
__ membar(MacroAssembler::StoreStore);
|
|
2097 |
|
|
2098 |
__ remove_activation(state);
|
|
2099 |
__ ret(lr);
|
|
2100 |
}
|
|
2101 |
|
|
2102 |
// ----------------------------------------------------------------------------
|
|
2103 |
// Volatile variables demand their effects be made known to all CPU's
|
|
2104 |
// in order. Store buffers on most chips allow reads & writes to
|
|
2105 |
// reorder; the JMM's ReadAfterWrite.java test fails in -Xint mode
|
|
2106 |
// without some kind of memory barrier (i.e., it's not sufficient that
|
|
2107 |
// the interpreter does not reorder volatile references, the hardware
|
|
2108 |
// also must not reorder them).
|
|
2109 |
//
|
|
2110 |
// According to the new Java Memory Model (JMM):
|
|
2111 |
// (1) All volatiles are serialized wrt to each other. ALSO reads &
|
|
2112 |
// writes act as aquire & release, so:
|
|
2113 |
// (2) A read cannot let unrelated NON-volatile memory refs that
|
|
2114 |
// happen after the read float up to before the read. It's OK for
|
|
2115 |
// non-volatile memory refs that happen before the volatile read to
|
|
2116 |
// float down below it.
|
|
2117 |
// (3) Similar a volatile write cannot let unrelated NON-volatile
|
|
2118 |
// memory refs that happen BEFORE the write float down to after the
|
|
2119 |
// write. It's OK for non-volatile memory refs that happen after the
|
|
2120 |
// volatile write to float up before it.
|
|
2121 |
//
|
|
2122 |
// We only put in barriers around volatile refs (they are expensive),
|
|
2123 |
// not _between_ memory refs (that would require us to track the
|
|
2124 |
// flavor of the previous memory refs). Requirements (2) and (3)
|
|
2125 |
// require some barriers before volatile stores and after volatile
|
|
2126 |
// loads. These nearly cover requirement (1) but miss the
|
|
2127 |
// volatile-store-volatile-load case. This final case is placed after
|
|
2128 |
// volatile-stores although it could just as well go before
|
|
2129 |
// volatile-loads.
|
|
2130 |
|
|
2131 |
void TemplateTable::resolve_cache_and_index(int byte_no,
|
|
2132 |
Register Rcache,
|
|
2133 |
Register index,
|
|
2134 |
size_t index_size) {
|
|
2135 |
const Register temp = r19;
|
|
2136 |
assert_different_registers(Rcache, index, temp);
|
|
2137 |
|
|
2138 |
Label resolved;
|
|
2139 |
assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
|
|
2140 |
__ get_cache_and_index_and_bytecode_at_bcp(Rcache, index, temp, byte_no, 1, index_size);
|
|
2141 |
__ cmp(temp, (int) bytecode()); // have we resolved this bytecode?
|
|
2142 |
__ br(Assembler::EQ, resolved);
|
|
2143 |
|
|
2144 |
// resolve first time through
|
|
2145 |
address entry;
|
|
2146 |
switch (bytecode()) {
|
|
2147 |
case Bytecodes::_getstatic:
|
|
2148 |
case Bytecodes::_putstatic:
|
|
2149 |
case Bytecodes::_getfield:
|
|
2150 |
case Bytecodes::_putfield:
|
|
2151 |
entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put);
|
|
2152 |
break;
|
|
2153 |
case Bytecodes::_invokevirtual:
|
|
2154 |
case Bytecodes::_invokespecial:
|
|
2155 |
case Bytecodes::_invokestatic:
|
|
2156 |
case Bytecodes::_invokeinterface:
|
|
2157 |
entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke);
|
|
2158 |
break;
|
|
2159 |
case Bytecodes::_invokehandle:
|
|
2160 |
entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokehandle);
|
|
2161 |
break;
|
|
2162 |
case Bytecodes::_invokedynamic:
|
|
2163 |
entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic);
|
|
2164 |
break;
|
|
2165 |
default:
|
|
2166 |
fatal(err_msg("unexpected bytecode: %s", Bytecodes::name(bytecode())));
|
|
2167 |
break;
|
|
2168 |
}
|
|
2169 |
__ mov(temp, (int) bytecode());
|
|
2170 |
__ call_VM(noreg, entry, temp);
|
|
2171 |
|
|
2172 |
// Update registers with resolved info
|
|
2173 |
__ get_cache_and_index_at_bcp(Rcache, index, 1, index_size);
|
|
2174 |
// n.b. unlike x86 Rcache is now rcpool plus the indexed offset
|
|
2175 |
// so all clients ofthis method must be modified accordingly
|
|
2176 |
__ bind(resolved);
|
|
2177 |
}
|
|
2178 |
|
|
2179 |
// The Rcache and index registers must be set before call
|
|
2180 |
// n.b unlike x86 cache already includes the index offset
|
|
2181 |
void TemplateTable::load_field_cp_cache_entry(Register obj,
|
|
2182 |
Register cache,
|
|
2183 |
Register index,
|
|
2184 |
Register off,
|
|
2185 |
Register flags,
|
|
2186 |
bool is_static = false) {
|
|
2187 |
assert_different_registers(cache, index, flags, off);
|
|
2188 |
|
|
2189 |
ByteSize cp_base_offset = ConstantPoolCache::base_offset();
|
|
2190 |
// Field offset
|
|
2191 |
__ ldr(off, Address(cache, in_bytes(cp_base_offset +
|
|
2192 |
ConstantPoolCacheEntry::f2_offset())));
|
|
2193 |
// Flags
|
|
2194 |
__ ldrw(flags, Address(cache, in_bytes(cp_base_offset +
|
|
2195 |
ConstantPoolCacheEntry::flags_offset())));
|
|
2196 |
|
|
2197 |
// klass overwrite register
|
|
2198 |
if (is_static) {
|
|
2199 |
__ ldr(obj, Address(cache, in_bytes(cp_base_offset +
|
|
2200 |
ConstantPoolCacheEntry::f1_offset())));
|
|
2201 |
const int mirror_offset = in_bytes(Klass::java_mirror_offset());
|
|
2202 |
__ ldr(obj, Address(obj, mirror_offset));
|
|
2203 |
}
|
|
2204 |
}
|
|
2205 |
|
|
2206 |
void TemplateTable::load_invoke_cp_cache_entry(int byte_no,
|
|
2207 |
Register method,
|
|
2208 |
Register itable_index,
|
|
2209 |
Register flags,
|
|
2210 |
bool is_invokevirtual,
|
|
2211 |
bool is_invokevfinal, /*unused*/
|
|
2212 |
bool is_invokedynamic) {
|
|
2213 |
// setup registers
|
|
2214 |
const Register cache = rscratch2;
|
|
2215 |
const Register index = r4;
|
|
2216 |
assert_different_registers(method, flags);
|
|
2217 |
assert_different_registers(method, cache, index);
|
|
2218 |
assert_different_registers(itable_index, flags);
|
|
2219 |
assert_different_registers(itable_index, cache, index);
|
|
2220 |
// determine constant pool cache field offsets
|
|
2221 |
assert(is_invokevirtual == (byte_no == f2_byte), "is_invokevirtual flag redundant");
|
|
2222 |
const int method_offset = in_bytes(
|
|
2223 |
ConstantPoolCache::base_offset() +
|
|
2224 |
(is_invokevirtual
|
|
2225 |
? ConstantPoolCacheEntry::f2_offset()
|
|
2226 |
: ConstantPoolCacheEntry::f1_offset()));
|
|
2227 |
const int flags_offset = in_bytes(ConstantPoolCache::base_offset() +
|
|
2228 |
ConstantPoolCacheEntry::flags_offset());
|
|
2229 |
// access constant pool cache fields
|
|
2230 |
const int index_offset = in_bytes(ConstantPoolCache::base_offset() +
|
|
2231 |
ConstantPoolCacheEntry::f2_offset());
|
|
2232 |
|
|
2233 |
size_t index_size = (is_invokedynamic ? sizeof(u4) : sizeof(u2));
|
|
2234 |
resolve_cache_and_index(byte_no, cache, index, index_size);
|
|
2235 |
__ ldr(method, Address(cache, method_offset));
|
|
2236 |
|
|
2237 |
if (itable_index != noreg) {
|
|
2238 |
__ ldr(itable_index, Address(cache, index_offset));
|
|
2239 |
}
|
|
2240 |
__ ldrw(flags, Address(cache, flags_offset));
|
|
2241 |
}
|
|
2242 |
|
|
2243 |
|
|
2244 |
// The registers cache and index expected to be set before call.
|
|
2245 |
// Correct values of the cache and index registers are preserved.
|
|
2246 |
void TemplateTable::jvmti_post_field_access(Register cache, Register index,
|
|
2247 |
bool is_static, bool has_tos) {
|
|
2248 |
// do the JVMTI work here to avoid disturbing the register state below
|
|
2249 |
// We use c_rarg registers here because we want to use the register used in
|
|
2250 |
// the call to the VM
|
|
2251 |
if (JvmtiExport::can_post_field_access()) {
|
|
2252 |
// Check to see if a field access watch has been set before we
|
|
2253 |
// take the time to call into the VM.
|
|
2254 |
Label L1;
|
|
2255 |
assert_different_registers(cache, index, r0);
|
|
2256 |
__ lea(rscratch1, ExternalAddress((address) JvmtiExport::get_field_access_count_addr()));
|
|
2257 |
__ ldrw(r0, Address(rscratch1));
|
|
2258 |
__ cbzw(r0, L1);
|
|
2259 |
|
|
2260 |
__ get_cache_and_index_at_bcp(c_rarg2, c_rarg3, 1);
|
|
2261 |
__ lea(c_rarg2, Address(c_rarg2, in_bytes(ConstantPoolCache::base_offset())));
|
|
2262 |
|
|
2263 |
if (is_static) {
|
|
2264 |
__ mov(c_rarg1, zr); // NULL object reference
|
|
2265 |
} else {
|
|
2266 |
__ ldr(c_rarg1, at_tos()); // get object pointer without popping it
|
|
2267 |
__ verify_oop(c_rarg1);
|
|
2268 |
}
|
|
2269 |
// c_rarg1: object pointer or NULL
|
|
2270 |
// c_rarg2: cache entry pointer
|
|
2271 |
// c_rarg3: jvalue object on the stack
|
|
2272 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address,
|
|
2273 |
InterpreterRuntime::post_field_access),
|
|
2274 |
c_rarg1, c_rarg2, c_rarg3);
|
|
2275 |
__ get_cache_and_index_at_bcp(cache, index, 1);
|
|
2276 |
__ bind(L1);
|
|
2277 |
}
|
|
2278 |
}
|
|
2279 |
|
|
2280 |
void TemplateTable::pop_and_check_object(Register r)
|
|
2281 |
{
|
|
2282 |
__ pop_ptr(r);
|
|
2283 |
__ null_check(r); // for field access must check obj.
|
|
2284 |
__ verify_oop(r);
|
|
2285 |
}
|
|
2286 |
|
|
2287 |
void TemplateTable::getfield_or_static(int byte_no, bool is_static)
|
|
2288 |
{
|
|
2289 |
const Register cache = r2;
|
|
2290 |
const Register index = r3;
|
|
2291 |
const Register obj = r4;
|
|
2292 |
const Register off = r19;
|
|
2293 |
const Register flags = r0;
|
|
2294 |
const Register bc = r4; // uses same reg as obj, so don't mix them
|
|
2295 |
|
|
2296 |
resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
|
|
2297 |
jvmti_post_field_access(cache, index, is_static, false);
|
|
2298 |
load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
|
|
2299 |
|
|
2300 |
if (!is_static) {
|
|
2301 |
// obj is on the stack
|
|
2302 |
pop_and_check_object(obj);
|
|
2303 |
}
|
|
2304 |
|
|
2305 |
const Address field(obj, off);
|
|
2306 |
|
|
2307 |
Label Done, notByte, notInt, notShort, notChar,
|
|
2308 |
notLong, notFloat, notObj, notDouble;
|
|
2309 |
|
|
2310 |
// x86 uses a shift and mask or wings it with a shift plus assert
|
|
2311 |
// the mask is not needed. aarch64 just uses bitfield extract
|
|
2312 |
__ ubfxw(flags, flags, ConstantPoolCacheEntry::tos_state_shift, ConstantPoolCacheEntry::tos_state_bits);
|
|
2313 |
|
|
2314 |
assert(btos == 0, "change code, btos != 0");
|
|
2315 |
__ cbnz(flags, notByte);
|
|
2316 |
|
|
2317 |
// btos
|
|
2318 |
__ load_signed_byte(r0, field);
|
|
2319 |
__ push(btos);
|
|
2320 |
// Rewrite bytecode to be faster
|
|
2321 |
if (!is_static) {
|
|
2322 |
patch_bytecode(Bytecodes::_fast_bgetfield, bc, r1);
|
|
2323 |
}
|
|
2324 |
__ b(Done);
|
|
2325 |
|
|
2326 |
__ bind(notByte);
|
|
2327 |
__ cmp(flags, atos);
|
|
2328 |
__ br(Assembler::NE, notObj);
|
|
2329 |
// atos
|
|
2330 |
__ load_heap_oop(r0, field);
|
|
2331 |
__ push(atos);
|
|
2332 |
if (!is_static) {
|
|
2333 |
patch_bytecode(Bytecodes::_fast_agetfield, bc, r1);
|
|
2334 |
}
|
|
2335 |
__ b(Done);
|
|
2336 |
|
|
2337 |
__ bind(notObj);
|
|
2338 |
__ cmp(flags, itos);
|
|
2339 |
__ br(Assembler::NE, notInt);
|
|
2340 |
// itos
|
|
2341 |
__ ldrw(r0, field);
|
|
2342 |
__ push(itos);
|
|
2343 |
// Rewrite bytecode to be faster
|
|
2344 |
if (!is_static) {
|
|
2345 |
patch_bytecode(Bytecodes::_fast_igetfield, bc, r1);
|
|
2346 |
}
|
|
2347 |
__ b(Done);
|
|
2348 |
|
|
2349 |
__ bind(notInt);
|
|
2350 |
__ cmp(flags, ctos);
|
|
2351 |
__ br(Assembler::NE, notChar);
|
|
2352 |
// ctos
|
|
2353 |
__ load_unsigned_short(r0, field);
|
|
2354 |
__ push(ctos);
|
|
2355 |
// Rewrite bytecode to be faster
|
|
2356 |
if (!is_static) {
|
|
2357 |
patch_bytecode(Bytecodes::_fast_cgetfield, bc, r1);
|
|
2358 |
}
|
|
2359 |
__ b(Done);
|
|
2360 |
|
|
2361 |
__ bind(notChar);
|
|
2362 |
__ cmp(flags, stos);
|
|
2363 |
__ br(Assembler::NE, notShort);
|
|
2364 |
// stos
|
|
2365 |
__ load_signed_short(r0, field);
|
|
2366 |
__ push(stos);
|
|
2367 |
// Rewrite bytecode to be faster
|
|
2368 |
if (!is_static) {
|
|
2369 |
patch_bytecode(Bytecodes::_fast_sgetfield, bc, r1);
|
|
2370 |
}
|
|
2371 |
__ b(Done);
|
|
2372 |
|
|
2373 |
__ bind(notShort);
|
|
2374 |
__ cmp(flags, ltos);
|
|
2375 |
__ br(Assembler::NE, notLong);
|
|
2376 |
// ltos
|
|
2377 |
__ ldr(r0, field);
|
|
2378 |
__ push(ltos);
|
|
2379 |
// Rewrite bytecode to be faster
|
|
2380 |
if (!is_static) {
|
|
2381 |
patch_bytecode(Bytecodes::_fast_lgetfield, bc, r1);
|
|
2382 |
}
|
|
2383 |
__ b(Done);
|
|
2384 |
|
|
2385 |
__ bind(notLong);
|
|
2386 |
__ cmp(flags, ftos);
|
|
2387 |
__ br(Assembler::NE, notFloat);
|
|
2388 |
// ftos
|
|
2389 |
__ ldrs(v0, field);
|
|
2390 |
__ push(ftos);
|
|
2391 |
// Rewrite bytecode to be faster
|
|
2392 |
if (!is_static) {
|
|
2393 |
patch_bytecode(Bytecodes::_fast_fgetfield, bc, r1);
|
|
2394 |
}
|
|
2395 |
__ b(Done);
|
|
2396 |
|
|
2397 |
__ bind(notFloat);
|
|
2398 |
#ifdef ASSERT
|
|
2399 |
__ cmp(flags, dtos);
|
|
2400 |
__ br(Assembler::NE, notDouble);
|
|
2401 |
#endif
|
|
2402 |
// dtos
|
|
2403 |
__ ldrd(v0, field);
|
|
2404 |
__ push(dtos);
|
|
2405 |
// Rewrite bytecode to be faster
|
|
2406 |
if (!is_static) {
|
|
2407 |
patch_bytecode(Bytecodes::_fast_dgetfield, bc, r1);
|
|
2408 |
}
|
|
2409 |
#ifdef ASSERT
|
|
2410 |
__ b(Done);
|
|
2411 |
|
|
2412 |
__ bind(notDouble);
|
|
2413 |
__ stop("Bad state");
|
|
2414 |
#endif
|
|
2415 |
|
|
2416 |
__ bind(Done);
|
|
2417 |
// It's really not worth bothering to check whether this field
|
|
2418 |
// really is volatile in the slow case.
|
|
2419 |
__ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);
|
|
2420 |
}
|
|
2421 |
|
|
2422 |
|
|
2423 |
void TemplateTable::getfield(int byte_no)
|
|
2424 |
{
|
|
2425 |
getfield_or_static(byte_no, false);
|
|
2426 |
}
|
|
2427 |
|
|
2428 |
void TemplateTable::getstatic(int byte_no)
|
|
2429 |
{
|
|
2430 |
getfield_or_static(byte_no, true);
|
|
2431 |
}
|
|
2432 |
|
|
2433 |
// The registers cache and index expected to be set before call.
|
|
2434 |
// The function may destroy various registers, just not the cache and index registers.
|
|
2435 |
void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is_static) {
|
|
2436 |
transition(vtos, vtos);
|
|
2437 |
|
|
2438 |
ByteSize cp_base_offset = ConstantPoolCache::base_offset();
|
|
2439 |
|
|
2440 |
if (JvmtiExport::can_post_field_modification()) {
|
|
2441 |
// Check to see if a field modification watch has been set before
|
|
2442 |
// we take the time to call into the VM.
|
|
2443 |
Label L1;
|
|
2444 |
assert_different_registers(cache, index, r0);
|
|
2445 |
__ lea(rscratch1, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr()));
|
|
2446 |
__ ldrw(r0, Address(rscratch1));
|
|
2447 |
__ cbz(r0, L1);
|
|
2448 |
|
|
2449 |
__ get_cache_and_index_at_bcp(c_rarg2, rscratch1, 1);
|
|
2450 |
|
|
2451 |
if (is_static) {
|
|
2452 |
// Life is simple. Null out the object pointer.
|
|
2453 |
__ mov(c_rarg1, zr);
|
|
2454 |
} else {
|
|
2455 |
// Life is harder. The stack holds the value on top, followed by
|
|
2456 |
// the object. We don't know the size of the value, though; it
|
|
2457 |
// could be one or two words depending on its type. As a result,
|
|
2458 |
// we must find the type to determine where the object is.
|
|
2459 |
__ ldrw(c_rarg3, Address(c_rarg2,
|
|
2460 |
in_bytes(cp_base_offset +
|
|
2461 |
ConstantPoolCacheEntry::flags_offset())));
|
|
2462 |
__ lsr(c_rarg3, c_rarg3,
|
|
2463 |
ConstantPoolCacheEntry::tos_state_shift);
|
|
2464 |
ConstantPoolCacheEntry::verify_tos_state_shift();
|
|
2465 |
Label nope2, done, ok;
|
|
2466 |
__ ldr(c_rarg1, at_tos_p1()); // initially assume a one word jvalue
|
|
2467 |
__ cmpw(c_rarg3, ltos);
|
|
2468 |
__ br(Assembler::EQ, ok);
|
|
2469 |
__ cmpw(c_rarg3, dtos);
|
|
2470 |
__ br(Assembler::NE, nope2);
|
|
2471 |
__ bind(ok);
|
|
2472 |
__ ldr(c_rarg1, at_tos_p2()); // ltos (two word jvalue)
|
|
2473 |
__ bind(nope2);
|
|
2474 |
}
|
|
2475 |
// cache entry pointer
|
|
2476 |
__ add(c_rarg2, c_rarg2, in_bytes(cp_base_offset));
|
|
2477 |
// object (tos)
|
|
2478 |
__ mov(c_rarg3, esp);
|
|
2479 |
// c_rarg1: object pointer set up above (NULL if static)
|
|
2480 |
// c_rarg2: cache entry pointer
|
|
2481 |
// c_rarg3: jvalue object on the stack
|
|
2482 |
__ call_VM(noreg,
|
|
2483 |
CAST_FROM_FN_PTR(address,
|
|
2484 |
InterpreterRuntime::post_field_modification),
|
|
2485 |
c_rarg1, c_rarg2, c_rarg3);
|
|
2486 |
__ get_cache_and_index_at_bcp(cache, index, 1);
|
|
2487 |
__ bind(L1);
|
|
2488 |
}
|
|
2489 |
}
|
|
2490 |
|
|
2491 |
void TemplateTable::putfield_or_static(int byte_no, bool is_static) {
|
|
2492 |
transition(vtos, vtos);
|
|
2493 |
|
|
2494 |
const Register cache = r2;
|
|
2495 |
const Register index = r3;
|
|
2496 |
const Register obj = r2;
|
|
2497 |
const Register off = r19;
|
|
2498 |
const Register flags = r0;
|
|
2499 |
const Register bc = r4;
|
|
2500 |
|
|
2501 |
resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
|
|
2502 |
jvmti_post_field_mod(cache, index, is_static);
|
|
2503 |
load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
|
|
2504 |
|
|
2505 |
Label Done;
|
|
2506 |
__ mov(r5, flags);
|
|
2507 |
|
|
2508 |
{
|
|
2509 |
Label notVolatile;
|
|
2510 |
__ tbz(r5, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
|
|
2511 |
__ membar(MacroAssembler::StoreStore);
|
|
2512 |
__ bind(notVolatile);
|
|
2513 |
}
|
|
2514 |
|
|
2515 |
// field address
|
|
2516 |
const Address field(obj, off);
|
|
2517 |
|
|
2518 |
Label notByte, notInt, notShort, notChar,
|
|
2519 |
notLong, notFloat, notObj, notDouble;
|
|
2520 |
|
|
2521 |
// x86 uses a shift and mask or wings it with a shift plus assert
|
|
2522 |
// the mask is not needed. aarch64 just uses bitfield extract
|
|
2523 |
__ ubfxw(flags, flags, ConstantPoolCacheEntry::tos_state_shift, ConstantPoolCacheEntry::tos_state_bits);
|
|
2524 |
|
|
2525 |
assert(btos == 0, "change code, btos != 0");
|
|
2526 |
__ cbnz(flags, notByte);
|
|
2527 |
|
|
2528 |
// btos
|
|
2529 |
{
|
|
2530 |
__ pop(btos);
|
|
2531 |
if (!is_static) pop_and_check_object(obj);
|
|
2532 |
__ strb(r0, field);
|
|
2533 |
if (!is_static) {
|
|
2534 |
patch_bytecode(Bytecodes::_fast_bputfield, bc, r1, true, byte_no);
|
|
2535 |
}
|
|
2536 |
__ b(Done);
|
|
2537 |
}
|
|
2538 |
|
|
2539 |
__ bind(notByte);
|
|
2540 |
__ cmp(flags, atos);
|
|
2541 |
__ br(Assembler::NE, notObj);
|
|
2542 |
|
|
2543 |
// atos
|
|
2544 |
{
|
|
2545 |
__ pop(atos);
|
|
2546 |
if (!is_static) pop_and_check_object(obj);
|
|
2547 |
// Store into the field
|
|
2548 |
do_oop_store(_masm, field, r0, _bs->kind(), false);
|
|
2549 |
if (!is_static) {
|
|
2550 |
patch_bytecode(Bytecodes::_fast_aputfield, bc, r1, true, byte_no);
|
|
2551 |
}
|
|
2552 |
__ b(Done);
|
|
2553 |
}
|
|
2554 |
|
|
2555 |
__ bind(notObj);
|
|
2556 |
__ cmp(flags, itos);
|
|
2557 |
__ br(Assembler::NE, notInt);
|
|
2558 |
|
|
2559 |
// itos
|
|
2560 |
{
|
|
2561 |
__ pop(itos);
|
|
2562 |
if (!is_static) pop_and_check_object(obj);
|
|
2563 |
__ strw(r0, field);
|
|
2564 |
if (!is_static) {
|
|
2565 |
patch_bytecode(Bytecodes::_fast_iputfield, bc, r1, true, byte_no);
|
|
2566 |
}
|
|
2567 |
__ b(Done);
|
|
2568 |
}
|
|
2569 |
|
|
2570 |
__ bind(notInt);
|
|
2571 |
__ cmp(flags, ctos);
|
|
2572 |
__ br(Assembler::NE, notChar);
|
|
2573 |
|
|
2574 |
// ctos
|
|
2575 |
{
|
|
2576 |
__ pop(ctos);
|
|
2577 |
if (!is_static) pop_and_check_object(obj);
|
|
2578 |
__ strh(r0, field);
|
|
2579 |
if (!is_static) {
|
|
2580 |
patch_bytecode(Bytecodes::_fast_cputfield, bc, r1, true, byte_no);
|
|
2581 |
}
|
|
2582 |
__ b(Done);
|
|
2583 |
}
|
|
2584 |
|
|
2585 |
__ bind(notChar);
|
|
2586 |
__ cmp(flags, stos);
|
|
2587 |
__ br(Assembler::NE, notShort);
|
|
2588 |
|
|
2589 |
// stos
|
|
2590 |
{
|
|
2591 |
__ pop(stos);
|
|
2592 |
if (!is_static) pop_and_check_object(obj);
|
|
2593 |
__ strh(r0, field);
|
|
2594 |
if (!is_static) {
|
|
2595 |
patch_bytecode(Bytecodes::_fast_sputfield, bc, r1, true, byte_no);
|
|
2596 |
}
|
|
2597 |
__ b(Done);
|
|
2598 |
}
|
|
2599 |
|
|
2600 |
__ bind(notShort);
|
|
2601 |
__ cmp(flags, ltos);
|
|
2602 |
__ br(Assembler::NE, notLong);
|
|
2603 |
|
|
2604 |
// ltos
|
|
2605 |
{
|
|
2606 |
__ pop(ltos);
|
|
2607 |
if (!is_static) pop_and_check_object(obj);
|
|
2608 |
__ str(r0, field);
|
|
2609 |
if (!is_static) {
|
|
2610 |
patch_bytecode(Bytecodes::_fast_lputfield, bc, r1, true, byte_no);
|
|
2611 |
}
|
|
2612 |
__ b(Done);
|
|
2613 |
}
|
|
2614 |
|
|
2615 |
__ bind(notLong);
|
|
2616 |
__ cmp(flags, ftos);
|
|
2617 |
__ br(Assembler::NE, notFloat);
|
|
2618 |
|
|
2619 |
// ftos
|
|
2620 |
{
|
|
2621 |
__ pop(ftos);
|
|
2622 |
if (!is_static) pop_and_check_object(obj);
|
|
2623 |
__ strs(v0, field);
|
|
2624 |
if (!is_static) {
|
|
2625 |
patch_bytecode(Bytecodes::_fast_fputfield, bc, r1, true, byte_no);
|
|
2626 |
}
|
|
2627 |
__ b(Done);
|
|
2628 |
}
|
|
2629 |
|
|
2630 |
__ bind(notFloat);
|
|
2631 |
#ifdef ASSERT
|
|
2632 |
__ cmp(flags, dtos);
|
|
2633 |
__ br(Assembler::NE, notDouble);
|
|
2634 |
#endif
|
|
2635 |
|
|
2636 |
// dtos
|
|
2637 |
{
|
|
2638 |
__ pop(dtos);
|
|
2639 |
if (!is_static) pop_and_check_object(obj);
|
|
2640 |
__ strd(v0, field);
|
|
2641 |
if (!is_static) {
|
|
2642 |
patch_bytecode(Bytecodes::_fast_dputfield, bc, r1, true, byte_no);
|
|
2643 |
}
|
|
2644 |
}
|
|
2645 |
|
|
2646 |
#ifdef ASSERT
|
|
2647 |
__ b(Done);
|
|
2648 |
|
|
2649 |
__ bind(notDouble);
|
|
2650 |
__ stop("Bad state");
|
|
2651 |
#endif
|
|
2652 |
|
|
2653 |
__ bind(Done);
|
|
2654 |
|
|
2655 |
{
|
|
2656 |
Label notVolatile;
|
|
2657 |
__ tbz(r5, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
|
|
2658 |
__ membar(MacroAssembler::StoreLoad);
|
|
2659 |
__ bind(notVolatile);
|
|
2660 |
}
|
|
2661 |
}
|
|
2662 |
|
|
2663 |
void TemplateTable::putfield(int byte_no)
|
|
2664 |
{
|
|
2665 |
putfield_or_static(byte_no, false);
|
|
2666 |
}
|
|
2667 |
|
|
2668 |
void TemplateTable::putstatic(int byte_no) {
|
|
2669 |
putfield_or_static(byte_no, true);
|
|
2670 |
}
|
|
2671 |
|
|
2672 |
void TemplateTable::jvmti_post_fast_field_mod()
|
|
2673 |
{
|
|
2674 |
if (JvmtiExport::can_post_field_modification()) {
|
|
2675 |
// Check to see if a field modification watch has been set before
|
|
2676 |
// we take the time to call into the VM.
|
|
2677 |
Label L2;
|
|
2678 |
__ lea(rscratch1, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr()));
|
|
2679 |
__ ldrw(c_rarg3, Address(rscratch1));
|
|
2680 |
__ cbzw(c_rarg3, L2);
|
|
2681 |
__ pop_ptr(r19); // copy the object pointer from tos
|
|
2682 |
__ verify_oop(r19);
|
|
2683 |
__ push_ptr(r19); // put the object pointer back on tos
|
|
2684 |
// Save tos values before call_VM() clobbers them. Since we have
|
|
2685 |
// to do it for every data type, we use the saved values as the
|
|
2686 |
// jvalue object.
|
|
2687 |
switch (bytecode()) { // load values into the jvalue object
|
|
2688 |
case Bytecodes::_fast_aputfield: __ push_ptr(r0); break;
|
|
2689 |
case Bytecodes::_fast_bputfield: // fall through
|
|
2690 |
case Bytecodes::_fast_sputfield: // fall through
|
|
2691 |
case Bytecodes::_fast_cputfield: // fall through
|
|
2692 |
case Bytecodes::_fast_iputfield: __ push_i(r0); break;
|
|
2693 |
case Bytecodes::_fast_dputfield: __ push_d(); break;
|
|
2694 |
case Bytecodes::_fast_fputfield: __ push_f(); break;
|
|
2695 |
case Bytecodes::_fast_lputfield: __ push_l(r0); break;
|
|
2696 |
|
|
2697 |
default:
|
|
2698 |
ShouldNotReachHere();
|
|
2699 |
}
|
|
2700 |
__ mov(c_rarg3, esp); // points to jvalue on the stack
|
|
2701 |
// access constant pool cache entry
|
|
2702 |
__ get_cache_entry_pointer_at_bcp(c_rarg2, r0, 1);
|
|
2703 |
__ verify_oop(r19);
|
|
2704 |
// r19: object pointer copied above
|
|
2705 |
// c_rarg2: cache entry pointer
|
|
2706 |
// c_rarg3: jvalue object on the stack
|
|
2707 |
__ call_VM(noreg,
|
|
2708 |
CAST_FROM_FN_PTR(address,
|
|
2709 |
InterpreterRuntime::post_field_modification),
|
|
2710 |
r19, c_rarg2, c_rarg3);
|
|
2711 |
|
|
2712 |
switch (bytecode()) { // restore tos values
|
|
2713 |
case Bytecodes::_fast_aputfield: __ pop_ptr(r0); break;
|
|
2714 |
case Bytecodes::_fast_bputfield: // fall through
|
|
2715 |
case Bytecodes::_fast_sputfield: // fall through
|
|
2716 |
case Bytecodes::_fast_cputfield: // fall through
|
|
2717 |
case Bytecodes::_fast_iputfield: __ pop_i(r0); break;
|
|
2718 |
case Bytecodes::_fast_dputfield: __ pop_d(); break;
|
|
2719 |
case Bytecodes::_fast_fputfield: __ pop_f(); break;
|
|
2720 |
case Bytecodes::_fast_lputfield: __ pop_l(r0); break;
|
|
2721 |
}
|
|
2722 |
__ bind(L2);
|
|
2723 |
}
|
|
2724 |
}
|
|
2725 |
|
|
2726 |
void TemplateTable::fast_storefield(TosState state)
|
|
2727 |
{
|
|
2728 |
transition(state, vtos);
|
|
2729 |
|
|
2730 |
ByteSize base = ConstantPoolCache::base_offset();
|
|
2731 |
|
|
2732 |
jvmti_post_fast_field_mod();
|
|
2733 |
|
|
2734 |
// access constant pool cache
|
|
2735 |
__ get_cache_and_index_at_bcp(r2, r1, 1);
|
|
2736 |
|
|
2737 |
// test for volatile with r3
|
|
2738 |
__ ldrw(r3, Address(r2, in_bytes(base +
|
|
2739 |
ConstantPoolCacheEntry::flags_offset())));
|
|
2740 |
|
|
2741 |
// replace index with field offset from cache entry
|
|
2742 |
__ ldr(r1, Address(r2, in_bytes(base + ConstantPoolCacheEntry::f2_offset())));
|
|
2743 |
|
|
2744 |
{
|
|
2745 |
Label notVolatile;
|
|
2746 |
__ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
|
|
2747 |
__ membar(MacroAssembler::StoreStore);
|
|
2748 |
__ bind(notVolatile);
|
|
2749 |
}
|
|
2750 |
|
|
2751 |
Label notVolatile;
|
|
2752 |
|
|
2753 |
// Get object from stack
|
|
2754 |
pop_and_check_object(r2);
|
|
2755 |
|
|
2756 |
// field address
|
|
2757 |
const Address field(r2, r1);
|
|
2758 |
|
|
2759 |
// access field
|
|
2760 |
switch (bytecode()) {
|
|
2761 |
case Bytecodes::_fast_aputfield:
|
|
2762 |
do_oop_store(_masm, field, r0, _bs->kind(), false);
|
|
2763 |
break;
|
|
2764 |
case Bytecodes::_fast_lputfield:
|
|
2765 |
__ str(r0, field);
|
|
2766 |
break;
|
|
2767 |
case Bytecodes::_fast_iputfield:
|
|
2768 |
__ strw(r0, field);
|
|
2769 |
break;
|
|
2770 |
case Bytecodes::_fast_bputfield:
|
|
2771 |
__ strb(r0, field);
|
|
2772 |
break;
|
|
2773 |
case Bytecodes::_fast_sputfield:
|
|
2774 |
// fall through
|
|
2775 |
case Bytecodes::_fast_cputfield:
|
|
2776 |
__ strh(r0, field);
|
|
2777 |
break;
|
|
2778 |
case Bytecodes::_fast_fputfield:
|
|
2779 |
__ strs(v0, field);
|
|
2780 |
break;
|
|
2781 |
case Bytecodes::_fast_dputfield:
|
|
2782 |
__ strd(v0, field);
|
|
2783 |
break;
|
|
2784 |
default:
|
|
2785 |
ShouldNotReachHere();
|
|
2786 |
}
|
|
2787 |
|
|
2788 |
{
|
|
2789 |
Label notVolatile;
|
|
2790 |
__ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
|
|
2791 |
__ membar(MacroAssembler::StoreLoad);
|
|
2792 |
__ bind(notVolatile);
|
|
2793 |
}
|
|
2794 |
}
|
|
2795 |
|
|
2796 |
|
|
2797 |
void TemplateTable::fast_accessfield(TosState state)
|
|
2798 |
{
|
|
2799 |
transition(atos, state);
|
|
2800 |
// Do the JVMTI work here to avoid disturbing the register state below
|
|
2801 |
if (JvmtiExport::can_post_field_access()) {
|
|
2802 |
// Check to see if a field access watch has been set before we
|
|
2803 |
// take the time to call into the VM.
|
|
2804 |
Label L1;
|
|
2805 |
__ lea(rscratch1, ExternalAddress((address) JvmtiExport::get_field_access_count_addr()));
|
|
2806 |
__ ldrw(r2, Address(rscratch1));
|
|
2807 |
__ cbzw(r2, L1);
|
|
2808 |
// access constant pool cache entry
|
|
2809 |
__ get_cache_entry_pointer_at_bcp(c_rarg2, rscratch2, 1);
|
|
2810 |
__ verify_oop(r0);
|
|
2811 |
__ push_ptr(r0); // save object pointer before call_VM() clobbers it
|
|
2812 |
__ mov(c_rarg1, r0);
|
|
2813 |
// c_rarg1: object pointer copied above
|
|
2814 |
// c_rarg2: cache entry pointer
|
|
2815 |
__ call_VM(noreg,
|
|
2816 |
CAST_FROM_FN_PTR(address,
|
|
2817 |
InterpreterRuntime::post_field_access),
|
|
2818 |
c_rarg1, c_rarg2);
|
|
2819 |
__ pop_ptr(r0); // restore object pointer
|
|
2820 |
__ bind(L1);
|
|
2821 |
}
|
|
2822 |
|
|
2823 |
// access constant pool cache
|
|
2824 |
__ get_cache_and_index_at_bcp(r2, r1, 1);
|
|
2825 |
__ ldr(r1, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
|
|
2826 |
ConstantPoolCacheEntry::f2_offset())));
|
|
2827 |
__ ldrw(r3, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
|
|
2828 |
ConstantPoolCacheEntry::flags_offset())));
|
|
2829 |
|
|
2830 |
// r0: object
|
|
2831 |
__ verify_oop(r0);
|
|
2832 |
__ null_check(r0);
|
|
2833 |
const Address field(r0, r1);
|
|
2834 |
|
|
2835 |
// access field
|
|
2836 |
switch (bytecode()) {
|
|
2837 |
case Bytecodes::_fast_agetfield:
|
|
2838 |
__ load_heap_oop(r0, field);
|
|
2839 |
__ verify_oop(r0);
|
|
2840 |
break;
|
|
2841 |
case Bytecodes::_fast_lgetfield:
|
|
2842 |
__ ldr(r0, field);
|
|
2843 |
break;
|
|
2844 |
case Bytecodes::_fast_igetfield:
|
|
2845 |
__ ldrw(r0, field);
|
|
2846 |
break;
|
|
2847 |
case Bytecodes::_fast_bgetfield:
|
|
2848 |
__ load_signed_byte(r0, field);
|
|
2849 |
break;
|
|
2850 |
case Bytecodes::_fast_sgetfield:
|
|
2851 |
__ load_signed_short(r0, field);
|
|
2852 |
break;
|
|
2853 |
case Bytecodes::_fast_cgetfield:
|
|
2854 |
__ load_unsigned_short(r0, field);
|
|
2855 |
break;
|
|
2856 |
case Bytecodes::_fast_fgetfield:
|
|
2857 |
__ ldrs(v0, field);
|
|
2858 |
break;
|
|
2859 |
case Bytecodes::_fast_dgetfield:
|
|
2860 |
__ ldrd(v0, field);
|
|
2861 |
break;
|
|
2862 |
default:
|
|
2863 |
ShouldNotReachHere();
|
|
2864 |
}
|
|
2865 |
{
|
|
2866 |
Label notVolatile;
|
|
2867 |
__ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
|
|
2868 |
__ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);
|
|
2869 |
__ bind(notVolatile);
|
|
2870 |
}
|
|
2871 |
}
|
|
2872 |
|
|
2873 |
void TemplateTable::fast_xaccess(TosState state)
|
|
2874 |
{
|
|
2875 |
transition(vtos, state);
|
|
2876 |
|
|
2877 |
// get receiver
|
|
2878 |
__ ldr(r0, aaddress(0));
|
|
2879 |
// access constant pool cache
|
|
2880 |
__ get_cache_and_index_at_bcp(r2, r3, 2);
|
|
2881 |
__ ldr(r1, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
|
|
2882 |
ConstantPoolCacheEntry::f2_offset())));
|
|
2883 |
// make sure exception is reported in correct bcp range (getfield is
|
|
2884 |
// next instruction)
|
|
2885 |
__ increment(rbcp);
|
|
2886 |
__ null_check(r0);
|
|
2887 |
switch (state) {
|
|
2888 |
case itos:
|
|
2889 |
__ ldr(r0, Address(r0, r1, Address::lsl(0)));
|
|
2890 |
break;
|
|
2891 |
case atos:
|
|
2892 |
__ load_heap_oop(r0, Address(r0, r1, Address::lsl(0)));
|
|
2893 |
__ verify_oop(r0);
|
|
2894 |
break;
|
|
2895 |
case ftos:
|
|
2896 |
__ ldrs(v0, Address(r0, r1, Address::lsl(0)));
|
|
2897 |
break;
|
|
2898 |
default:
|
|
2899 |
ShouldNotReachHere();
|
|
2900 |
}
|
|
2901 |
|
|
2902 |
{
|
|
2903 |
Label notVolatile;
|
|
2904 |
__ ldrw(r3, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
|
|
2905 |
ConstantPoolCacheEntry::flags_offset())));
|
|
2906 |
__ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
|
|
2907 |
__ membar(MacroAssembler::LoadLoad);
|
|
2908 |
__ bind(notVolatile);
|
|
2909 |
}
|
|
2910 |
|
|
2911 |
__ decrement(rbcp);
|
|
2912 |
}
|
|
2913 |
|
|
2914 |
|
|
2915 |
|
|
2916 |
//-----------------------------------------------------------------------------
|
|
2917 |
// Calls
|
|
2918 |
|
|
2919 |
void TemplateTable::count_calls(Register method, Register temp)
|
|
2920 |
{
|
|
2921 |
__ call_Unimplemented();
|
|
2922 |
}
|
|
2923 |
|
|
2924 |
void TemplateTable::prepare_invoke(int byte_no,
|
|
2925 |
Register method, // linked method (or i-klass)
|
|
2926 |
Register index, // itable index, MethodType, etc.
|
|
2927 |
Register recv, // if caller wants to see it
|
|
2928 |
Register flags // if caller wants to test it
|
|
2929 |
) {
|
|
2930 |
// determine flags
|
|
2931 |
Bytecodes::Code code = bytecode();
|
|
2932 |
const bool is_invokeinterface = code == Bytecodes::_invokeinterface;
|
|
2933 |
const bool is_invokedynamic = code == Bytecodes::_invokedynamic;
|
|
2934 |
const bool is_invokehandle = code == Bytecodes::_invokehandle;
|
|
2935 |
const bool is_invokevirtual = code == Bytecodes::_invokevirtual;
|
|
2936 |
const bool is_invokespecial = code == Bytecodes::_invokespecial;
|
|
2937 |
const bool load_receiver = (recv != noreg);
|
|
2938 |
const bool save_flags = (flags != noreg);
|
|
2939 |
assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic), "");
|
|
2940 |
assert(save_flags == (is_invokeinterface || is_invokevirtual), "need flags for vfinal");
|
|
2941 |
assert(flags == noreg || flags == r3, "");
|
|
2942 |
assert(recv == noreg || recv == r2, "");
|
|
2943 |
|
|
2944 |
// setup registers & access constant pool cache
|
|
2945 |
if (recv == noreg) recv = r2;
|
|
2946 |
if (flags == noreg) flags = r3;
|
|
2947 |
assert_different_registers(method, index, recv, flags);
|
|
2948 |
|
|
2949 |
// save 'interpreter return address'
|
|
2950 |
__ save_bcp();
|
|
2951 |
|
|
2952 |
load_invoke_cp_cache_entry(byte_no, method, index, flags, is_invokevirtual, false, is_invokedynamic);
|
|
2953 |
|
|
2954 |
// maybe push appendix to arguments (just before return address)
|
|
2955 |
if (is_invokedynamic || is_invokehandle) {
|
|
2956 |
Label L_no_push;
|
|
2957 |
__ tbz(flags, ConstantPoolCacheEntry::has_appendix_shift, L_no_push);
|
|
2958 |
// Push the appendix as a trailing parameter.
|
|
2959 |
// This must be done before we get the receiver,
|
|
2960 |
// since the parameter_size includes it.
|
|
2961 |
__ push(r19);
|
|
2962 |
__ mov(r19, index);
|
|
2963 |
assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0");
|
|
2964 |
__ load_resolved_reference_at_index(index, r19);
|
|
2965 |
__ pop(r19);
|
|
2966 |
__ push(index); // push appendix (MethodType, CallSite, etc.)
|
|
2967 |
__ bind(L_no_push);
|
|
2968 |
}
|
|
2969 |
|
|
2970 |
// load receiver if needed (note: no return address pushed yet)
|
|
2971 |
if (load_receiver) {
|
|
2972 |
__ andw(recv, flags, ConstantPoolCacheEntry::parameter_size_mask);
|
|
2973 |
// FIXME -- is this actually correct? looks like it should be 2
|
|
2974 |
// const int no_return_pc_pushed_yet = -1; // argument slot correction before we push return address
|
|
2975 |
// const int receiver_is_at_end = -1; // back off one slot to get receiver
|
|
2976 |
// Address recv_addr = __ argument_address(recv, no_return_pc_pushed_yet + receiver_is_at_end);
|
|
2977 |
// __ movptr(recv, recv_addr);
|
|
2978 |
__ add(rscratch1, esp, recv, ext::uxtx, 3); // FIXME: uxtb here?
|
|
2979 |
__ ldr(recv, Address(rscratch1, -Interpreter::expr_offset_in_bytes(1)));
|
|
2980 |
__ verify_oop(recv);
|
|
2981 |
}
|
|
2982 |
|
|
2983 |
// compute return type
|
|
2984 |
// x86 uses a shift and mask or wings it with a shift plus assert
|
|
2985 |
// the mask is not needed. aarch64 just uses bitfield extract
|
|
2986 |
__ ubfxw(rscratch2, flags, ConstantPoolCacheEntry::tos_state_shift, ConstantPoolCacheEntry::tos_state_bits);
|
|
2987 |
// load return address
|
|
2988 |
{
|
|
2989 |
const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code);
|
|
2990 |
__ mov(rscratch1, table_addr);
|
|
2991 |
__ ldr(lr, Address(rscratch1, rscratch2, Address::lsl(3)));
|
|
2992 |
}
|
|
2993 |
}
|
|
2994 |
|
|
2995 |
|
|
2996 |
void TemplateTable::invokevirtual_helper(Register index,
|
|
2997 |
Register recv,
|
|
2998 |
Register flags)
|
|
2999 |
{
|
|
3000 |
// Uses temporary registers r0, r3
|
|
3001 |
assert_different_registers(index, recv, r0, r3);
|
|
3002 |
// Test for an invoke of a final method
|
|
3003 |
Label notFinal;
|
|
3004 |
__ tbz(flags, ConstantPoolCacheEntry::is_vfinal_shift, notFinal);
|
|
3005 |
|
|
3006 |
const Register method = index; // method must be rmethod
|
|
3007 |
assert(method == rmethod,
|
|
3008 |
"methodOop must be rmethod for interpreter calling convention");
|
|
3009 |
|
|
3010 |
// do the call - the index is actually the method to call
|
|
3011 |
// that is, f2 is a vtable index if !is_vfinal, else f2 is a Method*
|
|
3012 |
|
|
3013 |
// It's final, need a null check here!
|
|
3014 |
__ null_check(recv);
|
|
3015 |
|
|
3016 |
// profile this call
|
|
3017 |
__ profile_final_call(r0);
|
|
3018 |
__ profile_arguments_type(r0, method, r4, true);
|
|
3019 |
|
|
3020 |
__ jump_from_interpreted(method, r0);
|
|
3021 |
|
|
3022 |
__ bind(notFinal);
|
|
3023 |
|
|
3024 |
// get receiver klass
|
|
3025 |
__ null_check(recv, oopDesc::klass_offset_in_bytes());
|
|
3026 |
__ load_klass(r0, recv);
|
|
3027 |
|
|
3028 |
// profile this call
|
|
3029 |
__ profile_virtual_call(r0, rlocals, r3);
|
|
3030 |
|
|
3031 |
// get target methodOop & entry point
|
|
3032 |
__ lookup_virtual_method(r0, index, method);
|
|
3033 |
__ profile_arguments_type(r3, method, r4, true);
|
|
3034 |
// FIXME -- this looks completely redundant. is it?
|
|
3035 |
// __ ldr(r3, Address(method, Method::interpreter_entry_offset()));
|
|
3036 |
__ jump_from_interpreted(method, r3);
|
|
3037 |
}
|
|
3038 |
|
|
3039 |
void TemplateTable::invokevirtual(int byte_no)
|
|
3040 |
{
|
|
3041 |
transition(vtos, vtos);
|
|
3042 |
assert(byte_no == f2_byte, "use this argument");
|
|
3043 |
|
|
3044 |
prepare_invoke(byte_no, rmethod, noreg, r2, r3);
|
|
3045 |
|
|
3046 |
// rmethod: index (actually a Method*)
|
|
3047 |
// r2: receiver
|
|
3048 |
// r3: flags
|
|
3049 |
|
|
3050 |
invokevirtual_helper(rmethod, r2, r3);
|
|
3051 |
}
|
|
3052 |
|
|
3053 |
void TemplateTable::invokespecial(int byte_no)
|
|
3054 |
{
|
|
3055 |
transition(vtos, vtos);
|
|
3056 |
assert(byte_no == f1_byte, "use this argument");
|
|
3057 |
|
|
3058 |
prepare_invoke(byte_no, rmethod, noreg, // get f1 Method*
|
|
3059 |
r2); // get receiver also for null check
|
|
3060 |
__ verify_oop(r2);
|
|
3061 |
__ null_check(r2);
|
|
3062 |
// do the call
|
|
3063 |
__ profile_call(r0);
|
|
3064 |
__ profile_arguments_type(r0, rmethod, rbcp, false);
|
|
3065 |
__ jump_from_interpreted(rmethod, r0);
|
|
3066 |
}
|
|
3067 |
|
|
3068 |
void TemplateTable::invokestatic(int byte_no)
|
|
3069 |
{
|
|
3070 |
transition(vtos, vtos);
|
|
3071 |
assert(byte_no == f1_byte, "use this argument");
|
|
3072 |
|
|
3073 |
prepare_invoke(byte_no, rmethod); // get f1 Method*
|
|
3074 |
// do the call
|
|
3075 |
__ profile_call(r0);
|
|
3076 |
__ profile_arguments_type(r0, rmethod, r4, false);
|
|
3077 |
__ jump_from_interpreted(rmethod, r0);
|
|
3078 |
}
|
|
3079 |
|
|
3080 |
void TemplateTable::fast_invokevfinal(int byte_no)
|
|
3081 |
{
|
|
3082 |
__ call_Unimplemented();
|
|
3083 |
}
|
|
3084 |
|
|
3085 |
void TemplateTable::invokeinterface(int byte_no) {
|
|
3086 |
transition(vtos, vtos);
|
|
3087 |
assert(byte_no == f1_byte, "use this argument");
|
|
3088 |
|
|
3089 |
prepare_invoke(byte_no, r0, rmethod, // get f1 Klass*, f2 itable index
|
|
3090 |
r2, r3); // recv, flags
|
|
3091 |
|
|
3092 |
// r0: interface klass (from f1)
|
|
3093 |
// rmethod: itable index (from f2)
|
|
3094 |
// r2: receiver
|
|
3095 |
// r3: flags
|
|
3096 |
|
|
3097 |
// Special case of invokeinterface called for virtual method of
|
|
3098 |
// java.lang.Object. See cpCacheOop.cpp for details.
|
|
3099 |
// This code isn't produced by javac, but could be produced by
|
|
3100 |
// another compliant java compiler.
|
|
3101 |
Label notMethod;
|
|
3102 |
__ tbz(r3, ConstantPoolCacheEntry::is_forced_virtual_shift, notMethod);
|
|
3103 |
|
|
3104 |
invokevirtual_helper(rmethod, r2, r3);
|
|
3105 |
__ bind(notMethod);
|
|
3106 |
|
|
3107 |
// Get receiver klass into r3 - also a null check
|
|
3108 |
__ restore_locals();
|
|
3109 |
__ null_check(r2, oopDesc::klass_offset_in_bytes());
|
|
3110 |
__ load_klass(r3, r2);
|
|
3111 |
|
|
3112 |
// profile this call
|
|
3113 |
__ profile_virtual_call(r3, r13, r19);
|
|
3114 |
|
|
3115 |
Label no_such_interface, no_such_method;
|
|
3116 |
|
|
3117 |
__ lookup_interface_method(// inputs: rec. class, interface, itable index
|
|
3118 |
r3, r0, rmethod,
|
|
3119 |
// outputs: method, scan temp. reg
|
|
3120 |
rmethod, r13,
|
|
3121 |
no_such_interface);
|
|
3122 |
|
|
3123 |
// rmethod,: methodOop to call
|
|
3124 |
// r2: receiver
|
|
3125 |
// Check for abstract method error
|
|
3126 |
// Note: This should be done more efficiently via a throw_abstract_method_error
|
|
3127 |
// interpreter entry point and a conditional jump to it in case of a null
|
|
3128 |
// method.
|
|
3129 |
__ cbz(rmethod, no_such_method);
|
|
3130 |
|
|
3131 |
__ profile_arguments_type(r3, rmethod, r13, true);
|
|
3132 |
|
|
3133 |
// do the call
|
|
3134 |
// r2: receiver
|
|
3135 |
// rmethod,: methodOop
|
|
3136 |
__ jump_from_interpreted(rmethod, r3);
|
|
3137 |
__ should_not_reach_here();
|
|
3138 |
|
|
3139 |
// exception handling code follows...
|
|
3140 |
// note: must restore interpreter registers to canonical
|
|
3141 |
// state for exception handling to work correctly!
|
|
3142 |
|
|
3143 |
__ bind(no_such_method);
|
|
3144 |
// throw exception
|
|
3145 |
__ restore_bcp(); // bcp must be correct for exception handler (was destroyed)
|
|
3146 |
__ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
|
|
3147 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
|
|
3148 |
// the call_VM checks for exception, so we should never return here.
|
|
3149 |
__ should_not_reach_here();
|
|
3150 |
|
|
3151 |
__ bind(no_such_interface);
|
|
3152 |
// throw exception
|
|
3153 |
__ restore_bcp(); // bcp must be correct for exception handler (was destroyed)
|
|
3154 |
__ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
|
|
3155 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address,
|
|
3156 |
InterpreterRuntime::throw_IncompatibleClassChangeError));
|
|
3157 |
// the call_VM checks for exception, so we should never return here.
|
|
3158 |
__ should_not_reach_here();
|
|
3159 |
return;
|
|
3160 |
}
|
|
3161 |
|
|
3162 |
void TemplateTable::invokehandle(int byte_no) {
|
|
3163 |
transition(vtos, vtos);
|
|
3164 |
assert(byte_no == f1_byte, "use this argument");
|
|
3165 |
|
|
3166 |
prepare_invoke(byte_no, rmethod, r0, r2);
|
|
3167 |
__ verify_method_ptr(r2);
|
|
3168 |
__ verify_oop(r2);
|
|
3169 |
__ null_check(r2);
|
|
3170 |
|
|
3171 |
// FIXME: profile the LambdaForm also
|
|
3172 |
|
|
3173 |
// r13 is safe to use here as a scratch reg because it is about to
|
|
3174 |
// be clobbered by jump_from_interpreted().
|
|
3175 |
__ profile_final_call(r13);
|
|
3176 |
__ profile_arguments_type(r13, rmethod, r4, true);
|
|
3177 |
|
|
3178 |
__ jump_from_interpreted(rmethod, r0);
|
|
3179 |
}
|
|
3180 |
|
|
3181 |
void TemplateTable::invokedynamic(int byte_no) {
|
|
3182 |
transition(vtos, vtos);
|
|
3183 |
assert(byte_no == f1_byte, "use this argument");
|
|
3184 |
|
|
3185 |
prepare_invoke(byte_no, rmethod, r0);
|
|
3186 |
|
|
3187 |
// r0: CallSite object (from cpool->resolved_references[])
|
|
3188 |
// rmethod: MH.linkToCallSite method (from f2)
|
|
3189 |
|
|
3190 |
// Note: r0_callsite is already pushed by prepare_invoke
|
|
3191 |
|
|
3192 |
// %%% should make a type profile for any invokedynamic that takes a ref argument
|
|
3193 |
// profile this call
|
|
3194 |
__ profile_call(rbcp);
|
|
3195 |
__ profile_arguments_type(r3, rmethod, r13, false);
|
|
3196 |
|
|
3197 |
__ verify_oop(r0);
|
|
3198 |
|
|
3199 |
__ jump_from_interpreted(rmethod, r0);
|
|
3200 |
}
|
|
3201 |
|
|
3202 |
|
|
3203 |
//-----------------------------------------------------------------------------
|
|
3204 |
// Allocation
|
|
3205 |
|
|
3206 |
void TemplateTable::_new() {
|
|
3207 |
transition(vtos, atos);
|
|
3208 |
|
|
3209 |
__ get_unsigned_2_byte_index_at_bcp(r3, 1);
|
|
3210 |
Label slow_case;
|
|
3211 |
Label done;
|
|
3212 |
Label initialize_header;
|
|
3213 |
Label initialize_object; // including clearing the fields
|
|
3214 |
Label allocate_shared;
|
|
3215 |
|
|
3216 |
__ get_cpool_and_tags(r4, r0);
|
|
3217 |
// Make sure the class we're about to instantiate has been resolved.
|
|
3218 |
// This is done before loading InstanceKlass to be consistent with the order
|
|
3219 |
// how Constant Pool is updated (see ConstantPool::klass_at_put)
|
|
3220 |
const int tags_offset = Array<u1>::base_offset_in_bytes();
|
|
3221 |
__ lea(rscratch1, Address(r0, r3, Address::lsl(0)));
|
|
3222 |
__ ldrb(rscratch1, Address(rscratch1, tags_offset));
|
|
3223 |
__ cmp(rscratch1, JVM_CONSTANT_Class);
|
|
3224 |
__ br(Assembler::NE, slow_case);
|
|
3225 |
|
|
3226 |
// get InstanceKlass
|
|
3227 |
__ lea(r4, Address(r4, r3, Address::lsl(3)));
|
|
3228 |
__ ldr(r4, Address(r4, sizeof(ConstantPool)));
|
|
3229 |
|
|
3230 |
// make sure klass is initialized & doesn't have finalizer
|
|
3231 |
// make sure klass is fully initialized
|
|
3232 |
__ ldrb(rscratch1, Address(r4, InstanceKlass::init_state_offset()));
|
|
3233 |
__ cmp(rscratch1, InstanceKlass::fully_initialized);
|
|
3234 |
__ br(Assembler::NE, slow_case);
|
|
3235 |
|
|
3236 |
// get instance_size in InstanceKlass (scaled to a count of bytes)
|
|
3237 |
__ ldrw(r3,
|
|
3238 |
Address(r4,
|
|
3239 |
Klass::layout_helper_offset()));
|
|
3240 |
// test to see if it has a finalizer or is malformed in some way
|
|
3241 |
__ tbnz(r3, exact_log2(Klass::_lh_instance_slow_path_bit), slow_case);
|
|
3242 |
|
|
3243 |
// Allocate the instance
|
|
3244 |
// 1) Try to allocate in the TLAB
|
|
3245 |
// 2) if fail and the object is large allocate in the shared Eden
|
|
3246 |
// 3) if the above fails (or is not applicable), go to a slow case
|
|
3247 |
// (creates a new TLAB, etc.)
|
|
3248 |
|
|
3249 |
const bool allow_shared_alloc =
|
|
3250 |
Universe::heap()->supports_inline_contig_alloc();
|
|
3251 |
|
|
3252 |
if (UseTLAB) {
|
|
3253 |
__ tlab_allocate(r0, r3, 0, noreg, r1,
|
|
3254 |
allow_shared_alloc ? allocate_shared : slow_case);
|
|
3255 |
|
|
3256 |
if (ZeroTLAB) {
|
|
3257 |
// the fields have been already cleared
|
|
3258 |
__ b(initialize_header);
|
|
3259 |
} else {
|
|
3260 |
// initialize both the header and fields
|
|
3261 |
__ b(initialize_object);
|
|
3262 |
}
|
|
3263 |
}
|
|
3264 |
|
|
3265 |
// Allocation in the shared Eden, if allowed.
|
|
3266 |
//
|
|
3267 |
// r3: instance size in bytes
|
|
3268 |
if (allow_shared_alloc) {
|
|
3269 |
__ bind(allocate_shared);
|
|
3270 |
|
|
3271 |
__ eden_allocate(r0, r3, 0, r10, slow_case);
|
|
3272 |
__ incr_allocated_bytes(rthread, r3, 0, rscratch1);
|
|
3273 |
}
|
|
3274 |
|
|
3275 |
if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
|
|
3276 |
// The object is initialized before the header. If the object size is
|
|
3277 |
// zero, go directly to the header initialization.
|
|
3278 |
__ bind(initialize_object);
|
|
3279 |
__ sub(r3, r3, sizeof(oopDesc));
|
|
3280 |
__ cbz(r3, initialize_header);
|
|
3281 |
|
|
3282 |
// Initialize object fields
|
|
3283 |
{
|
|
3284 |
__ add(r2, r0, sizeof(oopDesc));
|
|
3285 |
Label loop;
|
|
3286 |
__ bind(loop);
|
|
3287 |
__ str(zr, Address(__ post(r2, BytesPerLong)));
|
|
3288 |
__ sub(r3, r3, BytesPerLong);
|
|
3289 |
__ cbnz(r3, loop);
|
|
3290 |
}
|
|
3291 |
|
|
3292 |
// initialize object header only.
|
|
3293 |
__ bind(initialize_header);
|
|
3294 |
if (UseBiasedLocking) {
|
|
3295 |
__ ldr(rscratch1, Address(r4, Klass::prototype_header_offset()));
|
|
3296 |
} else {
|
|
3297 |
__ mov(rscratch1, (intptr_t)markOopDesc::prototype());
|
|
3298 |
}
|
|
3299 |
__ str(rscratch1, Address(r0, oopDesc::mark_offset_in_bytes()));
|
|
3300 |
__ store_klass_gap(r0, zr); // zero klass gap for compressed oops
|
|
3301 |
__ store_klass(r0, r4); // store klass last
|
|
3302 |
|
|
3303 |
{
|
|
3304 |
SkipIfEqual skip(_masm, &DTraceAllocProbes, false);
|
|
3305 |
// Trigger dtrace event for fastpath
|
|
3306 |
__ push(atos); // save the return value
|
|
3307 |
__ call_VM_leaf(
|
|
3308 |
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), r0);
|
|
3309 |
__ pop(atos); // restore the return value
|
|
3310 |
|
|
3311 |
}
|
|
3312 |
__ b(done);
|
|
3313 |
}
|
|
3314 |
|
|
3315 |
// slow case
|
|
3316 |
__ bind(slow_case);
|
|
3317 |
__ get_constant_pool(c_rarg1);
|
|
3318 |
__ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1);
|
|
3319 |
call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), c_rarg1, c_rarg2);
|
|
3320 |
__ verify_oop(r0);
|
|
3321 |
|
|
3322 |
// continue
|
|
3323 |
__ bind(done);
|
|
3324 |
// Must prevent reordering of stores for object initialization with stores that publish the new object.
|
|
3325 |
__ membar(Assembler::StoreStore);
|
|
3326 |
}
|
|
3327 |
|
|
3328 |
void TemplateTable::newarray() {
|
|
3329 |
transition(itos, atos);
|
|
3330 |
__ load_unsigned_byte(c_rarg1, at_bcp(1));
|
|
3331 |
__ mov(c_rarg2, r0);
|
|
3332 |
call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray),
|
|
3333 |
c_rarg1, c_rarg2);
|
|
3334 |
// Must prevent reordering of stores for object initialization with stores that publish the new object.
|
|
3335 |
__ membar(Assembler::StoreStore);
|
|
3336 |
}
|
|
3337 |
|
|
3338 |
void TemplateTable::anewarray() {
|
|
3339 |
transition(itos, atos);
|
|
3340 |
__ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1);
|
|
3341 |
__ get_constant_pool(c_rarg1);
|
|
3342 |
__ mov(c_rarg3, r0);
|
|
3343 |
call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray),
|
|
3344 |
c_rarg1, c_rarg2, c_rarg3);
|
|
3345 |
// Must prevent reordering of stores for object initialization with stores that publish the new object.
|
|
3346 |
__ membar(Assembler::StoreStore);
|
|
3347 |
}
|
|
3348 |
|
|
3349 |
void TemplateTable::arraylength() {
|
|
3350 |
transition(atos, itos);
|
|
3351 |
__ null_check(r0, arrayOopDesc::length_offset_in_bytes());
|
|
3352 |
__ ldrw(r0, Address(r0, arrayOopDesc::length_offset_in_bytes()));
|
|
3353 |
}
|
|
3354 |
|
|
3355 |
void TemplateTable::checkcast()
|
|
3356 |
{
|
|
3357 |
transition(atos, atos);
|
|
3358 |
Label done, is_null, ok_is_subtype, quicked, resolved;
|
|
3359 |
__ cbz(r0, is_null);
|
|
3360 |
|
|
3361 |
// Get cpool & tags index
|
|
3362 |
__ get_cpool_and_tags(r2, r3); // r2=cpool, r3=tags array
|
|
3363 |
__ get_unsigned_2_byte_index_at_bcp(r19, 1); // r19=index
|
|
3364 |
// See if bytecode has already been quicked
|
|
3365 |
__ add(rscratch1, r3, Array<u1>::base_offset_in_bytes());
|
|
3366 |
__ ldrb(r1, Address(rscratch1, r19));
|
|
3367 |
__ cmp(r1, JVM_CONSTANT_Class);
|
|
3368 |
__ br(Assembler::EQ, quicked);
|
|
3369 |
|
|
3370 |
__ push(atos); // save receiver for result, and for GC
|
|
3371 |
call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
|
|
3372 |
// vm_result_2 has metadata result
|
|
3373 |
__ get_vm_result_2(r0, rthread);
|
|
3374 |
__ pop(r3); // restore receiver
|
|
3375 |
__ b(resolved);
|
|
3376 |
|
|
3377 |
// Get superklass in r0 and subklass in r3
|
|
3378 |
__ bind(quicked);
|
|
3379 |
__ mov(r3, r0); // Save object in r3; r0 needed for subtype check
|
|
3380 |
__ lea(r0, Address(r2, r19, Address::lsl(3)));
|
|
3381 |
__ ldr(r0, Address(r0, sizeof(ConstantPool)));
|
|
3382 |
|
|
3383 |
__ bind(resolved);
|
|
3384 |
__ load_klass(r19, r3);
|
|
3385 |
|
|
3386 |
// Generate subtype check. Blows r2, r5. Object in r3.
|
|
3387 |
// Superklass in r0. Subklass in r19.
|
|
3388 |
__ gen_subtype_check(r19, ok_is_subtype);
|
|
3389 |
|
|
3390 |
// Come here on failure
|
|
3391 |
__ push(r3);
|
|
3392 |
// object is at TOS
|
|
3393 |
__ b(Interpreter::_throw_ClassCastException_entry);
|
|
3394 |
|
|
3395 |
// Come here on success
|
|
3396 |
__ bind(ok_is_subtype);
|
|
3397 |
__ mov(r0, r3); // Restore object in r3
|
|
3398 |
|
|
3399 |
// Collect counts on whether this test sees NULLs a lot or not.
|
|
3400 |
if (ProfileInterpreter) {
|
|
3401 |
__ b(done);
|
|
3402 |
__ bind(is_null);
|
|
3403 |
__ profile_null_seen(r2);
|
|
3404 |
} else {
|
|
3405 |
__ bind(is_null); // same as 'done'
|
|
3406 |
}
|
|
3407 |
__ bind(done);
|
|
3408 |
}
|
|
3409 |
|
|
3410 |
void TemplateTable::instanceof() {
|
|
3411 |
transition(atos, itos);
|
|
3412 |
Label done, is_null, ok_is_subtype, quicked, resolved;
|
|
3413 |
__ cbz(r0, is_null);
|
|
3414 |
|
|
3415 |
// Get cpool & tags index
|
|
3416 |
__ get_cpool_and_tags(r2, r3); // r2=cpool, r3=tags array
|
|
3417 |
__ get_unsigned_2_byte_index_at_bcp(r19, 1); // r19=index
|
|
3418 |
// See if bytecode has already been quicked
|
|
3419 |
__ add(rscratch1, r3, Array<u1>::base_offset_in_bytes());
|
|
3420 |
__ ldrb(r1, Address(rscratch1, r19));
|
|
3421 |
__ cmp(r1, JVM_CONSTANT_Class);
|
|
3422 |
__ br(Assembler::EQ, quicked);
|
|
3423 |
|
|
3424 |
__ push(atos); // save receiver for result, and for GC
|
|
3425 |
call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
|
|
3426 |
// vm_result_2 has metadata result
|
|
3427 |
__ get_vm_result_2(r0, rthread);
|
|
3428 |
__ pop(r3); // restore receiver
|
|
3429 |
__ verify_oop(r3);
|
|
3430 |
__ load_klass(r3, r3);
|
|
3431 |
__ b(resolved);
|
|
3432 |
|
|
3433 |
// Get superklass in r0 and subklass in r3
|
|
3434 |
__ bind(quicked);
|
|
3435 |
__ load_klass(r3, r0);
|
|
3436 |
__ lea(r0, Address(r2, r19, Address::lsl(3)));
|
|
3437 |
__ ldr(r0, Address(r0, sizeof(ConstantPool)));
|
|
3438 |
|
|
3439 |
__ bind(resolved);
|
|
3440 |
|
|
3441 |
// Generate subtype check. Blows r2, r5
|
|
3442 |
// Superklass in r0. Subklass in r3.
|
|
3443 |
__ gen_subtype_check(r3, ok_is_subtype);
|
|
3444 |
|
|
3445 |
// Come here on failure
|
|
3446 |
__ mov(r0, 0);
|
|
3447 |
__ b(done);
|
|
3448 |
// Come here on success
|
|
3449 |
__ bind(ok_is_subtype);
|
|
3450 |
__ mov(r0, 1);
|
|
3451 |
|
|
3452 |
// Collect counts on whether this test sees NULLs a lot or not.
|
|
3453 |
if (ProfileInterpreter) {
|
|
3454 |
__ b(done);
|
|
3455 |
__ bind(is_null);
|
|
3456 |
__ profile_null_seen(r2);
|
|
3457 |
} else {
|
|
3458 |
__ bind(is_null); // same as 'done'
|
|
3459 |
}
|
|
3460 |
__ bind(done);
|
|
3461 |
// r0 = 0: obj == NULL or obj is not an instanceof the specified klass
|
|
3462 |
// r0 = 1: obj != NULL and obj is an instanceof the specified klass
|
|
3463 |
}
|
|
3464 |
|
|
3465 |
//-----------------------------------------------------------------------------
|
|
3466 |
// Breakpoints
|
|
3467 |
void TemplateTable::_breakpoint() {
|
|
3468 |
// Note: We get here even if we are single stepping..
|
|
3469 |
// jbug inists on setting breakpoints at every bytecode
|
|
3470 |
// even if we are in single step mode.
|
|
3471 |
|
|
3472 |
transition(vtos, vtos);
|
|
3473 |
|
|
3474 |
// get the unpatched byte code
|
|
3475 |
__ get_method(c_rarg1);
|
|
3476 |
__ call_VM(noreg,
|
|
3477 |
CAST_FROM_FN_PTR(address,
|
|
3478 |
InterpreterRuntime::get_original_bytecode_at),
|
|
3479 |
c_rarg1, rbcp);
|
|
3480 |
__ mov(r19, r0);
|
|
3481 |
|
|
3482 |
// post the breakpoint event
|
|
3483 |
__ call_VM(noreg,
|
|
3484 |
CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint),
|
|
3485 |
rmethod, rbcp);
|
|
3486 |
|
|
3487 |
// complete the execution of original bytecode
|
|
3488 |
__ mov(rscratch1, r19);
|
|
3489 |
__ dispatch_only_normal(vtos);
|
|
3490 |
}
|
|
3491 |
|
|
3492 |
//-----------------------------------------------------------------------------
|
|
3493 |
// Exceptions
|
|
3494 |
|
|
3495 |
void TemplateTable::athrow() {
|
|
3496 |
transition(atos, vtos);
|
|
3497 |
__ null_check(r0);
|
|
3498 |
__ b(Interpreter::throw_exception_entry());
|
|
3499 |
}
|
|
3500 |
|
|
3501 |
//-----------------------------------------------------------------------------
|
|
3502 |
// Synchronization
|
|
3503 |
//
|
|
3504 |
// Note: monitorenter & exit are symmetric routines; which is reflected
|
|
3505 |
// in the assembly code structure as well
|
|
3506 |
//
|
|
3507 |
// Stack layout:
|
|
3508 |
//
|
|
3509 |
// [expressions ] <--- esp = expression stack top
|
|
3510 |
// ..
|
|
3511 |
// [expressions ]
|
|
3512 |
// [monitor entry] <--- monitor block top = expression stack bot
|
|
3513 |
// ..
|
|
3514 |
// [monitor entry]
|
|
3515 |
// [frame data ] <--- monitor block bot
|
|
3516 |
// ...
|
|
3517 |
// [saved rbp ] <--- rbp
|
|
3518 |
void TemplateTable::monitorenter()
|
|
3519 |
{
|
|
3520 |
transition(atos, vtos);
|
|
3521 |
|
|
3522 |
// check for NULL object
|
|
3523 |
__ null_check(r0);
|
|
3524 |
|
|
3525 |
const Address monitor_block_top(
|
|
3526 |
rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
|
|
3527 |
const Address monitor_block_bot(
|
|
3528 |
rfp, frame::interpreter_frame_initial_sp_offset * wordSize);
|
|
3529 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
|
|
3530 |
|
|
3531 |
Label allocated;
|
|
3532 |
|
|
3533 |
// initialize entry pointer
|
|
3534 |
__ mov(c_rarg1, zr); // points to free slot or NULL
|
|
3535 |
|
|
3536 |
// find a free slot in the monitor block (result in c_rarg1)
|
|
3537 |
{
|
|
3538 |
Label entry, loop, exit;
|
|
3539 |
__ ldr(c_rarg3, monitor_block_top); // points to current entry,
|
|
3540 |
// starting with top-most entry
|
|
3541 |
__ lea(c_rarg2, monitor_block_bot); // points to word before bottom
|
|
3542 |
|
|
3543 |
__ b(entry);
|
|
3544 |
|
|
3545 |
__ bind(loop);
|
|
3546 |
// check if current entry is used
|
|
3547 |
// if not used then remember entry in c_rarg1
|
|
3548 |
__ ldr(rscratch1, Address(c_rarg3, BasicObjectLock::obj_offset_in_bytes()));
|
|
3549 |
__ cmp(zr, rscratch1);
|
|
3550 |
__ csel(c_rarg1, c_rarg3, c_rarg1, Assembler::EQ);
|
|
3551 |
// check if current entry is for same object
|
|
3552 |
__ cmp(r0, rscratch1);
|
|
3553 |
// if same object then stop searching
|
|
3554 |
__ br(Assembler::EQ, exit);
|
|
3555 |
// otherwise advance to next entry
|
|
3556 |
__ add(c_rarg3, c_rarg3, entry_size);
|
|
3557 |
__ bind(entry);
|
|
3558 |
// check if bottom reached
|
|
3559 |
__ cmp(c_rarg3, c_rarg2);
|
|
3560 |
// if not at bottom then check this entry
|
|
3561 |
__ br(Assembler::NE, loop);
|
|
3562 |
__ bind(exit);
|
|
3563 |
}
|
|
3564 |
|
|
3565 |
__ cbnz(c_rarg1, allocated); // check if a slot has been found and
|
|
3566 |
// if found, continue with that on
|
|
3567 |
|
|
3568 |
// allocate one if there's no free slot
|
|
3569 |
{
|
|
3570 |
Label entry, loop, no_adjust;
|
|
3571 |
// 1. compute new pointers // rsp: old expression stack top
|
|
3572 |
__ ldr(c_rarg1, monitor_block_bot); // c_rarg1: old expression stack bottom
|
|
3573 |
__ sub(esp, esp, entry_size); // move expression stack top
|
|
3574 |
__ sub(c_rarg1, c_rarg1, entry_size); // move expression stack bottom
|
|
3575 |
__ mov(c_rarg3, esp); // set start value for copy loop
|
|
3576 |
__ str(c_rarg1, monitor_block_bot); // set new monitor block bottom
|
|
3577 |
|
|
3578 |
__ cmp(sp, c_rarg3); // Check if we need to move sp
|
|
3579 |
__ br(Assembler::LO, no_adjust); // to allow more stack space
|
|
3580 |
// for our new esp
|
|
3581 |
__ sub(sp, sp, 2 * wordSize);
|
|
3582 |
__ bind(no_adjust);
|
|
3583 |
|
|
3584 |
__ b(entry);
|
|
3585 |
// 2. move expression stack contents
|
|
3586 |
__ bind(loop);
|
|
3587 |
__ ldr(c_rarg2, Address(c_rarg3, entry_size)); // load expression stack
|
|
3588 |
// word from old location
|
|
3589 |
__ str(c_rarg2, Address(c_rarg3, 0)); // and store it at new location
|
|
3590 |
__ add(c_rarg3, c_rarg3, wordSize); // advance to next word
|
|
3591 |
__ bind(entry);
|
|
3592 |
__ cmp(c_rarg3, c_rarg1); // check if bottom reached
|
|
3593 |
__ br(Assembler::NE, loop); // if not at bottom then
|
|
3594 |
// copy next word
|
|
3595 |
}
|
|
3596 |
|
|
3597 |
// call run-time routine
|
|
3598 |
// c_rarg1: points to monitor entry
|
|
3599 |
__ bind(allocated);
|
|
3600 |
|
|
3601 |
// Increment bcp to point to the next bytecode, so exception
|
|
3602 |
// handling for async. exceptions work correctly.
|
|
3603 |
// The object has already been poped from the stack, so the
|
|
3604 |
// expression stack looks correct.
|
|
3605 |
__ increment(rbcp);
|
|
3606 |
|
|
3607 |
// store object
|
|
3608 |
__ str(r0, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes()));
|
|
3609 |
__ lock_object(c_rarg1);
|
|
3610 |
|
|
3611 |
// check to make sure this monitor doesn't cause stack overflow after locking
|
|
3612 |
__ save_bcp(); // in case of exception
|
|
3613 |
__ generate_stack_overflow_check(0);
|
|
3614 |
|
|
3615 |
// The bcp has already been incremented. Just need to dispatch to
|
|
3616 |
// next instruction.
|
|
3617 |
__ dispatch_next(vtos);
|
|
3618 |
}
|
|
3619 |
|
|
3620 |
|
|
3621 |
void TemplateTable::monitorexit()
|
|
3622 |
{
|
|
3623 |
transition(atos, vtos);
|
|
3624 |
|
|
3625 |
// check for NULL object
|
|
3626 |
__ null_check(r0);
|
|
3627 |
|
|
3628 |
const Address monitor_block_top(
|
|
3629 |
rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
|
|
3630 |
const Address monitor_block_bot(
|
|
3631 |
rfp, frame::interpreter_frame_initial_sp_offset * wordSize);
|
|
3632 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
|
|
3633 |
|
|
3634 |
Label found;
|
|
3635 |
|
|
3636 |
// find matching slot
|
|
3637 |
{
|
|
3638 |
Label entry, loop;
|
|
3639 |
__ ldr(c_rarg1, monitor_block_top); // points to current entry,
|
|
3640 |
// starting with top-most entry
|
|
3641 |
__ lea(c_rarg2, monitor_block_bot); // points to word before bottom
|
|
3642 |
// of monitor block
|
|
3643 |
__ b(entry);
|
|
3644 |
|
|
3645 |
__ bind(loop);
|
|
3646 |
// check if current entry is for same object
|
|
3647 |
__ ldr(rscratch1, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes()));
|
|
3648 |
__ cmp(r0, rscratch1);
|
|
3649 |
// if same object then stop searching
|
|
3650 |
__ br(Assembler::EQ, found);
|
|
3651 |
// otherwise advance to next entry
|
|
3652 |
__ add(c_rarg1, c_rarg1, entry_size);
|
|
3653 |
__ bind(entry);
|
|
3654 |
// check if bottom reached
|
|
3655 |
__ cmp(c_rarg1, c_rarg2);
|
|
3656 |
// if not at bottom then check this entry
|
|
3657 |
__ br(Assembler::NE, loop);
|
|
3658 |
}
|
|
3659 |
|
|
3660 |
// error handling. Unlocking was not block-structured
|
|
3661 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address,
|
|
3662 |
InterpreterRuntime::throw_illegal_monitor_state_exception));
|
|
3663 |
__ should_not_reach_here();
|
|
3664 |
|
|
3665 |
// call run-time routine
|
|
3666 |
__ bind(found);
|
|
3667 |
__ push_ptr(r0); // make sure object is on stack (contract with oopMaps)
|
|
3668 |
__ unlock_object(c_rarg1);
|
|
3669 |
__ pop_ptr(r0); // discard object
|
|
3670 |
}
|
|
3671 |
|
|
3672 |
|
|
3673 |
// Wide instructions
|
|
3674 |
void TemplateTable::wide()
|
|
3675 |
{
|
|
3676 |
__ load_unsigned_byte(r19, at_bcp(1));
|
|
3677 |
__ mov(rscratch1, (address)Interpreter::_wentry_point);
|
|
3678 |
__ ldr(rscratch1, Address(rscratch1, r19, Address::uxtw(3)));
|
|
3679 |
__ br(rscratch1);
|
|
3680 |
}
|
|
3681 |
|
|
3682 |
|
|
3683 |
// Multi arrays
|
|
3684 |
void TemplateTable::multianewarray() {
|
|
3685 |
transition(vtos, atos);
|
|
3686 |
__ load_unsigned_byte(r0, at_bcp(3)); // get number of dimensions
|
|
3687 |
// last dim is on top of stack; we want address of first one:
|
|
3688 |
// first_addr = last_addr + (ndims - 1) * wordSize
|
|
3689 |
__ lea(c_rarg1, Address(esp, r0, Address::uxtw(3)));
|
|
3690 |
__ sub(c_rarg1, c_rarg1, wordSize);
|
|
3691 |
call_VM(r0,
|
|
3692 |
CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray),
|
|
3693 |
c_rarg1);
|
|
3694 |
__ load_unsigned_byte(r1, at_bcp(3));
|
|
3695 |
__ lea(esp, Address(esp, r1, Address::uxtw(3)));
|
|
3696 |
}
|
|
3697 |
#endif // !CC_INTERP
|