0N/A/*
3790N/A * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef CPU_X86_VM_INTERP_MASM_X86_64_HPP
1879N/A#define CPU_X86_VM_INTERP_MASM_X86_64_HPP
1879N/A
1879N/A#include "assembler_x86.inline.hpp"
1879N/A#include "interpreter/invocationCounter.hpp"
1879N/A
0N/A// This file specializes the assember with interpreter-specific macros
0N/A
0N/A
304N/Aclass InterpreterMacroAssembler: public MacroAssembler {
304N/A#ifndef CC_INTERP
0N/A protected:
0N/A // Interpreter specific version of call_VM_base
0N/A virtual void call_VM_leaf_base(address entry_point,
0N/A int number_of_arguments);
0N/A
0N/A virtual void call_VM_base(Register oop_result,
0N/A Register java_thread,
0N/A Register last_java_sp,
0N/A address entry_point,
0N/A int number_of_arguments,
0N/A bool check_exceptions);
0N/A
0N/A virtual void check_and_handle_popframe(Register java_thread);
0N/A virtual void check_and_handle_earlyret(Register java_thread);
0N/A
0N/A // base routine for all dispatches
0N/A void dispatch_base(TosState state, address* table, bool verifyoop = true);
304N/A#endif // CC_INTERP
0N/A
0N/A public:
304N/A InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {}
0N/A
0N/A void load_earlyret_value(TosState state);
0N/A
304N/A#ifdef CC_INTERP
304N/A void save_bcp() { /* not needed in c++ interpreter and harmless */ }
304N/A void restore_bcp() { /* not needed in c++ interpreter and harmless */ }
304N/A
304N/A // Helpers for runtime call arguments/results
304N/A void get_method(Register reg);
304N/A
304N/A#else
304N/A
0N/A // Interpreter-specific registers
304N/A void save_bcp() {
304N/A movptr(Address(rbp, frame::interpreter_frame_bcx_offset * wordSize), r13);
0N/A }
0N/A
304N/A void restore_bcp() {
304N/A movptr(r13, Address(rbp, frame::interpreter_frame_bcx_offset * wordSize));
0N/A }
0N/A
304N/A void restore_locals() {
304N/A movptr(r14, Address(rbp, frame::interpreter_frame_locals_offset * wordSize));
0N/A }
0N/A
0N/A // Helpers for runtime call arguments/results
304N/A void get_method(Register reg) {
304N/A movptr(reg, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
0N/A }
0N/A
3790N/A void get_const(Register reg) {
0N/A get_method(reg);
3790N/A movptr(reg, Address(reg, methodOopDesc::const_offset()));
3790N/A }
3790N/A
3790N/A void get_constant_pool(Register reg) {
3790N/A get_const(reg);
3790N/A movptr(reg, Address(reg, constMethodOopDesc::constants_offset()));
0N/A }
0N/A
304N/A void get_constant_pool_cache(Register reg) {
0N/A get_constant_pool(reg);
304N/A movptr(reg, Address(reg, constantPoolOopDesc::cache_offset_in_bytes()));
0N/A }
0N/A
304N/A void get_cpool_and_tags(Register cpool, Register tags) {
0N/A get_constant_pool(cpool);
304N/A movptr(tags, Address(cpool, constantPoolOopDesc::tags_offset_in_bytes()));
0N/A }
0N/A
0N/A void get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset);
2677N/A void get_cache_and_index_at_bcp(Register cache, Register index, int bcp_offset, size_t index_size = sizeof(u2));
2677N/A void get_cache_and_index_and_bytecode_at_bcp(Register cache, Register index, Register bytecode, int byte_no, int bcp_offset, size_t index_size = sizeof(u2));
2677N/A void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2));
1485N/A void get_cache_index_at_bcp(Register index, int bcp_offset, size_t index_size = sizeof(u2));
0N/A
0N/A void pop_ptr(Register r = rax);
0N/A void pop_i(Register r = rax);
0N/A void pop_l(Register r = rax);
0N/A void pop_f(XMMRegister r = xmm0);
0N/A void pop_d(XMMRegister r = xmm0);
0N/A void push_ptr(Register r = rax);
0N/A void push_i(Register r = rax);
0N/A void push_l(Register r = rax);
0N/A void push_f(XMMRegister r = xmm0);
0N/A void push_d(XMMRegister r = xmm0);
0N/A
304N/A void pop(Register r ) { ((MacroAssembler*)this)->pop(r); }
304N/A
304N/A void push(Register r ) { ((MacroAssembler*)this)->push(r); }
304N/A void push(int32_t imm ) { ((MacroAssembler*)this)->push(imm); }
304N/A
0N/A void pop(TosState state); // transition vtos -> state
0N/A void push(TosState state); // transition state -> vtos
0N/A
1426N/A void empty_expression_stack() {
304N/A movptr(rsp, Address(rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize));
0N/A // NULL last_sp until next java call
304N/A movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
0N/A }
0N/A
1426N/A // Helpers for swap and dup
1426N/A void load_ptr(int n, Register val);
1426N/A void store_ptr(int n, Register val);
1426N/A
0N/A // Generate a subtype check: branch to ok_is_subtype if sub_klass is
0N/A // a subtype of super_klass.
0N/A void gen_subtype_check( Register sub_klass, Label &ok_is_subtype );
0N/A
0N/A // Dispatching
0N/A void dispatch_prolog(TosState state, int step = 0);
0N/A void dispatch_epilog(TosState state, int step = 0);
0N/A // dispatch via ebx (assume ebx is loaded already)
0N/A void dispatch_only(TosState state);
0N/A // dispatch normal table via ebx (assume ebx is loaded already)
0N/A void dispatch_only_normal(TosState state);
0N/A void dispatch_only_noverify(TosState state);
0N/A // load ebx from [esi + step] and dispatch via ebx
0N/A void dispatch_next(TosState state, int step = 0);
0N/A // load ebx from [esi] and dispatch via ebx and table
0N/A void dispatch_via (TosState state, address* table);
0N/A
0N/A // jump to an invoked target
710N/A void prepare_to_jump_from_interpreted();
0N/A void jump_from_interpreted(Register method, Register temp);
0N/A
0N/A
0N/A // Returning from interpreted functions
0N/A //
0N/A // Removes the current activation (incl. unlocking of monitors)
0N/A // and sets up the return address. This code is also used for
0N/A // exception unwindwing. In that case, we do not want to throw
0N/A // IllegalMonitorStateExceptions, since that might get us into an
0N/A // infinite rethrow exception loop.
0N/A // Additionally this code is used for popFrame and earlyReturn.
0N/A // In popFrame case we want to skip throwing an exception,
0N/A // installing an exception, and notifying jvmdi.
0N/A // In earlyReturn case we only want to skip throwing an exception
0N/A // and installing an exception.
0N/A void remove_activation(TosState state, Register ret_addr,
0N/A bool throw_monitor_exception = true,
0N/A bool install_monitor_exception = true,
0N/A bool notify_jvmdi = true);
304N/A#endif // CC_INTERP
0N/A
0N/A // Object locking
0N/A void lock_object (Register lock_reg);
0N/A void unlock_object(Register lock_reg);
0N/A
304N/A#ifndef CC_INTERP
304N/A
0N/A // Interpreter profiling operations
0N/A void set_method_data_pointer_for_bcp();
0N/A void test_method_data_pointer(Register mdp, Label& zero_continue);
0N/A void verify_method_data_pointer();
0N/A
0N/A void set_mdp_data_at(Register mdp_in, int constant, Register value);
0N/A void increment_mdp_data_at(Address data, bool decrement = false);
0N/A void increment_mdp_data_at(Register mdp_in, int constant,
0N/A bool decrement = false);
0N/A void increment_mdp_data_at(Register mdp_in, Register reg, int constant,
0N/A bool decrement = false);
1703N/A void increment_mask_and_jump(Address counter_addr,
1703N/A int increment, int mask,
1703N/A Register scratch, bool preloaded,
1703N/A Condition cond, Label* where);
0N/A void set_mdp_flag_at(Register mdp_in, int flag_constant);
0N/A void test_mdp_data_at(Register mdp_in, int offset, Register value,
0N/A Register test_value_out,
0N/A Label& not_equal_continue);
0N/A
0N/A void record_klass_in_profile(Register receiver, Register mdp,
1206N/A Register reg2, bool is_virtual_call);
0N/A void record_klass_in_profile_helper(Register receiver, Register mdp,
1206N/A Register reg2, int start_row,
1206N/A Label& done, bool is_virtual_call);
0N/A
0N/A void update_mdp_by_offset(Register mdp_in, int offset_of_offset);
0N/A void update_mdp_by_offset(Register mdp_in, Register reg, int offset_of_disp);
0N/A void update_mdp_by_constant(Register mdp_in, int constant);
0N/A void update_mdp_for_ret(Register return_bci);
0N/A
0N/A void profile_taken_branch(Register mdp, Register bumped_count);
0N/A void profile_not_taken_branch(Register mdp);
0N/A void profile_call(Register mdp);
0N/A void profile_final_call(Register mdp);
0N/A void profile_virtual_call(Register receiver, Register mdp,
1108N/A Register scratch2,
1108N/A bool receiver_can_be_null = false);
0N/A void profile_ret(Register return_bci, Register mdp);
0N/A void profile_null_seen(Register mdp);
0N/A void profile_typecheck(Register mdp, Register klass, Register scratch);
0N/A void profile_typecheck_failed(Register mdp);
0N/A void profile_switch_default(Register mdp);
0N/A void profile_switch_case(Register index_in_scratch, Register mdp,
0N/A Register scratch2);
0N/A
0N/A // Debugging
0N/A // only if +VerifyOops && state == atos
0N/A void verify_oop(Register reg, TosState state = atos);
0N/A // only if +VerifyFPU && (state == ftos || state == dtos)
0N/A void verify_FPU(int stack_depth, TosState state = ftos);
0N/A
304N/A#endif // !CC_INTERP
304N/A
0N/A typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;
0N/A
0N/A // support for jvmti/dtrace
0N/A void notify_method_entry();
0N/A void notify_method_exit(TosState state, NotifyMethodExitMode mode);
0N/A};
1879N/A
1879N/A#endif // CPU_X86_VM_INTERP_MASM_X86_64_HPP