1 /*
2 * Copyright (c) 1997, 2025, 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 "compiler/compiler_globals.hpp"
26 #include "interp_masm_x86.hpp"
27 #include "interpreter/interpreter.hpp"
28 #include "interpreter/interpreterRuntime.hpp"
29 #include "logging/log.hpp"
30 #include "oops/arrayOop.hpp"
31 #include "oops/markWord.hpp"
32 #include "oops/methodData.hpp"
33 #include "oops/method.hpp"
34 #include "oops/resolvedFieldEntry.hpp"
35 #include "oops/resolvedIndyEntry.hpp"
36 #include "oops/resolvedMethodEntry.hpp"
37 #include "prims/jvmtiExport.hpp"
38 #include "prims/jvmtiThreadState.hpp"
39 #include "runtime/basicLock.hpp"
40 #include "runtime/frame.inline.hpp"
41 #include "runtime/javaThread.hpp"
42 #include "runtime/safepointMechanism.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "utilities/powerOfTwo.hpp"
45
46 // Implementation of InterpreterMacroAssembler
47
48 void InterpreterMacroAssembler::jump_to_entry(address entry) {
49 assert(entry, "Entry must have been generated by now");
50 jump(RuntimeAddress(entry));
51 }
52
53 void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) {
54 Label update, next, none;
55
56 assert_different_registers(obj, rscratch1, mdo_addr.base(), mdo_addr.index());
57
58 interp_verify_oop(obj, atos);
59
60 testptr(obj, obj);
61 jccb(Assembler::notZero, update);
62 testptr(mdo_addr, TypeEntries::null_seen);
63 jccb(Assembler::notZero, next); // null already seen. Nothing to do anymore.
64 // atomic update to prevent overwriting Klass* with 0
65 lock();
66 orptr(mdo_addr, TypeEntries::null_seen);
67 jmpb(next);
68
69 bind(update);
70 load_klass(obj, obj, rscratch1);
71 mov(rscratch1, obj);
72
73 xorptr(obj, mdo_addr);
74 testptr(obj, TypeEntries::type_klass_mask);
75 jccb(Assembler::zero, next); // klass seen before, nothing to
76 // do. The unknown bit may have been
77 // set already but no need to check.
78
79 testptr(obj, TypeEntries::type_unknown);
80 jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
81
82 cmpptr(mdo_addr, 0);
83 jccb(Assembler::equal, none);
84 cmpptr(mdo_addr, TypeEntries::null_seen);
85 jccb(Assembler::equal, none);
86
87 // There is a chance that the checks above (re-reading profiling
88 // data from memory) fail if another thread has just set the
89 // profiling to this obj's klass
90 mov(obj, rscratch1);
91 xorptr(obj, mdo_addr);
92 testptr(obj, TypeEntries::type_klass_mask);
93 jccb(Assembler::zero, next);
94
95 // different than before. Cannot keep accurate profile.
96 orptr(mdo_addr, TypeEntries::type_unknown);
97 jmpb(next);
98
99 bind(none);
100 // first time here. Set profile type.
101 movptr(mdo_addr, obj);
102 #ifdef ASSERT
103 andptr(obj, TypeEntries::type_klass_mask);
104 verify_klass_ptr(obj);
105 #endif
106
107 bind(next);
108 }
109
110 void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) {
111 if (!ProfileInterpreter) {
112 return;
113 }
114
115 if (MethodData::profile_arguments() || MethodData::profile_return()) {
116 Label profile_continue;
117
118 test_method_data_pointer(mdp, profile_continue);
119
120 int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
121
122 cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag);
123 jcc(Assembler::notEqual, profile_continue);
124
125 if (MethodData::profile_arguments()) {
126 Label done;
127 int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset());
128 addptr(mdp, off_to_args);
129
130 for (int i = 0; i < TypeProfileArgsLimit; i++) {
131 if (i > 0 || MethodData::profile_return()) {
132 // If return value type is profiled we may have no argument to profile
133 movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args));
134 subl(tmp, i*TypeStackSlotEntries::per_arg_count());
135 cmpl(tmp, TypeStackSlotEntries::per_arg_count());
136 jcc(Assembler::less, done);
137 }
138 movptr(tmp, Address(callee, Method::const_offset()));
139 load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset()));
140 // stack offset o (zero based) from the start of the argument
141 // list, for n arguments translates into offset n - o - 1 from
142 // the end of the argument list
143 subptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args));
144 subl(tmp, 1);
145 Address arg_addr = argument_address(tmp);
146 movptr(tmp, arg_addr);
147
148 Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args);
149 profile_obj_type(tmp, mdo_arg_addr);
150
151 int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
152 addptr(mdp, to_add);
153 off_to_args += to_add;
154 }
155
156 if (MethodData::profile_return()) {
157 movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args));
158 subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
159 }
160
161 bind(done);
162
163 if (MethodData::profile_return()) {
164 // We're right after the type profile for the last
165 // argument. tmp is the number of cells left in the
166 // CallTypeData/VirtualCallTypeData to reach its end. Non null
167 // if there's a return to profile.
168 assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
169 shll(tmp, log2i_exact((int)DataLayout::cell_size));
170 addptr(mdp, tmp);
171 }
172 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp);
173 } else {
174 assert(MethodData::profile_return(), "either profile call args or call ret");
175 update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
176 }
177
178 // mdp points right after the end of the
179 // CallTypeData/VirtualCallTypeData, right after the cells for the
180 // return value type if there's one
181
182 bind(profile_continue);
183 }
184 }
185
186 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
187 assert_different_registers(mdp, ret, tmp, _bcp_register);
188 if (ProfileInterpreter && MethodData::profile_return()) {
189 Label profile_continue;
190
191 test_method_data_pointer(mdp, profile_continue);
192
193 if (MethodData::profile_return_jsr292_only()) {
194 assert(Method::intrinsic_id_size_in_bytes() == 2, "assuming Method::_intrinsic_id is u2");
195
196 // If we don't profile all invoke bytecodes we must make sure
197 // it's a bytecode we indeed profile. We can't go back to the
198 // beginning of the ProfileData we intend to update to check its
199 // type because we're right after it and we don't known its
200 // length
201 Label do_profile;
202 cmpb(Address(_bcp_register, 0), Bytecodes::_invokedynamic);
203 jcc(Assembler::equal, do_profile);
204 cmpb(Address(_bcp_register, 0), Bytecodes::_invokehandle);
205 jcc(Assembler::equal, do_profile);
206 get_method(tmp);
207 cmpw(Address(tmp, Method::intrinsic_id_offset()), static_cast<int>(vmIntrinsics::_compiledLambdaForm));
208 jcc(Assembler::notEqual, profile_continue);
209
210 bind(do_profile);
211 }
212
213 Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
214 mov(tmp, ret);
215 profile_obj_type(tmp, mdo_ret_addr);
216
217 bind(profile_continue);
218 }
219 }
220
221 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
222 if (ProfileInterpreter && MethodData::profile_parameters()) {
223 Label profile_continue;
224
225 test_method_data_pointer(mdp, profile_continue);
226
227 // Load the offset of the area within the MDO used for
228 // parameters. If it's negative we're not profiling any parameters
229 movl(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
230 testl(tmp1, tmp1);
231 jcc(Assembler::negative, profile_continue);
232
233 // Compute a pointer to the area for parameters from the offset
234 // and move the pointer to the slot for the last
235 // parameters. Collect profiling from last parameter down.
236 // mdo start + parameters offset + array length - 1
237 addptr(mdp, tmp1);
238 movptr(tmp1, Address(mdp, ArrayData::array_len_offset()));
239 decrement(tmp1, TypeStackSlotEntries::per_arg_count());
240
241 Label loop;
242 bind(loop);
243
244 int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0));
245 int type_base = in_bytes(ParametersTypeData::type_offset(0));
246 Address::ScaleFactor per_arg_scale = Address::times(DataLayout::cell_size);
247 Address arg_off(mdp, tmp1, per_arg_scale, off_base);
248 Address arg_type(mdp, tmp1, per_arg_scale, type_base);
249
250 // load offset on the stack from the slot for this parameter
251 movptr(tmp2, arg_off);
252 negptr(tmp2);
253 // read the parameter from the local area
254 movptr(tmp2, Address(_locals_register, tmp2, Interpreter::stackElementScale()));
255
256 // profile the parameter
257 profile_obj_type(tmp2, arg_type);
258
259 // go to next parameter
260 decrement(tmp1, TypeStackSlotEntries::per_arg_count());
261 jcc(Assembler::positive, loop);
262
263 bind(profile_continue);
264 }
265 }
266
267 void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point,
268 int number_of_arguments) {
269 // interpreter specific
270 //
271 // Note: No need to save/restore bcp & locals registers
272 // since these are callee saved registers and no blocking/
273 // GC can happen in leaf calls.
274 // Further Note: DO NOT save/restore bcp/locals. If a caller has
275 // already saved them so that it can use rsi/rdi as temporaries
276 // then a save/restore here will DESTROY the copy the caller
277 // saved! There used to be a save_bcp() that only happened in
278 // the ASSERT path (no restore_bcp). Which caused bizarre failures
279 // when jvm built with ASSERTs.
280 #ifdef ASSERT
281 {
282 Label L;
283 cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
284 jcc(Assembler::equal, L);
285 stop("InterpreterMacroAssembler::call_VM_leaf_base:"
286 " last_sp != null");
287 bind(L);
288 }
289 #endif
290 // super call
291 MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments);
292 // interpreter specific
293 // LP64: Used to ASSERT that r13/r14 were equal to frame's bcp/locals
294 // but since they may not have been saved (and we don't want to
295 // save them here (see note above) the assert is invalid.
296 }
297
298 void InterpreterMacroAssembler::call_VM_base(Register oop_result,
299 Register last_java_sp,
300 address entry_point,
301 int number_of_arguments,
302 bool check_exceptions) {
303 // interpreter specific
304 //
305 // Note: Could avoid restoring locals ptr (callee saved) - however doesn't
306 // really make a difference for these runtime calls, since they are
307 // slow anyway. Btw., bcp must be saved/restored since it may change
308 // due to GC.
309 save_bcp();
310 #ifdef ASSERT
311 {
312 Label L;
313 cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
314 jcc(Assembler::equal, L);
315 stop("InterpreterMacroAssembler::call_VM_base:"
316 " last_sp isn't null");
317 bind(L);
318 }
319 #endif /* ASSERT */
320 // super call
321 MacroAssembler::call_VM_base(oop_result, last_java_sp,
322 entry_point, number_of_arguments,
323 check_exceptions);
324 // interpreter specific
325 restore_bcp();
326 restore_locals();
327 }
328
329 void InterpreterMacroAssembler::call_VM_preemptable_helper(Register oop_result,
330 address entry_point,
331 int number_of_arguments,
332 bool check_exceptions) {
333 assert(InterpreterRuntime::is_preemptable_call(entry_point), "VM call not preemptable, should use call_VM()");
334 Label resume_pc, not_preempted;
335
336 #ifdef ASSERT
337 {
338 Label L1, L2;
339 cmpptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
340 jcc(Assembler::equal, L1);
341 stop("call_VM_preemptable_helper: should not have alternate return address set");
342 bind(L1);
343 // We check this counter in patch_return_pc_with_preempt_stub() during freeze.
344 incrementl(Address(r15_thread, JavaThread::interp_at_preemptable_vmcall_cnt_offset()));
345 cmpl(Address(r15_thread, JavaThread::interp_at_preemptable_vmcall_cnt_offset()), 0);
346 jcc(Assembler::greater, L2);
347 stop("call_VM_preemptable_helper: should be > 0");
348 bind(L2);
349 }
350 #endif /* ASSERT */
351
352 // Force freeze slow path.
353 push_cont_fastpath();
354
355 // Make VM call. In case of preemption set last_pc to the one we want to resume to.
356 lea(rscratch1, resume_pc);
357 push(rscratch1);
358 lea(rax, Address(rsp, wordSize));
359 call_VM_base(noreg, rax, entry_point, number_of_arguments, false);
360 pop(rscratch1);
361
362 pop_cont_fastpath();
363
364 #ifdef ASSERT
365 {
366 Label L;
367 decrementl(Address(r15_thread, JavaThread::interp_at_preemptable_vmcall_cnt_offset()));
368 cmpl(Address(r15_thread, JavaThread::interp_at_preemptable_vmcall_cnt_offset()), 0);
369 jcc(Assembler::greaterEqual, L);
370 stop("call_VM_preemptable_helper: should be >= 0");
371 bind(L);
372 }
373 #endif /* ASSERT */
374
375 // Check if preempted.
376 movptr(rscratch1, Address(r15_thread, JavaThread::preempt_alternate_return_offset()));
377 cmpptr(rscratch1, NULL_WORD);
378 jccb(Assembler::zero, not_preempted);
379 movptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
380 jmp(rscratch1);
381
382 // In case of preemption, this is where we will resume once we finally acquire the monitor.
383 bind(resume_pc);
384 restore_after_resume(false /* is_native */);
385
386 bind(not_preempted);
387 if (check_exceptions) {
388 // check for pending exceptions
389 cmpptr(Address(r15_thread, Thread::pending_exception_offset()), NULL_WORD);
390 Label ok;
391 jcc(Assembler::equal, ok);
392 // Exception stub expects return pc to be at top of stack. We only need
393 // it to check Interpreter::contains(return_address) so anything will do.
394 lea(rscratch1, resume_pc);
395 push(rscratch1);
396 jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
397 bind(ok);
398 }
399
400 // get oop result if there is one and reset the value in the thread
401 if (oop_result->is_valid()) {
402 get_vm_result_oop(oop_result);
403 }
404 }
405
406 static void pass_arg1(MacroAssembler* masm, Register arg) {
407 if (c_rarg1 != arg ) {
408 masm->mov(c_rarg1, arg);
409 }
410 }
411
412 static void pass_arg2(MacroAssembler* masm, Register arg) {
413 if (c_rarg2 != arg ) {
414 masm->mov(c_rarg2, arg);
415 }
416 }
417
418 void InterpreterMacroAssembler::call_VM_preemptable(Register oop_result,
419 address entry_point,
420 Register arg_1,
421 bool check_exceptions) {
422 pass_arg1(this, arg_1);
423 call_VM_preemptable_helper(oop_result, entry_point, 1, check_exceptions);
424 }
425
426 void InterpreterMacroAssembler::call_VM_preemptable(Register oop_result,
427 address entry_point,
428 Register arg_1,
429 Register arg_2,
430 bool check_exceptions) {
431 LP64_ONLY(assert_different_registers(arg_1, c_rarg2));
432 pass_arg2(this, arg_2);
433 pass_arg1(this, arg_1);
434 call_VM_preemptable_helper(oop_result, entry_point, 2, check_exceptions);
435 }
436
437 void InterpreterMacroAssembler::restore_after_resume(bool is_native) {
438 lea(rscratch1, ExternalAddress(Interpreter::cont_resume_interpreter_adapter()));
439 call(rscratch1);
440 if (is_native) {
441 // On resume we need to set up stack as expected.
442 push(dtos);
443 push(ltos);
444 }
445 }
446
447 void InterpreterMacroAssembler::check_and_handle_popframe() {
448 if (JvmtiExport::can_pop_frame()) {
449 Label L;
450 // Initiate popframe handling only if it is not already being
451 // processed. If the flag has the popframe_processing bit set, it
452 // means that this code is called *during* popframe handling - we
453 // don't want to reenter.
454 // This method is only called just after the call into the vm in
455 // call_VM_base, so the arg registers are available.
456 Register pop_cond = c_rarg0;
457 movl(pop_cond, Address(r15_thread, JavaThread::popframe_condition_offset()));
458 testl(pop_cond, JavaThread::popframe_pending_bit);
459 jcc(Assembler::zero, L);
460 testl(pop_cond, JavaThread::popframe_processing_bit);
461 jcc(Assembler::notZero, L);
462 // Call Interpreter::remove_activation_preserving_args_entry() to get the
463 // address of the same-named entrypoint in the generated interpreter code.
464 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
465 jmp(rax);
466 bind(L);
467 }
468 }
469
470 void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
471 movptr(rcx, Address(r15_thread, JavaThread::jvmti_thread_state_offset()));
472 const Address tos_addr(rcx, JvmtiThreadState::earlyret_tos_offset());
473 const Address oop_addr(rcx, JvmtiThreadState::earlyret_oop_offset());
474 const Address val_addr(rcx, JvmtiThreadState::earlyret_value_offset());
475
476 switch (state) {
477 case atos: movptr(rax, oop_addr);
478 movptr(oop_addr, NULL_WORD);
479 interp_verify_oop(rax, state); break;
480 case ltos: movptr(rax, val_addr); break;
481 case btos: // fall through
482 case ztos: // fall through
483 case ctos: // fall through
484 case stos: // fall through
485 case itos: movl(rax, val_addr); break;
486 case ftos: movflt(xmm0, val_addr); break;
487 case dtos: movdbl(xmm0, val_addr); break;
488 case vtos: /* nothing to do */ break;
489 default : ShouldNotReachHere();
490 }
491
492 // Clean up tos value in the thread object
493 movl(tos_addr, ilgl);
494 movptr(val_addr, NULL_WORD);
495 }
496
497
498 void InterpreterMacroAssembler::check_and_handle_earlyret() {
499 if (JvmtiExport::can_force_early_return()) {
500 Label L;
501 Register tmp = c_rarg0;
502 Register rthread = r15_thread;
503
504 movptr(tmp, Address(rthread, JavaThread::jvmti_thread_state_offset()));
505 testptr(tmp, tmp);
506 jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == nullptr) exit;
507
508 // Initiate earlyret handling only if it is not already being processed.
509 // If the flag has the earlyret_processing bit set, it means that this code
510 // is called *during* earlyret handling - we don't want to reenter.
511 movl(tmp, Address(tmp, JvmtiThreadState::earlyret_state_offset()));
512 cmpl(tmp, JvmtiThreadState::earlyret_pending);
513 jcc(Assembler::notEqual, L);
514
515 // Call Interpreter::remove_activation_early_entry() to get the address of the
516 // same-named entrypoint in the generated interpreter code.
517 movptr(tmp, Address(rthread, JavaThread::jvmti_thread_state_offset()));
518 movl(tmp, Address(tmp, JvmtiThreadState::earlyret_tos_offset()));
519 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), tmp);
520 jmp(rax);
521 bind(L);
522 }
523 }
524
525 void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) {
526 assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode");
527 load_unsigned_short(reg, Address(_bcp_register, bcp_offset));
528 bswapl(reg);
529 shrl(reg, 16);
530 }
531
532 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
533 int bcp_offset,
534 size_t index_size) {
535 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
536 if (index_size == sizeof(u2)) {
537 load_unsigned_short(index, Address(_bcp_register, bcp_offset));
538 } else if (index_size == sizeof(u4)) {
539 movl(index, Address(_bcp_register, bcp_offset));
540 } else if (index_size == sizeof(u1)) {
541 load_unsigned_byte(index, Address(_bcp_register, bcp_offset));
542 } else {
543 ShouldNotReachHere();
544 }
545 }
546
547 // Load object from cpool->resolved_references(index)
548 void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result,
549 Register index,
550 Register tmp) {
551 assert_different_registers(result, index);
552
553 get_constant_pool(result);
554 // load pointer for resolved_references[] objArray
555 movptr(result, Address(result, ConstantPool::cache_offset()));
556 movptr(result, Address(result, ConstantPoolCache::resolved_references_offset()));
557 resolve_oop_handle(result, tmp);
558 load_heap_oop(result, Address(result, index,
559 UseCompressedOops ? Address::times_4 : Address::times_ptr,
560 arrayOopDesc::base_offset_in_bytes(T_OBJECT)), tmp);
561 }
562
563 // load cpool->resolved_klass_at(index)
564 void InterpreterMacroAssembler::load_resolved_klass_at_index(Register klass,
565 Register cpool,
566 Register index) {
567 assert_different_registers(cpool, index);
568
569 movw(index, Address(cpool, index, Address::times_ptr, sizeof(ConstantPool)));
570 Register resolved_klasses = cpool;
571 movptr(resolved_klasses, Address(cpool, ConstantPool::resolved_klasses_offset()));
572 movptr(klass, Address(resolved_klasses, index, Address::times_ptr, Array<Klass*>::base_offset_in_bytes()));
573 }
574
575 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
576 // subtype of super_klass.
577 //
578 // Args:
579 // rax: superklass
580 // Rsub_klass: subklass
581 //
582 // Kills:
583 // rcx, rdi
584 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
585 Label& ok_is_subtype) {
586 assert(Rsub_klass != rax, "rax holds superklass");
587 LP64_ONLY(assert(Rsub_klass != r14, "r14 holds locals");)
588 LP64_ONLY(assert(Rsub_klass != r13, "r13 holds bcp");)
589 assert(Rsub_klass != rcx, "rcx holds 2ndary super array length");
590 assert(Rsub_klass != rdi, "rdi holds 2ndary super array scan ptr");
591
592 // Profile the not-null value's klass.
593 profile_typecheck(rcx, Rsub_klass, rdi); // blows rcx, reloads rdi
594
595 // Do the check.
596 check_klass_subtype(Rsub_klass, rax, rcx, ok_is_subtype); // blows rcx
597 }
598
599
600 // Java Expression Stack
601
602 void InterpreterMacroAssembler::pop_ptr(Register r) {
603 pop(r);
604 }
605
606 void InterpreterMacroAssembler::push_ptr(Register r) {
607 push(r);
608 }
609
610 void InterpreterMacroAssembler::push_i(Register r) {
611 push(r);
612 }
613
614 void InterpreterMacroAssembler::push_i_or_ptr(Register r) {
615 push(r);
616 }
617
618 void InterpreterMacroAssembler::push_f(XMMRegister r) {
619 subptr(rsp, wordSize);
620 movflt(Address(rsp, 0), r);
621 }
622
623 void InterpreterMacroAssembler::pop_f(XMMRegister r) {
624 movflt(r, Address(rsp, 0));
625 addptr(rsp, wordSize);
626 }
627
628 void InterpreterMacroAssembler::push_d(XMMRegister r) {
629 subptr(rsp, 2 * wordSize);
630 movdbl(Address(rsp, 0), r);
631 }
632
633 void InterpreterMacroAssembler::pop_d(XMMRegister r) {
634 movdbl(r, Address(rsp, 0));
635 addptr(rsp, 2 * Interpreter::stackElementSize);
636 }
637
638 void InterpreterMacroAssembler::pop_i(Register r) {
639 // XXX can't use pop currently, upper half non clean
640 movl(r, Address(rsp, 0));
641 addptr(rsp, wordSize);
642 }
643
644 void InterpreterMacroAssembler::pop_l(Register r) {
645 movq(r, Address(rsp, 0));
646 addptr(rsp, 2 * Interpreter::stackElementSize);
647 }
648
649 void InterpreterMacroAssembler::push_l(Register r) {
650 subptr(rsp, 2 * wordSize);
651 movptr(Address(rsp, Interpreter::expr_offset_in_bytes(0)), r );
652 movptr(Address(rsp, Interpreter::expr_offset_in_bytes(1)), NULL_WORD );
653 }
654
655 void InterpreterMacroAssembler::pop(TosState state) {
656 switch (state) {
657 case atos: pop_ptr(); break;
658 case btos:
659 case ztos:
660 case ctos:
661 case stos:
662 case itos: pop_i(); break;
663 case ltos: pop_l(); break;
664 case ftos: pop_f(xmm0); break;
665 case dtos: pop_d(xmm0); break;
666 case vtos: /* nothing to do */ break;
667 default: ShouldNotReachHere();
668 }
669 interp_verify_oop(rax, state);
670 }
671
672 void InterpreterMacroAssembler::push(TosState state) {
673 interp_verify_oop(rax, state);
674 switch (state) {
675 case atos: push_ptr(); break;
676 case btos:
677 case ztos:
678 case ctos:
679 case stos:
680 case itos: push_i(); break;
681 case ltos: push_l(); break;
682 case ftos: push_f(xmm0); break;
683 case dtos: push_d(xmm0); break;
684 case vtos: /* nothing to do */ break;
685 default : ShouldNotReachHere();
686 }
687 }
688
689 // Helpers for swap and dup
690 void InterpreterMacroAssembler::load_ptr(int n, Register val) {
691 movptr(val, Address(rsp, Interpreter::expr_offset_in_bytes(n)));
692 }
693
694 void InterpreterMacroAssembler::store_ptr(int n, Register val) {
695 movptr(Address(rsp, Interpreter::expr_offset_in_bytes(n)), val);
696 }
697
698
699 void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() {
700 // set sender sp
701 lea(_bcp_register, Address(rsp, wordSize));
702 // record last_sp
703 mov(rcx, _bcp_register);
704 subptr(rcx, rbp);
705 sarptr(rcx, LogBytesPerWord);
706 movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), rcx);
707 }
708
709
710 // Jump to from_interpreted entry of a call unless single stepping is possible
711 // in this thread in which case we must call the i2i entry
712 void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) {
713 prepare_to_jump_from_interpreted();
714
715 if (JvmtiExport::can_post_interpreter_events()) {
716 Label run_compiled_code;
717 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
718 // compiled code in threads for which the event is enabled. Check here for
719 // interp_only_mode if these events CAN be enabled.
720 // interp_only is an int, on little endian it is sufficient to test the byte only
721 // Is a cmpl faster?
722 cmpb(Address(r15_thread, JavaThread::interp_only_mode_offset()), 0);
723 jccb(Assembler::zero, run_compiled_code);
724 jmp(Address(method, Method::interpreter_entry_offset()));
725 bind(run_compiled_code);
726 }
727
728 jmp(Address(method, Method::from_interpreted_offset()));
729 }
730
731 // The following two routines provide a hook so that an implementation
732 // can schedule the dispatch in two parts. x86 does not do this.
733 void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) {
734 // Nothing x86 specific to be done here
735 }
736
737 void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) {
738 dispatch_next(state, step);
739 }
740
741 void InterpreterMacroAssembler::dispatch_base(TosState state,
742 address* table,
743 bool verifyoop,
744 bool generate_poll) {
745 if (VerifyActivationFrameSize) {
746 Label L;
747 mov(rcx, rbp);
748 subptr(rcx, rsp);
749 int32_t min_frame_size =
750 (frame::link_offset - frame::interpreter_frame_initial_sp_offset) *
751 wordSize;
752 cmpptr(rcx, min_frame_size);
753 jcc(Assembler::greaterEqual, L);
754 stop("broken stack frame");
755 bind(L);
756 }
757 if (verifyoop) {
758 interp_verify_oop(rax, state);
759 }
760
761 address* const safepoint_table = Interpreter::safept_table(state);
762 Label no_safepoint, dispatch;
763 if (table != safepoint_table && generate_poll) {
764 NOT_PRODUCT(block_comment("Thread-local Safepoint poll"));
765 testb(Address(r15_thread, JavaThread::polling_word_offset()), SafepointMechanism::poll_bit());
766
767 jccb(Assembler::zero, no_safepoint);
768 lea(rscratch1, ExternalAddress((address)safepoint_table));
769 jmpb(dispatch);
770 }
771
772 bind(no_safepoint);
773 lea(rscratch1, ExternalAddress((address)table));
774 bind(dispatch);
775 jmp(Address(rscratch1, rbx, Address::times_8));
776 }
777
778 void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) {
779 dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
780 }
781
782 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
783 dispatch_base(state, Interpreter::normal_table(state));
784 }
785
786 void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) {
787 dispatch_base(state, Interpreter::normal_table(state), false);
788 }
789
790
791 void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) {
792 // load next bytecode (load before advancing _bcp_register to prevent AGI)
793 load_unsigned_byte(rbx, Address(_bcp_register, step));
794 // advance _bcp_register
795 increment(_bcp_register, step);
796 dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
797 }
798
799 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
800 // load current bytecode
801 load_unsigned_byte(rbx, Address(_bcp_register, 0));
802 dispatch_base(state, table);
803 }
804
805 void InterpreterMacroAssembler::narrow(Register result) {
806
807 // Get method->_constMethod->_result_type
808 movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
809 movptr(rcx, Address(rcx, Method::const_offset()));
810 load_unsigned_byte(rcx, Address(rcx, ConstMethod::result_type_offset()));
811
812 Label done, notBool, notByte, notChar;
813
814 // common case first
815 cmpl(rcx, T_INT);
816 jcc(Assembler::equal, done);
817
818 // mask integer result to narrower return type.
819 cmpl(rcx, T_BOOLEAN);
820 jcc(Assembler::notEqual, notBool);
821 andl(result, 0x1);
822 jmp(done);
823
824 bind(notBool);
825 cmpl(rcx, T_BYTE);
826 jcc(Assembler::notEqual, notByte);
827 movsbl(result, result);
828 jmp(done);
829
830 bind(notByte);
831 cmpl(rcx, T_CHAR);
832 jcc(Assembler::notEqual, notChar);
833 movzwl(result, result);
834 jmp(done);
835
836 bind(notChar);
837 // cmpl(rcx, T_SHORT); // all that's left
838 // jcc(Assembler::notEqual, done);
839 movswl(result, result);
840
841 // Nothing to do for T_INT
842 bind(done);
843 }
844
845 // remove activation
846 //
847 // Unlock the receiver if this is a synchronized method.
848 // Unlock any Java monitors from synchronized blocks.
849 // Apply stack watermark barrier.
850 // Notify JVMTI.
851 // Remove the activation from the stack.
852 //
853 // If there are locked Java monitors
854 // If throw_monitor_exception
855 // throws IllegalMonitorStateException
856 // Else if install_monitor_exception
857 // installs IllegalMonitorStateException
858 // Else
859 // no error processing
860 void InterpreterMacroAssembler::remove_activation(TosState state,
861 Register ret_addr,
862 bool throw_monitor_exception,
863 bool install_monitor_exception,
864 bool notify_jvmdi) {
865 // Note: Registers rdx xmm0 may be in use for the
866 // result check if synchronized method
867 Label unlocked, unlock, no_unlock;
868
869 #ifdef ASSERT
870 Label not_preempted;
871 cmpptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD);
872 jcc(Assembler::equal, not_preempted);
873 stop("remove_activation: should not have alternate return address set");
874 bind(not_preempted);
875 #endif /* ASSERT */
876
877 const Register rthread = r15_thread;
878 const Register robj = c_rarg1;
879 const Register rmon = c_rarg1;
880
881 // get the value of _do_not_unlock_if_synchronized into rdx
882 const Address do_not_unlock_if_synchronized(rthread,
883 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
884 movbool(rbx, do_not_unlock_if_synchronized);
885 movbool(do_not_unlock_if_synchronized, false); // reset the flag
886
887 // get method access flags
888 movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
889 load_unsigned_short(rcx, Address(rcx, Method::access_flags_offset()));
890 testl(rcx, JVM_ACC_SYNCHRONIZED);
891 jcc(Assembler::zero, unlocked);
892
893 // Don't unlock anything if the _do_not_unlock_if_synchronized flag
894 // is set.
895 testbool(rbx);
896 jcc(Assembler::notZero, no_unlock);
897
898 // unlock monitor
899 push(state); // save result
900
901 // BasicObjectLock will be first in list, since this is a
902 // synchronized method. However, need to check that the object has
903 // not been unlocked by an explicit monitorexit bytecode.
904 const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset *
905 wordSize - (int) sizeof(BasicObjectLock));
906 // We use c_rarg1/rdx so that if we go slow path it will be the correct
907 // register for unlock_object to pass to VM directly
908 lea(robj, monitor); // address of first monitor
909
910 movptr(rax, Address(robj, BasicObjectLock::obj_offset()));
911 testptr(rax, rax);
912 jcc(Assembler::notZero, unlock);
913
914 pop(state);
915 if (throw_monitor_exception) {
916 // Entry already unlocked, need to throw exception
917 call_VM(noreg, CAST_FROM_FN_PTR(address,
918 InterpreterRuntime::throw_illegal_monitor_state_exception));
919 should_not_reach_here();
920 } else {
921 // Monitor already unlocked during a stack unroll. If requested,
922 // install an illegal_monitor_state_exception. Continue with
923 // stack unrolling.
924 if (install_monitor_exception) {
925 call_VM(noreg, CAST_FROM_FN_PTR(address,
926 InterpreterRuntime::new_illegal_monitor_state_exception));
927 }
928 jmp(unlocked);
929 }
930
931 bind(unlock);
932 unlock_object(robj);
933 pop(state);
934
935 // Check that for block-structured locking (i.e., that all locked
936 // objects has been unlocked)
937 bind(unlocked);
938
939 // rax, rdx: Might contain return value
940
941 // Check that all monitors are unlocked
942 {
943 Label loop, exception, entry, restart;
944 const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();
945 const Address monitor_block_top(
946 rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
947 const Address monitor_block_bot(
948 rbp, frame::interpreter_frame_initial_sp_offset * wordSize);
949
950 bind(restart);
951 // We use c_rarg1 so that if we go slow path it will be the correct
952 // register for unlock_object to pass to VM directly
953 movptr(rmon, monitor_block_top); // derelativize pointer
954 lea(rmon, Address(rbp, rmon, Address::times_ptr));
955 // c_rarg1 points to current entry, starting with top-most entry
956
957 lea(rbx, monitor_block_bot); // points to word before bottom of
958 // monitor block
959 jmp(entry);
960
961 // Entry already locked, need to throw exception
962 bind(exception);
963
964 if (throw_monitor_exception) {
965 // Throw exception
966 MacroAssembler::call_VM(noreg,
967 CAST_FROM_FN_PTR(address, InterpreterRuntime::
968 throw_illegal_monitor_state_exception));
969 should_not_reach_here();
970 } else {
971 // Stack unrolling. Unlock object and install illegal_monitor_exception.
972 // Unlock does not block, so don't have to worry about the frame.
973 // We don't have to preserve c_rarg1 since we are going to throw an exception.
974
975 push(state);
976 mov(robj, rmon); // nop if robj and rmon are the same
977 unlock_object(robj);
978 pop(state);
979
980 if (install_monitor_exception) {
981 call_VM(noreg, CAST_FROM_FN_PTR(address,
982 InterpreterRuntime::
983 new_illegal_monitor_state_exception));
984 }
985
986 jmp(restart);
987 }
988
989 bind(loop);
990 // check if current entry is used
991 cmpptr(Address(rmon, BasicObjectLock::obj_offset()), NULL_WORD);
992 jcc(Assembler::notEqual, exception);
993
994 addptr(rmon, entry_size); // otherwise advance to next entry
995 bind(entry);
996 cmpptr(rmon, rbx); // check if bottom reached
997 jcc(Assembler::notEqual, loop); // if not at bottom then check this entry
998 }
999
1000 bind(no_unlock);
1001
1002 JFR_ONLY(enter_jfr_critical_section();)
1003
1004 // The below poll is for the stack watermark barrier. It allows fixing up frames lazily,
1005 // that would normally not be safe to use. Such bad returns into unsafe territory of
1006 // the stack, will call InterpreterRuntime::at_unwind.
1007 Label slow_path;
1008 Label fast_path;
1009 safepoint_poll(slow_path, true /* at_return */, false /* in_nmethod */);
1010 jmp(fast_path);
1011 bind(slow_path);
1012 push(state);
1013 set_last_Java_frame(noreg, rbp, (address)pc(), rscratch1);
1014 super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), r15_thread);
1015 reset_last_Java_frame(true);
1016 pop(state);
1017 bind(fast_path);
1018
1019 // JVMTI support. Make sure the safepoint poll test is issued prior.
1020 if (notify_jvmdi) {
1021 notify_method_exit(state, NotifyJVMTI); // preserve TOSCA
1022 } else {
1023 notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA
1024 }
1025
1026 // remove activation
1027 // get sender sp
1028 movptr(rbx,
1029 Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize));
1030 if (StackReservedPages > 0) {
1031 // testing if reserved zone needs to be re-enabled
1032 Register rthread = r15_thread;
1033 Label no_reserved_zone_enabling;
1034
1035 // check if already enabled - if so no re-enabling needed
1036 assert(sizeof(StackOverflow::StackGuardState) == 4, "unexpected size");
1037 cmpl(Address(rthread, JavaThread::stack_guard_state_offset()), StackOverflow::stack_guard_enabled);
1038 jcc(Assembler::equal, no_reserved_zone_enabling);
1039
1040 cmpptr(rbx, Address(rthread, JavaThread::reserved_stack_activation_offset()));
1041 jcc(Assembler::lessEqual, no_reserved_zone_enabling);
1042
1043 JFR_ONLY(leave_jfr_critical_section();)
1044
1045 call_VM_leaf(
1046 CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread);
1047 call_VM(noreg, CAST_FROM_FN_PTR(address,
1048 InterpreterRuntime::throw_delayed_StackOverflowError));
1049 should_not_reach_here();
1050
1051 bind(no_reserved_zone_enabling);
1052 }
1053
1054 leave(); // remove frame anchor
1055
1056 JFR_ONLY(leave_jfr_critical_section();)
1057
1058 pop(ret_addr); // get return address
1059 mov(rsp, rbx); // set sp to sender sp
1060 pop_cont_fastpath();
1061
1062 }
1063
1064 #if INCLUDE_JFR
1065 void InterpreterMacroAssembler::enter_jfr_critical_section() {
1066 const Address sampling_critical_section(r15_thread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
1067 movbool(sampling_critical_section, true);
1068 }
1069
1070 void InterpreterMacroAssembler::leave_jfr_critical_section() {
1071 const Address sampling_critical_section(r15_thread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
1072 movbool(sampling_critical_section, false);
1073 }
1074 #endif // INCLUDE_JFR
1075
1076 void InterpreterMacroAssembler::get_method_counters(Register method,
1077 Register mcs, Label& skip) {
1078 Label has_counters;
1079 movptr(mcs, Address(method, Method::method_counters_offset()));
1080 testptr(mcs, mcs);
1081 jcc(Assembler::notZero, has_counters);
1082 call_VM(noreg, CAST_FROM_FN_PTR(address,
1083 InterpreterRuntime::build_method_counters), method);
1084 movptr(mcs, Address(method,Method::method_counters_offset()));
1085 testptr(mcs, mcs);
1086 jcc(Assembler::zero, skip); // No MethodCounters allocated, OutOfMemory
1087 bind(has_counters);
1088 }
1089
1090
1091 // Lock object
1092 //
1093 // Args:
1094 // rdx, c_rarg1: BasicObjectLock to be used for locking
1095 //
1096 // Kills:
1097 // rax, rbx
1098 void InterpreterMacroAssembler::lock_object(Register lock_reg) {
1099 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1");
1100
1101 Label done, slow_case;
1102
1103 const Register swap_reg = rax; // Must use rax for cmpxchg instruction
1104 const Register tmp_reg = rbx;
1105 const Register obj_reg = c_rarg3; // Will contain the oop
1106
1107 // Load object pointer into obj_reg
1108 movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset()));
1109
1110 lightweight_lock(lock_reg, obj_reg, swap_reg, tmp_reg, slow_case);
1111 jmp(done);
1112
1113 bind(slow_case);
1114
1115 // Call the runtime routine for slow case
1116 call_VM_preemptable(noreg,
1117 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
1118 lock_reg);
1119 bind(done);
1120 }
1121
1122
1123 // Unlocks an object. Used in monitorexit bytecode and
1124 // remove_activation. Throws an IllegalMonitorException if object is
1125 // not locked by current thread.
1126 //
1127 // Args:
1128 // rdx, c_rarg1: BasicObjectLock for lock
1129 //
1130 // Kills:
1131 // rax
1132 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, ... (param regs)
1133 // rscratch1 (scratch reg)
1134 // rax, rbx, rcx, rdx
1135 void InterpreterMacroAssembler::unlock_object(Register lock_reg) {
1136 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1");
1137
1138 Label done, slow_case;
1139
1140 const Register swap_reg = rax; // Must use rax for cmpxchg instruction
1141 const Register header_reg = c_rarg2; // Will contain the old oopMark
1142 const Register obj_reg = c_rarg3; // Will contain the oop
1143
1144 save_bcp(); // Save in case of exception
1145
1146 // Load oop into obj_reg(%c_rarg3)
1147 movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset()));
1148
1149 // Free entry
1150 movptr(Address(lock_reg, BasicObjectLock::obj_offset()), NULL_WORD);
1151
1152 lightweight_unlock(obj_reg, swap_reg, header_reg, slow_case);
1153 jmp(done);
1154
1155 bind(slow_case);
1156 // Call the runtime routine for slow case.
1157 movptr(Address(lock_reg, BasicObjectLock::obj_offset()), obj_reg); // restore obj
1158 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);
1159
1160 bind(done);
1161
1162 restore_bcp();
1163 }
1164
1165 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp,
1166 Label& zero_continue) {
1167 assert(ProfileInterpreter, "must be profiling interpreter");
1168 movptr(mdp, Address(rbp, frame::interpreter_frame_mdp_offset * wordSize));
1169 testptr(mdp, mdp);
1170 jcc(Assembler::zero, zero_continue);
1171 }
1172
1173
1174 // Set the method data pointer for the current bcp.
1175 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
1176 assert(ProfileInterpreter, "must be profiling interpreter");
1177 Label set_mdp;
1178 push(rax);
1179 push(rbx);
1180
1181 get_method(rbx);
1182 // Test MDO to avoid the call if it is null.
1183 movptr(rax, Address(rbx, in_bytes(Method::method_data_offset())));
1184 testptr(rax, rax);
1185 jcc(Assembler::zero, set_mdp);
1186 // rbx: method
1187 // _bcp_register: bcp
1188 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, _bcp_register);
1189 // rax: mdi
1190 // mdo is guaranteed to be non-zero here, we checked for it before the call.
1191 movptr(rbx, Address(rbx, in_bytes(Method::method_data_offset())));
1192 addptr(rbx, in_bytes(MethodData::data_offset()));
1193 addptr(rax, rbx);
1194 bind(set_mdp);
1195 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), rax);
1196 pop(rbx);
1197 pop(rax);
1198 }
1199
1200 void InterpreterMacroAssembler::verify_method_data_pointer() {
1201 assert(ProfileInterpreter, "must be profiling interpreter");
1202 #ifdef ASSERT
1203 Label verify_continue;
1204 push(rax);
1205 push(rbx);
1206 Register arg3_reg = c_rarg3;
1207 Register arg2_reg = c_rarg2;
1208 push(arg3_reg);
1209 push(arg2_reg);
1210 test_method_data_pointer(arg3_reg, verify_continue); // If mdp is zero, continue
1211 get_method(rbx);
1212
1213 // If the mdp is valid, it will point to a DataLayout header which is
1214 // consistent with the bcp. The converse is highly probable also.
1215 load_unsigned_short(arg2_reg,
1216 Address(arg3_reg, in_bytes(DataLayout::bci_offset())));
1217 addptr(arg2_reg, Address(rbx, Method::const_offset()));
1218 lea(arg2_reg, Address(arg2_reg, ConstMethod::codes_offset()));
1219 cmpptr(arg2_reg, _bcp_register);
1220 jcc(Assembler::equal, verify_continue);
1221 // rbx: method
1222 // _bcp_register: bcp
1223 // c_rarg3: mdp
1224 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp),
1225 rbx, _bcp_register, arg3_reg);
1226 bind(verify_continue);
1227 pop(arg2_reg);
1228 pop(arg3_reg);
1229 pop(rbx);
1230 pop(rax);
1231 #endif // ASSERT
1232 }
1233
1234
1235 void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in,
1236 int constant,
1237 Register value) {
1238 assert(ProfileInterpreter, "must be profiling interpreter");
1239 Address data(mdp_in, constant);
1240 movptr(data, value);
1241 }
1242
1243
1244 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
1245 int constant) {
1246 assert(ProfileInterpreter, "must be profiling interpreter");
1247 Address data(mdp_in, constant);
1248 addptr(data, DataLayout::counter_increment);
1249 }
1250
1251
1252 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
1253 Register index,
1254 int constant) {
1255 assert(ProfileInterpreter, "must be profiling interpreter");
1256 Address data(mdp_in, index, Address::times_1, constant);
1257 addptr(data, DataLayout::counter_increment);
1258 }
1259
1260 void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in,
1261 int flag_byte_constant) {
1262 assert(ProfileInterpreter, "must be profiling interpreter");
1263 int header_offset = in_bytes(DataLayout::flags_offset());
1264 int header_bits = flag_byte_constant;
1265 // Set the flag
1266 orb(Address(mdp_in, header_offset), header_bits);
1267 }
1268
1269
1270
1271 void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in,
1272 int offset,
1273 Register value,
1274 Register test_value_out,
1275 Label& not_equal_continue) {
1276 assert(ProfileInterpreter, "must be profiling interpreter");
1277 if (test_value_out == noreg) {
1278 cmpptr(value, Address(mdp_in, offset));
1279 } else {
1280 // Put the test value into a register, so caller can use it:
1281 movptr(test_value_out, Address(mdp_in, offset));
1282 cmpptr(test_value_out, value);
1283 }
1284 jcc(Assembler::notEqual, not_equal_continue);
1285 }
1286
1287
1288 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in,
1289 int offset_of_disp) {
1290 assert(ProfileInterpreter, "must be profiling interpreter");
1291 Address disp_address(mdp_in, offset_of_disp);
1292 addptr(mdp_in, disp_address);
1293 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in);
1294 }
1295
1296
1297 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in,
1298 Register reg,
1299 int offset_of_disp) {
1300 assert(ProfileInterpreter, "must be profiling interpreter");
1301 Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp);
1302 addptr(mdp_in, disp_address);
1303 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in);
1304 }
1305
1306
1307 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in,
1308 int constant) {
1309 assert(ProfileInterpreter, "must be profiling interpreter");
1310 addptr(mdp_in, constant);
1311 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in);
1312 }
1313
1314
1315 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
1316 assert(ProfileInterpreter, "must be profiling interpreter");
1317 push(return_bci); // save/restore across call_VM
1318 call_VM(noreg,
1319 CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret),
1320 return_bci);
1321 pop(return_bci);
1322 }
1323
1324
1325 void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
1326 if (ProfileInterpreter) {
1327 Label profile_continue;
1328
1329 // If no method data exists, go to profile_continue.
1330 test_method_data_pointer(mdp, profile_continue);
1331
1332 // We are taking a branch. Increment the taken count.
1333 increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
1334
1335 // The method data pointer needs to be updated to reflect the new target.
1336 update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
1337 bind(profile_continue);
1338 }
1339 }
1340
1341
1342 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
1343 if (ProfileInterpreter) {
1344 Label profile_continue;
1345
1346 // If no method data exists, go to profile_continue.
1347 test_method_data_pointer(mdp, profile_continue);
1348
1349 // We are not taking a branch. Increment the not taken count.
1350 increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
1351
1352 // The method data pointer needs to be updated to correspond to
1353 // the next bytecode
1354 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
1355 bind(profile_continue);
1356 }
1357 }
1358
1359 void InterpreterMacroAssembler::profile_call(Register mdp) {
1360 if (ProfileInterpreter) {
1361 Label profile_continue;
1362
1363 // If no method data exists, go to profile_continue.
1364 test_method_data_pointer(mdp, profile_continue);
1365
1366 // We are making a call. Increment the count.
1367 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1368
1369 // The method data pointer needs to be updated to reflect the new target.
1370 update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1371 bind(profile_continue);
1372 }
1373 }
1374
1375
1376 void InterpreterMacroAssembler::profile_final_call(Register mdp) {
1377 if (ProfileInterpreter) {
1378 Label profile_continue;
1379
1380 // If no method data exists, go to profile_continue.
1381 test_method_data_pointer(mdp, profile_continue);
1382
1383 // We are making a call. Increment the count.
1384 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1385
1386 // The method data pointer needs to be updated to reflect the new target.
1387 update_mdp_by_constant(mdp,
1388 in_bytes(VirtualCallData::
1389 virtual_call_data_size()));
1390 bind(profile_continue);
1391 }
1392 }
1393
1394
1395 void InterpreterMacroAssembler::profile_virtual_call(Register receiver,
1396 Register mdp,
1397 Register reg2,
1398 bool receiver_can_be_null) {
1399 if (ProfileInterpreter) {
1400 Label profile_continue;
1401
1402 // If no method data exists, go to profile_continue.
1403 test_method_data_pointer(mdp, profile_continue);
1404
1405 Label skip_receiver_profile;
1406 if (receiver_can_be_null) {
1407 Label not_null;
1408 testptr(receiver, receiver);
1409 jccb(Assembler::notZero, not_null);
1410 // We are making a call. Increment the count for null receiver.
1411 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1412 jmp(skip_receiver_profile);
1413 bind(not_null);
1414 }
1415
1416 // Record the receiver type.
1417 record_klass_in_profile(receiver, mdp, reg2, true);
1418 bind(skip_receiver_profile);
1419
1420 // The method data pointer needs to be updated to reflect the new target.
1421 update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));
1422 bind(profile_continue);
1423 }
1424 }
1425
1426 // This routine creates a state machine for updating the multi-row
1427 // type profile at a virtual call site (or other type-sensitive bytecode).
1428 // The machine visits each row (of receiver/count) until the receiver type
1429 // is found, or until it runs out of rows. At the same time, it remembers
1430 // the location of the first empty row. (An empty row records null for its
1431 // receiver, and can be allocated for a newly-observed receiver type.)
1432 // Because there are two degrees of freedom in the state, a simple linear
1433 // search will not work; it must be a decision tree. Hence this helper
1434 // function is recursive, to generate the required tree structured code.
1435 // It's the interpreter, so we are trading off code space for speed.
1436 // See below for example code.
1437 void InterpreterMacroAssembler::record_klass_in_profile_helper(
1438 Register receiver, Register mdp,
1439 Register reg2, int start_row,
1440 Label& done, bool is_virtual_call) {
1441 if (TypeProfileWidth == 0) {
1442 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1443 } else {
1444 record_item_in_profile_helper(receiver, mdp, reg2, 0, done, TypeProfileWidth,
1445 &VirtualCallData::receiver_offset, &VirtualCallData::receiver_count_offset);
1446 }
1447 }
1448
1449 void InterpreterMacroAssembler::record_item_in_profile_helper(Register item, Register mdp, Register reg2, int start_row,
1450 Label& done, int total_rows,
1451 OffsetFunction item_offset_fn,
1452 OffsetFunction item_count_offset_fn) {
1453 int last_row = total_rows - 1;
1454 assert(start_row <= last_row, "must be work left to do");
1455 // Test this row for both the item and for null.
1456 // Take any of three different outcomes:
1457 // 1. found item => increment count and goto done
1458 // 2. found null => keep looking for case 1, maybe allocate this cell
1459 // 3. found something else => keep looking for cases 1 and 2
1460 // Case 3 is handled by a recursive call.
1461 for (int row = start_row; row <= last_row; row++) {
1462 Label next_test;
1463 bool test_for_null_also = (row == start_row);
1464
1465 // See if the item is item[n].
1466 int item_offset = in_bytes(item_offset_fn(row));
1467 test_mdp_data_at(mdp, item_offset, item,
1468 (test_for_null_also ? reg2 : noreg),
1469 next_test);
1470 // (Reg2 now contains the item from the CallData.)
1471
1472 // The item is item[n]. Increment count[n].
1473 int count_offset = in_bytes(item_count_offset_fn(row));
1474 increment_mdp_data_at(mdp, count_offset);
1475 jmp(done);
1476 bind(next_test);
1477
1478 if (test_for_null_also) {
1479 // Failed the equality check on item[n]... Test for null.
1480 testptr(reg2, reg2);
1481 if (start_row == last_row) {
1482 // The only thing left to do is handle the null case.
1483 Label found_null;
1484 jccb(Assembler::zero, found_null);
1485 // Item did not match any saved item and there is no empty row for it.
1486 // Increment total counter to indicate polymorphic case.
1487 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1488 jmp(done);
1489 bind(found_null);
1490 break;
1491 }
1492 Label found_null;
1493 // Since null is rare, make it be the branch-taken case.
1494 jcc(Assembler::zero, found_null);
1495
1496 // Put all the "Case 3" tests here.
1497 record_item_in_profile_helper(item, mdp, reg2, start_row + 1, done, total_rows,
1498 item_offset_fn, item_count_offset_fn);
1499
1500 // Found a null. Keep searching for a matching item,
1501 // but remember that this is an empty (unused) slot.
1502 bind(found_null);
1503 }
1504 }
1505
1506 // In the fall-through case, we found no matching item, but we
1507 // observed the item[start_row] is null.
1508
1509 // Fill in the item field and increment the count.
1510 int item_offset = in_bytes(item_offset_fn(start_row));
1511 set_mdp_data_at(mdp, item_offset, item);
1512 int count_offset = in_bytes(item_count_offset_fn(start_row));
1513 movl(reg2, DataLayout::counter_increment);
1514 set_mdp_data_at(mdp, count_offset, reg2);
1515 if (start_row > 0) {
1516 jmp(done);
1517 }
1518 }
1519
1520 // Example state machine code for three profile rows:
1521 // // main copy of decision tree, rooted at row[1]
1522 // if (row[0].rec == rec) { row[0].incr(); goto done; }
1523 // if (row[0].rec != nullptr) {
1524 // // inner copy of decision tree, rooted at row[1]
1525 // if (row[1].rec == rec) { row[1].incr(); goto done; }
1526 // if (row[1].rec != nullptr) {
1527 // // degenerate decision tree, rooted at row[2]
1528 // if (row[2].rec == rec) { row[2].incr(); goto done; }
1529 // if (row[2].rec != nullptr) { count.incr(); goto done; } // overflow
1530 // row[2].init(rec); goto done;
1531 // } else {
1532 // // remember row[1] is empty
1533 // if (row[2].rec == rec) { row[2].incr(); goto done; }
1534 // row[1].init(rec); goto done;
1535 // }
1536 // } else {
1537 // // remember row[0] is empty
1538 // if (row[1].rec == rec) { row[1].incr(); goto done; }
1539 // if (row[2].rec == rec) { row[2].incr(); goto done; }
1540 // row[0].init(rec); goto done;
1541 // }
1542 // done:
1543
1544 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
1545 Register mdp, Register reg2,
1546 bool is_virtual_call) {
1547 assert(ProfileInterpreter, "must be profiling");
1548 Label done;
1549
1550 record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call);
1551
1552 bind (done);
1553 }
1554
1555 void InterpreterMacroAssembler::profile_ret(Register return_bci,
1556 Register mdp) {
1557 if (ProfileInterpreter) {
1558 Label profile_continue;
1559 uint row;
1560
1561 // If no method data exists, go to profile_continue.
1562 test_method_data_pointer(mdp, profile_continue);
1563
1564 // Update the total ret count.
1565 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1566
1567 for (row = 0; row < RetData::row_limit(); row++) {
1568 Label next_test;
1569
1570 // See if return_bci is equal to bci[n]:
1571 test_mdp_data_at(mdp,
1572 in_bytes(RetData::bci_offset(row)),
1573 return_bci, noreg,
1574 next_test);
1575
1576 // return_bci is equal to bci[n]. Increment the count.
1577 increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row)));
1578
1579 // The method data pointer needs to be updated to reflect the new target.
1580 update_mdp_by_offset(mdp,
1581 in_bytes(RetData::bci_displacement_offset(row)));
1582 jmp(profile_continue);
1583 bind(next_test);
1584 }
1585
1586 update_mdp_for_ret(return_bci);
1587
1588 bind(profile_continue);
1589 }
1590 }
1591
1592
1593 void InterpreterMacroAssembler::profile_null_seen(Register mdp) {
1594 if (ProfileInterpreter) {
1595 Label profile_continue;
1596
1597 // If no method data exists, go to profile_continue.
1598 test_method_data_pointer(mdp, profile_continue);
1599
1600 set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
1601
1602 // The method data pointer needs to be updated.
1603 int mdp_delta = in_bytes(BitData::bit_data_size());
1604 if (TypeProfileCasts) {
1605 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
1606 }
1607 update_mdp_by_constant(mdp, mdp_delta);
1608
1609 bind(profile_continue);
1610 }
1611 }
1612
1613
1614 void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) {
1615 if (ProfileInterpreter) {
1616 Label profile_continue;
1617
1618 // If no method data exists, go to profile_continue.
1619 test_method_data_pointer(mdp, profile_continue);
1620
1621 // The method data pointer needs to be updated.
1622 int mdp_delta = in_bytes(BitData::bit_data_size());
1623 if (TypeProfileCasts) {
1624 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
1625
1626 // Record the object type.
1627 record_klass_in_profile(klass, mdp, reg2, false);
1628 }
1629 update_mdp_by_constant(mdp, mdp_delta);
1630
1631 bind(profile_continue);
1632 }
1633 }
1634
1635
1636 void InterpreterMacroAssembler::profile_switch_default(Register mdp) {
1637 if (ProfileInterpreter) {
1638 Label profile_continue;
1639
1640 // If no method data exists, go to profile_continue.
1641 test_method_data_pointer(mdp, profile_continue);
1642
1643 // Update the default case count
1644 increment_mdp_data_at(mdp,
1645 in_bytes(MultiBranchData::default_count_offset()));
1646
1647 // The method data pointer needs to be updated.
1648 update_mdp_by_offset(mdp,
1649 in_bytes(MultiBranchData::
1650 default_displacement_offset()));
1651
1652 bind(profile_continue);
1653 }
1654 }
1655
1656
1657 void InterpreterMacroAssembler::profile_switch_case(Register index,
1658 Register mdp,
1659 Register reg2) {
1660 if (ProfileInterpreter) {
1661 Label profile_continue;
1662
1663 // If no method data exists, go to profile_continue.
1664 test_method_data_pointer(mdp, profile_continue);
1665
1666 // Build the base (index * per_case_size_in_bytes()) +
1667 // case_array_offset_in_bytes()
1668 movl(reg2, in_bytes(MultiBranchData::per_case_size()));
1669 imulptr(index, reg2); // XXX l ?
1670 addptr(index, in_bytes(MultiBranchData::case_array_offset())); // XXX l ?
1671
1672 // Update the case count
1673 increment_mdp_data_at(mdp,
1674 index,
1675 in_bytes(MultiBranchData::relative_count_offset()));
1676
1677 // The method data pointer needs to be updated.
1678 update_mdp_by_offset(mdp,
1679 index,
1680 in_bytes(MultiBranchData::
1681 relative_displacement_offset()));
1682
1683 bind(profile_continue);
1684 }
1685 }
1686
1687
1688
1689 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1690 if (state == atos) {
1691 MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
1692 }
1693 }
1694
1695
1696 // Jump if ((*counter_addr += increment) & mask) == 0
1697 void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr, Address mask,
1698 Register scratch, Label* where) {
1699 // This update is actually not atomic and can lose a number of updates
1700 // under heavy contention, but the alternative of using the (contended)
1701 // atomic update here penalizes profiling paths too much.
1702 movl(scratch, counter_addr);
1703 incrementl(scratch, InvocationCounter::count_increment);
1704 movl(counter_addr, scratch);
1705 andl(scratch, mask);
1706 if (where != nullptr) {
1707 jcc(Assembler::zero, *where);
1708 }
1709 }
1710
1711 void InterpreterMacroAssembler::notify_method_entry() {
1712 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1713 // track stack depth. If it is possible to enter interp_only_mode we add
1714 // the code to check if the event should be sent.
1715 Register rthread = r15_thread;
1716 Register rarg = c_rarg1;
1717 if (JvmtiExport::can_post_interpreter_events()) {
1718 Label L;
1719 movl(rdx, Address(rthread, JavaThread::interp_only_mode_offset()));
1720 testl(rdx, rdx);
1721 jcc(Assembler::zero, L);
1722 call_VM(noreg, CAST_FROM_FN_PTR(address,
1723 InterpreterRuntime::post_method_entry));
1724 bind(L);
1725 }
1726
1727 if (DTraceMethodProbes) {
1728 get_method(rarg);
1729 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
1730 rthread, rarg);
1731 }
1732
1733 // RedefineClasses() tracing support for obsolete method entry
1734 if (log_is_enabled(Trace, redefine, class, obsolete)) {
1735 get_method(rarg);
1736 call_VM_leaf(
1737 CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
1738 rthread, rarg);
1739 }
1740 }
1741
1742
1743 void InterpreterMacroAssembler::notify_method_exit(
1744 TosState state, NotifyMethodExitMode mode) {
1745 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1746 // track stack depth. If it is possible to enter interp_only_mode we add
1747 // the code to check if the event should be sent.
1748 Register rthread = r15_thread;
1749 Register rarg = c_rarg1;
1750 if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) {
1751 Label L;
1752 // Note: frame::interpreter_frame_result has a dependency on how the
1753 // method result is saved across the call to post_method_exit. If this
1754 // is changed then the interpreter_frame_result implementation will
1755 // need to be updated too.
1756
1757 // template interpreter will leave the result on the top of the stack.
1758 push(state);
1759 movl(rdx, Address(rthread, JavaThread::interp_only_mode_offset()));
1760 testl(rdx, rdx);
1761 jcc(Assembler::zero, L);
1762 call_VM(noreg,
1763 CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit));
1764 bind(L);
1765 pop(state);
1766 }
1767
1768 if (DTraceMethodProbes) {
1769 push(state);
1770 get_method(rarg);
1771 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
1772 rthread, rarg);
1773 pop(state);
1774 }
1775 }
1776
1777 void InterpreterMacroAssembler::load_resolved_indy_entry(Register cache, Register index) {
1778 // Get index out of bytecode pointer
1779 get_cache_index_at_bcp(index, 1, sizeof(u4));
1780 // Get address of invokedynamic array
1781 movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));
1782 movptr(cache, Address(cache, in_bytes(ConstantPoolCache::invokedynamic_entries_offset())));
1783 if (is_power_of_2(sizeof(ResolvedIndyEntry))) {
1784 shll(index, log2i_exact(sizeof(ResolvedIndyEntry))); // Scale index by power of 2
1785 } else {
1786 imull(index, index, sizeof(ResolvedIndyEntry)); // Scale the index to be the entry index * sizeof(ResolvedIndyEntry)
1787 }
1788 lea(cache, Address(cache, index, Address::times_1, Array<ResolvedIndyEntry>::base_offset_in_bytes()));
1789 }
1790
1791 void InterpreterMacroAssembler::load_field_entry(Register cache, Register index, int bcp_offset) {
1792 // Get index out of bytecode pointer
1793 movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));
1794 get_cache_index_at_bcp(index, bcp_offset, sizeof(u2));
1795
1796 movptr(cache, Address(cache, ConstantPoolCache::field_entries_offset()));
1797 // Take shortcut if the size is a power of 2
1798 if (is_power_of_2(sizeof(ResolvedFieldEntry))) {
1799 shll(index, log2i_exact(sizeof(ResolvedFieldEntry))); // Scale index by power of 2
1800 } else {
1801 imull(index, index, sizeof(ResolvedFieldEntry)); // Scale the index to be the entry index * sizeof(ResolvedFieldEntry)
1802 }
1803 lea(cache, Address(cache, index, Address::times_1, Array<ResolvedFieldEntry>::base_offset_in_bytes()));
1804 }
1805
1806 void InterpreterMacroAssembler::load_method_entry(Register cache, Register index, int bcp_offset) {
1807 // Get index out of bytecode pointer
1808 movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));
1809 get_cache_index_at_bcp(index, bcp_offset, sizeof(u2));
1810
1811 movptr(cache, Address(cache, ConstantPoolCache::method_entries_offset()));
1812 imull(index, index, sizeof(ResolvedMethodEntry)); // Scale the index to be the entry index * sizeof(ResolvedMethodEntry)
1813 lea(cache, Address(cache, index, Address::times_1, Array<ResolvedMethodEntry>::base_offset_in_bytes()));
1814 }