Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/cpu/arm/interp_masm_arm.cpp
40930 views
1
/*
2
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#include "precompiled.hpp"
26
#include "jvm.h"
27
#include "asm/macroAssembler.inline.hpp"
28
#include "gc/shared/barrierSet.hpp"
29
#include "gc/shared/cardTable.hpp"
30
#include "gc/shared/cardTableBarrierSet.inline.hpp"
31
#include "gc/shared/collectedHeap.hpp"
32
#include "interp_masm_arm.hpp"
33
#include "interpreter/interpreter.hpp"
34
#include "interpreter/interpreterRuntime.hpp"
35
#include "logging/log.hpp"
36
#include "oops/arrayOop.hpp"
37
#include "oops/markWord.hpp"
38
#include "oops/method.hpp"
39
#include "oops/methodData.hpp"
40
#include "prims/jvmtiExport.hpp"
41
#include "prims/jvmtiThreadState.hpp"
42
#include "runtime/basicLock.hpp"
43
#include "runtime/biasedLocking.hpp"
44
#include "runtime/frame.inline.hpp"
45
#include "runtime/safepointMechanism.hpp"
46
#include "runtime/sharedRuntime.hpp"
47
#include "utilities/powerOfTwo.hpp"
48
49
//--------------------------------------------------------------------
50
// Implementation of InterpreterMacroAssembler
51
52
53
54
55
InterpreterMacroAssembler::InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {
56
}
57
58
void InterpreterMacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
59
#ifdef ASSERT
60
// Ensure that last_sp is not filled.
61
{ Label L;
62
ldr(Rtemp, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize));
63
cbz(Rtemp, L);
64
stop("InterpreterMacroAssembler::call_VM_helper: last_sp != NULL");
65
bind(L);
66
}
67
#endif // ASSERT
68
69
// Rbcp must be saved/restored since it may change due to GC.
70
save_bcp();
71
72
73
// super call
74
MacroAssembler::call_VM_helper(oop_result, entry_point, number_of_arguments, check_exceptions);
75
76
77
// Restore interpreter specific registers.
78
restore_bcp();
79
restore_method();
80
}
81
82
void InterpreterMacroAssembler::jump_to_entry(address entry) {
83
assert(entry, "Entry must have been generated by now");
84
b(entry);
85
}
86
87
void InterpreterMacroAssembler::check_and_handle_popframe() {
88
if (can_pop_frame()) {
89
Label L;
90
const Register popframe_cond = R2_tmp;
91
92
// Initiate popframe handling only if it is not already being processed. If the flag
93
// has the popframe_processing bit set, it means that this code is called *during* popframe
94
// handling - we don't want to reenter.
95
96
ldr_s32(popframe_cond, Address(Rthread, JavaThread::popframe_condition_offset()));
97
tbz(popframe_cond, exact_log2(JavaThread::popframe_pending_bit), L);
98
tbnz(popframe_cond, exact_log2(JavaThread::popframe_processing_bit), L);
99
100
// Call Interpreter::remove_activation_preserving_args_entry() to get the
101
// address of the same-named entrypoint in the generated interpreter code.
102
call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
103
104
// Call indirectly to avoid generation ordering problem.
105
jump(R0);
106
107
bind(L);
108
}
109
}
110
111
112
// Blows R2, Rtemp. Sets TOS cached value.
113
void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
114
const Register thread_state = R2_tmp;
115
116
ldr(thread_state, Address(Rthread, JavaThread::jvmti_thread_state_offset()));
117
118
const Address tos_addr(thread_state, JvmtiThreadState::earlyret_tos_offset());
119
const Address oop_addr(thread_state, JvmtiThreadState::earlyret_oop_offset());
120
const Address val_addr(thread_state, JvmtiThreadState::earlyret_value_offset());
121
const Address val_addr_hi(thread_state, JvmtiThreadState::earlyret_value_offset()
122
+ in_ByteSize(wordSize));
123
124
Register zero = zero_register(Rtemp);
125
126
switch (state) {
127
case atos: ldr(R0_tos, oop_addr);
128
str(zero, oop_addr);
129
interp_verify_oop(R0_tos, state, __FILE__, __LINE__);
130
break;
131
132
case ltos: ldr(R1_tos_hi, val_addr_hi); // fall through
133
case btos: // fall through
134
case ztos: // fall through
135
case ctos: // fall through
136
case stos: // fall through
137
case itos: ldr_s32(R0_tos, val_addr); break;
138
#ifdef __SOFTFP__
139
case dtos: ldr(R1_tos_hi, val_addr_hi); // fall through
140
case ftos: ldr(R0_tos, val_addr); break;
141
#else
142
case ftos: ldr_float (S0_tos, val_addr); break;
143
case dtos: ldr_double(D0_tos, val_addr); break;
144
#endif // __SOFTFP__
145
case vtos: /* nothing to do */ break;
146
default : ShouldNotReachHere();
147
}
148
// Clean up tos value in the thread object
149
str(zero, val_addr);
150
str(zero, val_addr_hi);
151
152
mov(Rtemp, (int) ilgl);
153
str_32(Rtemp, tos_addr);
154
}
155
156
157
// Blows R2, Rtemp.
158
void InterpreterMacroAssembler::check_and_handle_earlyret() {
159
if (can_force_early_return()) {
160
Label L;
161
const Register thread_state = R2_tmp;
162
163
ldr(thread_state, Address(Rthread, JavaThread::jvmti_thread_state_offset()));
164
cbz(thread_state, L); // if (thread->jvmti_thread_state() == NULL) exit;
165
166
// Initiate earlyret handling only if it is not already being processed.
167
// If the flag has the earlyret_processing bit set, it means that this code
168
// is called *during* earlyret handling - we don't want to reenter.
169
170
ldr_s32(Rtemp, Address(thread_state, JvmtiThreadState::earlyret_state_offset()));
171
cmp(Rtemp, JvmtiThreadState::earlyret_pending);
172
b(L, ne);
173
174
// Call Interpreter::remove_activation_early_entry() to get the address of the
175
// same-named entrypoint in the generated interpreter code.
176
177
ldr_s32(R0, Address(thread_state, JvmtiThreadState::earlyret_tos_offset()));
178
call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), R0);
179
180
jump(R0);
181
182
bind(L);
183
}
184
}
185
186
187
// Sets reg. Blows Rtemp.
188
void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) {
189
assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode");
190
assert(reg != Rtemp, "should be different registers");
191
192
ldrb(Rtemp, Address(Rbcp, bcp_offset));
193
ldrb(reg, Address(Rbcp, bcp_offset+1));
194
orr(reg, reg, AsmOperand(Rtemp, lsl, BitsPerByte));
195
}
196
197
void InterpreterMacroAssembler::get_index_at_bcp(Register index, int bcp_offset, Register tmp_reg, size_t index_size) {
198
assert_different_registers(index, tmp_reg);
199
if (index_size == sizeof(u2)) {
200
// load bytes of index separately to avoid unaligned access
201
ldrb(index, Address(Rbcp, bcp_offset+1));
202
ldrb(tmp_reg, Address(Rbcp, bcp_offset));
203
orr(index, tmp_reg, AsmOperand(index, lsl, BitsPerByte));
204
} else if (index_size == sizeof(u4)) {
205
ldrb(index, Address(Rbcp, bcp_offset+3));
206
ldrb(tmp_reg, Address(Rbcp, bcp_offset+2));
207
orr(index, tmp_reg, AsmOperand(index, lsl, BitsPerByte));
208
ldrb(tmp_reg, Address(Rbcp, bcp_offset+1));
209
orr(index, tmp_reg, AsmOperand(index, lsl, BitsPerByte));
210
ldrb(tmp_reg, Address(Rbcp, bcp_offset));
211
orr(index, tmp_reg, AsmOperand(index, lsl, BitsPerByte));
212
// Check if the secondary index definition is still ~x, otherwise
213
// we have to change the following assembler code to calculate the
214
// plain index.
215
assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
216
mvn_32(index, index); // convert to plain index
217
} else if (index_size == sizeof(u1)) {
218
ldrb(index, Address(Rbcp, bcp_offset));
219
} else {
220
ShouldNotReachHere();
221
}
222
}
223
224
// Sets cache, index.
225
void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, Register index, int bcp_offset, size_t index_size) {
226
assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
227
assert_different_registers(cache, index);
228
229
get_index_at_bcp(index, bcp_offset, cache, index_size);
230
231
// load constant pool cache pointer
232
ldr(cache, Address(FP, frame::interpreter_frame_cache_offset * wordSize));
233
234
// convert from field index to ConstantPoolCacheEntry index
235
assert(sizeof(ConstantPoolCacheEntry) == 4*wordSize, "adjust code below");
236
logical_shift_left(index, index, 2);
237
}
238
239
// Sets cache, index, bytecode.
240
void InterpreterMacroAssembler::get_cache_and_index_and_bytecode_at_bcp(Register cache, Register index, Register bytecode, int byte_no, int bcp_offset, size_t index_size) {
241
get_cache_and_index_at_bcp(cache, index, bcp_offset, index_size);
242
// caution index and bytecode can be the same
243
add(bytecode, cache, AsmOperand(index, lsl, LogBytesPerWord));
244
ldrb(bytecode, Address(bytecode, (1 + byte_no) + in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset())));
245
TemplateTable::volatile_barrier(MacroAssembler::LoadLoad, noreg, true);
246
}
247
248
// Sets cache. Blows reg_tmp.
249
void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache, Register reg_tmp, int bcp_offset, size_t index_size) {
250
assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
251
assert_different_registers(cache, reg_tmp);
252
253
get_index_at_bcp(reg_tmp, bcp_offset, cache, index_size);
254
255
// load constant pool cache pointer
256
ldr(cache, Address(FP, frame::interpreter_frame_cache_offset * wordSize));
257
258
// skip past the header
259
add(cache, cache, in_bytes(ConstantPoolCache::base_offset()));
260
// convert from field index to ConstantPoolCacheEntry index
261
// and from word offset to byte offset
262
assert(sizeof(ConstantPoolCacheEntry) == 4*wordSize, "adjust code below");
263
add(cache, cache, AsmOperand(reg_tmp, lsl, 2 + LogBytesPerWord));
264
}
265
266
// Load object from cpool->resolved_references(index)
267
void InterpreterMacroAssembler::load_resolved_reference_at_index(
268
Register result, Register index) {
269
assert_different_registers(result, index);
270
get_constant_pool(result);
271
272
Register cache = result;
273
// load pointer for resolved_references[] objArray
274
ldr(cache, Address(result, ConstantPool::cache_offset_in_bytes()));
275
ldr(cache, Address(result, ConstantPoolCache::resolved_references_offset_in_bytes()));
276
resolve_oop_handle(cache);
277
// Add in the index
278
// convert from field index to resolved_references() index and from
279
// word index to byte offset. Since this is a java object, it can be compressed
280
logical_shift_left(index, index, LogBytesPerHeapOop);
281
add(index, index, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
282
load_heap_oop(result, Address(cache, index));
283
}
284
285
void InterpreterMacroAssembler::load_resolved_klass_at_offset(
286
Register Rcpool, Register Rindex, Register Rklass) {
287
add(Rtemp, Rcpool, AsmOperand(Rindex, lsl, LogBytesPerWord));
288
ldrh(Rtemp, Address(Rtemp, sizeof(ConstantPool))); // Rtemp = resolved_klass_index
289
ldr(Rklass, Address(Rcpool, ConstantPool::resolved_klasses_offset_in_bytes())); // Rklass = cpool->_resolved_klasses
290
add(Rklass, Rklass, AsmOperand(Rtemp, lsl, LogBytesPerWord));
291
ldr(Rklass, Address(Rklass, Array<Klass*>::base_offset_in_bytes()));
292
}
293
294
// Generate a subtype check: branch to not_subtype if sub_klass is
295
// not a subtype of super_klass.
296
// Profiling code for the subtype check failure (profile_typecheck_failed)
297
// should be explicitly generated by the caller in the not_subtype case.
298
// Blows Rtemp, tmp1, tmp2.
299
void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
300
Register Rsuper_klass,
301
Label &not_subtype,
302
Register tmp1,
303
Register tmp2) {
304
305
assert_different_registers(Rsub_klass, Rsuper_klass, tmp1, tmp2, Rtemp);
306
Label ok_is_subtype, loop, update_cache;
307
308
const Register super_check_offset = tmp1;
309
const Register cached_super = tmp2;
310
311
// Profile the not-null value's klass.
312
profile_typecheck(tmp1, Rsub_klass);
313
314
// Load the super-klass's check offset into
315
ldr_u32(super_check_offset, Address(Rsuper_klass, Klass::super_check_offset_offset()));
316
317
// Check for self
318
cmp(Rsub_klass, Rsuper_klass);
319
320
// Load from the sub-klass's super-class display list, or a 1-word cache of
321
// the secondary superclass list, or a failing value with a sentinel offset
322
// if the super-klass is an interface or exceptionally deep in the Java
323
// hierarchy and we have to scan the secondary superclass list the hard way.
324
// See if we get an immediate positive hit
325
ldr(cached_super, Address(Rsub_klass, super_check_offset));
326
327
cond_cmp(Rsuper_klass, cached_super, ne);
328
b(ok_is_subtype, eq);
329
330
// Check for immediate negative hit
331
cmp(super_check_offset, in_bytes(Klass::secondary_super_cache_offset()));
332
b(not_subtype, ne);
333
334
// Now do a linear scan of the secondary super-klass chain.
335
const Register supers_arr = tmp1;
336
const Register supers_cnt = tmp2;
337
const Register cur_super = Rtemp;
338
339
// Load objArrayOop of secondary supers.
340
ldr(supers_arr, Address(Rsub_klass, Klass::secondary_supers_offset()));
341
342
ldr_u32(supers_cnt, Address(supers_arr, Array<Klass*>::length_offset_in_bytes())); // Load the array length
343
cmp(supers_cnt, 0);
344
345
// Skip to the start of array elements and prefetch the first super-klass.
346
ldr(cur_super, Address(supers_arr, Array<Klass*>::base_offset_in_bytes(), pre_indexed), ne);
347
b(not_subtype, eq);
348
349
bind(loop);
350
351
352
cmp(cur_super, Rsuper_klass);
353
b(update_cache, eq);
354
355
subs(supers_cnt, supers_cnt, 1);
356
357
ldr(cur_super, Address(supers_arr, wordSize, pre_indexed), ne);
358
359
b(loop, ne);
360
361
b(not_subtype);
362
363
bind(update_cache);
364
// Must be equal but missed in cache. Update cache.
365
str(Rsuper_klass, Address(Rsub_klass, Klass::secondary_super_cache_offset()));
366
367
bind(ok_is_subtype);
368
}
369
370
371
//////////////////////////////////////////////////////////////////////////////////
372
373
374
// Java Expression Stack
375
376
void InterpreterMacroAssembler::pop_ptr(Register r) {
377
assert(r != Rstack_top, "unpredictable instruction");
378
ldr(r, Address(Rstack_top, wordSize, post_indexed));
379
}
380
381
void InterpreterMacroAssembler::pop_i(Register r) {
382
assert(r != Rstack_top, "unpredictable instruction");
383
ldr_s32(r, Address(Rstack_top, wordSize, post_indexed));
384
zap_high_non_significant_bits(r);
385
}
386
387
void InterpreterMacroAssembler::pop_l(Register lo, Register hi) {
388
assert_different_registers(lo, hi);
389
assert(lo < hi, "lo must be < hi");
390
pop(RegisterSet(lo) | RegisterSet(hi));
391
}
392
393
void InterpreterMacroAssembler::pop_f(FloatRegister fd) {
394
fpops(fd);
395
}
396
397
void InterpreterMacroAssembler::pop_d(FloatRegister fd) {
398
fpopd(fd);
399
}
400
401
402
// Transition vtos -> state. Blows R0, R1. Sets TOS cached value.
403
void InterpreterMacroAssembler::pop(TosState state) {
404
switch (state) {
405
case atos: pop_ptr(R0_tos); break;
406
case btos: // fall through
407
case ztos: // fall through
408
case ctos: // fall through
409
case stos: // fall through
410
case itos: pop_i(R0_tos); break;
411
case ltos: pop_l(R0_tos_lo, R1_tos_hi); break;
412
#ifdef __SOFTFP__
413
case ftos: pop_i(R0_tos); break;
414
case dtos: pop_l(R0_tos_lo, R1_tos_hi); break;
415
#else
416
case ftos: pop_f(S0_tos); break;
417
case dtos: pop_d(D0_tos); break;
418
#endif // __SOFTFP__
419
case vtos: /* nothing to do */ break;
420
default : ShouldNotReachHere();
421
}
422
interp_verify_oop(R0_tos, state, __FILE__, __LINE__);
423
}
424
425
void InterpreterMacroAssembler::push_ptr(Register r) {
426
assert(r != Rstack_top, "unpredictable instruction");
427
str(r, Address(Rstack_top, -wordSize, pre_indexed));
428
check_stack_top_on_expansion();
429
}
430
431
void InterpreterMacroAssembler::push_i(Register r) {
432
assert(r != Rstack_top, "unpredictable instruction");
433
str_32(r, Address(Rstack_top, -wordSize, pre_indexed));
434
check_stack_top_on_expansion();
435
}
436
437
void InterpreterMacroAssembler::push_l(Register lo, Register hi) {
438
assert_different_registers(lo, hi);
439
assert(lo < hi, "lo must be < hi");
440
push(RegisterSet(lo) | RegisterSet(hi));
441
}
442
443
void InterpreterMacroAssembler::push_f() {
444
fpushs(S0_tos);
445
}
446
447
void InterpreterMacroAssembler::push_d() {
448
fpushd(D0_tos);
449
}
450
451
// Transition state -> vtos. Blows Rtemp.
452
void InterpreterMacroAssembler::push(TosState state) {
453
interp_verify_oop(R0_tos, state, __FILE__, __LINE__);
454
switch (state) {
455
case atos: push_ptr(R0_tos); break;
456
case btos: // fall through
457
case ztos: // fall through
458
case ctos: // fall through
459
case stos: // fall through
460
case itos: push_i(R0_tos); break;
461
case ltos: push_l(R0_tos_lo, R1_tos_hi); break;
462
#ifdef __SOFTFP__
463
case ftos: push_i(R0_tos); break;
464
case dtos: push_l(R0_tos_lo, R1_tos_hi); break;
465
#else
466
case ftos: push_f(); break;
467
case dtos: push_d(); break;
468
#endif // __SOFTFP__
469
case vtos: /* nothing to do */ break;
470
default : ShouldNotReachHere();
471
}
472
}
473
474
475
476
// Converts return value in R0/R1 (interpreter calling conventions) to TOS cached value.
477
void InterpreterMacroAssembler::convert_retval_to_tos(TosState state) {
478
#if (!defined __SOFTFP__ && !defined __ABI_HARD__)
479
// According to interpreter calling conventions, result is returned in R0/R1,
480
// but templates expect ftos in S0, and dtos in D0.
481
if (state == ftos) {
482
fmsr(S0_tos, R0);
483
} else if (state == dtos) {
484
fmdrr(D0_tos, R0, R1);
485
}
486
#endif // !__SOFTFP__ && !__ABI_HARD__
487
}
488
489
// Converts TOS cached value to return value in R0/R1 (according to interpreter calling conventions).
490
void InterpreterMacroAssembler::convert_tos_to_retval(TosState state) {
491
#if (!defined __SOFTFP__ && !defined __ABI_HARD__)
492
// According to interpreter calling conventions, result is returned in R0/R1,
493
// so ftos (S0) and dtos (D0) are moved to R0/R1.
494
if (state == ftos) {
495
fmrs(R0, S0_tos);
496
} else if (state == dtos) {
497
fmrrd(R0, R1, D0_tos);
498
}
499
#endif // !__SOFTFP__ && !__ABI_HARD__
500
}
501
502
503
504
// Helpers for swap and dup
505
void InterpreterMacroAssembler::load_ptr(int n, Register val) {
506
ldr(val, Address(Rstack_top, Interpreter::expr_offset_in_bytes(n)));
507
}
508
509
void InterpreterMacroAssembler::store_ptr(int n, Register val) {
510
str(val, Address(Rstack_top, Interpreter::expr_offset_in_bytes(n)));
511
}
512
513
514
void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() {
515
516
// set sender sp
517
mov(Rsender_sp, SP);
518
519
// record last_sp
520
str(Rsender_sp, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize));
521
}
522
523
// Jump to from_interpreted entry of a call unless single stepping is possible
524
// in this thread in which case we must call the i2i entry
525
void InterpreterMacroAssembler::jump_from_interpreted(Register method) {
526
assert_different_registers(method, Rtemp);
527
528
prepare_to_jump_from_interpreted();
529
530
if (can_post_interpreter_events()) {
531
// JVMTI events, such as single-stepping, are implemented partly by avoiding running
532
// compiled code in threads for which the event is enabled. Check here for
533
// interp_only_mode if these events CAN be enabled.
534
535
ldr_s32(Rtemp, Address(Rthread, JavaThread::interp_only_mode_offset()));
536
cmp(Rtemp, 0);
537
ldr(PC, Address(method, Method::interpreter_entry_offset()), ne);
538
}
539
540
indirect_jump(Address(method, Method::from_interpreted_offset()), Rtemp);
541
}
542
543
544
void InterpreterMacroAssembler::restore_dispatch() {
545
mov_slow(RdispatchTable, (address)Interpreter::dispatch_table(vtos));
546
}
547
548
549
// The following two routines provide a hook so that an implementation
550
// can schedule the dispatch in two parts.
551
void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) {
552
// Nothing ARM-specific to be done here.
553
}
554
555
void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) {
556
dispatch_next(state, step);
557
}
558
559
void InterpreterMacroAssembler::dispatch_base(TosState state,
560
DispatchTableMode table_mode,
561
bool verifyoop, bool generate_poll) {
562
if (VerifyActivationFrameSize) {
563
Label L;
564
sub(Rtemp, FP, SP);
565
int min_frame_size = (frame::link_offset - frame::interpreter_frame_initial_sp_offset) * wordSize;
566
cmp(Rtemp, min_frame_size);
567
b(L, ge);
568
stop("broken stack frame");
569
bind(L);
570
}
571
572
if (verifyoop) {
573
interp_verify_oop(R0_tos, state, __FILE__, __LINE__);
574
}
575
576
Label safepoint;
577
address* const safepoint_table = Interpreter::safept_table(state);
578
address* const table = Interpreter::dispatch_table(state);
579
bool needs_thread_local_poll = generate_poll && table != safepoint_table;
580
581
if (needs_thread_local_poll) {
582
NOT_PRODUCT(block_comment("Thread-local Safepoint poll"));
583
ldr(Rtemp, Address(Rthread, JavaThread::polling_word_offset()));
584
tbnz(Rtemp, exact_log2(SafepointMechanism::poll_bit()), safepoint);
585
}
586
587
if((state == itos) || (state == btos) || (state == ztos) || (state == ctos) || (state == stos)) {
588
zap_high_non_significant_bits(R0_tos);
589
}
590
591
#ifdef ASSERT
592
Label L;
593
mov_slow(Rtemp, (address)Interpreter::dispatch_table(vtos));
594
cmp(Rtemp, RdispatchTable);
595
b(L, eq);
596
stop("invalid RdispatchTable");
597
bind(L);
598
#endif
599
600
if (table_mode == DispatchDefault) {
601
if (state == vtos) {
602
indirect_jump(Address::indexed_ptr(RdispatchTable, R3_bytecode), Rtemp);
603
} else {
604
// on 32-bit ARM this method is faster than the one above.
605
sub(Rtemp, RdispatchTable, (Interpreter::distance_from_dispatch_table(vtos) -
606
Interpreter::distance_from_dispatch_table(state)) * wordSize);
607
indirect_jump(Address::indexed_ptr(Rtemp, R3_bytecode), Rtemp);
608
}
609
} else {
610
assert(table_mode == DispatchNormal, "invalid dispatch table mode");
611
address table = (address) Interpreter::normal_table(state);
612
mov_slow(Rtemp, table);
613
indirect_jump(Address::indexed_ptr(Rtemp, R3_bytecode), Rtemp);
614
}
615
616
if (needs_thread_local_poll) {
617
bind(safepoint);
618
lea(Rtemp, ExternalAddress((address)safepoint_table));
619
indirect_jump(Address::indexed_ptr(Rtemp, R3_bytecode), Rtemp);
620
}
621
622
nop(); // to avoid filling CPU pipeline with invalid instructions
623
nop();
624
}
625
626
void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) {
627
dispatch_base(state, DispatchDefault, true, generate_poll);
628
}
629
630
631
void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
632
dispatch_base(state, DispatchNormal);
633
}
634
635
void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) {
636
dispatch_base(state, DispatchNormal, false);
637
}
638
639
void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) {
640
// load next bytecode and advance Rbcp
641
ldrb(R3_bytecode, Address(Rbcp, step, pre_indexed));
642
dispatch_base(state, DispatchDefault, true, generate_poll);
643
}
644
645
void InterpreterMacroAssembler::narrow(Register result) {
646
// mask integer result to narrower return type.
647
const Register Rtmp = R2;
648
649
// get method type
650
ldr(Rtmp, Address(Rmethod, Method::const_offset()));
651
ldrb(Rtmp, Address(Rtmp, ConstMethod::result_type_offset()));
652
653
Label notBool, notByte, notChar, done;
654
cmp(Rtmp, T_INT);
655
b(done, eq);
656
657
cmp(Rtmp, T_BOOLEAN);
658
b(notBool, ne);
659
and_32(result, result, 1);
660
b(done);
661
662
bind(notBool);
663
cmp(Rtmp, T_BYTE);
664
b(notByte, ne);
665
sign_extend(result, result, 8);
666
b(done);
667
668
bind(notByte);
669
cmp(Rtmp, T_CHAR);
670
b(notChar, ne);
671
zero_extend(result, result, 16);
672
b(done);
673
674
bind(notChar);
675
// cmp(Rtmp, T_SHORT);
676
// b(done, ne);
677
sign_extend(result, result, 16);
678
679
// Nothing to do
680
bind(done);
681
}
682
683
// remove activation
684
//
685
// Unlock the receiver if this is a synchronized method.
686
// Unlock any Java monitors from syncronized blocks.
687
// Remove the activation from the stack.
688
//
689
// If there are locked Java monitors
690
// If throw_monitor_exception
691
// throws IllegalMonitorStateException
692
// Else if install_monitor_exception
693
// installs IllegalMonitorStateException
694
// Else
695
// no error processing
696
void InterpreterMacroAssembler::remove_activation(TosState state, Register ret_addr,
697
bool throw_monitor_exception,
698
bool install_monitor_exception,
699
bool notify_jvmdi) {
700
Label unlock, unlocked, no_unlock;
701
702
// Note: Registers R0, R1, S0 and D0 (TOS cached value) may be in use for the result.
703
704
const Address do_not_unlock_if_synchronized(Rthread,
705
JavaThread::do_not_unlock_if_synchronized_offset());
706
707
const Register Rflag = R2;
708
const Register Raccess_flags = R3;
709
710
restore_method();
711
712
ldrb(Rflag, do_not_unlock_if_synchronized);
713
714
// get method access flags
715
ldr_u32(Raccess_flags, Address(Rmethod, Method::access_flags_offset()));
716
717
strb(zero_register(Rtemp), do_not_unlock_if_synchronized); // reset the flag
718
719
// check if method is synchronized
720
721
tbz(Raccess_flags, JVM_ACC_SYNCHRONIZED_BIT, unlocked);
722
723
// Don't unlock anything if the _do_not_unlock_if_synchronized flag is set.
724
cbnz(Rflag, no_unlock);
725
726
// unlock monitor
727
push(state); // save result
728
729
// BasicObjectLock will be first in list, since this is a synchronized method. However, need
730
// to check that the object has not been unlocked by an explicit monitorexit bytecode.
731
732
const Register Rmonitor = R0; // fixed in unlock_object()
733
const Register Robj = R2;
734
735
// address of first monitor
736
sub(Rmonitor, FP, - frame::interpreter_frame_monitor_block_bottom_offset * wordSize + (int)sizeof(BasicObjectLock));
737
738
ldr(Robj, Address(Rmonitor, BasicObjectLock::obj_offset_in_bytes()));
739
cbnz(Robj, unlock);
740
741
pop(state);
742
743
if (throw_monitor_exception) {
744
// Entry already unlocked, need to throw exception
745
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
746
should_not_reach_here();
747
} else {
748
// Monitor already unlocked during a stack unroll.
749
// If requested, install an illegal_monitor_state_exception.
750
// Continue with stack unrolling.
751
if (install_monitor_exception) {
752
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception));
753
}
754
b(unlocked);
755
}
756
757
758
// Exception case for the check that all monitors are unlocked.
759
const Register Rcur = R2;
760
Label restart_check_monitors_unlocked, exception_monitor_is_still_locked;
761
762
bind(exception_monitor_is_still_locked);
763
// Monitor entry is still locked, need to throw exception.
764
// Rcur: monitor entry.
765
766
if (throw_monitor_exception) {
767
// Throw exception
768
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
769
should_not_reach_here();
770
} else {
771
// Stack unrolling. Unlock object and install illegal_monitor_exception
772
// Unlock does not block, so don't have to worry about the frame
773
774
push(state);
775
mov(Rmonitor, Rcur);
776
unlock_object(Rmonitor);
777
778
if (install_monitor_exception) {
779
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception));
780
}
781
782
pop(state);
783
b(restart_check_monitors_unlocked);
784
}
785
786
bind(unlock);
787
unlock_object(Rmonitor);
788
pop(state);
789
790
// Check that for block-structured locking (i.e., that all locked objects has been unlocked)
791
bind(unlocked);
792
793
// Check that all monitors are unlocked
794
{
795
Label loop;
796
797
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
798
const Register Rbottom = R3;
799
const Register Rcur_obj = Rtemp;
800
801
bind(restart_check_monitors_unlocked);
802
803
ldr(Rcur, Address(FP, frame::interpreter_frame_monitor_block_top_offset * wordSize));
804
// points to current entry, starting with top-most entry
805
sub(Rbottom, FP, -frame::interpreter_frame_monitor_block_bottom_offset * wordSize);
806
// points to word before bottom of monitor block
807
808
cmp(Rcur, Rbottom); // check if there are no monitors
809
ldr(Rcur_obj, Address(Rcur, BasicObjectLock::obj_offset_in_bytes()), ne);
810
// prefetch monitor's object
811
b(no_unlock, eq);
812
813
bind(loop);
814
// check if current entry is used
815
cbnz(Rcur_obj, exception_monitor_is_still_locked);
816
817
add(Rcur, Rcur, entry_size); // otherwise advance to next entry
818
cmp(Rcur, Rbottom); // check if bottom reached
819
ldr(Rcur_obj, Address(Rcur, BasicObjectLock::obj_offset_in_bytes()), ne);
820
// prefetch monitor's object
821
b(loop, ne); // if not at bottom then check this entry
822
}
823
824
bind(no_unlock);
825
826
// jvmti support
827
if (notify_jvmdi) {
828
notify_method_exit(state, NotifyJVMTI); // preserve TOSCA
829
} else {
830
notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA
831
}
832
833
// remove activation
834
mov(Rtemp, FP);
835
ldmia(FP, RegisterSet(FP) | RegisterSet(LR));
836
ldr(SP, Address(Rtemp, frame::interpreter_frame_sender_sp_offset * wordSize));
837
838
if (ret_addr != LR) {
839
mov(ret_addr, LR);
840
}
841
}
842
843
844
// At certain points in the method invocation the monitor of
845
// synchronized methods hasn't been entered yet.
846
// To correctly handle exceptions at these points, we set the thread local
847
// variable _do_not_unlock_if_synchronized to true. The remove_activation will
848
// check this flag.
849
void InterpreterMacroAssembler::set_do_not_unlock_if_synchronized(bool flag, Register tmp) {
850
const Address do_not_unlock_if_synchronized(Rthread,
851
JavaThread::do_not_unlock_if_synchronized_offset());
852
if (flag) {
853
mov(tmp, 1);
854
strb(tmp, do_not_unlock_if_synchronized);
855
} else {
856
strb(zero_register(tmp), do_not_unlock_if_synchronized);
857
}
858
}
859
860
// Lock object
861
//
862
// Argument: R1 : Points to BasicObjectLock to be used for locking.
863
// Must be initialized with object to lock.
864
// Blows volatile registers R0-R3, Rtemp, LR. Calls VM.
865
void InterpreterMacroAssembler::lock_object(Register Rlock) {
866
assert(Rlock == R1, "the second argument");
867
868
if (UseHeavyMonitors) {
869
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), Rlock);
870
} else {
871
Label done;
872
873
const Register Robj = R2;
874
const Register Rmark = R3;
875
assert_different_registers(Robj, Rmark, Rlock, R0, Rtemp);
876
877
const int obj_offset = BasicObjectLock::obj_offset_in_bytes();
878
const int lock_offset = BasicObjectLock::lock_offset_in_bytes ();
879
const int mark_offset = lock_offset + BasicLock::displaced_header_offset_in_bytes();
880
881
Label already_locked, slow_case;
882
883
// Load object pointer
884
ldr(Robj, Address(Rlock, obj_offset));
885
886
if (DiagnoseSyncOnValueBasedClasses != 0) {
887
load_klass(R0, Robj);
888
ldr_u32(R0, Address(R0, Klass::access_flags_offset()));
889
tst(R0, JVM_ACC_IS_VALUE_BASED_CLASS);
890
b(slow_case, ne);
891
}
892
893
if (UseBiasedLocking) {
894
biased_locking_enter(Robj, Rmark/*scratched*/, R0, false, Rtemp, done, slow_case);
895
}
896
897
898
// On MP platforms the next load could return a 'stale' value if the memory location has been modified by another thread.
899
// That would be acceptable as ether CAS or slow case path is taken in that case.
900
// Exception to that is if the object is locked by the calling thread, then the recursive test will pass (guaranteed as
901
// loads are satisfied from a store queue if performed on the same processor).
902
903
assert(oopDesc::mark_offset_in_bytes() == 0, "must be");
904
ldr(Rmark, Address(Robj, oopDesc::mark_offset_in_bytes()));
905
906
// Test if object is already locked
907
tst(Rmark, markWord::unlocked_value);
908
b(already_locked, eq);
909
910
// Save old object->mark() into BasicLock's displaced header
911
str(Rmark, Address(Rlock, mark_offset));
912
913
cas_for_lock_acquire(Rmark, Rlock, Robj, Rtemp, slow_case);
914
915
#ifndef PRODUCT
916
if (PrintBiasedLockingStatistics) {
917
cond_atomic_inc32(al, BiasedLocking::fast_path_entry_count_addr());
918
}
919
#endif //!PRODUCT
920
921
b(done);
922
923
// If we got here that means the object is locked by ether calling thread or another thread.
924
bind(already_locked);
925
// Handling of locked objects: recursive locks and slow case.
926
927
// Fast check for recursive lock.
928
//
929
// Can apply the optimization only if this is a stack lock
930
// allocated in this thread. For efficiency, we can focus on
931
// recently allocated stack locks (instead of reading the stack
932
// base and checking whether 'mark' points inside the current
933
// thread stack):
934
// 1) (mark & 3) == 0
935
// 2) SP <= mark < SP + os::pagesize()
936
//
937
// Warning: SP + os::pagesize can overflow the stack base. We must
938
// neither apply the optimization for an inflated lock allocated
939
// just above the thread stack (this is why condition 1 matters)
940
// nor apply the optimization if the stack lock is inside the stack
941
// of another thread. The latter is avoided even in case of overflow
942
// because we have guard pages at the end of all stacks. Hence, if
943
// we go over the stack base and hit the stack of another thread,
944
// this should not be in a writeable area that could contain a
945
// stack lock allocated by that thread. As a consequence, a stack
946
// lock less than page size away from SP is guaranteed to be
947
// owned by the current thread.
948
//
949
// Note: assuming SP is aligned, we can check the low bits of
950
// (mark-SP) instead of the low bits of mark. In that case,
951
// assuming page size is a power of 2, we can merge the two
952
// conditions into a single test:
953
// => ((mark - SP) & (3 - os::pagesize())) == 0
954
955
// (3 - os::pagesize()) cannot be encoded as an ARM immediate operand.
956
// Check independently the low bits and the distance to SP.
957
// -1- test low 2 bits
958
movs(R0, AsmOperand(Rmark, lsl, 30));
959
// -2- test (mark - SP) if the low two bits are 0
960
sub(R0, Rmark, SP, eq);
961
movs(R0, AsmOperand(R0, lsr, exact_log2(os::vm_page_size())), eq);
962
// If still 'eq' then recursive locking OK: store 0 into lock record
963
str(R0, Address(Rlock, mark_offset), eq);
964
965
966
#ifndef PRODUCT
967
if (PrintBiasedLockingStatistics) {
968
cond_atomic_inc32(eq, BiasedLocking::fast_path_entry_count_addr());
969
}
970
#endif // !PRODUCT
971
972
b(done, eq);
973
974
bind(slow_case);
975
976
// Call the runtime routine for slow case
977
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), Rlock);
978
979
bind(done);
980
}
981
}
982
983
984
// Unlocks an object. Used in monitorexit bytecode and remove_activation.
985
//
986
// Argument: R0: Points to BasicObjectLock structure for lock
987
// Throw an IllegalMonitorException if object is not locked by current thread
988
// Blows volatile registers R0-R3, Rtemp, LR. Calls VM.
989
void InterpreterMacroAssembler::unlock_object(Register Rlock) {
990
assert(Rlock == R0, "the first argument");
991
992
if (UseHeavyMonitors) {
993
call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), Rlock);
994
} else {
995
Label done, slow_case;
996
997
const Register Robj = R2;
998
const Register Rmark = R3;
999
assert_different_registers(Robj, Rmark, Rlock, Rtemp);
1000
1001
const int obj_offset = BasicObjectLock::obj_offset_in_bytes();
1002
const int lock_offset = BasicObjectLock::lock_offset_in_bytes ();
1003
const int mark_offset = lock_offset + BasicLock::displaced_header_offset_in_bytes();
1004
1005
const Register Rzero = zero_register(Rtemp);
1006
1007
// Load oop into Robj
1008
ldr(Robj, Address(Rlock, obj_offset));
1009
1010
// Free entry
1011
str(Rzero, Address(Rlock, obj_offset));
1012
1013
if (UseBiasedLocking) {
1014
biased_locking_exit(Robj, Rmark, done);
1015
}
1016
1017
// Load the old header from BasicLock structure
1018
ldr(Rmark, Address(Rlock, mark_offset));
1019
1020
// Test for recursion (zero mark in BasicLock)
1021
cbz(Rmark, done);
1022
1023
bool allow_fallthrough_on_failure = true;
1024
1025
cas_for_lock_release(Rlock, Rmark, Robj, Rtemp, slow_case, allow_fallthrough_on_failure);
1026
1027
b(done, eq);
1028
1029
bind(slow_case);
1030
1031
// Call the runtime routine for slow case.
1032
str(Robj, Address(Rlock, obj_offset)); // restore obj
1033
call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), Rlock);
1034
1035
bind(done);
1036
}
1037
}
1038
1039
1040
// Test ImethodDataPtr. If it is null, continue at the specified label
1041
void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, Label& zero_continue) {
1042
assert(ProfileInterpreter, "must be profiling interpreter");
1043
ldr(mdp, Address(FP, frame::interpreter_frame_mdp_offset * wordSize));
1044
cbz(mdp, zero_continue);
1045
}
1046
1047
1048
// Set the method data pointer for the current bcp.
1049
// Blows volatile registers R0-R3, Rtemp, LR.
1050
void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
1051
assert(ProfileInterpreter, "must be profiling interpreter");
1052
Label set_mdp;
1053
1054
// Test MDO to avoid the call if it is NULL.
1055
ldr(Rtemp, Address(Rmethod, Method::method_data_offset()));
1056
cbz(Rtemp, set_mdp);
1057
1058
mov(R0, Rmethod);
1059
mov(R1, Rbcp);
1060
call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), R0, R1);
1061
// R0/W0: mdi
1062
1063
// mdo is guaranteed to be non-zero here, we checked for it before the call.
1064
ldr(Rtemp, Address(Rmethod, Method::method_data_offset()));
1065
add(Rtemp, Rtemp, in_bytes(MethodData::data_offset()));
1066
add_ptr_scaled_int32(Rtemp, Rtemp, R0, 0);
1067
1068
bind(set_mdp);
1069
str(Rtemp, Address(FP, frame::interpreter_frame_mdp_offset * wordSize));
1070
}
1071
1072
1073
void InterpreterMacroAssembler::verify_method_data_pointer() {
1074
assert(ProfileInterpreter, "must be profiling interpreter");
1075
#ifdef ASSERT
1076
Label verify_continue;
1077
save_caller_save_registers();
1078
1079
const Register Rmdp = R2;
1080
test_method_data_pointer(Rmdp, verify_continue); // If mdp is zero, continue
1081
1082
// If the mdp is valid, it will point to a DataLayout header which is
1083
// consistent with the bcp. The converse is highly probable also.
1084
1085
ldrh(R3, Address(Rmdp, DataLayout::bci_offset()));
1086
ldr(Rtemp, Address(Rmethod, Method::const_offset()));
1087
add(R3, R3, Rtemp);
1088
add(R3, R3, in_bytes(ConstMethod::codes_offset()));
1089
cmp(R3, Rbcp);
1090
b(verify_continue, eq);
1091
1092
mov(R0, Rmethod);
1093
mov(R1, Rbcp);
1094
call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp), R0, R1, Rmdp);
1095
1096
bind(verify_continue);
1097
restore_caller_save_registers();
1098
#endif // ASSERT
1099
}
1100
1101
1102
void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, int offset, Register value) {
1103
assert(ProfileInterpreter, "must be profiling interpreter");
1104
assert_different_registers(mdp_in, value);
1105
str(value, Address(mdp_in, offset));
1106
}
1107
1108
1109
// Increments mdp data. Sets bumped_count register to adjusted counter.
1110
void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
1111
int offset,
1112
Register bumped_count,
1113
bool decrement) {
1114
assert(ProfileInterpreter, "must be profiling interpreter");
1115
1116
// Counter address
1117
Address data(mdp_in, offset);
1118
assert_different_registers(mdp_in, bumped_count);
1119
1120
increment_mdp_data_at(data, bumped_count, decrement);
1121
}
1122
1123
void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in, int flag_byte_constant) {
1124
assert_different_registers(mdp_in, Rtemp);
1125
assert(ProfileInterpreter, "must be profiling interpreter");
1126
assert((0 < flag_byte_constant) && (flag_byte_constant < (1 << BitsPerByte)), "flag mask is out of range");
1127
1128
// Set the flag
1129
ldrb(Rtemp, Address(mdp_in, in_bytes(DataLayout::flags_offset())));
1130
orr(Rtemp, Rtemp, (unsigned)flag_byte_constant);
1131
strb(Rtemp, Address(mdp_in, in_bytes(DataLayout::flags_offset())));
1132
}
1133
1134
1135
// Increments mdp data. Sets bumped_count register to adjusted counter.
1136
void InterpreterMacroAssembler::increment_mdp_data_at(Address data,
1137
Register bumped_count,
1138
bool decrement) {
1139
assert(ProfileInterpreter, "must be profiling interpreter");
1140
1141
ldr(bumped_count, data);
1142
if (decrement) {
1143
// Decrement the register. Set condition codes.
1144
subs(bumped_count, bumped_count, DataLayout::counter_increment);
1145
// Avoid overflow.
1146
add(bumped_count, bumped_count, DataLayout::counter_increment, pl);
1147
} else {
1148
// Increment the register. Set condition codes.
1149
adds(bumped_count, bumped_count, DataLayout::counter_increment);
1150
// Avoid overflow.
1151
sub(bumped_count, bumped_count, DataLayout::counter_increment, mi);
1152
}
1153
str(bumped_count, data);
1154
}
1155
1156
1157
void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in,
1158
int offset,
1159
Register value,
1160
Register test_value_out,
1161
Label& not_equal_continue) {
1162
assert(ProfileInterpreter, "must be profiling interpreter");
1163
assert_different_registers(mdp_in, test_value_out, value);
1164
1165
ldr(test_value_out, Address(mdp_in, offset));
1166
cmp(test_value_out, value);
1167
1168
b(not_equal_continue, ne);
1169
}
1170
1171
1172
void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, int offset_of_disp, Register reg_temp) {
1173
assert(ProfileInterpreter, "must be profiling interpreter");
1174
assert_different_registers(mdp_in, reg_temp);
1175
1176
ldr(reg_temp, Address(mdp_in, offset_of_disp));
1177
add(mdp_in, mdp_in, reg_temp);
1178
str(mdp_in, Address(FP, frame::interpreter_frame_mdp_offset * wordSize));
1179
}
1180
1181
1182
void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, Register reg_offset, Register reg_tmp) {
1183
assert(ProfileInterpreter, "must be profiling interpreter");
1184
assert_different_registers(mdp_in, reg_offset, reg_tmp);
1185
1186
ldr(reg_tmp, Address(mdp_in, reg_offset));
1187
add(mdp_in, mdp_in, reg_tmp);
1188
str(mdp_in, Address(FP, frame::interpreter_frame_mdp_offset * wordSize));
1189
}
1190
1191
1192
void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, int constant) {
1193
assert(ProfileInterpreter, "must be profiling interpreter");
1194
add(mdp_in, mdp_in, constant);
1195
str(mdp_in, Address(FP, frame::interpreter_frame_mdp_offset * wordSize));
1196
}
1197
1198
1199
// Blows volatile registers R0-R3, Rtemp, LR).
1200
void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
1201
assert(ProfileInterpreter, "must be profiling interpreter");
1202
assert_different_registers(return_bci, R0, R1, R2, R3, Rtemp);
1203
1204
mov(R1, return_bci);
1205
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), R1);
1206
}
1207
1208
1209
// Sets mdp, bumped_count registers, blows Rtemp.
1210
void InterpreterMacroAssembler::profile_taken_branch(Register mdp, Register bumped_count) {
1211
assert_different_registers(mdp, bumped_count);
1212
1213
if (ProfileInterpreter) {
1214
Label profile_continue;
1215
1216
// If no method data exists, go to profile_continue.
1217
// Otherwise, assign to mdp
1218
test_method_data_pointer(mdp, profile_continue);
1219
1220
// We are taking a branch. Increment the taken count.
1221
increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()), bumped_count);
1222
1223
// The method data pointer needs to be updated to reflect the new target.
1224
update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()), Rtemp);
1225
1226
bind (profile_continue);
1227
}
1228
}
1229
1230
1231
// Sets mdp, blows Rtemp.
1232
void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
1233
assert_different_registers(mdp, Rtemp);
1234
1235
if (ProfileInterpreter) {
1236
Label profile_continue;
1237
1238
// If no method data exists, go to profile_continue.
1239
test_method_data_pointer(mdp, profile_continue);
1240
1241
// We are taking a branch. Increment the not taken count.
1242
increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()), Rtemp);
1243
1244
// The method data pointer needs to be updated to correspond to the next bytecode
1245
update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
1246
1247
bind (profile_continue);
1248
}
1249
}
1250
1251
1252
// Sets mdp, blows Rtemp.
1253
void InterpreterMacroAssembler::profile_call(Register mdp) {
1254
assert_different_registers(mdp, Rtemp);
1255
1256
if (ProfileInterpreter) {
1257
Label profile_continue;
1258
1259
// If no method data exists, go to profile_continue.
1260
test_method_data_pointer(mdp, profile_continue);
1261
1262
// We are making a call. Increment the count.
1263
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()), Rtemp);
1264
1265
// The method data pointer needs to be updated to reflect the new target.
1266
update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1267
1268
bind (profile_continue);
1269
}
1270
}
1271
1272
1273
// Sets mdp, blows Rtemp.
1274
void InterpreterMacroAssembler::profile_final_call(Register mdp) {
1275
if (ProfileInterpreter) {
1276
Label profile_continue;
1277
1278
// If no method data exists, go to profile_continue.
1279
test_method_data_pointer(mdp, profile_continue);
1280
1281
// We are making a call. Increment the count.
1282
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()), Rtemp);
1283
1284
// The method data pointer needs to be updated to reflect the new target.
1285
update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));
1286
1287
bind (profile_continue);
1288
}
1289
}
1290
1291
1292
// Sets mdp, blows Rtemp.
1293
void InterpreterMacroAssembler::profile_virtual_call(Register mdp, Register receiver, bool receiver_can_be_null) {
1294
assert_different_registers(mdp, receiver, Rtemp);
1295
1296
if (ProfileInterpreter) {
1297
Label profile_continue;
1298
1299
// If no method data exists, go to profile_continue.
1300
test_method_data_pointer(mdp, profile_continue);
1301
1302
Label skip_receiver_profile;
1303
if (receiver_can_be_null) {
1304
Label not_null;
1305
cbnz(receiver, not_null);
1306
// We are making a call. Increment the count for null receiver.
1307
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()), Rtemp);
1308
b(skip_receiver_profile);
1309
bind(not_null);
1310
}
1311
1312
// Record the receiver type.
1313
record_klass_in_profile(receiver, mdp, Rtemp, true);
1314
bind(skip_receiver_profile);
1315
1316
// The method data pointer needs to be updated to reflect the new target.
1317
update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));
1318
bind(profile_continue);
1319
}
1320
}
1321
1322
1323
void InterpreterMacroAssembler::record_klass_in_profile_helper(
1324
Register receiver, Register mdp,
1325
Register reg_tmp,
1326
int start_row, Label& done, bool is_virtual_call) {
1327
if (TypeProfileWidth == 0)
1328
return;
1329
1330
assert_different_registers(receiver, mdp, reg_tmp);
1331
1332
int last_row = VirtualCallData::row_limit() - 1;
1333
assert(start_row <= last_row, "must be work left to do");
1334
// Test this row for both the receiver and for null.
1335
// Take any of three different outcomes:
1336
// 1. found receiver => increment count and goto done
1337
// 2. found null => keep looking for case 1, maybe allocate this cell
1338
// 3. found something else => keep looking for cases 1 and 2
1339
// Case 3 is handled by a recursive call.
1340
for (int row = start_row; row <= last_row; row++) {
1341
Label next_test;
1342
1343
// See if the receiver is receiver[n].
1344
int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row));
1345
1346
test_mdp_data_at(mdp, recvr_offset, receiver, reg_tmp, next_test);
1347
1348
// The receiver is receiver[n]. Increment count[n].
1349
int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row));
1350
increment_mdp_data_at(mdp, count_offset, reg_tmp);
1351
b(done);
1352
1353
bind(next_test);
1354
// reg_tmp now contains the receiver from the CallData.
1355
1356
if (row == start_row) {
1357
Label found_null;
1358
// Failed the equality check on receiver[n]... Test for null.
1359
if (start_row == last_row) {
1360
// The only thing left to do is handle the null case.
1361
if (is_virtual_call) {
1362
cbz(reg_tmp, found_null);
1363
// Receiver did not match any saved receiver and there is no empty row for it.
1364
// Increment total counter to indicate polymorphic case.
1365
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()), reg_tmp);
1366
b(done);
1367
bind(found_null);
1368
} else {
1369
cbnz(reg_tmp, done);
1370
}
1371
break;
1372
}
1373
// Since null is rare, make it be the branch-taken case.
1374
cbz(reg_tmp, found_null);
1375
1376
// Put all the "Case 3" tests here.
1377
record_klass_in_profile_helper(receiver, mdp, reg_tmp, start_row + 1, done, is_virtual_call);
1378
1379
// Found a null. Keep searching for a matching receiver,
1380
// but remember that this is an empty (unused) slot.
1381
bind(found_null);
1382
}
1383
}
1384
1385
// In the fall-through case, we found no matching receiver, but we
1386
// observed the receiver[start_row] is NULL.
1387
1388
// Fill in the receiver field and increment the count.
1389
int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
1390
set_mdp_data_at(mdp, recvr_offset, receiver);
1391
int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
1392
mov(reg_tmp, DataLayout::counter_increment);
1393
set_mdp_data_at(mdp, count_offset, reg_tmp);
1394
if (start_row > 0) {
1395
b(done);
1396
}
1397
}
1398
1399
void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
1400
Register mdp,
1401
Register reg_tmp,
1402
bool is_virtual_call) {
1403
assert(ProfileInterpreter, "must be profiling");
1404
assert_different_registers(receiver, mdp, reg_tmp);
1405
1406
Label done;
1407
1408
record_klass_in_profile_helper(receiver, mdp, reg_tmp, 0, done, is_virtual_call);
1409
1410
bind (done);
1411
}
1412
1413
// Sets mdp, blows volatile registers R0-R3, Rtemp, LR).
1414
void InterpreterMacroAssembler::profile_ret(Register mdp, Register return_bci) {
1415
assert_different_registers(mdp, return_bci, Rtemp, R0, R1, R2, R3);
1416
1417
if (ProfileInterpreter) {
1418
Label profile_continue;
1419
uint row;
1420
1421
// If no method data exists, go to profile_continue.
1422
test_method_data_pointer(mdp, profile_continue);
1423
1424
// Update the total ret count.
1425
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()), Rtemp);
1426
1427
for (row = 0; row < RetData::row_limit(); row++) {
1428
Label next_test;
1429
1430
// See if return_bci is equal to bci[n]:
1431
test_mdp_data_at(mdp, in_bytes(RetData::bci_offset(row)), return_bci,
1432
Rtemp, next_test);
1433
1434
// return_bci is equal to bci[n]. Increment the count.
1435
increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row)), Rtemp);
1436
1437
// The method data pointer needs to be updated to reflect the new target.
1438
update_mdp_by_offset(mdp, in_bytes(RetData::bci_displacement_offset(row)), Rtemp);
1439
b(profile_continue);
1440
bind(next_test);
1441
}
1442
1443
update_mdp_for_ret(return_bci);
1444
1445
bind(profile_continue);
1446
}
1447
}
1448
1449
1450
// Sets mdp.
1451
void InterpreterMacroAssembler::profile_null_seen(Register mdp) {
1452
if (ProfileInterpreter) {
1453
Label profile_continue;
1454
1455
// If no method data exists, go to profile_continue.
1456
test_method_data_pointer(mdp, profile_continue);
1457
1458
set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
1459
1460
// The method data pointer needs to be updated.
1461
int mdp_delta = in_bytes(BitData::bit_data_size());
1462
if (TypeProfileCasts) {
1463
mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
1464
}
1465
update_mdp_by_constant(mdp, mdp_delta);
1466
1467
bind (profile_continue);
1468
}
1469
}
1470
1471
1472
// Sets mdp, blows Rtemp.
1473
void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) {
1474
assert_different_registers(mdp, Rtemp);
1475
1476
if (ProfileInterpreter && TypeProfileCasts) {
1477
Label profile_continue;
1478
1479
// If no method data exists, go to profile_continue.
1480
test_method_data_pointer(mdp, profile_continue);
1481
1482
int count_offset = in_bytes(CounterData::count_offset());
1483
// Back up the address, since we have already bumped the mdp.
1484
count_offset -= in_bytes(VirtualCallData::virtual_call_data_size());
1485
1486
// *Decrement* the counter. We expect to see zero or small negatives.
1487
increment_mdp_data_at(mdp, count_offset, Rtemp, true);
1488
1489
bind (profile_continue);
1490
}
1491
}
1492
1493
1494
// Sets mdp, blows Rtemp.
1495
void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass)
1496
{
1497
assert_different_registers(mdp, klass, Rtemp);
1498
1499
if (ProfileInterpreter) {
1500
Label profile_continue;
1501
1502
// If no method data exists, go to profile_continue.
1503
test_method_data_pointer(mdp, profile_continue);
1504
1505
// The method data pointer needs to be updated.
1506
int mdp_delta = in_bytes(BitData::bit_data_size());
1507
if (TypeProfileCasts) {
1508
mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
1509
1510
// Record the object type.
1511
record_klass_in_profile(klass, mdp, Rtemp, false);
1512
}
1513
update_mdp_by_constant(mdp, mdp_delta);
1514
1515
bind(profile_continue);
1516
}
1517
}
1518
1519
1520
// Sets mdp, blows Rtemp.
1521
void InterpreterMacroAssembler::profile_switch_default(Register mdp) {
1522
assert_different_registers(mdp, Rtemp);
1523
1524
if (ProfileInterpreter) {
1525
Label profile_continue;
1526
1527
// If no method data exists, go to profile_continue.
1528
test_method_data_pointer(mdp, profile_continue);
1529
1530
// Update the default case count
1531
increment_mdp_data_at(mdp, in_bytes(MultiBranchData::default_count_offset()), Rtemp);
1532
1533
// The method data pointer needs to be updated.
1534
update_mdp_by_offset(mdp, in_bytes(MultiBranchData::default_displacement_offset()), Rtemp);
1535
1536
bind(profile_continue);
1537
}
1538
}
1539
1540
1541
// Sets mdp. Blows reg_tmp1, reg_tmp2. Index could be the same as reg_tmp2.
1542
void InterpreterMacroAssembler::profile_switch_case(Register mdp, Register index, Register reg_tmp1, Register reg_tmp2) {
1543
assert_different_registers(mdp, reg_tmp1, reg_tmp2);
1544
assert_different_registers(mdp, reg_tmp1, index);
1545
1546
if (ProfileInterpreter) {
1547
Label profile_continue;
1548
1549
const int count_offset = in_bytes(MultiBranchData::case_array_offset()) +
1550
in_bytes(MultiBranchData::relative_count_offset());
1551
1552
const int displacement_offset = in_bytes(MultiBranchData::case_array_offset()) +
1553
in_bytes(MultiBranchData::relative_displacement_offset());
1554
1555
// If no method data exists, go to profile_continue.
1556
test_method_data_pointer(mdp, profile_continue);
1557
1558
// Build the base (index * per_case_size_in_bytes())
1559
logical_shift_left(reg_tmp1, index, exact_log2(in_bytes(MultiBranchData::per_case_size())));
1560
1561
// Update the case count
1562
add(reg_tmp1, reg_tmp1, count_offset);
1563
increment_mdp_data_at(Address(mdp, reg_tmp1), reg_tmp2);
1564
1565
// The method data pointer needs to be updated.
1566
add(reg_tmp1, reg_tmp1, displacement_offset - count_offset);
1567
update_mdp_by_offset(mdp, reg_tmp1, reg_tmp2);
1568
1569
bind (profile_continue);
1570
}
1571
}
1572
1573
1574
void InterpreterMacroAssembler::byteswap_u32(Register r, Register rtmp1, Register rtmp2) {
1575
if (VM_Version::supports_rev()) {
1576
rev(r, r);
1577
} else {
1578
eor(rtmp1, r, AsmOperand(r, ror, 16));
1579
mvn(rtmp2, 0x0000ff00);
1580
andr(rtmp1, rtmp2, AsmOperand(rtmp1, lsr, 8));
1581
eor(r, rtmp1, AsmOperand(r, ror, 8));
1582
}
1583
}
1584
1585
1586
void InterpreterMacroAssembler::inc_global_counter(address address_of_counter, int offset, Register tmp1, Register tmp2, bool avoid_overflow) {
1587
const intx addr = (intx) (address_of_counter + offset);
1588
1589
assert ((addr & 0x3) == 0, "address of counter should be aligned");
1590
const intx offset_mask = right_n_bits(12);
1591
1592
const address base = (address) (addr & ~offset_mask);
1593
const int offs = (int) (addr & offset_mask);
1594
1595
const Register addr_base = tmp1;
1596
const Register val = tmp2;
1597
1598
mov_slow(addr_base, base);
1599
ldr_s32(val, Address(addr_base, offs));
1600
1601
if (avoid_overflow) {
1602
adds_32(val, val, 1);
1603
str(val, Address(addr_base, offs), pl);
1604
} else {
1605
add_32(val, val, 1);
1606
str_32(val, Address(addr_base, offs));
1607
}
1608
}
1609
1610
void InterpreterMacroAssembler::interp_verify_oop(Register reg, TosState state, const char *file, int line) {
1611
if (state == atos) { MacroAssembler::_verify_oop(reg, "broken oop", file, line); }
1612
}
1613
1614
// Inline assembly for:
1615
//
1616
// if (thread is in interp_only_mode) {
1617
// InterpreterRuntime::post_method_entry();
1618
// }
1619
// if (DTraceMethodProbes) {
1620
// SharedRuntime::dtrace_method_entry(method, receiver);
1621
// }
1622
// if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
1623
// SharedRuntime::rc_trace_method_entry(method, receiver);
1624
// }
1625
1626
void InterpreterMacroAssembler::notify_method_entry() {
1627
// Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1628
// track stack depth. If it is possible to enter interp_only_mode we add
1629
// the code to check if the event should be sent.
1630
if (can_post_interpreter_events()) {
1631
Label L;
1632
1633
ldr_s32(Rtemp, Address(Rthread, JavaThread::interp_only_mode_offset()));
1634
cbz(Rtemp, L);
1635
1636
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry));
1637
1638
bind(L);
1639
}
1640
1641
// Note: Disable DTrace runtime check for now to eliminate overhead on each method entry
1642
if (DTraceMethodProbes) {
1643
Label Lcontinue;
1644
1645
ldrb_global(Rtemp, (address)&DTraceMethodProbes);
1646
cbz(Rtemp, Lcontinue);
1647
1648
mov(R0, Rthread);
1649
mov(R1, Rmethod);
1650
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), R0, R1);
1651
1652
bind(Lcontinue);
1653
}
1654
// RedefineClasses() tracing support for obsolete method entry
1655
if (log_is_enabled(Trace, redefine, class, obsolete)) {
1656
mov(R0, Rthread);
1657
mov(R1, Rmethod);
1658
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
1659
R0, R1);
1660
}
1661
}
1662
1663
1664
void InterpreterMacroAssembler::notify_method_exit(
1665
TosState state, NotifyMethodExitMode mode,
1666
bool native, Register result_lo, Register result_hi, FloatRegister result_fp) {
1667
// Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1668
// track stack depth. If it is possible to enter interp_only_mode we add
1669
// the code to check if the event should be sent.
1670
if (mode == NotifyJVMTI && can_post_interpreter_events()) {
1671
Label L;
1672
// Note: frame::interpreter_frame_result has a dependency on how the
1673
// method result is saved across the call to post_method_exit. If this
1674
// is changed then the interpreter_frame_result implementation will
1675
// need to be updated too.
1676
1677
ldr_s32(Rtemp, Address(Rthread, JavaThread::interp_only_mode_offset()));
1678
cbz(Rtemp, L);
1679
1680
if (native) {
1681
// For c++ and template interpreter push both result registers on the
1682
// stack in native, we don't know the state.
1683
// See frame::interpreter_frame_result for code that gets the result values from here.
1684
assert(result_lo != noreg, "result registers should be defined");
1685
1686
assert(result_hi != noreg, "result registers should be defined");
1687
1688
#ifdef __ABI_HARD__
1689
assert(result_fp != fnoreg, "FP result register must be defined");
1690
sub(SP, SP, 2 * wordSize);
1691
fstd(result_fp, Address(SP));
1692
#endif // __ABI_HARD__
1693
1694
push(RegisterSet(result_lo) | RegisterSet(result_hi));
1695
1696
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit));
1697
1698
pop(RegisterSet(result_lo) | RegisterSet(result_hi));
1699
#ifdef __ABI_HARD__
1700
fldd(result_fp, Address(SP));
1701
add(SP, SP, 2 * wordSize);
1702
#endif // __ABI_HARD__
1703
1704
} else {
1705
// For the template interpreter, the value on tos is the size of the
1706
// state. (c++ interpreter calls jvmti somewhere else).
1707
push(state);
1708
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit));
1709
pop(state);
1710
}
1711
1712
bind(L);
1713
}
1714
1715
// Note: Disable DTrace runtime check for now to eliminate overhead on each method exit
1716
if (DTraceMethodProbes) {
1717
Label Lcontinue;
1718
1719
ldrb_global(Rtemp, (address)&DTraceMethodProbes);
1720
cbz(Rtemp, Lcontinue);
1721
1722
push(state);
1723
1724
mov(R0, Rthread);
1725
mov(R1, Rmethod);
1726
1727
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), R0, R1);
1728
1729
pop(state);
1730
1731
bind(Lcontinue);
1732
}
1733
}
1734
1735
1736
#ifndef PRODUCT
1737
1738
void InterpreterMacroAssembler::trace_state(const char* msg) {
1739
int push_size = save_caller_save_registers();
1740
1741
Label Lcontinue;
1742
InlinedString Lmsg0("%s: FP=" INTPTR_FORMAT ", SP=" INTPTR_FORMAT "\n");
1743
InlinedString Lmsg(msg);
1744
InlinedAddress Lprintf((address)printf);
1745
1746
ldr_literal(R0, Lmsg0);
1747
ldr_literal(R1, Lmsg);
1748
mov(R2, FP);
1749
add(R3, SP, push_size); // original SP (without saved registers)
1750
ldr_literal(Rtemp, Lprintf);
1751
call(Rtemp);
1752
1753
b(Lcontinue);
1754
1755
bind_literal(Lmsg0);
1756
bind_literal(Lmsg);
1757
bind_literal(Lprintf);
1758
1759
1760
bind(Lcontinue);
1761
1762
restore_caller_save_registers();
1763
}
1764
1765
#endif
1766
1767
// Jump if ((*counter_addr += increment) & mask) satisfies the condition.
1768
void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,
1769
int increment, Address mask_addr,
1770
Register scratch, Register scratch2,
1771
AsmCondition cond, Label* where) {
1772
// caution: scratch2 and base address of counter_addr can be the same
1773
assert_different_registers(scratch, scratch2);
1774
ldr_u32(scratch, counter_addr);
1775
add(scratch, scratch, increment);
1776
str_32(scratch, counter_addr);
1777
1778
ldr(scratch2, mask_addr);
1779
andrs(scratch, scratch, scratch2);
1780
b(*where, cond);
1781
}
1782
1783
void InterpreterMacroAssembler::get_method_counters(Register method,
1784
Register Rcounters,
1785
Label& skip,
1786
bool saveRegs,
1787
Register reg1,
1788
Register reg2,
1789
Register reg3) {
1790
const Address method_counters(method, Method::method_counters_offset());
1791
Label has_counters;
1792
1793
ldr(Rcounters, method_counters);
1794
cbnz(Rcounters, has_counters);
1795
1796
if (saveRegs) {
1797
// Save and restore in use caller-saved registers since they will be trashed by call_VM
1798
assert(reg1 != noreg, "must specify reg1");
1799
assert(reg2 != noreg, "must specify reg2");
1800
assert(reg3 == noreg, "must not specify reg3");
1801
push(RegisterSet(reg1) | RegisterSet(reg2));
1802
}
1803
1804
mov(R1, method);
1805
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters), R1);
1806
1807
if (saveRegs) {
1808
pop(RegisterSet(reg1) | RegisterSet(reg2));
1809
}
1810
1811
ldr(Rcounters, method_counters);
1812
cbz(Rcounters, skip); // No MethodCounters created, OutOfMemory
1813
1814
bind(has_counters);
1815
}
1816
1817