| /* | |
| * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. | |
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| * | |
| * This code is free software; you can redistribute it and/or modify it | |
| * under the terms of the GNU General Public License version 2 only, as | |
| * published by the Free Software Foundation. | |
| * | |
| * This code is distributed in the hope that it will be useful, but WITHOUT | |
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| * version 2 for more details (a copy is included in the LICENSE file that | |
| * accompanied this code). | |
| * | |
| * You should have received a copy of the GNU General Public License version | |
| * 2 along with this work; if not, write to the Free Software Foundation, | |
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| * | |
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| * or visit www.oracle.com if you need additional information or have any | |
| * questions. | |
| * | |
| */ | |
| #include "compiler/compiler_globals.hpp" | |
| #include "interp_masm_x86.hpp" | |
| #include "interpreter/interpreter.hpp" | |
| #include "interpreter/interpreterRuntime.hpp" | |
| #include "logging/log.hpp" | |
| #include "oops/arrayOop.hpp" | |
| #include "oops/markWord.hpp" | |
| #include "oops/methodData.hpp" | |
| #include "oops/method.hpp" | |
| #include "oops/resolvedFieldEntry.hpp" | |
| #include "oops/resolvedIndyEntry.hpp" | |
| #include "oops/resolvedMethodEntry.hpp" | |
| #include "prims/jvmtiExport.hpp" | |
| #include "prims/jvmtiThreadState.hpp" | |
| #include "runtime/basicLock.hpp" | |
| #include "runtime/frame.inline.hpp" | |
| #include "runtime/javaThread.hpp" | |
| #include "runtime/safepointMechanism.hpp" | |
| #include "runtime/sharedRuntime.hpp" | |
| #include "utilities/powerOfTwo.hpp" | |
| // Implementation of InterpreterMacroAssembler | |
| void InterpreterMacroAssembler::jump_to_entry(address entry) { | |
| assert(entry, "Entry must have been generated by now"); | |
| jump(RuntimeAddress(entry)); | |
| } | |
| void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { | |
| Label update, next, none; | |
| assert_different_registers(obj, rscratch1, mdo_addr.base(), mdo_addr.index()); | |
| interp_verify_oop(obj, atos); | |
| testptr(obj, obj); | |
| jccb(Assembler::notZero, update); | |
| testptr(mdo_addr, TypeEntries::null_seen); | |
| jccb(Assembler::notZero, next); // null already seen. Nothing to do anymore. | |
| // atomic update to prevent overwriting Klass* with 0 | |
| lock(); | |
| orptr(mdo_addr, TypeEntries::null_seen); | |
| jmpb(next); | |
| bind(update); | |
| load_klass(obj, obj, rscratch1); | |
| mov(rscratch1, obj); | |
| xorptr(obj, mdo_addr); | |
| testptr(obj, TypeEntries::type_klass_mask); | |
| jccb(Assembler::zero, next); // klass seen before, nothing to | |
| // do. The unknown bit may have been | |
| // set already but no need to check. | |
| testptr(obj, TypeEntries::type_unknown); | |
| jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore. | |
| cmpptr(mdo_addr, 0); | |
| jccb(Assembler::equal, none); | |
| cmpptr(mdo_addr, TypeEntries::null_seen); | |
| jccb(Assembler::equal, none); | |
| // There is a chance that the checks above (re-reading profiling | |
| // data from memory) fail if another thread has just set the | |
| // profiling to this obj's klass | |
| mov(obj, rscratch1); | |
| xorptr(obj, mdo_addr); | |
| testptr(obj, TypeEntries::type_klass_mask); | |
| jccb(Assembler::zero, next); | |
| // different than before. Cannot keep accurate profile. | |
| orptr(mdo_addr, TypeEntries::type_unknown); | |
| jmpb(next); | |
| bind(none); | |
| // first time here. Set profile type. | |
| movptr(mdo_addr, obj); | |
| #ifdef ASSERT | |
| andptr(obj, TypeEntries::type_klass_mask); | |
| verify_klass_ptr(obj); | |
| #endif | |
| bind(next); | |
| } | |
| void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { | |
| if (!ProfileInterpreter) { | |
| return; | |
| } | |
| if (MethodData::profile_arguments() || MethodData::profile_return()) { | |
| Label profile_continue; | |
| test_method_data_pointer(mdp, profile_continue); | |
| int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); | |
| cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); | |
| jcc(Assembler::notEqual, profile_continue); | |
| if (MethodData::profile_arguments()) { | |
| Label done; | |
| int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); | |
| addptr(mdp, off_to_args); | |
| for (int i = 0; i < TypeProfileArgsLimit; i++) { | |
| if (i > 0 || MethodData::profile_return()) { | |
| // If return value type is profiled we may have no argument to profile | |
| movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); | |
| subl(tmp, i*TypeStackSlotEntries::per_arg_count()); | |
| cmpl(tmp, TypeStackSlotEntries::per_arg_count()); | |
| jcc(Assembler::less, done); | |
| } | |
| movptr(tmp, Address(callee, Method::const_offset())); | |
| load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); | |
| // stack offset o (zero based) from the start of the argument | |
| // list, for n arguments translates into offset n - o - 1 from | |
| // the end of the argument list | |
| subptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args)); | |
| subl(tmp, 1); | |
| Address arg_addr = argument_address(tmp); | |
| movptr(tmp, arg_addr); | |
| Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args); | |
| profile_obj_type(tmp, mdo_arg_addr); | |
| int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); | |
| addptr(mdp, to_add); | |
| off_to_args += to_add; | |
| } | |
| if (MethodData::profile_return()) { | |
| movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); | |
| subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); | |
| } | |
| bind(done); | |
| if (MethodData::profile_return()) { | |
| // We're right after the type profile for the last | |
| // argument. tmp is the number of cells left in the | |
| // CallTypeData/VirtualCallTypeData to reach its end. Non null | |
| // if there's a return to profile. | |
| assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type"); | |
| shll(tmp, log2i_exact((int)DataLayout::cell_size)); | |
| addptr(mdp, tmp); | |
| } | |
| movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp); | |
| } else { | |
| assert(MethodData::profile_return(), "either profile call args or call ret"); | |
| update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size())); | |
| } | |
| // mdp points right after the end of the | |
| // CallTypeData/VirtualCallTypeData, right after the cells for the | |
| // return value type if there's one | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) { | |
| assert_different_registers(mdp, ret, tmp, _bcp_register); | |
| if (ProfileInterpreter && MethodData::profile_return()) { | |
| Label profile_continue; | |
| test_method_data_pointer(mdp, profile_continue); | |
| if (MethodData::profile_return_jsr292_only()) { | |
| assert(Method::intrinsic_id_size_in_bytes() == 2, "assuming Method::_intrinsic_id is u2"); | |
| // If we don't profile all invoke bytecodes we must make sure | |
| // it's a bytecode we indeed profile. We can't go back to the | |
| // beginning of the ProfileData we intend to update to check its | |
| // type because we're right after it and we don't known its | |
| // length | |
| Label do_profile; | |
| cmpb(Address(_bcp_register, 0), Bytecodes::_invokedynamic); | |
| jcc(Assembler::equal, do_profile); | |
| cmpb(Address(_bcp_register, 0), Bytecodes::_invokehandle); | |
| jcc(Assembler::equal, do_profile); | |
| get_method(tmp); | |
| cmpw(Address(tmp, Method::intrinsic_id_offset()), static_cast<int>(vmIntrinsics::_compiledLambdaForm)); | |
| jcc(Assembler::notEqual, profile_continue); | |
| bind(do_profile); | |
| } | |
| Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size())); | |
| mov(tmp, ret); | |
| profile_obj_type(tmp, mdo_ret_addr); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) { | |
| if (ProfileInterpreter && MethodData::profile_parameters()) { | |
| Label profile_continue; | |
| test_method_data_pointer(mdp, profile_continue); | |
| // Load the offset of the area within the MDO used for | |
| // parameters. If it's negative we're not profiling any parameters | |
| movl(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset()))); | |
| testl(tmp1, tmp1); | |
| jcc(Assembler::negative, profile_continue); | |
| // Compute a pointer to the area for parameters from the offset | |
| // and move the pointer to the slot for the last | |
| // parameters. Collect profiling from last parameter down. | |
| // mdo start + parameters offset + array length - 1 | |
| addptr(mdp, tmp1); | |
| movptr(tmp1, Address(mdp, ArrayData::array_len_offset())); | |
| decrement(tmp1, TypeStackSlotEntries::per_arg_count()); | |
| Label loop; | |
| bind(loop); | |
| int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0)); | |
| int type_base = in_bytes(ParametersTypeData::type_offset(0)); | |
| Address::ScaleFactor per_arg_scale = Address::times(DataLayout::cell_size); | |
| Address arg_off(mdp, tmp1, per_arg_scale, off_base); | |
| Address arg_type(mdp, tmp1, per_arg_scale, type_base); | |
| // load offset on the stack from the slot for this parameter | |
| movptr(tmp2, arg_off); | |
| negptr(tmp2); | |
| // read the parameter from the local area | |
| movptr(tmp2, Address(_locals_register, tmp2, Interpreter::stackElementScale())); | |
| // profile the parameter | |
| profile_obj_type(tmp2, arg_type); | |
| // go to next parameter | |
| decrement(tmp1, TypeStackSlotEntries::per_arg_count()); | |
| jcc(Assembler::positive, loop); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point, | |
| int number_of_arguments) { | |
| // interpreter specific | |
| // | |
| // Note: No need to save/restore bcp & locals registers | |
| // since these are callee saved registers and no blocking/ | |
| // GC can happen in leaf calls. | |
| // Further Note: DO NOT save/restore bcp/locals. If a caller has | |
| // already saved them so that it can use rsi/rdi as temporaries | |
| // then a save/restore here will DESTROY the copy the caller | |
| // saved! There used to be a save_bcp() that only happened in | |
| // the ASSERT path (no restore_bcp). Which caused bizarre failures | |
| // when jvm built with ASSERTs. | |
| #ifdef ASSERT | |
| { | |
| Label L; | |
| cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); | |
| jcc(Assembler::equal, L); | |
| stop("InterpreterMacroAssembler::call_VM_leaf_base:" | |
| " last_sp != null"); | |
| bind(L); | |
| } | |
| #endif | |
| // super call | |
| MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments); | |
| // interpreter specific | |
| // LP64: Used to ASSERT that r13/r14 were equal to frame's bcp/locals | |
| // but since they may not have been saved (and we don't want to | |
| // save them here (see note above) the assert is invalid. | |
| } | |
| void InterpreterMacroAssembler::call_VM_base(Register oop_result, | |
| Register last_java_sp, | |
| address entry_point, | |
| int number_of_arguments, | |
| bool check_exceptions) { | |
| // interpreter specific | |
| // | |
| // Note: Could avoid restoring locals ptr (callee saved) - however doesn't | |
| // really make a difference for these runtime calls, since they are | |
| // slow anyway. Btw., bcp must be saved/restored since it may change | |
| // due to GC. | |
| save_bcp(); | |
| #ifdef ASSERT | |
| { | |
| Label L; | |
| cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); | |
| jcc(Assembler::equal, L); | |
| stop("InterpreterMacroAssembler::call_VM_base:" | |
| " last_sp isn't null"); | |
| bind(L); | |
| } | |
| #endif /* ASSERT */ | |
| // super call | |
| MacroAssembler::call_VM_base(oop_result, last_java_sp, | |
| entry_point, number_of_arguments, | |
| check_exceptions); | |
| // interpreter specific | |
| restore_bcp(); | |
| restore_locals(); | |
| } | |
| void InterpreterMacroAssembler::call_VM_preemptable(Register oop_result, | |
| address entry_point, | |
| Register arg_1) { | |
| assert(arg_1 == c_rarg1, ""); | |
| Label resume_pc, not_preempted; | |
| #ifdef ASSERT | |
| { | |
| Label L; | |
| cmpptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD); | |
| jcc(Assembler::equal, L); | |
| stop("Should not have alternate return address set"); | |
| bind(L); | |
| } | |
| #endif /* ASSERT */ | |
| // Force freeze slow path. | |
| push_cont_fastpath(); | |
| // Make VM call. In case of preemption set last_pc to the one we want to resume to. | |
| // Note: call_VM_helper requires last_Java_pc for anchor to be at the top of the stack. | |
| lea(rscratch1, resume_pc); | |
| push(rscratch1); | |
| MacroAssembler::call_VM_helper(oop_result, entry_point, 1, false /*check_exceptions*/); | |
| pop(rscratch1); | |
| pop_cont_fastpath(); | |
| // Check if preempted. | |
| movptr(rscratch1, Address(r15_thread, JavaThread::preempt_alternate_return_offset())); | |
| cmpptr(rscratch1, NULL_WORD); | |
| jccb(Assembler::zero, not_preempted); | |
| movptr(Address(r15_thread, JavaThread::preempt_alternate_return_offset()), NULL_WORD); | |
| jmp(rscratch1); | |
| // In case of preemption, this is where we will resume once we finally acquire the monitor. | |
| bind(resume_pc); | |
| restore_after_resume(false /* is_native */); | |
| bind(not_preempted); | |
| } | |
| void InterpreterMacroAssembler::restore_after_resume(bool is_native) { | |
| lea(rscratch1, ExternalAddress(Interpreter::cont_resume_interpreter_adapter())); | |
| call(rscratch1); | |
| if (is_native) { | |
| // On resume we need to set up stack as expected. | |
| push(dtos); | |
| push(ltos); | |
| } | |
| } | |
| void InterpreterMacroAssembler::check_and_handle_popframe() { | |
| if (JvmtiExport::can_pop_frame()) { | |
| Label L; | |
| // Initiate popframe handling only if it is not already being | |
| // processed. If the flag has the popframe_processing bit set, it | |
| // means that this code is called *during* popframe handling - we | |
| // don't want to reenter. | |
| // This method is only called just after the call into the vm in | |
| // call_VM_base, so the arg registers are available. | |
| Register pop_cond = c_rarg0; | |
| movl(pop_cond, Address(r15_thread, JavaThread::popframe_condition_offset())); | |
| testl(pop_cond, JavaThread::popframe_pending_bit); | |
| jcc(Assembler::zero, L); | |
| testl(pop_cond, JavaThread::popframe_processing_bit); | |
| jcc(Assembler::notZero, L); | |
| // Call Interpreter::remove_activation_preserving_args_entry() to get the | |
| // address of the same-named entrypoint in the generated interpreter code. | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry)); | |
| jmp(rax); | |
| bind(L); | |
| } | |
| } | |
| void InterpreterMacroAssembler::load_earlyret_value(TosState state) { | |
| movptr(rcx, Address(r15_thread, JavaThread::jvmti_thread_state_offset())); | |
| const Address tos_addr(rcx, JvmtiThreadState::earlyret_tos_offset()); | |
| const Address oop_addr(rcx, JvmtiThreadState::earlyret_oop_offset()); | |
| const Address val_addr(rcx, JvmtiThreadState::earlyret_value_offset()); | |
| switch (state) { | |
| case atos: movptr(rax, oop_addr); | |
| movptr(oop_addr, NULL_WORD); | |
| interp_verify_oop(rax, state); break; | |
| case ltos: movptr(rax, val_addr); break; | |
| case btos: // fall through | |
| case ztos: // fall through | |
| case ctos: // fall through | |
| case stos: // fall through | |
| case itos: movl(rax, val_addr); break; | |
| case ftos: movflt(xmm0, val_addr); break; | |
| case dtos: movdbl(xmm0, val_addr); break; | |
| case vtos: /* nothing to do */ break; | |
| default : ShouldNotReachHere(); | |
| } | |
| // Clean up tos value in the thread object | |
| movl(tos_addr, ilgl); | |
| movptr(val_addr, NULL_WORD); | |
| } | |
| void InterpreterMacroAssembler::check_and_handle_earlyret() { | |
| if (JvmtiExport::can_force_early_return()) { | |
| Label L; | |
| Register tmp = c_rarg0; | |
| Register rthread = r15_thread; | |
| movptr(tmp, Address(rthread, JavaThread::jvmti_thread_state_offset())); | |
| testptr(tmp, tmp); | |
| jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == nullptr) exit; | |
| // Initiate earlyret handling only if it is not already being processed. | |
| // If the flag has the earlyret_processing bit set, it means that this code | |
| // is called *during* earlyret handling - we don't want to reenter. | |
| movl(tmp, Address(tmp, JvmtiThreadState::earlyret_state_offset())); | |
| cmpl(tmp, JvmtiThreadState::earlyret_pending); | |
| jcc(Assembler::notEqual, L); | |
| // Call Interpreter::remove_activation_early_entry() to get the address of the | |
| // same-named entrypoint in the generated interpreter code. | |
| movptr(tmp, Address(rthread, JavaThread::jvmti_thread_state_offset())); | |
| movl(tmp, Address(tmp, JvmtiThreadState::earlyret_tos_offset())); | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), tmp); | |
| jmp(rax); | |
| bind(L); | |
| } | |
| } | |
| void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) { | |
| assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode"); | |
| load_unsigned_short(reg, Address(_bcp_register, bcp_offset)); | |
| bswapl(reg); | |
| shrl(reg, 16); | |
| } | |
| void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index, | |
| int bcp_offset, | |
| size_t index_size) { | |
| assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); | |
| if (index_size == sizeof(u2)) { | |
| load_unsigned_short(index, Address(_bcp_register, bcp_offset)); | |
| } else if (index_size == sizeof(u4)) { | |
| movl(index, Address(_bcp_register, bcp_offset)); | |
| } else if (index_size == sizeof(u1)) { | |
| load_unsigned_byte(index, Address(_bcp_register, bcp_offset)); | |
| } else { | |
| ShouldNotReachHere(); | |
| } | |
| } | |
| // Load object from cpool->resolved_references(index) | |
| void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, | |
| Register index, | |
| Register tmp) { | |
| assert_different_registers(result, index); | |
| get_constant_pool(result); | |
| // load pointer for resolved_references[] objArray | |
| movptr(result, Address(result, ConstantPool::cache_offset())); | |
| movptr(result, Address(result, ConstantPoolCache::resolved_references_offset())); | |
| resolve_oop_handle(result, tmp); | |
| load_heap_oop(result, Address(result, index, | |
| UseCompressedOops ? Address::times_4 : Address::times_ptr, | |
| arrayOopDesc::base_offset_in_bytes(T_OBJECT)), tmp); | |
| } | |
| // load cpool->resolved_klass_at(index) | |
| void InterpreterMacroAssembler::load_resolved_klass_at_index(Register klass, | |
| Register cpool, | |
| Register index) { | |
| assert_different_registers(cpool, index); | |
| movw(index, Address(cpool, index, Address::times_ptr, sizeof(ConstantPool))); | |
| Register resolved_klasses = cpool; | |
| movptr(resolved_klasses, Address(cpool, ConstantPool::resolved_klasses_offset())); | |
| movptr(klass, Address(resolved_klasses, index, Address::times_ptr, Array<Klass*>::base_offset_in_bytes())); | |
| } | |
| // Generate a subtype check: branch to ok_is_subtype if sub_klass is a | |
| // subtype of super_klass. | |
| // | |
| // Args: | |
| // rax: superklass | |
| // Rsub_klass: subklass | |
| // | |
| // Kills: | |
| // rcx, rdi | |
| void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, | |
| Label& ok_is_subtype) { | |
| assert(Rsub_klass != rax, "rax holds superklass"); | |
| LP64_ONLY(assert(Rsub_klass != r14, "r14 holds locals");) | |
| LP64_ONLY(assert(Rsub_klass != r13, "r13 holds bcp");) | |
| assert(Rsub_klass != rcx, "rcx holds 2ndary super array length"); | |
| assert(Rsub_klass != rdi, "rdi holds 2ndary super array scan ptr"); | |
| // Profile the not-null value's klass. | |
| profile_typecheck(rcx, Rsub_klass, rdi); // blows rcx, reloads rdi | |
| // Do the check. | |
| check_klass_subtype(Rsub_klass, rax, rcx, ok_is_subtype); // blows rcx | |
| } | |
| // Java Expression Stack | |
| void InterpreterMacroAssembler::pop_ptr(Register r) { | |
| pop(r); | |
| } | |
| void InterpreterMacroAssembler::push_ptr(Register r) { | |
| push(r); | |
| } | |
| void InterpreterMacroAssembler::push_i(Register r) { | |
| push(r); | |
| } | |
| void InterpreterMacroAssembler::push_i_or_ptr(Register r) { | |
| push(r); | |
| } | |
| void InterpreterMacroAssembler::push_f(XMMRegister r) { | |
| subptr(rsp, wordSize); | |
| movflt(Address(rsp, 0), r); | |
| } | |
| void InterpreterMacroAssembler::pop_f(XMMRegister r) { | |
| movflt(r, Address(rsp, 0)); | |
| addptr(rsp, wordSize); | |
| } | |
| void InterpreterMacroAssembler::push_d(XMMRegister r) { | |
| subptr(rsp, 2 * wordSize); | |
| movdbl(Address(rsp, 0), r); | |
| } | |
| void InterpreterMacroAssembler::pop_d(XMMRegister r) { | |
| movdbl(r, Address(rsp, 0)); | |
| addptr(rsp, 2 * Interpreter::stackElementSize); | |
| } | |
| void InterpreterMacroAssembler::pop_i(Register r) { | |
| // XXX can't use pop currently, upper half non clean | |
| movl(r, Address(rsp, 0)); | |
| addptr(rsp, wordSize); | |
| } | |
| void InterpreterMacroAssembler::pop_l(Register r) { | |
| movq(r, Address(rsp, 0)); | |
| addptr(rsp, 2 * Interpreter::stackElementSize); | |
| } | |
| void InterpreterMacroAssembler::push_l(Register r) { | |
| subptr(rsp, 2 * wordSize); | |
| movptr(Address(rsp, Interpreter::expr_offset_in_bytes(0)), r ); | |
| movptr(Address(rsp, Interpreter::expr_offset_in_bytes(1)), NULL_WORD ); | |
| } | |
| void InterpreterMacroAssembler::pop(TosState state) { | |
| switch (state) { | |
| case atos: pop_ptr(); break; | |
| case btos: | |
| case ztos: | |
| case ctos: | |
| case stos: | |
| case itos: pop_i(); break; | |
| case ltos: pop_l(); break; | |
| case ftos: pop_f(xmm0); break; | |
| case dtos: pop_d(xmm0); break; | |
| case vtos: /* nothing to do */ break; | |
| default: ShouldNotReachHere(); | |
| } | |
| interp_verify_oop(rax, state); | |
| } | |
| void InterpreterMacroAssembler::push(TosState state) { | |
| interp_verify_oop(rax, state); | |
| switch (state) { | |
| case atos: push_ptr(); break; | |
| case btos: | |
| case ztos: | |
| case ctos: | |
| case stos: | |
| case itos: push_i(); break; | |
| case ltos: push_l(); break; | |
| case ftos: push_f(xmm0); break; | |
| case dtos: push_d(xmm0); break; | |
| case vtos: /* nothing to do */ break; | |
| default : ShouldNotReachHere(); | |
| } | |
| } | |
| // Helpers for swap and dup | |
| void InterpreterMacroAssembler::load_ptr(int n, Register val) { | |
| movptr(val, Address(rsp, Interpreter::expr_offset_in_bytes(n))); | |
| } | |
| void InterpreterMacroAssembler::store_ptr(int n, Register val) { | |
| movptr(Address(rsp, Interpreter::expr_offset_in_bytes(n)), val); | |
| } | |
| void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() { | |
| // set sender sp | |
| lea(_bcp_register, Address(rsp, wordSize)); | |
| // record last_sp | |
| mov(rcx, _bcp_register); | |
| subptr(rcx, rbp); | |
| sarptr(rcx, LogBytesPerWord); | |
| movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), rcx); | |
| } | |
| // Jump to from_interpreted entry of a call unless single stepping is possible | |
| // in this thread in which case we must call the i2i entry | |
| void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) { | |
| prepare_to_jump_from_interpreted(); | |
| if (JvmtiExport::can_post_interpreter_events()) { | |
| Label run_compiled_code; | |
| // JVMTI events, such as single-stepping, are implemented partly by avoiding running | |
| // compiled code in threads for which the event is enabled. Check here for | |
| // interp_only_mode if these events CAN be enabled. | |
| // interp_only is an int, on little endian it is sufficient to test the byte only | |
| // Is a cmpl faster? | |
| cmpb(Address(r15_thread, JavaThread::interp_only_mode_offset()), 0); | |
| jccb(Assembler::zero, run_compiled_code); | |
| jmp(Address(method, Method::interpreter_entry_offset())); | |
| bind(run_compiled_code); | |
| } | |
| jmp(Address(method, Method::from_interpreted_offset())); | |
| } | |
| // The following two routines provide a hook so that an implementation | |
| // can schedule the dispatch in two parts. x86 does not do this. | |
| void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) { | |
| // Nothing x86 specific to be done here | |
| } | |
| void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) { | |
| dispatch_next(state, step); | |
| } | |
| void InterpreterMacroAssembler::dispatch_base(TosState state, | |
| address* table, | |
| bool verifyoop, | |
| bool generate_poll) { | |
| if (VerifyActivationFrameSize) { | |
| Label L; | |
| mov(rcx, rbp); | |
| subptr(rcx, rsp); | |
| int32_t min_frame_size = | |
| (frame::link_offset - frame::interpreter_frame_initial_sp_offset) * | |
| wordSize; | |
| cmpptr(rcx, min_frame_size); | |
| jcc(Assembler::greaterEqual, L); | |
| stop("broken stack frame"); | |
| bind(L); | |
| } | |
| if (verifyoop) { | |
| interp_verify_oop(rax, state); | |
| } | |
| address* const safepoint_table = Interpreter::safept_table(state); | |
| Label no_safepoint, dispatch; | |
| if (table != safepoint_table && generate_poll) { | |
| NOT_PRODUCT(block_comment("Thread-local Safepoint poll")); | |
| testb(Address(r15_thread, JavaThread::polling_word_offset()), SafepointMechanism::poll_bit()); | |
| jccb(Assembler::zero, no_safepoint); | |
| lea(rscratch1, ExternalAddress((address)safepoint_table)); | |
| jmpb(dispatch); | |
| } | |
| bind(no_safepoint); | |
| lea(rscratch1, ExternalAddress((address)table)); | |
| bind(dispatch); | |
| jmp(Address(rscratch1, rbx, Address::times_8)); | |
| } | |
| void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) { | |
| dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll); | |
| } | |
| void InterpreterMacroAssembler::dispatch_only_normal(TosState state) { | |
| dispatch_base(state, Interpreter::normal_table(state)); | |
| } | |
| void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) { | |
| dispatch_base(state, Interpreter::normal_table(state), false); | |
| } | |
| void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) { | |
| // load next bytecode (load before advancing _bcp_register to prevent AGI) | |
| load_unsigned_byte(rbx, Address(_bcp_register, step)); | |
| // advance _bcp_register | |
| increment(_bcp_register, step); | |
| dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll); | |
| } | |
| void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) { | |
| // load current bytecode | |
| load_unsigned_byte(rbx, Address(_bcp_register, 0)); | |
| dispatch_base(state, table); | |
| } | |
| void InterpreterMacroAssembler::narrow(Register result) { | |
| // Get method->_constMethod->_result_type | |
| movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); | |
| movptr(rcx, Address(rcx, Method::const_offset())); | |
| load_unsigned_byte(rcx, Address(rcx, ConstMethod::result_type_offset())); | |
| Label done, notBool, notByte, notChar; | |
| // common case first | |
| cmpl(rcx, T_INT); | |
| jcc(Assembler::equal, done); | |
| // mask integer result to narrower return type. | |
| cmpl(rcx, T_BOOLEAN); | |
| jcc(Assembler::notEqual, notBool); | |
| andl(result, 0x1); | |
| jmp(done); | |
| bind(notBool); | |
| cmpl(rcx, T_BYTE); | |
| jcc(Assembler::notEqual, notByte); | |
| movsbl(result, result); | |
| jmp(done); | |
| bind(notByte); | |
| cmpl(rcx, T_CHAR); | |
| jcc(Assembler::notEqual, notChar); | |
| movzwl(result, result); | |
| jmp(done); | |
| bind(notChar); | |
| // cmpl(rcx, T_SHORT); // all that's left | |
| // jcc(Assembler::notEqual, done); | |
| movswl(result, result); | |
| // Nothing to do for T_INT | |
| bind(done); | |
| } | |
| // remove activation | |
| // | |
| // Unlock the receiver if this is a synchronized method. | |
| // Unlock any Java monitors from synchronized blocks. | |
| // Apply stack watermark barrier. | |
| // Notify JVMTI. | |
| // Remove the activation from the stack. | |
| // | |
| // If there are locked Java monitors | |
| // If throw_monitor_exception | |
| // throws IllegalMonitorStateException | |
| // Else if install_monitor_exception | |
| // installs IllegalMonitorStateException | |
| // Else | |
| // no error processing | |
| void InterpreterMacroAssembler::remove_activation(TosState state, | |
| Register ret_addr, | |
| bool throw_monitor_exception, | |
| bool install_monitor_exception, | |
| bool notify_jvmdi) { | |
| // Note: Registers rdx xmm0 may be in use for the | |
| // result check if synchronized method | |
| Label unlocked, unlock, no_unlock; | |
| const Register rthread = r15_thread; | |
| const Register robj = c_rarg1; | |
| const Register rmon = c_rarg1; | |
| // get the value of _do_not_unlock_if_synchronized into rdx | |
| const Address do_not_unlock_if_synchronized(rthread, | |
| in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); | |
| movbool(rbx, do_not_unlock_if_synchronized); | |
| movbool(do_not_unlock_if_synchronized, false); // reset the flag | |
| // get method access flags | |
| movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); | |
| load_unsigned_short(rcx, Address(rcx, Method::access_flags_offset())); | |
| testl(rcx, JVM_ACC_SYNCHRONIZED); | |
| jcc(Assembler::zero, unlocked); | |
| // Don't unlock anything if the _do_not_unlock_if_synchronized flag | |
| // is set. | |
| testbool(rbx); | |
| jcc(Assembler::notZero, no_unlock); | |
| // unlock monitor | |
| push(state); // save result | |
| // BasicObjectLock will be first in list, since this is a | |
| // synchronized method. However, need to check that the object has | |
| // not been unlocked by an explicit monitorexit bytecode. | |
| const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset * | |
| wordSize - (int) sizeof(BasicObjectLock)); | |
| // We use c_rarg1/rdx so that if we go slow path it will be the correct | |
| // register for unlock_object to pass to VM directly | |
| lea(robj, monitor); // address of first monitor | |
| movptr(rax, Address(robj, BasicObjectLock::obj_offset())); | |
| testptr(rax, rax); | |
| jcc(Assembler::notZero, unlock); | |
| pop(state); | |
| if (throw_monitor_exception) { | |
| // Entry already unlocked, need to throw exception | |
| call_VM(noreg, CAST_FROM_FN_PTR(address, | |
| InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
| should_not_reach_here(); | |
| } else { | |
| // Monitor already unlocked during a stack unroll. If requested, | |
| // install an illegal_monitor_state_exception. Continue with | |
| // stack unrolling. | |
| if (install_monitor_exception) { | |
| call_VM(noreg, CAST_FROM_FN_PTR(address, | |
| InterpreterRuntime::new_illegal_monitor_state_exception)); | |
| } | |
| jmp(unlocked); | |
| } | |
| bind(unlock); | |
| unlock_object(robj); | |
| pop(state); | |
| // Check that for block-structured locking (i.e., that all locked | |
| // objects has been unlocked) | |
| bind(unlocked); | |
| // rax, rdx: Might contain return value | |
| // Check that all monitors are unlocked | |
| { | |
| Label loop, exception, entry, restart; | |
| const int entry_size = frame::interpreter_frame_monitor_size_in_bytes(); | |
| const Address monitor_block_top( | |
| rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
| const Address monitor_block_bot( | |
| rbp, frame::interpreter_frame_initial_sp_offset * wordSize); | |
| bind(restart); | |
| // We use c_rarg1 so that if we go slow path it will be the correct | |
| // register for unlock_object to pass to VM directly | |
| movptr(rmon, monitor_block_top); // derelativize pointer | |
| lea(rmon, Address(rbp, rmon, Address::times_ptr)); | |
| // c_rarg1 points to current entry, starting with top-most entry | |
| lea(rbx, monitor_block_bot); // points to word before bottom of | |
| // monitor block | |
| jmp(entry); | |
| // Entry already locked, need to throw exception | |
| bind(exception); | |
| if (throw_monitor_exception) { | |
| // Throw exception | |
| MacroAssembler::call_VM(noreg, | |
| CAST_FROM_FN_PTR(address, InterpreterRuntime:: | |
| throw_illegal_monitor_state_exception)); | |
| should_not_reach_here(); | |
| } else { | |
| // Stack unrolling. Unlock object and install illegal_monitor_exception. | |
| // Unlock does not block, so don't have to worry about the frame. | |
| // We don't have to preserve c_rarg1 since we are going to throw an exception. | |
| push(state); | |
| mov(robj, rmon); // nop if robj and rmon are the same | |
| unlock_object(robj); | |
| pop(state); | |
| if (install_monitor_exception) { | |
| call_VM(noreg, CAST_FROM_FN_PTR(address, | |
| InterpreterRuntime:: | |
| new_illegal_monitor_state_exception)); | |
| } | |
| jmp(restart); | |
| } | |
| bind(loop); | |
| // check if current entry is used | |
| cmpptr(Address(rmon, BasicObjectLock::obj_offset()), NULL_WORD); | |
| jcc(Assembler::notEqual, exception); | |
| addptr(rmon, entry_size); // otherwise advance to next entry | |
| bind(entry); | |
| cmpptr(rmon, rbx); // check if bottom reached | |
| jcc(Assembler::notEqual, loop); // if not at bottom then check this entry | |
| } | |
| bind(no_unlock); | |
| JFR_ONLY(enter_jfr_critical_section();) | |
| // The below poll is for the stack watermark barrier. It allows fixing up frames lazily, | |
| // that would normally not be safe to use. Such bad returns into unsafe territory of | |
| // the stack, will call InterpreterRuntime::at_unwind. | |
| Label slow_path; | |
| Label fast_path; | |
| safepoint_poll(slow_path, true /* at_return */, false /* in_nmethod */); | |
| jmp(fast_path); | |
| bind(slow_path); | |
| push(state); | |
| set_last_Java_frame(noreg, rbp, (address)pc(), rscratch1); | |
| super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), r15_thread); | |
| reset_last_Java_frame(true); | |
| pop(state); | |
| bind(fast_path); | |
| // JVMTI support. Make sure the safepoint poll test is issued prior. | |
| if (notify_jvmdi) { | |
| notify_method_exit(state, NotifyJVMTI); // preserve TOSCA | |
| } else { | |
| notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA | |
| } | |
| // remove activation | |
| // get sender sp | |
| movptr(rbx, | |
| Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize)); | |
| if (StackReservedPages > 0) { | |
| // testing if reserved zone needs to be re-enabled | |
| Register rthread = r15_thread; | |
| Label no_reserved_zone_enabling; | |
| // check if already enabled - if so no re-enabling needed | |
| assert(sizeof(StackOverflow::StackGuardState) == 4, "unexpected size"); | |
| cmpl(Address(rthread, JavaThread::stack_guard_state_offset()), StackOverflow::stack_guard_enabled); | |
| jcc(Assembler::equal, no_reserved_zone_enabling); | |
| cmpptr(rbx, Address(rthread, JavaThread::reserved_stack_activation_offset())); | |
| jcc(Assembler::lessEqual, no_reserved_zone_enabling); | |
| JFR_ONLY(leave_jfr_critical_section();) | |
| call_VM_leaf( | |
| CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread); | |
| call_VM(noreg, CAST_FROM_FN_PTR(address, | |
| InterpreterRuntime::throw_delayed_StackOverflowError)); | |
| should_not_reach_here(); | |
| bind(no_reserved_zone_enabling); | |
| } | |
| leave(); // remove frame anchor | |
| JFR_ONLY(leave_jfr_critical_section();) | |
| pop(ret_addr); // get return address | |
| mov(rsp, rbx); // set sp to sender sp | |
| pop_cont_fastpath(); | |
| } | |
| #if INCLUDE_JFR | |
| void InterpreterMacroAssembler::enter_jfr_critical_section() { | |
| const Address sampling_critical_section(r15_thread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR)); | |
| movbool(sampling_critical_section, true); | |
| } | |
| void InterpreterMacroAssembler::leave_jfr_critical_section() { | |
| const Address sampling_critical_section(r15_thread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR)); | |
| movbool(sampling_critical_section, false); | |
| } | |
| #endif // INCLUDE_JFR | |
| void InterpreterMacroAssembler::get_method_counters(Register method, | |
| Register mcs, Label& skip) { | |
| Label has_counters; | |
| movptr(mcs, Address(method, Method::method_counters_offset())); | |
| testptr(mcs, mcs); | |
| jcc(Assembler::notZero, has_counters); | |
| call_VM(noreg, CAST_FROM_FN_PTR(address, | |
| InterpreterRuntime::build_method_counters), method); | |
| movptr(mcs, Address(method,Method::method_counters_offset())); | |
| testptr(mcs, mcs); | |
| jcc(Assembler::zero, skip); // No MethodCounters allocated, OutOfMemory | |
| bind(has_counters); | |
| } | |
| // Lock object | |
| // | |
| // Args: | |
| // rdx, c_rarg1: BasicObjectLock to be used for locking | |
| // | |
| // Kills: | |
| // rax, rbx | |
| void InterpreterMacroAssembler::lock_object(Register lock_reg) { | |
| assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1"); | |
| if (LockingMode == LM_MONITOR) { | |
| call_VM_preemptable(noreg, | |
| CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), | |
| lock_reg); | |
| } else { | |
| Label count_locking, done, slow_case; | |
| const Register swap_reg = rax; // Must use rax for cmpxchg instruction | |
| const Register tmp_reg = rbx; | |
| const Register obj_reg = c_rarg3; // Will contain the oop | |
| const Register rklass_decode_tmp = rscratch1; | |
| const int obj_offset = in_bytes(BasicObjectLock::obj_offset()); | |
| const int lock_offset = in_bytes(BasicObjectLock::lock_offset()); | |
| const int mark_offset = lock_offset + | |
| BasicLock::displaced_header_offset_in_bytes(); | |
| // Load object pointer into obj_reg | |
| movptr(obj_reg, Address(lock_reg, obj_offset)); | |
| if (LockingMode == LM_LIGHTWEIGHT) { | |
| lightweight_lock(lock_reg, obj_reg, swap_reg, tmp_reg, slow_case); | |
| } else if (LockingMode == LM_LEGACY) { | |
| if (DiagnoseSyncOnValueBasedClasses != 0) { | |
| load_klass(tmp_reg, obj_reg, rklass_decode_tmp); | |
| testb(Address(tmp_reg, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); | |
| jcc(Assembler::notZero, slow_case); | |
| } | |
| // Load immediate 1 into swap_reg %rax | |
| movl(swap_reg, 1); | |
| // Load (object->mark() | 1) into swap_reg %rax | |
| orptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes())); | |
| // Save (object->mark() | 1) into BasicLock's displaced header | |
| movptr(Address(lock_reg, mark_offset), swap_reg); | |
| assert(lock_offset == 0, | |
| "displaced header must be first word in BasicObjectLock"); | |
| lock(); | |
| cmpxchgptr(lock_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes())); | |
| jcc(Assembler::zero, count_locking); | |
| const int zero_bits = 7; | |
| // Fast check for recursive lock. | |
| // | |
| // Can apply the optimization only if this is a stack lock | |
| // allocated in this thread. For efficiency, we can focus on | |
| // recently allocated stack locks (instead of reading the stack | |
| // base and checking whether 'mark' points inside the current | |
| // thread stack): | |
| // 1) (mark & zero_bits) == 0, and | |
| // 2) rsp <= mark < mark + os::pagesize() | |
| // | |
| // Warning: rsp + os::pagesize can overflow the stack base. We must | |
| // neither apply the optimization for an inflated lock allocated | |
| // just above the thread stack (this is why condition 1 matters) | |
| // nor apply the optimization if the stack lock is inside the stack | |
| // of another thread. The latter is avoided even in case of overflow | |
| // because we have guard pages at the end of all stacks. Hence, if | |
| // we go over the stack base and hit the stack of another thread, | |
| // this should not be in a writeable area that could contain a | |
| // stack lock allocated by that thread. As a consequence, a stack | |
| // lock less than page size away from rsp is guaranteed to be | |
| // owned by the current thread. | |
| // | |
| // These 3 tests can be done by evaluating the following | |
| // expression: ((mark - rsp) & (zero_bits - os::vm_page_size())), | |
| // assuming both stack pointer and pagesize have their | |
| // least significant bits clear. | |
| // NOTE: the mark is in swap_reg %rax as the result of cmpxchg | |
| subptr(swap_reg, rsp); | |
| andptr(swap_reg, zero_bits - (int)os::vm_page_size()); | |
| // Save the test result, for recursive case, the result is zero | |
| movptr(Address(lock_reg, mark_offset), swap_reg); | |
| jcc(Assembler::notZero, slow_case); | |
| bind(count_locking); | |
| inc_held_monitor_count(); | |
| } | |
| jmp(done); | |
| bind(slow_case); | |
| // Call the runtime routine for slow case | |
| call_VM_preemptable(noreg, | |
| CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), | |
| lock_reg); | |
| bind(done); | |
| } | |
| } | |
| // Unlocks an object. Used in monitorexit bytecode and | |
| // remove_activation. Throws an IllegalMonitorException if object is | |
| // not locked by current thread. | |
| // | |
| // Args: | |
| // rdx, c_rarg1: BasicObjectLock for lock | |
| // | |
| // Kills: | |
| // rax | |
| // c_rarg0, c_rarg1, c_rarg2, c_rarg3, ... (param regs) | |
| // rscratch1 (scratch reg) | |
| // rax, rbx, rcx, rdx | |
| void InterpreterMacroAssembler::unlock_object(Register lock_reg) { | |
| assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1"); | |
| if (LockingMode == LM_MONITOR) { | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg); | |
| } else { | |
| Label count_locking, done, slow_case; | |
| const Register swap_reg = rax; // Must use rax for cmpxchg instruction | |
| const Register header_reg = c_rarg2; // Will contain the old oopMark | |
| const Register obj_reg = c_rarg3; // Will contain the oop | |
| save_bcp(); // Save in case of exception | |
| if (LockingMode != LM_LIGHTWEIGHT) { | |
| // Convert from BasicObjectLock structure to object and BasicLock | |
| // structure Store the BasicLock address into %rax | |
| lea(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset())); | |
| } | |
| // Load oop into obj_reg(%c_rarg3) | |
| movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset())); | |
| // Free entry | |
| movptr(Address(lock_reg, BasicObjectLock::obj_offset()), NULL_WORD); | |
| if (LockingMode == LM_LIGHTWEIGHT) { | |
| lightweight_unlock(obj_reg, swap_reg, header_reg, slow_case); | |
| } else if (LockingMode == LM_LEGACY) { | |
| // Load the old header from BasicLock structure | |
| movptr(header_reg, Address(swap_reg, | |
| BasicLock::displaced_header_offset_in_bytes())); | |
| // Test for recursion | |
| testptr(header_reg, header_reg); | |
| // zero for recursive case | |
| jcc(Assembler::zero, count_locking); | |
| // Atomic swap back the old header | |
| lock(); | |
| cmpxchgptr(header_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes())); | |
| // zero for simple unlock of a stack-lock case | |
| jcc(Assembler::notZero, slow_case); | |
| bind(count_locking); | |
| dec_held_monitor_count(); | |
| } | |
| jmp(done); | |
| bind(slow_case); | |
| // Call the runtime routine for slow case. | |
| movptr(Address(lock_reg, BasicObjectLock::obj_offset()), obj_reg); // restore obj | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg); | |
| bind(done); | |
| restore_bcp(); | |
| } | |
| } | |
| void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, | |
| Label& zero_continue) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| movptr(mdp, Address(rbp, frame::interpreter_frame_mdp_offset * wordSize)); | |
| testptr(mdp, mdp); | |
| jcc(Assembler::zero, zero_continue); | |
| } | |
| // Set the method data pointer for the current bcp. | |
| void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| Label set_mdp; | |
| push(rax); | |
| push(rbx); | |
| get_method(rbx); | |
| // Test MDO to avoid the call if it is null. | |
| movptr(rax, Address(rbx, in_bytes(Method::method_data_offset()))); | |
| testptr(rax, rax); | |
| jcc(Assembler::zero, set_mdp); | |
| // rbx: method | |
| // _bcp_register: bcp | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, _bcp_register); | |
| // rax: mdi | |
| // mdo is guaranteed to be non-zero here, we checked for it before the call. | |
| movptr(rbx, Address(rbx, in_bytes(Method::method_data_offset()))); | |
| addptr(rbx, in_bytes(MethodData::data_offset())); | |
| addptr(rax, rbx); | |
| bind(set_mdp); | |
| movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), rax); | |
| pop(rbx); | |
| pop(rax); | |
| } | |
| void InterpreterMacroAssembler::verify_method_data_pointer() { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| #ifdef ASSERT | |
| Label verify_continue; | |
| push(rax); | |
| push(rbx); | |
| Register arg3_reg = c_rarg3; | |
| Register arg2_reg = c_rarg2; | |
| push(arg3_reg); | |
| push(arg2_reg); | |
| test_method_data_pointer(arg3_reg, verify_continue); // If mdp is zero, continue | |
| get_method(rbx); | |
| // If the mdp is valid, it will point to a DataLayout header which is | |
| // consistent with the bcp. The converse is highly probable also. | |
| load_unsigned_short(arg2_reg, | |
| Address(arg3_reg, in_bytes(DataLayout::bci_offset()))); | |
| addptr(arg2_reg, Address(rbx, Method::const_offset())); | |
| lea(arg2_reg, Address(arg2_reg, ConstMethod::codes_offset())); | |
| cmpptr(arg2_reg, _bcp_register); | |
| jcc(Assembler::equal, verify_continue); | |
| // rbx: method | |
| // _bcp_register: bcp | |
| // c_rarg3: mdp | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp), | |
| rbx, _bcp_register, arg3_reg); | |
| bind(verify_continue); | |
| pop(arg2_reg); | |
| pop(arg3_reg); | |
| pop(rbx); | |
| pop(rax); | |
| #endif // ASSERT | |
| } | |
| void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, | |
| int constant, | |
| Register value) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| Address data(mdp_in, constant); | |
| movptr(data, value); | |
| } | |
| void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, | |
| int constant) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| Address data(mdp_in, constant); | |
| addptr(data, DataLayout::counter_increment); | |
| } | |
| void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, | |
| Register index, | |
| int constant) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| Address data(mdp_in, index, Address::times_1, constant); | |
| addptr(data, DataLayout::counter_increment); | |
| } | |
| void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in, | |
| int flag_byte_constant) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| int header_offset = in_bytes(DataLayout::flags_offset()); | |
| int header_bits = flag_byte_constant; | |
| // Set the flag | |
| orb(Address(mdp_in, header_offset), header_bits); | |
| } | |
| void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in, | |
| int offset, | |
| Register value, | |
| Register test_value_out, | |
| Label& not_equal_continue) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| if (test_value_out == noreg) { | |
| cmpptr(value, Address(mdp_in, offset)); | |
| } else { | |
| // Put the test value into a register, so caller can use it: | |
| movptr(test_value_out, Address(mdp_in, offset)); | |
| cmpptr(test_value_out, value); | |
| } | |
| jcc(Assembler::notEqual, not_equal_continue); | |
| } | |
| void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, | |
| int offset_of_disp) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| Address disp_address(mdp_in, offset_of_disp); | |
| addptr(mdp_in, disp_address); | |
| movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in); | |
| } | |
| void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, | |
| Register reg, | |
| int offset_of_disp) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp); | |
| addptr(mdp_in, disp_address); | |
| movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in); | |
| } | |
| void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, | |
| int constant) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| addptr(mdp_in, constant); | |
| movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in); | |
| } | |
| void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) { | |
| assert(ProfileInterpreter, "must be profiling interpreter"); | |
| push(return_bci); // save/restore across call_VM | |
| call_VM(noreg, | |
| CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), | |
| return_bci); | |
| pop(return_bci); | |
| } | |
| void InterpreterMacroAssembler::profile_taken_branch(Register mdp) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // We are taking a branch. Increment the taken count. | |
| increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset())); | |
| // The method data pointer needs to be updated to reflect the new target. | |
| update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset())); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // We are not taking a branch. Increment the not taken count. | |
| increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset())); | |
| // The method data pointer needs to be updated to correspond to | |
| // the next bytecode | |
| update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size())); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_call(Register mdp) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // We are making a call. Increment the count. | |
| increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
| // The method data pointer needs to be updated to reflect the new target. | |
| update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size())); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_final_call(Register mdp) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // We are making a call. Increment the count. | |
| increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
| // The method data pointer needs to be updated to reflect the new target. | |
| update_mdp_by_constant(mdp, | |
| in_bytes(VirtualCallData:: | |
| virtual_call_data_size())); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_virtual_call(Register receiver, | |
| Register mdp, | |
| Register reg2, | |
| bool receiver_can_be_null) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| Label skip_receiver_profile; | |
| if (receiver_can_be_null) { | |
| Label not_null; | |
| testptr(receiver, receiver); | |
| jccb(Assembler::notZero, not_null); | |
| // We are making a call. Increment the count for null receiver. | |
| increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
| jmp(skip_receiver_profile); | |
| bind(not_null); | |
| } | |
| // Record the receiver type. | |
| record_klass_in_profile(receiver, mdp, reg2, true); | |
| bind(skip_receiver_profile); | |
| // The method data pointer needs to be updated to reflect the new target. | |
| update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); | |
| bind(profile_continue); | |
| } | |
| } | |
| // This routine creates a state machine for updating the multi-row | |
| // type profile at a virtual call site (or other type-sensitive bytecode). | |
| // The machine visits each row (of receiver/count) until the receiver type | |
| // is found, or until it runs out of rows. At the same time, it remembers | |
| // the location of the first empty row. (An empty row records null for its | |
| // receiver, and can be allocated for a newly-observed receiver type.) | |
| // Because there are two degrees of freedom in the state, a simple linear | |
| // search will not work; it must be a decision tree. Hence this helper | |
| // function is recursive, to generate the required tree structured code. | |
| // It's the interpreter, so we are trading off code space for speed. | |
| // See below for example code. | |
| void InterpreterMacroAssembler::record_klass_in_profile_helper( | |
| Register receiver, Register mdp, | |
| Register reg2, int start_row, | |
| Label& done, bool is_virtual_call) { | |
| if (TypeProfileWidth == 0) { | |
| increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
| } else { | |
| record_item_in_profile_helper(receiver, mdp, reg2, 0, done, TypeProfileWidth, | |
| &VirtualCallData::receiver_offset, &VirtualCallData::receiver_count_offset); | |
| } | |
| } | |
| void InterpreterMacroAssembler::record_item_in_profile_helper(Register item, Register mdp, Register reg2, int start_row, | |
| Label& done, int total_rows, | |
| OffsetFunction item_offset_fn, | |
| OffsetFunction item_count_offset_fn) { | |
| int last_row = total_rows - 1; | |
| assert(start_row <= last_row, "must be work left to do"); | |
| // Test this row for both the item and for null. | |
| // Take any of three different outcomes: | |
| // 1. found item => increment count and goto done | |
| // 2. found null => keep looking for case 1, maybe allocate this cell | |
| // 3. found something else => keep looking for cases 1 and 2 | |
| // Case 3 is handled by a recursive call. | |
| for (int row = start_row; row <= last_row; row++) { | |
| Label next_test; | |
| bool test_for_null_also = (row == start_row); | |
| // See if the item is item[n]. | |
| int item_offset = in_bytes(item_offset_fn(row)); | |
| test_mdp_data_at(mdp, item_offset, item, | |
| (test_for_null_also ? reg2 : noreg), | |
| next_test); | |
| // (Reg2 now contains the item from the CallData.) | |
| // The item is item[n]. Increment count[n]. | |
| int count_offset = in_bytes(item_count_offset_fn(row)); | |
| increment_mdp_data_at(mdp, count_offset); | |
| jmp(done); | |
| bind(next_test); | |
| if (test_for_null_also) { | |
| // Failed the equality check on item[n]... Test for null. | |
| testptr(reg2, reg2); | |
| if (start_row == last_row) { | |
| // The only thing left to do is handle the null case. | |
| Label found_null; | |
| jccb(Assembler::zero, found_null); | |
| // Item did not match any saved item and there is no empty row for it. | |
| // Increment total counter to indicate polymorphic case. | |
| increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
| jmp(done); | |
| bind(found_null); | |
| break; | |
| } | |
| Label found_null; | |
| // Since null is rare, make it be the branch-taken case. | |
| jcc(Assembler::zero, found_null); | |
| // Put all the "Case 3" tests here. | |
| record_item_in_profile_helper(item, mdp, reg2, start_row + 1, done, total_rows, | |
| item_offset_fn, item_count_offset_fn); | |
| // Found a null. Keep searching for a matching item, | |
| // but remember that this is an empty (unused) slot. | |
| bind(found_null); | |
| } | |
| } | |
| // In the fall-through case, we found no matching item, but we | |
| // observed the item[start_row] is null. | |
| // Fill in the item field and increment the count. | |
| int item_offset = in_bytes(item_offset_fn(start_row)); | |
| set_mdp_data_at(mdp, item_offset, item); | |
| int count_offset = in_bytes(item_count_offset_fn(start_row)); | |
| movl(reg2, DataLayout::counter_increment); | |
| set_mdp_data_at(mdp, count_offset, reg2); | |
| if (start_row > 0) { | |
| jmp(done); | |
| } | |
| } | |
| // Example state machine code for three profile rows: | |
| // // main copy of decision tree, rooted at row[1] | |
| // if (row[0].rec == rec) { row[0].incr(); goto done; } | |
| // if (row[0].rec != nullptr) { | |
| // // inner copy of decision tree, rooted at row[1] | |
| // if (row[1].rec == rec) { row[1].incr(); goto done; } | |
| // if (row[1].rec != nullptr) { | |
| // // degenerate decision tree, rooted at row[2] | |
| // if (row[2].rec == rec) { row[2].incr(); goto done; } | |
| // if (row[2].rec != nullptr) { count.incr(); goto done; } // overflow | |
| // row[2].init(rec); goto done; | |
| // } else { | |
| // // remember row[1] is empty | |
| // if (row[2].rec == rec) { row[2].incr(); goto done; } | |
| // row[1].init(rec); goto done; | |
| // } | |
| // } else { | |
| // // remember row[0] is empty | |
| // if (row[1].rec == rec) { row[1].incr(); goto done; } | |
| // if (row[2].rec == rec) { row[2].incr(); goto done; } | |
| // row[0].init(rec); goto done; | |
| // } | |
| // done: | |
| void InterpreterMacroAssembler::record_klass_in_profile(Register receiver, | |
| Register mdp, Register reg2, | |
| bool is_virtual_call) { | |
| assert(ProfileInterpreter, "must be profiling"); | |
| Label done; | |
| record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call); | |
| bind (done); | |
| } | |
| void InterpreterMacroAssembler::profile_ret(Register return_bci, | |
| Register mdp) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| uint row; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // Update the total ret count. | |
| increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
| for (row = 0; row < RetData::row_limit(); row++) { | |
| Label next_test; | |
| // See if return_bci is equal to bci[n]: | |
| test_mdp_data_at(mdp, | |
| in_bytes(RetData::bci_offset(row)), | |
| return_bci, noreg, | |
| next_test); | |
| // return_bci is equal to bci[n]. Increment the count. | |
| increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row))); | |
| // The method data pointer needs to be updated to reflect the new target. | |
| update_mdp_by_offset(mdp, | |
| in_bytes(RetData::bci_displacement_offset(row))); | |
| jmp(profile_continue); | |
| bind(next_test); | |
| } | |
| update_mdp_for_ret(return_bci); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_null_seen(Register mdp) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| set_mdp_flag_at(mdp, BitData::null_seen_byte_constant()); | |
| // The method data pointer needs to be updated. | |
| int mdp_delta = in_bytes(BitData::bit_data_size()); | |
| if (TypeProfileCasts) { | |
| mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); | |
| } | |
| update_mdp_by_constant(mdp, mdp_delta); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // The method data pointer needs to be updated. | |
| int mdp_delta = in_bytes(BitData::bit_data_size()); | |
| if (TypeProfileCasts) { | |
| mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); | |
| // Record the object type. | |
| record_klass_in_profile(klass, mdp, reg2, false); | |
| } | |
| update_mdp_by_constant(mdp, mdp_delta); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_switch_default(Register mdp) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // Update the default case count | |
| increment_mdp_data_at(mdp, | |
| in_bytes(MultiBranchData::default_count_offset())); | |
| // The method data pointer needs to be updated. | |
| update_mdp_by_offset(mdp, | |
| in_bytes(MultiBranchData:: | |
| default_displacement_offset())); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::profile_switch_case(Register index, | |
| Register mdp, | |
| Register reg2) { | |
| if (ProfileInterpreter) { | |
| Label profile_continue; | |
| // If no method data exists, go to profile_continue. | |
| test_method_data_pointer(mdp, profile_continue); | |
| // Build the base (index * per_case_size_in_bytes()) + | |
| // case_array_offset_in_bytes() | |
| movl(reg2, in_bytes(MultiBranchData::per_case_size())); | |
| imulptr(index, reg2); // XXX l ? | |
| addptr(index, in_bytes(MultiBranchData::case_array_offset())); // XXX l ? | |
| // Update the case count | |
| increment_mdp_data_at(mdp, | |
| index, | |
| in_bytes(MultiBranchData::relative_count_offset())); | |
| // The method data pointer needs to be updated. | |
| update_mdp_by_offset(mdp, | |
| index, | |
| in_bytes(MultiBranchData:: | |
| relative_displacement_offset())); | |
| bind(profile_continue); | |
| } | |
| } | |
| void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) { | |
| if (state == atos) { | |
| MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line); | |
| } | |
| } | |
| // Jump if ((*counter_addr += increment) & mask) == 0 | |
| void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr, Address mask, | |
| Register scratch, Label* where) { | |
| // This update is actually not atomic and can lose a number of updates | |
| // under heavy contention, but the alternative of using the (contended) | |
| // atomic update here penalizes profiling paths too much. | |
| movl(scratch, counter_addr); | |
| incrementl(scratch, InvocationCounter::count_increment); | |
| movl(counter_addr, scratch); | |
| andl(scratch, mask); | |
| if (where != nullptr) { | |
| jcc(Assembler::zero, *where); | |
| } | |
| } | |
| void InterpreterMacroAssembler::notify_method_entry() { | |
| // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to | |
| // track stack depth. If it is possible to enter interp_only_mode we add | |
| // the code to check if the event should be sent. | |
| Register rthread = r15_thread; | |
| Register rarg = c_rarg1; | |
| if (JvmtiExport::can_post_interpreter_events()) { | |
| Label L; | |
| movl(rdx, Address(rthread, JavaThread::interp_only_mode_offset())); | |
| testl(rdx, rdx); | |
| jcc(Assembler::zero, L); | |
| call_VM(noreg, CAST_FROM_FN_PTR(address, | |
| InterpreterRuntime::post_method_entry)); | |
| bind(L); | |
| } | |
| if (DTraceMethodProbes) { | |
| get_method(rarg); | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), | |
| rthread, rarg); | |
| } | |
| // RedefineClasses() tracing support for obsolete method entry | |
| if (log_is_enabled(Trace, redefine, class, obsolete)) { | |
| get_method(rarg); | |
| call_VM_leaf( | |
| CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry), | |
| rthread, rarg); | |
| } | |
| } | |
| void InterpreterMacroAssembler::notify_method_exit( | |
| TosState state, NotifyMethodExitMode mode) { | |
| // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to | |
| // track stack depth. If it is possible to enter interp_only_mode we add | |
| // the code to check if the event should be sent. | |
| Register rthread = r15_thread; | |
| Register rarg = c_rarg1; | |
| if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) { | |
| Label L; | |
| // Note: frame::interpreter_frame_result has a dependency on how the | |
| // method result is saved across the call to post_method_exit. If this | |
| // is changed then the interpreter_frame_result implementation will | |
| // need to be updated too. | |
| // template interpreter will leave the result on the top of the stack. | |
| push(state); | |
| movl(rdx, Address(rthread, JavaThread::interp_only_mode_offset())); | |
| testl(rdx, rdx); | |
| jcc(Assembler::zero, L); | |
| call_VM(noreg, | |
| CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit)); | |
| bind(L); | |
| pop(state); | |
| } | |
| if (DTraceMethodProbes) { | |
| push(state); | |
| get_method(rarg); | |
| call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), | |
| rthread, rarg); | |
| pop(state); | |
| } | |
| } | |
| void InterpreterMacroAssembler::load_resolved_indy_entry(Register cache, Register index) { | |
| // Get index out of bytecode pointer | |
| get_cache_index_at_bcp(index, 1, sizeof(u4)); | |
| // Get address of invokedynamic array | |
| movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize)); | |
| movptr(cache, Address(cache, in_bytes(ConstantPoolCache::invokedynamic_entries_offset()))); | |
| if (is_power_of_2(sizeof(ResolvedIndyEntry))) { | |
| shll(index, log2i_exact(sizeof(ResolvedIndyEntry))); // Scale index by power of 2 | |
| } else { | |
| imull(index, index, sizeof(ResolvedIndyEntry)); // Scale the index to be the entry index * sizeof(ResolvedIndyEntry) | |
| } | |
| lea(cache, Address(cache, index, Address::times_1, Array<ResolvedIndyEntry>::base_offset_in_bytes())); | |
| } | |
| void InterpreterMacroAssembler::load_field_entry(Register cache, Register index, int bcp_offset) { | |
| // Get index out of bytecode pointer | |
| movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize)); | |
| get_cache_index_at_bcp(index, bcp_offset, sizeof(u2)); | |
| movptr(cache, Address(cache, ConstantPoolCache::field_entries_offset())); | |
| // Take shortcut if the size is a power of 2 | |
| if (is_power_of_2(sizeof(ResolvedFieldEntry))) { | |
| shll(index, log2i_exact(sizeof(ResolvedFieldEntry))); // Scale index by power of 2 | |
| } else { | |
| imull(index, index, sizeof(ResolvedFieldEntry)); // Scale the index to be the entry index * sizeof(ResolvedFieldEntry) | |
| } | |
| lea(cache, Address(cache, index, Address::times_1, Array<ResolvedFieldEntry>::base_offset_in_bytes())); | |
| } | |
| void InterpreterMacroAssembler::load_method_entry(Register cache, Register index, int bcp_offset) { | |
| // Get index out of bytecode pointer | |
| movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize)); | |
| get_cache_index_at_bcp(index, bcp_offset, sizeof(u2)); | |
| movptr(cache, Address(cache, ConstantPoolCache::method_entries_offset())); | |
| imull(index, index, sizeof(ResolvedMethodEntry)); // Scale the index to be the entry index * sizeof(ResolvedMethodEntry) | |
| lea(cache, Address(cache, index, Address::times_1, Array<ResolvedMethodEntry>::base_offset_in_bytes())); | |
| } |