Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp
32285 views
/*1* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "interp_masm_x86.hpp"26#include "interpreter/interpreter.hpp"27#include "interpreter/interpreterRuntime.hpp"28#include "oops/arrayOop.hpp"29#include "oops/markOop.hpp"30#include "oops/methodData.hpp"31#include "oops/method.hpp"32#include "prims/jvmtiExport.hpp"33#include "prims/jvmtiRedefineClassesTrace.hpp"34#include "prims/jvmtiThreadState.hpp"35#include "runtime/basicLock.hpp"36#include "runtime/biasedLocking.hpp"37#include "runtime/sharedRuntime.hpp"38#include "runtime/thread.inline.hpp"394041// Implementation of InterpreterMacroAssembler42#ifdef CC_INTERP43void InterpreterMacroAssembler::get_method(Register reg) {44movptr(reg, Address(rbp, -(sizeof(BytecodeInterpreter) + 2 * wordSize)));45movptr(reg, Address(reg, byte_offset_of(BytecodeInterpreter, _method)));46}47#endif // CC_INTERP484950#ifndef CC_INTERP51void InterpreterMacroAssembler::call_VM_leaf_base(52address entry_point,53int number_of_arguments54) {55// interpreter specific56//57// Note: No need to save/restore bcp & locals (rsi & rdi) pointer58// since these are callee saved registers and no blocking/59// GC can happen in leaf calls.60// Further Note: DO NOT save/restore bcp/locals. If a caller has61// already saved them so that it can use rsi/rdi as temporaries62// then a save/restore here will DESTROY the copy the caller63// saved! There used to be a save_bcp() that only happened in64// the ASSERT path (no restore_bcp). Which caused bizarre failures65// when jvm built with ASSERTs.66#ifdef ASSERT67{ Label L;68cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);69jcc(Assembler::equal, L);70stop("InterpreterMacroAssembler::call_VM_leaf_base: last_sp != NULL");71bind(L);72}73#endif74// super call75MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments);76// interpreter specific7778// Used to ASSERT that rsi/rdi were equal to frame's bcp/locals79// but since they may not have been saved (and we don't want to80// save them here (see note above) the assert is invalid.81}828384void InterpreterMacroAssembler::call_VM_base(85Register oop_result,86Register java_thread,87Register last_java_sp,88address entry_point,89int number_of_arguments,90bool check_exceptions91) {92#ifdef ASSERT93{ Label L;94cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);95jcc(Assembler::equal, L);96stop("InterpreterMacroAssembler::call_VM_base: last_sp != NULL");97bind(L);98}99#endif /* ASSERT */100// interpreter specific101//102// Note: Could avoid restoring locals ptr (callee saved) - however doesn't103// really make a difference for these runtime calls, since they are104// slow anyway. Btw., bcp must be saved/restored since it may change105// due to GC.106assert(java_thread == noreg , "not expecting a precomputed java thread");107save_bcp();108// super call109MacroAssembler::call_VM_base(oop_result, java_thread, last_java_sp, entry_point, number_of_arguments, check_exceptions);110// interpreter specific111restore_bcp();112restore_locals();113}114115116void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) {117if (JvmtiExport::can_pop_frame()) {118Label L;119// Initiate popframe handling only if it is not already being processed. If the flag120// has the popframe_processing bit set, it means that this code is called *during* popframe121// handling - we don't want to reenter.122Register pop_cond = java_thread; // Not clear if any other register is available...123movl(pop_cond, Address(java_thread, JavaThread::popframe_condition_offset()));124testl(pop_cond, JavaThread::popframe_pending_bit);125jcc(Assembler::zero, L);126testl(pop_cond, JavaThread::popframe_processing_bit);127jcc(Assembler::notZero, L);128// Call Interpreter::remove_activation_preserving_args_entry() to get the129// address of the same-named entrypoint in the generated interpreter code.130call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));131jmp(rax);132bind(L);133get_thread(java_thread);134}135}136137138void InterpreterMacroAssembler::load_earlyret_value(TosState state) {139get_thread(rcx);140movl(rcx, Address(rcx, JavaThread::jvmti_thread_state_offset()));141const Address tos_addr (rcx, JvmtiThreadState::earlyret_tos_offset());142const Address oop_addr (rcx, JvmtiThreadState::earlyret_oop_offset());143const Address val_addr (rcx, JvmtiThreadState::earlyret_value_offset());144const Address val_addr1(rcx, JvmtiThreadState::earlyret_value_offset()145+ in_ByteSize(wordSize));146switch (state) {147case atos: movptr(rax, oop_addr);148movptr(oop_addr, NULL_WORD);149verify_oop(rax, state); break;150case ltos:151movl(rdx, val_addr1); // fall through152case btos: // fall through153case ztos: // fall through154case ctos: // fall through155case stos: // fall through156case itos: movl(rax, val_addr); break;157case ftos: fld_s(val_addr); break;158case dtos: fld_d(val_addr); break;159case vtos: /* nothing to do */ break;160default : ShouldNotReachHere();161}162// Clean up tos value in the thread object163movl(tos_addr, (int32_t) ilgl);164movptr(val_addr, NULL_WORD);165NOT_LP64(movptr(val_addr1, NULL_WORD));166}167168169void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) {170if (JvmtiExport::can_force_early_return()) {171Label L;172Register tmp = java_thread;173movptr(tmp, Address(tmp, JavaThread::jvmti_thread_state_offset()));174testptr(tmp, tmp);175jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == NULL) exit;176177// Initiate earlyret handling only if it is not already being processed.178// If the flag has the earlyret_processing bit set, it means that this code179// is called *during* earlyret handling - we don't want to reenter.180movl(tmp, Address(tmp, JvmtiThreadState::earlyret_state_offset()));181cmpl(tmp, JvmtiThreadState::earlyret_pending);182jcc(Assembler::notEqual, L);183184// Call Interpreter::remove_activation_early_entry() to get the address of the185// same-named entrypoint in the generated interpreter code.186get_thread(java_thread);187movptr(tmp, Address(java_thread, JavaThread::jvmti_thread_state_offset()));188pushl(Address(tmp, JvmtiThreadState::earlyret_tos_offset()));189call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), 1);190jmp(rax);191bind(L);192get_thread(java_thread);193}194}195196197void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) {198assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode");199load_unsigned_short(reg, Address(rsi, bcp_offset));200bswapl(reg);201shrl(reg, 16);202}203204205void InterpreterMacroAssembler::get_cache_index_at_bcp(Register reg, int bcp_offset, size_t index_size) {206assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");207if (index_size == sizeof(u2)) {208load_unsigned_short(reg, Address(rsi, bcp_offset));209} else if (index_size == sizeof(u4)) {210assert(EnableInvokeDynamic, "giant index used only for JSR 292");211movl(reg, Address(rsi, bcp_offset));212// Check if the secondary index definition is still ~x, otherwise213// we have to change the following assembler code to calculate the214// plain index.215assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");216notl(reg); // convert to plain index217} else if (index_size == sizeof(u1)) {218load_unsigned_byte(reg, Address(rsi, bcp_offset));219} else {220ShouldNotReachHere();221}222}223224225void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, Register index,226int bcp_offset, size_t index_size) {227assert_different_registers(cache, index);228get_cache_index_at_bcp(index, bcp_offset, index_size);229movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));230assert(sizeof(ConstantPoolCacheEntry) == 4*wordSize, "adjust code below");231assert(exact_log2(in_words(ConstantPoolCacheEntry::size())) == 2, "else change next line");232shlptr(index, 2); // convert from field index to ConstantPoolCacheEntry index233}234235236void InterpreterMacroAssembler::get_cache_and_index_and_bytecode_at_bcp(Register cache,237Register index,238Register bytecode,239int byte_no,240int bcp_offset,241size_t index_size) {242get_cache_and_index_at_bcp(cache, index, bcp_offset, index_size);243movptr(bytecode, Address(cache, index, Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()));244const int shift_count = (1 + byte_no) * BitsPerByte;245assert((byte_no == TemplateTable::f1_byte && shift_count == ConstantPoolCacheEntry::bytecode_1_shift) ||246(byte_no == TemplateTable::f2_byte && shift_count == ConstantPoolCacheEntry::bytecode_2_shift),247"correct shift count");248shrptr(bytecode, shift_count);249assert(ConstantPoolCacheEntry::bytecode_1_mask == ConstantPoolCacheEntry::bytecode_2_mask, "common mask");250andptr(bytecode, ConstantPoolCacheEntry::bytecode_1_mask);251}252253254void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache, Register tmp,255int bcp_offset, size_t index_size) {256assert(cache != tmp, "must use different register");257get_cache_index_at_bcp(tmp, bcp_offset, index_size);258assert(sizeof(ConstantPoolCacheEntry) == 4*wordSize, "adjust code below");259// convert from field index to ConstantPoolCacheEntry index260// and from word offset to byte offset261assert(exact_log2(in_bytes(ConstantPoolCacheEntry::size_in_bytes())) == 2 + LogBytesPerWord, "else change next line");262shll(tmp, 2 + LogBytesPerWord);263movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));264// skip past the header265addptr(cache, in_bytes(ConstantPoolCache::base_offset()));266addptr(cache, tmp); // construct pointer to cache entry267}268269void InterpreterMacroAssembler::get_method_counters(Register method,270Register mcs, Label& skip) {271Label has_counters;272movptr(mcs, Address(method, Method::method_counters_offset()));273testptr(mcs, mcs);274jcc(Assembler::notZero, has_counters);275call_VM(noreg, CAST_FROM_FN_PTR(address,276InterpreterRuntime::build_method_counters), method);277movptr(mcs, Address(method,Method::method_counters_offset()));278testptr(mcs, mcs);279jcc(Assembler::zero, skip); // No MethodCounters allocated, OutOfMemory280bind(has_counters);281}282283// Load object from cpool->resolved_references(index)284void InterpreterMacroAssembler::load_resolved_reference_at_index(285Register result, Register index) {286assert_different_registers(result, index);287// convert from field index to resolved_references() index and from288// word index to byte offset. Since this is a java object, it can be compressed289Register tmp = index; // reuse290shll(tmp, LogBytesPerHeapOop);291292get_constant_pool(result);293// load pointer for resolved_references[] objArray294movptr(result, Address(result, ConstantPool::resolved_references_offset_in_bytes()));295// JNIHandles::resolve(obj);296movptr(result, Address(result, 0));297// Add in the index298addptr(result, tmp);299load_heap_oop(result, Address(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT)));300}301302// Generate a subtype check: branch to ok_is_subtype if sub_klass is303// a subtype of super_klass. EAX holds the super_klass. Blows ECX.304// Resets EDI to locals. Register sub_klass cannot be any of the above.305void InterpreterMacroAssembler::gen_subtype_check( Register Rsub_klass, Label &ok_is_subtype ) {306assert( Rsub_klass != rax, "rax, holds superklass" );307assert( Rsub_klass != rcx, "used as a temp" );308assert( Rsub_klass != rdi, "used as a temp, restored from locals" );309310// Profile the not-null value's klass.311profile_typecheck(rcx, Rsub_klass, rdi); // blows rcx, reloads rdi312313// Do the check.314check_klass_subtype(Rsub_klass, rax, rcx, ok_is_subtype); // blows rcx315316// Profile the failure of the check.317profile_typecheck_failed(rcx); // blows rcx318}319320void InterpreterMacroAssembler::f2ieee() {321if (IEEEPrecision) {322fstp_s(Address(rsp, 0));323fld_s(Address(rsp, 0));324}325}326327328void InterpreterMacroAssembler::d2ieee() {329if (IEEEPrecision) {330fstp_d(Address(rsp, 0));331fld_d(Address(rsp, 0));332}333}334335// Java Expression Stack336337void InterpreterMacroAssembler::pop_ptr(Register r) {338pop(r);339}340341void InterpreterMacroAssembler::pop_i(Register r) {342pop(r);343}344345void InterpreterMacroAssembler::pop_l(Register lo, Register hi) {346pop(lo);347pop(hi);348}349350void InterpreterMacroAssembler::pop_f() {351fld_s(Address(rsp, 0));352addptr(rsp, 1 * wordSize);353}354355void InterpreterMacroAssembler::pop_d() {356fld_d(Address(rsp, 0));357addptr(rsp, 2 * wordSize);358}359360361void InterpreterMacroAssembler::pop(TosState state) {362switch (state) {363case atos: pop_ptr(rax); break;364case btos: // fall through365case ztos: // fall through366case ctos: // fall through367case stos: // fall through368case itos: pop_i(rax); break;369case ltos: pop_l(rax, rdx); break;370case ftos: pop_f(); break;371case dtos: pop_d(); break;372case vtos: /* nothing to do */ break;373default : ShouldNotReachHere();374}375verify_oop(rax, state);376}377378void InterpreterMacroAssembler::push_ptr(Register r) {379push(r);380}381382void InterpreterMacroAssembler::push_i(Register r) {383push(r);384}385386void InterpreterMacroAssembler::push_l(Register lo, Register hi) {387push(hi);388push(lo);389}390391void InterpreterMacroAssembler::push_f() {392// Do not schedule for no AGI! Never write beyond rsp!393subptr(rsp, 1 * wordSize);394fstp_s(Address(rsp, 0));395}396397void InterpreterMacroAssembler::push_d(Register r) {398// Do not schedule for no AGI! Never write beyond rsp!399subptr(rsp, 2 * wordSize);400fstp_d(Address(rsp, 0));401}402403404void InterpreterMacroAssembler::push(TosState state) {405verify_oop(rax, state);406switch (state) {407case atos: push_ptr(rax); break;408case btos: // fall through409case ztos: // fall through410case ctos: // fall through411case stos: // fall through412case itos: push_i(rax); break;413case ltos: push_l(rax, rdx); break;414case ftos: push_f(); break;415case dtos: push_d(rax); break;416case vtos: /* nothing to do */ break;417default : ShouldNotReachHere();418}419}420421422// Helpers for swap and dup423void InterpreterMacroAssembler::load_ptr(int n, Register val) {424movptr(val, Address(rsp, Interpreter::expr_offset_in_bytes(n)));425}426427void InterpreterMacroAssembler::store_ptr(int n, Register val) {428movptr(Address(rsp, Interpreter::expr_offset_in_bytes(n)), val);429}430431void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() {432// set sender sp433lea(rsi, Address(rsp, wordSize));434// record last_sp435movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), rsi);436}437438439// Jump to from_interpreted entry of a call unless single stepping is possible440// in this thread in which case we must call the i2i entry441void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) {442prepare_to_jump_from_interpreted();443444if (JvmtiExport::can_post_interpreter_events()) {445Label run_compiled_code;446// JVMTI events, such as single-stepping, are implemented partly by avoiding running447// compiled code in threads for which the event is enabled. Check here for448// interp_only_mode if these events CAN be enabled.449get_thread(temp);450// interp_only is an int, on little endian it is sufficient to test the byte only451// Is a cmpl faster?452cmpb(Address(temp, JavaThread::interp_only_mode_offset()), 0);453jccb(Assembler::zero, run_compiled_code);454jmp(Address(method, Method::interpreter_entry_offset()));455bind(run_compiled_code);456}457458jmp(Address(method, Method::from_interpreted_offset()));459460}461462463// The following two routines provide a hook so that an implementation464// can schedule the dispatch in two parts. Intel does not do this.465void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) {466// Nothing Intel-specific to be done here.467}468469void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) {470dispatch_next(state, step);471}472473void InterpreterMacroAssembler::dispatch_base(TosState state, address* table,474bool verifyoop) {475verify_FPU(1, state);476if (VerifyActivationFrameSize) {477Label L;478mov(rcx, rbp);479subptr(rcx, rsp);480int min_frame_size = (frame::link_offset - frame::interpreter_frame_initial_sp_offset) * wordSize;481cmpptr(rcx, min_frame_size);482jcc(Assembler::greaterEqual, L);483stop("broken stack frame");484bind(L);485}486if (verifyoop) verify_oop(rax, state);487Address index(noreg, rbx, Address::times_ptr);488ExternalAddress tbl((address)table);489ArrayAddress dispatch(tbl, index);490jump(dispatch);491}492493494void InterpreterMacroAssembler::dispatch_only(TosState state) {495dispatch_base(state, Interpreter::dispatch_table(state));496}497498499void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {500dispatch_base(state, Interpreter::normal_table(state));501}502503void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) {504dispatch_base(state, Interpreter::normal_table(state), false);505}506507508void InterpreterMacroAssembler::dispatch_next(TosState state, int step) {509// load next bytecode (load before advancing rsi to prevent AGI)510load_unsigned_byte(rbx, Address(rsi, step));511// advance rsi512increment(rsi, step);513dispatch_base(state, Interpreter::dispatch_table(state));514}515516517void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {518// load current bytecode519load_unsigned_byte(rbx, Address(rsi, 0));520dispatch_base(state, table);521}522523// remove activation524//525// Unlock the receiver if this is a synchronized method.526// Unlock any Java monitors from syncronized blocks.527// Remove the activation from the stack.528//529// If there are locked Java monitors530// If throw_monitor_exception531// throws IllegalMonitorStateException532// Else if install_monitor_exception533// installs IllegalMonitorStateException534// Else535// no error processing536void InterpreterMacroAssembler::remove_activation(TosState state, Register ret_addr,537bool throw_monitor_exception,538bool install_monitor_exception,539bool notify_jvmdi) {540// Note: Registers rax, rdx and FPU ST(0) may be in use for the result541// check if synchronized method542Label unlocked, unlock, no_unlock;543544get_thread(rcx);545const Address do_not_unlock_if_synchronized(rcx,546in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));547548movbool(rbx, do_not_unlock_if_synchronized);549mov(rdi,rbx);550movbool(do_not_unlock_if_synchronized, false); // reset the flag551552movptr(rbx, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); // get method access flags553movl(rcx, Address(rbx, Method::access_flags_offset()));554555testl(rcx, JVM_ACC_SYNCHRONIZED);556jcc(Assembler::zero, unlocked);557558// Don't unlock anything if the _do_not_unlock_if_synchronized flag559// is set.560mov(rcx,rdi);561testbool(rcx);562jcc(Assembler::notZero, no_unlock);563564// unlock monitor565push(state); // save result566567// BasicObjectLock will be first in list, since this is a synchronized method. However, need568// to check that the object has not been unlocked by an explicit monitorexit bytecode.569const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset * wordSize - (int)sizeof(BasicObjectLock));570lea (rdx, monitor); // address of first monitor571572movptr (rax, Address(rdx, BasicObjectLock::obj_offset_in_bytes()));573testptr(rax, rax);574jcc (Assembler::notZero, unlock);575576pop(state);577if (throw_monitor_exception) {578empty_FPU_stack(); // remove possible return value from FPU-stack, otherwise stack could overflow579580// Entry already unlocked, need to throw exception581call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));582should_not_reach_here();583} else {584// Monitor already unlocked during a stack unroll.585// If requested, install an illegal_monitor_state_exception.586// Continue with stack unrolling.587if (install_monitor_exception) {588empty_FPU_stack(); // remove possible return value from FPU-stack, otherwise stack could overflow589call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception));590}591jmp(unlocked);592}593594bind(unlock);595unlock_object(rdx);596pop(state);597598// Check that for block-structured locking (i.e., that all locked objects has been unlocked)599bind(unlocked);600601// rax, rdx: Might contain return value602603// Check that all monitors are unlocked604{605Label loop, exception, entry, restart;606const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;607const Address monitor_block_top(rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);608const Address monitor_block_bot(rbp, frame::interpreter_frame_initial_sp_offset * wordSize);609610bind(restart);611movptr(rcx, monitor_block_top); // points to current entry, starting with top-most entry612lea(rbx, monitor_block_bot); // points to word before bottom of monitor block613jmp(entry);614615// Entry already locked, need to throw exception616bind(exception);617618if (throw_monitor_exception) {619empty_FPU_stack(); // remove possible return value from FPU-stack, otherwise stack could overflow620621// Throw exception622call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));623should_not_reach_here();624} else {625// Stack unrolling. Unlock object and install illegal_monitor_exception626// Unlock does not block, so don't have to worry about the frame627628push(state);629mov(rdx, rcx);630unlock_object(rdx);631pop(state);632633if (install_monitor_exception) {634empty_FPU_stack(); // remove possible return value from FPU-stack, otherwise stack could overflow635call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception));636}637638jmp(restart);639}640641bind(loop);642cmpptr(Address(rcx, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD); // check if current entry is used643jcc(Assembler::notEqual, exception);644645addptr(rcx, entry_size); // otherwise advance to next entry646bind(entry);647cmpptr(rcx, rbx); // check if bottom reached648jcc(Assembler::notEqual, loop); // if not at bottom then check this entry649}650651bind(no_unlock);652653// jvmti support654if (notify_jvmdi) {655notify_method_exit(state, NotifyJVMTI); // preserve TOSCA656} else {657notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA658}659660// remove activation661movptr(rbx, Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize)); // get sender sp662leave(); // remove frame anchor663pop(ret_addr); // get return address664mov(rsp, rbx); // set sp to sender sp665if (UseSSE) {666// float and double are returned in xmm register in SSE-mode667if (state == ftos && UseSSE >= 1) {668subptr(rsp, wordSize);669fstp_s(Address(rsp, 0));670movflt(xmm0, Address(rsp, 0));671addptr(rsp, wordSize);672} else if (state == dtos && UseSSE >= 2) {673subptr(rsp, 2*wordSize);674fstp_d(Address(rsp, 0));675movdbl(xmm0, Address(rsp, 0));676addptr(rsp, 2*wordSize);677}678}679}680681#endif /* !CC_INTERP */682683684// Lock object685//686// Argument: rdx : Points to BasicObjectLock to be used for locking. Must687// be initialized with object to lock688void InterpreterMacroAssembler::lock_object(Register lock_reg) {689assert(lock_reg == rdx, "The argument is only for looks. It must be rdx");690691if (UseHeavyMonitors) {692call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), lock_reg);693} else {694695Label done;696697const Register swap_reg = rax; // Must use rax, for cmpxchg instruction698const Register obj_reg = rcx; // Will contain the oop699700const int obj_offset = BasicObjectLock::obj_offset_in_bytes();701const int lock_offset = BasicObjectLock::lock_offset_in_bytes ();702const int mark_offset = lock_offset + BasicLock::displaced_header_offset_in_bytes();703704Label slow_case;705706// Load object pointer into obj_reg %rcx707movptr(obj_reg, Address(lock_reg, obj_offset));708709if (UseBiasedLocking) {710// Note: we use noreg for the temporary register since it's hard711// to come up with a free register on all incoming code paths712biased_locking_enter(lock_reg, obj_reg, swap_reg, noreg, false, done, &slow_case);713}714715// Load immediate 1 into swap_reg %rax,716movptr(swap_reg, (int32_t)1);717718// Load (object->mark() | 1) into swap_reg %rax,719orptr(swap_reg, Address(obj_reg, 0));720721// Save (object->mark() | 1) into BasicLock's displaced header722movptr(Address(lock_reg, mark_offset), swap_reg);723724assert(lock_offset == 0, "displached header must be first word in BasicObjectLock");725if (os::is_MP()) {726lock();727}728cmpxchgptr(lock_reg, Address(obj_reg, 0));729if (PrintBiasedLockingStatistics) {730cond_inc32(Assembler::zero,731ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr()));732}733jcc(Assembler::zero, done);734735// Test if the oopMark is an obvious stack pointer, i.e.,736// 1) (mark & 3) == 0, and737// 2) rsp <= mark < mark + os::pagesize()738//739// These 3 tests can be done by evaluating the following740// expression: ((mark - rsp) & (3 - os::vm_page_size())),741// assuming both stack pointer and pagesize have their742// least significant 2 bits clear.743// NOTE: the oopMark is in swap_reg %rax, as the result of cmpxchg744subptr(swap_reg, rsp);745andptr(swap_reg, 3 - os::vm_page_size());746747// Save the test result, for recursive case, the result is zero748movptr(Address(lock_reg, mark_offset), swap_reg);749750if (PrintBiasedLockingStatistics) {751cond_inc32(Assembler::zero,752ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr()));753}754jcc(Assembler::zero, done);755756bind(slow_case);757758// Call the runtime routine for slow case759call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), lock_reg);760761bind(done);762}763}764765766// Unlocks an object. Used in monitorexit bytecode and remove_activation.767//768// Argument: rdx : Points to BasicObjectLock structure for lock769// Throw an IllegalMonitorException if object is not locked by current thread770//771// Uses: rax, rbx, rcx, rdx772void InterpreterMacroAssembler::unlock_object(Register lock_reg) {773assert(lock_reg == rdx, "The argument is only for looks. It must be rdx");774775if (UseHeavyMonitors) {776call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);777} else {778Label done;779780const Register swap_reg = rax; // Must use rax, for cmpxchg instruction781const Register header_reg = rbx; // Will contain the old oopMark782const Register obj_reg = rcx; // Will contain the oop783784save_bcp(); // Save in case of exception785786// Convert from BasicObjectLock structure to object and BasicLock structure787// Store the BasicLock address into %rax,788lea(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset_in_bytes()));789790// Load oop into obj_reg(%rcx)791movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes ()));792793// Free entry794movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), NULL_WORD);795796if (UseBiasedLocking) {797biased_locking_exit(obj_reg, header_reg, done);798}799800// Load the old header from BasicLock structure801movptr(header_reg, Address(swap_reg, BasicLock::displaced_header_offset_in_bytes()));802803// Test for recursion804testptr(header_reg, header_reg);805806// zero for recursive case807jcc(Assembler::zero, done);808809// Atomic swap back the old header810if (os::is_MP()) lock();811cmpxchgptr(header_reg, Address(obj_reg, 0));812813// zero for recursive case814jcc(Assembler::zero, done);815816// Call the runtime routine for slow case.817movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), obj_reg); // restore obj818call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);819820bind(done);821822restore_bcp();823}824}825826827#ifndef CC_INTERP828829// Test ImethodDataPtr. If it is null, continue at the specified label830void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, Label& zero_continue) {831assert(ProfileInterpreter, "must be profiling interpreter");832movptr(mdp, Address(rbp, frame::interpreter_frame_mdx_offset * wordSize));833testptr(mdp, mdp);834jcc(Assembler::zero, zero_continue);835}836837838// Set the method data pointer for the current bcp.839void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {840assert(ProfileInterpreter, "must be profiling interpreter");841Label set_mdp;842push(rax);843push(rbx);844845get_method(rbx);846// Test MDO to avoid the call if it is NULL.847movptr(rax, Address(rbx, in_bytes(Method::method_data_offset())));848testptr(rax, rax);849jcc(Assembler::zero, set_mdp);850// rbx,: method851// rsi: bcp852call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, rsi);853// rax,: mdi854// mdo is guaranteed to be non-zero here, we checked for it before the call.855movptr(rbx, Address(rbx, in_bytes(Method::method_data_offset())));856addptr(rbx, in_bytes(MethodData::data_offset()));857addptr(rax, rbx);858bind(set_mdp);859movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), rax);860pop(rbx);861pop(rax);862}863864void InterpreterMacroAssembler::verify_method_data_pointer() {865assert(ProfileInterpreter, "must be profiling interpreter");866#ifdef ASSERT867Label verify_continue;868push(rax);869push(rbx);870push(rcx);871push(rdx);872test_method_data_pointer(rcx, verify_continue); // If mdp is zero, continue873get_method(rbx);874875// If the mdp is valid, it will point to a DataLayout header which is876// consistent with the bcp. The converse is highly probable also.877load_unsigned_short(rdx, Address(rcx, in_bytes(DataLayout::bci_offset())));878addptr(rdx, Address(rbx, Method::const_offset()));879lea(rdx, Address(rdx, ConstMethod::codes_offset()));880cmpptr(rdx, rsi);881jcc(Assembler::equal, verify_continue);882// rbx,: method883// rsi: bcp884// rcx: mdp885call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp), rbx, rsi, rcx);886bind(verify_continue);887pop(rdx);888pop(rcx);889pop(rbx);890pop(rax);891#endif // ASSERT892}893894895void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, int constant, Register value) {896// %%% this seems to be used to store counter data which is surely 32bits897// however 64bit side stores 64 bits which seems wrong898assert(ProfileInterpreter, "must be profiling interpreter");899Address data(mdp_in, constant);900movptr(data, value);901}902903904void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,905int constant,906bool decrement) {907// Counter address908Address data(mdp_in, constant);909910increment_mdp_data_at(data, decrement);911}912913914void InterpreterMacroAssembler::increment_mdp_data_at(Address data,915bool decrement) {916917assert( DataLayout::counter_increment==1, "flow-free idiom only works with 1" );918assert(ProfileInterpreter, "must be profiling interpreter");919920// %%% 64bit treats this as 64 bit which seems unlikely921if (decrement) {922// Decrement the register. Set condition codes.923addl(data, -DataLayout::counter_increment);924// If the decrement causes the counter to overflow, stay negative925Label L;926jcc(Assembler::negative, L);927addl(data, DataLayout::counter_increment);928bind(L);929} else {930assert(DataLayout::counter_increment == 1,931"flow-free idiom only works with 1");932// Increment the register. Set carry flag.933addl(data, DataLayout::counter_increment);934// If the increment causes the counter to overflow, pull back by 1.935sbbl(data, 0);936}937}938939940void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,941Register reg,942int constant,943bool decrement) {944Address data(mdp_in, reg, Address::times_1, constant);945946increment_mdp_data_at(data, decrement);947}948949950void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in, int flag_byte_constant) {951assert(ProfileInterpreter, "must be profiling interpreter");952int header_offset = in_bytes(DataLayout::header_offset());953int header_bits = DataLayout::flag_mask_to_header_mask(flag_byte_constant);954// Set the flag955orl(Address(mdp_in, header_offset), header_bits);956}957958959960void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in,961int offset,962Register value,963Register test_value_out,964Label& not_equal_continue) {965assert(ProfileInterpreter, "must be profiling interpreter");966if (test_value_out == noreg) {967cmpptr(value, Address(mdp_in, offset));968} else {969// Put the test value into a register, so caller can use it:970movptr(test_value_out, Address(mdp_in, offset));971cmpptr(test_value_out, value);972}973jcc(Assembler::notEqual, not_equal_continue);974}975976977void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, int offset_of_disp) {978assert(ProfileInterpreter, "must be profiling interpreter");979Address disp_address(mdp_in, offset_of_disp);980addptr(mdp_in,disp_address);981movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in);982}983984985void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, Register reg, int offset_of_disp) {986assert(ProfileInterpreter, "must be profiling interpreter");987Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp);988addptr(mdp_in, disp_address);989movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in);990}991992993void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, int constant) {994assert(ProfileInterpreter, "must be profiling interpreter");995addptr(mdp_in, constant);996movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in);997}9989991000void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {1001assert(ProfileInterpreter, "must be profiling interpreter");1002push(return_bci); // save/restore across call_VM1003call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), return_bci);1004pop(return_bci);1005}100610071008void InterpreterMacroAssembler::profile_taken_branch(Register mdp, Register bumped_count) {1009if (ProfileInterpreter) {1010Label profile_continue;10111012// If no method data exists, go to profile_continue.1013// Otherwise, assign to mdp1014test_method_data_pointer(mdp, profile_continue);10151016// We are taking a branch. Increment the taken count.1017// We inline increment_mdp_data_at to return bumped_count in a register1018//increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));1019Address data(mdp, in_bytes(JumpData::taken_offset()));10201021// %%% 64bit treats these cells as 64 bit but they seem to be 32 bit1022movl(bumped_count,data);1023assert( DataLayout::counter_increment==1, "flow-free idiom only works with 1" );1024addl(bumped_count, DataLayout::counter_increment);1025sbbl(bumped_count, 0);1026movl(data,bumped_count); // Store back out10271028// The method data pointer needs to be updated to reflect the new target.1029update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));1030bind (profile_continue);1031}1032}103310341035void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {1036if (ProfileInterpreter) {1037Label profile_continue;10381039// If no method data exists, go to profile_continue.1040test_method_data_pointer(mdp, profile_continue);10411042// We are taking a branch. Increment the not taken count.1043increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));10441045// The method data pointer needs to be updated to correspond to the next bytecode1046update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));1047bind (profile_continue);1048}1049}10501051void InterpreterMacroAssembler::profile_call(Register mdp) {1052if (ProfileInterpreter) {1053Label profile_continue;10541055// If no method data exists, go to profile_continue.1056test_method_data_pointer(mdp, profile_continue);10571058// We are making a call. Increment the count.1059increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));10601061// The method data pointer needs to be updated to reflect the new target.1062update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));1063bind (profile_continue);1064}1065}106610671068void InterpreterMacroAssembler::profile_final_call(Register mdp) {1069if (ProfileInterpreter) {1070Label profile_continue;10711072// If no method data exists, go to profile_continue.1073test_method_data_pointer(mdp, profile_continue);10741075// We are making a call. Increment the count.1076increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));10771078// The method data pointer needs to be updated to reflect the new target.1079update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));1080bind (profile_continue);1081}1082}108310841085void InterpreterMacroAssembler::profile_virtual_call(Register receiver, Register mdp,1086Register reg2,1087bool receiver_can_be_null) {1088if (ProfileInterpreter) {1089Label profile_continue;10901091// If no method data exists, go to profile_continue.1092test_method_data_pointer(mdp, profile_continue);10931094Label skip_receiver_profile;1095if (receiver_can_be_null) {1096Label not_null;1097testptr(receiver, receiver);1098jccb(Assembler::notZero, not_null);1099// We are making a call. Increment the count for null receiver.1100increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));1101jmp(skip_receiver_profile);1102bind(not_null);1103}11041105// Record the receiver type.1106record_klass_in_profile(receiver, mdp, reg2, true);1107bind(skip_receiver_profile);11081109// The method data pointer needs to be updated to reflect the new target.1110update_mdp_by_constant(mdp,1111in_bytes(VirtualCallData::1112virtual_call_data_size()));1113bind(profile_continue);1114}1115}111611171118void InterpreterMacroAssembler::record_klass_in_profile_helper(1119Register receiver, Register mdp,1120Register reg2, int start_row,1121Label& done, bool is_virtual_call) {1122if (TypeProfileWidth == 0) {1123if (is_virtual_call) {1124increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));1125}1126return;1127}11281129int last_row = VirtualCallData::row_limit() - 1;1130assert(start_row <= last_row, "must be work left to do");1131// Test this row for both the receiver and for null.1132// Take any of three different outcomes:1133// 1. found receiver => increment count and goto done1134// 2. found null => keep looking for case 1, maybe allocate this cell1135// 3. found something else => keep looking for cases 1 and 21136// Case 3 is handled by a recursive call.1137for (int row = start_row; row <= last_row; row++) {1138Label next_test;1139bool test_for_null_also = (row == start_row);11401141// See if the receiver is receiver[n].1142int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row));1143test_mdp_data_at(mdp, recvr_offset, receiver,1144(test_for_null_also ? reg2 : noreg),1145next_test);1146// (Reg2 now contains the receiver from the CallData.)11471148// The receiver is receiver[n]. Increment count[n].1149int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row));1150increment_mdp_data_at(mdp, count_offset);1151jmp(done);1152bind(next_test);11531154if (row == start_row) {1155Label found_null;1156// Failed the equality check on receiver[n]... Test for null.1157testptr(reg2, reg2);1158if (start_row == last_row) {1159// The only thing left to do is handle the null case.1160if (is_virtual_call) {1161jccb(Assembler::zero, found_null);1162// Receiver did not match any saved receiver and there is no empty row for it.1163// Increment total counter to indicate polymorphic case.1164increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));1165jmp(done);1166bind(found_null);1167} else {1168jcc(Assembler::notZero, done);1169}1170break;1171}1172// Since null is rare, make it be the branch-taken case.1173jcc(Assembler::zero, found_null);11741175// Put all the "Case 3" tests here.1176record_klass_in_profile_helper(receiver, mdp, reg2, start_row + 1, done, is_virtual_call);11771178// Found a null. Keep searching for a matching receiver,1179// but remember that this is an empty (unused) slot.1180bind(found_null);1181}1182}11831184// In the fall-through case, we found no matching receiver, but we1185// observed the receiver[start_row] is NULL.11861187// Fill in the receiver field and increment the count.1188int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));1189set_mdp_data_at(mdp, recvr_offset, receiver);1190int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));1191movptr(reg2, (intptr_t)DataLayout::counter_increment);1192set_mdp_data_at(mdp, count_offset, reg2);1193if (start_row > 0) {1194jmp(done);1195}1196}11971198void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,1199Register mdp, Register reg2,1200bool is_virtual_call) {1201assert(ProfileInterpreter, "must be profiling");1202Label done;12031204record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call);12051206bind (done);1207}12081209void InterpreterMacroAssembler::profile_ret(Register return_bci, Register mdp) {1210if (ProfileInterpreter) {1211Label profile_continue;1212uint row;12131214// If no method data exists, go to profile_continue.1215test_method_data_pointer(mdp, profile_continue);12161217// Update the total ret count.1218increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));12191220for (row = 0; row < RetData::row_limit(); row++) {1221Label next_test;12221223// See if return_bci is equal to bci[n]:1224test_mdp_data_at(mdp, in_bytes(RetData::bci_offset(row)), return_bci,1225noreg, next_test);12261227// return_bci is equal to bci[n]. Increment the count.1228increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row)));12291230// The method data pointer needs to be updated to reflect the new target.1231update_mdp_by_offset(mdp, in_bytes(RetData::bci_displacement_offset(row)));1232jmp(profile_continue);1233bind(next_test);1234}12351236update_mdp_for_ret(return_bci);12371238bind (profile_continue);1239}1240}124112421243void InterpreterMacroAssembler::profile_null_seen(Register mdp) {1244if (ProfileInterpreter) {1245Label profile_continue;12461247// If no method data exists, go to profile_continue.1248test_method_data_pointer(mdp, profile_continue);12491250set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());12511252// The method data pointer needs to be updated.1253int mdp_delta = in_bytes(BitData::bit_data_size());1254if (TypeProfileCasts) {1255mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());1256}1257update_mdp_by_constant(mdp, mdp_delta);12581259bind (profile_continue);1260}1261}126212631264void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) {1265if (ProfileInterpreter && TypeProfileCasts) {1266Label profile_continue;12671268// If no method data exists, go to profile_continue.1269test_method_data_pointer(mdp, profile_continue);12701271int count_offset = in_bytes(CounterData::count_offset());1272// Back up the address, since we have already bumped the mdp.1273count_offset -= in_bytes(VirtualCallData::virtual_call_data_size());12741275// *Decrement* the counter. We expect to see zero or small negatives.1276increment_mdp_data_at(mdp, count_offset, true);12771278bind (profile_continue);1279}1280}128112821283void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2)1284{1285if (ProfileInterpreter) {1286Label profile_continue;12871288// If no method data exists, go to profile_continue.1289test_method_data_pointer(mdp, profile_continue);12901291// The method data pointer needs to be updated.1292int mdp_delta = in_bytes(BitData::bit_data_size());1293if (TypeProfileCasts) {1294mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());12951296// Record the object type.1297record_klass_in_profile(klass, mdp, reg2, false);1298assert(reg2 == rdi, "we know how to fix this blown reg");1299restore_locals(); // Restore EDI1300}1301update_mdp_by_constant(mdp, mdp_delta);13021303bind(profile_continue);1304}1305}130613071308void InterpreterMacroAssembler::profile_switch_default(Register mdp) {1309if (ProfileInterpreter) {1310Label profile_continue;13111312// If no method data exists, go to profile_continue.1313test_method_data_pointer(mdp, profile_continue);13141315// Update the default case count1316increment_mdp_data_at(mdp, in_bytes(MultiBranchData::default_count_offset()));13171318// The method data pointer needs to be updated.1319update_mdp_by_offset(mdp, in_bytes(MultiBranchData::default_displacement_offset()));13201321bind (profile_continue);1322}1323}132413251326void InterpreterMacroAssembler::profile_switch_case(Register index, Register mdp, Register reg2) {1327if (ProfileInterpreter) {1328Label profile_continue;13291330// If no method data exists, go to profile_continue.1331test_method_data_pointer(mdp, profile_continue);13321333// Build the base (index * per_case_size_in_bytes()) + case_array_offset_in_bytes()1334movptr(reg2, (intptr_t)in_bytes(MultiBranchData::per_case_size()));1335// index is positive and so should have correct value if this code were1336// used on 64bits1337imulptr(index, reg2);1338addptr(index, in_bytes(MultiBranchData::case_array_offset()));13391340// Update the case count1341increment_mdp_data_at(mdp, index, in_bytes(MultiBranchData::relative_count_offset()));13421343// The method data pointer needs to be updated.1344update_mdp_by_offset(mdp, index, in_bytes(MultiBranchData::relative_displacement_offset()));13451346bind (profile_continue);1347}1348}13491350#endif // !CC_INTERP1351135213531354void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) {1355if (state == atos) MacroAssembler::verify_oop(reg);1356}135713581359#ifndef CC_INTERP1360void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {1361if (state == ftos || state == dtos) MacroAssembler::verify_FPU(stack_depth);1362}13631364#endif /* CC_INTERP */136513661367void InterpreterMacroAssembler::notify_method_entry() {1368// Whenever JVMTI is interp_only_mode, method entry/exit events are sent to1369// track stack depth. If it is possible to enter interp_only_mode we add1370// the code to check if the event should be sent.1371if (JvmtiExport::can_post_interpreter_events()) {1372Label L;1373get_thread(rcx);1374movl(rcx, Address(rcx, JavaThread::interp_only_mode_offset()));1375testl(rcx,rcx);1376jcc(Assembler::zero, L);1377call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry));1378bind(L);1379}13801381{1382SkipIfEqual skip_if(this, &DTraceMethodProbes, 0);1383get_thread(rcx);1384get_method(rbx);1385call_VM_leaf(1386CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), rcx, rbx);1387}13881389// RedefineClasses() tracing support for obsolete method entry1390if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {1391get_thread(rcx);1392get_method(rbx);1393call_VM_leaf(1394CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),1395rcx, rbx);1396}1397}139813991400void InterpreterMacroAssembler::notify_method_exit(1401TosState state, NotifyMethodExitMode mode) {1402// Whenever JVMTI is interp_only_mode, method entry/exit events are sent to1403// track stack depth. If it is possible to enter interp_only_mode we add1404// the code to check if the event should be sent.1405if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) {1406Label L;1407// Note: frame::interpreter_frame_result has a dependency on how the1408// method result is saved across the call to post_method_exit. If this1409// is changed then the interpreter_frame_result implementation will1410// need to be updated too.14111412// For c++ interpreter the result is always stored at a known location in the frame1413// template interpreter will leave it on the top of the stack.1414NOT_CC_INTERP(push(state);)1415get_thread(rcx);1416movl(rcx, Address(rcx, JavaThread::interp_only_mode_offset()));1417testl(rcx,rcx);1418jcc(Assembler::zero, L);1419call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit));1420bind(L);1421NOT_CC_INTERP(pop(state);)1422}14231424{1425SkipIfEqual skip_if(this, &DTraceMethodProbes, 0);1426NOT_CC_INTERP(push(state));1427get_thread(rbx);1428get_method(rcx);1429call_VM_leaf(1430CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),1431rbx, rcx);1432NOT_CC_INTERP(pop(state));1433}1434}14351436// Jump if ((*counter_addr += increment) & mask) satisfies the condition.1437void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,1438int increment, int mask,1439Register scratch, bool preloaded,1440Condition cond, Label* where) {1441if (!preloaded) {1442movl(scratch, counter_addr);1443}1444incrementl(scratch, increment);1445movl(counter_addr, scratch);1446andl(scratch, mask);1447if (where != NULL) {1448jcc(cond, *where);1449}1450}145114521453