duke@435: /* trims@1907: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: duke@435: // This file specializes the assember with interpreter-specific macros duke@435: duke@435: REGISTER_DECLARATION( Register, Otos_i , O0); // tos for ints, etc duke@435: REGISTER_DECLARATION( Register, Otos_l , O0); // for longs duke@435: REGISTER_DECLARATION( Register, Otos_l1, O0); // for 1st part of longs duke@435: REGISTER_DECLARATION( Register, Otos_l2, O1); // for 2nd part of longs duke@435: REGISTER_DECLARATION(FloatRegister, Ftos_f , F0); // for floats duke@435: REGISTER_DECLARATION(FloatRegister, Ftos_d , F0); // for doubles duke@435: REGISTER_DECLARATION(FloatRegister, Ftos_d1, F0); // for 1st part of double duke@435: REGISTER_DECLARATION(FloatRegister, Ftos_d2, F1); // for 2nd part of double duke@435: duke@435: #ifndef DONT_USE_REGISTER_DEFINES duke@435: #define Otos_i O0 duke@435: #define Otos_l O0 duke@435: #define Otos_l1 O0 duke@435: #define Otos_l2 O1 duke@435: #define Ftos_f F0 duke@435: #define Ftos_d F0 duke@435: #define Ftos_d1 F0 duke@435: #define Ftos_d2 F1 duke@435: #endif // DONT_USE_REGISTER_DEFINES duke@435: duke@435: class InterpreterMacroAssembler: public MacroAssembler { duke@435: protected: duke@435: #ifndef CC_INTERP duke@435: // Interpreter specific version of call_VM_base duke@435: virtual void call_VM_leaf_base( duke@435: Register java_thread, duke@435: address entry_point, duke@435: int number_of_arguments duke@435: ); duke@435: duke@435: virtual void call_VM_base( duke@435: Register oop_result, duke@435: Register java_thread, duke@435: Register last_java_sp, duke@435: address entry_point, duke@435: int number_of_arguments, duke@435: bool check_exception=true duke@435: ); duke@435: duke@435: virtual void check_and_handle_popframe(Register java_thread); duke@435: virtual void check_and_handle_earlyret(Register java_thread); duke@435: duke@435: // base routine for all dispatches duke@435: void dispatch_base(TosState state, address* table); duke@435: #endif /* CC_INTERP */ duke@435: duke@435: public: duke@435: InterpreterMacroAssembler(CodeBuffer* c) duke@435: : MacroAssembler(c) {} duke@435: duke@435: #ifndef CC_INTERP duke@435: virtual void load_earlyret_value(TosState state); duke@435: duke@435: static const Address l_tmp ; duke@435: static const Address d_tmp ; duke@435: #endif /* CC_INTERP */ duke@435: duke@435: // helper routine for frame allocation/deallocation duke@435: // compute the delta by which the caller's SP has to duke@435: // be adjusted to accomodate for the non-argument duke@435: // locals duke@435: void compute_extra_locals_size_in_bytes(Register args_size, Register locals_size, Register delta); duke@435: duke@435: #ifndef CC_INTERP duke@435: duke@435: // dispatch routines duke@435: void dispatch_prolog(TosState state, int step = 0); duke@435: void dispatch_epilog(TosState state, int step = 0); duke@435: void dispatch_only(TosState state); duke@435: void dispatch_normal(TosState state); duke@435: void dispatch_next(TosState state, int step = 0); duke@435: void dispatch_next_noverify_oop(TosState state, int step = 0); duke@435: void dispatch_via (TosState state, address* table); duke@435: duke@435: duke@435: // Removes the current activation (incl. unlocking of monitors). duke@435: // Additionally this code is used for earlyReturn in which case we duke@435: // want to skip throwing an exception and installing an exception. duke@435: void remove_activation(TosState state, duke@435: bool throw_monitor_exception = true, duke@435: bool install_monitor_exception = true); duke@435: duke@435: protected: duke@435: void dispatch_Lbyte_code(TosState state, address* table, int bcp_incr = 0, bool verify = true); duke@435: #endif /* CC_INTERP */ duke@435: duke@435: public: duke@435: // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls duke@435: void super_call_VM(Register thread_cache, duke@435: Register oop_result, duke@435: Register last_java_sp, duke@435: address entry_point, duke@435: Register arg_1, duke@435: Register arg_2, duke@435: bool check_exception = true); duke@435: duke@435: #ifndef CC_INTERP twisti@1730: void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2); duke@435: duke@435: // Generate a subtype check: branch to ok_is_subtype if sub_klass is duke@435: // a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3. duke@435: void gen_subtype_check( Register sub_klass, Register super_klass, Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype ); duke@435: duke@435: // helpers for tossing exceptions duke@435: void throw_if_not_1_icc( Condition ok_condition, Label& ok ); duke@435: void throw_if_not_1_xcc( Condition ok_condition, Label& ok ); duke@435: void throw_if_not_1_x ( Condition ok_condition, Label& ok ); // chooses icc or xcc based on _LP64 duke@435: duke@435: void throw_if_not_2( address throw_entry_point, Register Rscratch, Label& ok); duke@435: duke@435: void throw_if_not_icc( Condition ok_condition, address throw_entry_point, Register Rscratch ); duke@435: void throw_if_not_xcc( Condition ok_condition, address throw_entry_point, Register Rscratch ); duke@435: void throw_if_not_x ( Condition ok_condition, address throw_entry_point, Register Rscratch ); duke@435: duke@435: // helpers for expression stack duke@435: duke@435: void pop_i( Register r = Otos_i); duke@435: void pop_ptr( Register r = Otos_i, Register scratch = O4); duke@435: void pop_l( Register r = Otos_l1); duke@435: // G4_scratch and Lscratch are used at call sites!! duke@435: void pop_f(FloatRegister f = Ftos_f, Register scratch = G1_scratch); duke@435: void pop_d(FloatRegister f = Ftos_d1, Register scratch = G1_scratch); duke@435: duke@435: void push_i( Register r = Otos_i); duke@435: void push_ptr( Register r = Otos_i); duke@435: void push_l( Register r = Otos_l1); duke@435: void push_f(FloatRegister f = Ftos_f); duke@435: void push_d(FloatRegister f = Ftos_d1); duke@435: duke@435: duke@435: void pop (TosState state); // transition vtos -> state duke@435: void push(TosState state); // transition state -> vtos duke@435: void empty_expression_stack(); // resets both Lesp and SP duke@435: duke@435: #ifdef ASSERT duke@435: void verify_sp(Register Rsp, Register Rtemp); duke@435: void verify_esp(Register Resp); // verify that Lesp points to a word in the temp stack duke@435: #endif // ASSERT duke@435: duke@435: public: duke@435: void if_cmp(Condition cc, bool ptr_compare); duke@435: duke@435: // Load values from bytecode stream: duke@435: duke@435: enum signedOrNot { Signed, Unsigned }; duke@435: enum setCCOrNot { set_CC, dont_set_CC }; duke@435: duke@435: void get_2_byte_integer_at_bcp( int bcp_offset, duke@435: Register Rtmp, duke@435: Register Rdst, duke@435: signedOrNot is_signed, duke@435: setCCOrNot should_set_CC = dont_set_CC ); duke@435: duke@435: void get_4_byte_integer_at_bcp( int bcp_offset, duke@435: Register Rtmp, duke@435: Register Rdst, duke@435: setCCOrNot should_set_CC = dont_set_CC ); duke@435: jrose@1920: void get_cache_and_index_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2)); jrose@1920: void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2)); jrose@1920: void get_cache_index_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2)); duke@435: duke@435: duke@435: // common code duke@435: duke@435: void field_offset_at(int n, Register tmp, Register dest, Register base); duke@435: int field_offset_at(Register object, address bcp, int offset); duke@435: void fast_iaaccess(int n, address bcp); duke@435: void fast_iagetfield(address bcp); duke@435: void fast_iaputfield(address bcp, bool do_store_check ); duke@435: duke@435: void index_check(Register array, Register index, int index_shift, Register tmp, Register res); duke@435: void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res); duke@435: duke@435: void get_constant_pool(Register Rdst); duke@435: void get_constant_pool_cache(Register Rdst); duke@435: void get_cpool_and_tags(Register Rcpool, Register Rtags); duke@435: void is_a(Label& L); duke@435: duke@435: // Load compiled (i2c) or interpreter entry and call from interpreted duke@435: void call_from_interpreter(Register target, Register scratch, Register Rret); duke@435: duke@435: // -------------------------------------------------- duke@435: duke@435: void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true, bool install_monitor_exception = true); duke@435: duke@435: void add_monitor_to_stack( bool stack_is_empty, duke@435: Register Rtemp, duke@435: Register Rtemp2 ); duke@435: duke@435: // Load/store aligned in _LP64 but unaligned otherwise duke@435: // These only apply to the Interpreter expression stack and locals! duke@435: void load_unaligned_double(Register r1, int offset, FloatRegister d); duke@435: void store_unaligned_double(FloatRegister d, Register r1, int offset ); duke@435: duke@435: // Load/store aligned in _LP64 but unaligned otherwise duke@435: void load_unaligned_long(Register r1, int offset, Register d); duke@435: void store_unaligned_long(Register d, Register r1, int offset ); duke@435: duke@435: void access_local_int( Register index, Register dst ); duke@435: void access_local_ptr( Register index, Register dst ); duke@435: void access_local_returnAddress( Register index, Register dst ); duke@435: void access_local_long( Register index, Register dst ); duke@435: void access_local_float( Register index, FloatRegister dst ); duke@435: void access_local_double( Register index, FloatRegister dst ); duke@435: #ifdef ASSERT duke@435: void check_for_regarea_stomp( Register Rindex, int offset, Register Rlimit, Register Rscratch, Register Rscratch1); duke@435: #endif // ASSERT duke@435: void store_local_int( Register index, Register src ); twisti@1861: void store_local_ptr( Register index, Register src ); twisti@1861: void store_local_ptr( int n, Register src ); duke@435: void store_local_long( Register index, Register src ); duke@435: void store_local_float( Register index, FloatRegister src ); duke@435: void store_local_double( Register index, FloatRegister src ); duke@435: twisti@1861: // Helpers for swap and dup twisti@1861: void load_ptr(int n, Register val); twisti@1861: void store_ptr(int n, Register val); duke@435: twisti@1861: // Helper for getting receiver in register. duke@435: void load_receiver(Register param_count, Register recv); duke@435: duke@435: static int top_most_monitor_byte_offset(); // offset in bytes to top of monitor block duke@435: Address top_most_monitor(); duke@435: void compute_stack_base( Register Rdest ); duke@435: duke@435: #endif /* CC_INTERP */ duke@435: void increment_invocation_counter( Register Rtmp, Register Rtmp2 ); duke@435: void increment_backedge_counter( Register Rtmp, Register Rtmp2 ); duke@435: #ifndef CC_INTERP duke@435: void test_backedge_count_for_osr( Register backedge_count, Register branch_bcp, Register Rtmp ); duke@435: duke@435: #endif /* CC_INTERP */ duke@435: // Object locking duke@435: void lock_object (Register lock_reg, Register obj_reg); duke@435: void unlock_object(Register lock_reg); duke@435: duke@435: #ifndef CC_INTERP duke@435: // Interpreter profiling operations duke@435: void set_method_data_pointer() { set_method_data_pointer_offset(noreg); } duke@435: void set_method_data_pointer_for_bcp(); duke@435: void set_method_data_pointer_offset(Register mdi_reg); duke@435: void test_method_data_pointer(Label& zero_continue); duke@435: void verify_method_data_pointer(); duke@435: void test_invocation_counter_for_mdp(Register invocation_count, Register cur_bcp, Register Rtmp, Label &profile_continue); duke@435: duke@435: void set_mdp_data_at(int constant, Register value); duke@435: void increment_mdp_data_at(Address counter, Register bumped_count, duke@435: bool decrement = false); duke@435: void increment_mdp_data_at(int constant, Register bumped_count, duke@435: bool decrement = false); duke@435: void increment_mdp_data_at(Register reg, int constant, duke@435: Register bumped_count, Register scratch2, duke@435: bool decrement = false); duke@435: void set_mdp_flag_at(int flag_constant, Register scratch); duke@435: void test_mdp_data_at(int offset, Register value, Label& not_equal_continue, duke@435: Register scratch); duke@435: kvn@1641: void record_klass_in_profile(Register receiver, Register scratch, bool is_virtual_call); duke@435: void record_klass_in_profile_helper(Register receiver, Register scratch, kvn@1641: int start_row, Label& done, bool is_virtual_call); duke@435: duke@435: void update_mdp_by_offset(int offset_of_disp, Register scratch); duke@435: void update_mdp_by_offset(Register reg, int offset_of_disp, duke@435: Register scratch); duke@435: void update_mdp_by_constant(int constant); duke@435: void update_mdp_for_ret(TosState state, Register return_bci); duke@435: duke@435: void profile_taken_branch(Register scratch, Register bumped_count); duke@435: void profile_not_taken_branch(Register scratch); duke@435: void profile_call(Register scratch); duke@435: void profile_final_call(Register scratch); twisti@1858: void profile_virtual_call(Register receiver, Register scratch, bool receiver_can_be_null = false); duke@435: void profile_ret(TosState state, Register return_bci, Register scratch); duke@435: void profile_null_seen(Register scratch); duke@435: void profile_typecheck(Register klass, Register scratch); duke@435: void profile_typecheck_failed(Register scratch); duke@435: void profile_switch_default(Register scratch); duke@435: void profile_switch_case(Register index, duke@435: Register scratch1, duke@435: Register scratch2, duke@435: Register scratch3); duke@435: duke@435: // Debugging duke@435: void interp_verify_oop(Register reg, TosState state, const char * file, int line); // only if +VerifyOops && state == atos duke@435: void verify_oop_or_return_address(Register reg, Register rtmp); // for astore duke@435: void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU && (state == ftos || state == dtos) duke@435: duke@435: #endif /* CC_INTERP */ duke@435: // support for JVMTI/Dtrace duke@435: typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode; duke@435: void notify_method_entry(); duke@435: void notify_method_exit( duke@435: bool save_result, TosState state, NotifyMethodExitMode mode); duke@435: duke@435: void save_return_value(TosState state, bool is_native_call); duke@435: void restore_return_value(TosState state, bool is_native_call); duke@435: };