Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/sparc/vm/interp_masm_sparc.hpp
32285 views
/*1* Copyright (c) 1997, 2016, 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#ifndef CPU_SPARC_VM_INTERP_MASM_SPARC_HPP25#define CPU_SPARC_VM_INTERP_MASM_SPARC_HPP2627#include "asm/macroAssembler.inline.hpp"28#include "interpreter/invocationCounter.hpp"2930// This file specializes the assember with interpreter-specific macros3132REGISTER_DECLARATION( Register, Otos_i , O0); // tos for ints, etc33REGISTER_DECLARATION( Register, Otos_l , O0); // for longs34REGISTER_DECLARATION( Register, Otos_l1, O0); // for 1st part of longs35REGISTER_DECLARATION( Register, Otos_l2, O1); // for 2nd part of longs36REGISTER_DECLARATION(FloatRegister, Ftos_f , F0); // for floats37REGISTER_DECLARATION(FloatRegister, Ftos_d , F0); // for doubles38REGISTER_DECLARATION(FloatRegister, Ftos_d1, F0); // for 1st part of double39REGISTER_DECLARATION(FloatRegister, Ftos_d2, F1); // for 2nd part of double4041#ifndef DONT_USE_REGISTER_DEFINES42#define Otos_i O043#define Otos_l O044#define Otos_l1 O045#define Otos_l2 O146#define Ftos_f F047#define Ftos_d F048#define Ftos_d1 F049#define Ftos_d2 F150#endif // DONT_USE_REGISTER_DEFINES5152class InterpreterMacroAssembler: public MacroAssembler {53protected:54#ifndef CC_INTERP55// Interpreter specific version of call_VM_base56virtual void call_VM_leaf_base(57Register java_thread,58address entry_point,59int number_of_arguments60);6162virtual void call_VM_base(63Register oop_result,64Register java_thread,65Register last_java_sp,66address entry_point,67int number_of_arguments,68bool check_exception=true69);7071virtual void check_and_handle_popframe(Register java_thread);72virtual void check_and_handle_earlyret(Register java_thread);7374// base routine for all dispatches75void dispatch_base(TosState state, address* table);76#endif /* CC_INTERP */7778public:79InterpreterMacroAssembler(CodeBuffer* c)80: MacroAssembler(c) {}8182#ifndef CC_INTERP83virtual void load_earlyret_value(TosState state);8485static const Address l_tmp ;86static const Address d_tmp ;87#endif /* CC_INTERP */8889// helper routine for frame allocation/deallocation90// compute the delta by which the caller's SP has to91// be adjusted to accomodate for the non-argument92// locals93void compute_extra_locals_size_in_bytes(Register args_size, Register locals_size, Register delta);9495#ifndef CC_INTERP9697// dispatch routines98void dispatch_prolog(TosState state, int step = 0);99void dispatch_epilog(TosState state, int step = 0);100void dispatch_only(TosState state);101void dispatch_normal(TosState state);102void dispatch_next(TosState state, int step = 0);103void dispatch_next_noverify_oop(TosState state, int step = 0);104void dispatch_via (TosState state, address* table);105106107void narrow(Register result);108109// Removes the current activation (incl. unlocking of monitors).110// Additionally this code is used for earlyReturn in which case we111// want to skip throwing an exception and installing an exception.112void remove_activation(TosState state,113bool throw_monitor_exception = true,114bool install_monitor_exception = true);115116protected:117void dispatch_Lbyte_code(TosState state, address* table, int bcp_incr = 0, bool verify = true);118#endif /* CC_INTERP */119120public:121// Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls122void super_call_VM(Register thread_cache,123Register oop_result,124Register last_java_sp,125address entry_point,126Register arg_1,127Register arg_2,128bool check_exception = true);129130#ifndef CC_INTERP131void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2);132133// Generate a subtype check: branch to ok_is_subtype if sub_klass is134// a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3.135void gen_subtype_check( Register sub_klass, Register super_klass, Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype );136137// helpers for tossing exceptions138void throw_if_not_1_icc( Condition ok_condition, Label& ok );139void throw_if_not_1_xcc( Condition ok_condition, Label& ok );140void throw_if_not_1_x ( Condition ok_condition, Label& ok ); // chooses icc or xcc based on _LP64141142void throw_if_not_2( address throw_entry_point, Register Rscratch, Label& ok);143144void throw_if_not_icc( Condition ok_condition, address throw_entry_point, Register Rscratch );145void throw_if_not_xcc( Condition ok_condition, address throw_entry_point, Register Rscratch );146void throw_if_not_x ( Condition ok_condition, address throw_entry_point, Register Rscratch );147148// helpers for expression stack149150void pop_i( Register r = Otos_i);151void pop_ptr( Register r = Otos_i, Register scratch = O4);152void pop_l( Register r = Otos_l1);153// G4_scratch and Lscratch are used at call sites!!154void pop_f(FloatRegister f = Ftos_f, Register scratch = G1_scratch);155void pop_d(FloatRegister f = Ftos_d1, Register scratch = G1_scratch);156157void push_i( Register r = Otos_i);158void push_ptr( Register r = Otos_i);159void push_l( Register r = Otos_l1);160void push_f(FloatRegister f = Ftos_f);161void push_d(FloatRegister f = Ftos_d1);162163164void pop (TosState state); // transition vtos -> state165void push(TosState state); // transition state -> vtos166void empty_expression_stack(); // resets both Lesp and SP167168#ifdef ASSERT169void verify_sp(Register Rsp, Register Rtemp);170void verify_esp(Register Resp); // verify that Lesp points to a word in the temp stack171#endif // ASSERT172173public:174void if_cmp(Condition cc, bool ptr_compare);175176// Load values from bytecode stream:177178enum signedOrNot { Signed, Unsigned };179enum setCCOrNot { set_CC, dont_set_CC };180181void get_2_byte_integer_at_bcp( int bcp_offset,182Register Rtmp,183Register Rdst,184signedOrNot is_signed,185setCCOrNot should_set_CC = dont_set_CC );186187void get_4_byte_integer_at_bcp( int bcp_offset,188Register Rtmp,189Register Rdst,190setCCOrNot should_set_CC = dont_set_CC );191192// Note: "get_cache_and_index" really means "get the index, use it to get the cache entry, and throw away the index".193void get_cache_and_index_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2));194void get_cache_and_index_and_bytecode_at_bcp(Register cache, Register temp, Register bytecode, int byte_no, int bcp_offset, size_t index_size = sizeof(u2));195void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2));196// Note: This one does not fetch the cache. The first argument is a temp which may be killed.197void get_cache_index_at_bcp(Register temp, Register index, int bcp_offset, size_t index_size = sizeof(u2));198199// load cpool->resolved_references(index);200void load_resolved_reference_at_index(Register result, Register index);201202// common code203204void field_offset_at(int n, Register tmp, Register dest, Register base);205int field_offset_at(Register object, address bcp, int offset);206void fast_iaaccess(int n, address bcp);207void fast_iagetfield(address bcp);208void fast_iaputfield(address bcp, bool do_store_check );209210void index_check(Register array, Register index, int index_shift, Register tmp, Register res);211void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res);212213void get_const(Register Rdst);214void get_constant_pool(Register Rdst);215void get_constant_pool_cache(Register Rdst);216void get_cpool_and_tags(Register Rcpool, Register Rtags);217void is_a(Label& L);218219// Load compiled (i2c) or interpreter entry and call from interpreted220void call_from_interpreter(Register target, Register scratch, Register Rret);221222// --------------------------------------------------223224void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true, bool install_monitor_exception = true);225226void add_monitor_to_stack( bool stack_is_empty,227Register Rtemp,228Register Rtemp2 );229230// Load/store aligned in _LP64 but unaligned otherwise231// These only apply to the Interpreter expression stack and locals!232void load_unaligned_double(Register r1, int offset, FloatRegister d);233void store_unaligned_double(FloatRegister d, Register r1, int offset );234235// Load/store aligned in _LP64 but unaligned otherwise236void load_unaligned_long(Register r1, int offset, Register d);237void store_unaligned_long(Register d, Register r1, int offset );238239void access_local_int( Register index, Register dst );240void access_local_ptr( Register index, Register dst );241void access_local_returnAddress( Register index, Register dst );242void access_local_long( Register index, Register dst );243void access_local_float( Register index, FloatRegister dst );244void access_local_double( Register index, FloatRegister dst );245#ifdef ASSERT246void check_for_regarea_stomp( Register Rindex, int offset, Register Rlimit, Register Rscratch, Register Rscratch1);247#endif // ASSERT248void store_local_int( Register index, Register src );249void store_local_ptr( Register index, Register src );250void store_local_ptr( int n, Register src );251void store_local_long( Register index, Register src );252void store_local_float( Register index, FloatRegister src );253void store_local_double( Register index, FloatRegister src );254255// Helpers for swap and dup256void load_ptr(int n, Register val);257void store_ptr(int n, Register val);258259// Helper for getting receiver in register.260void load_receiver(Register param_count, Register recv);261262static int top_most_monitor_byte_offset(); // offset in bytes to top of monitor block263Address top_most_monitor();264void compute_stack_base( Register Rdest );265266#endif /* CC_INTERP */267void get_method_counters(Register method, Register Rcounters, Label& skip);268void increment_invocation_counter( Register Rcounters, Register Rtmp, Register Rtmp2 );269void increment_backedge_counter( Register Rcounters, Register Rtmp, Register Rtmp2 );270#ifndef CC_INTERP271void test_backedge_count_for_osr( Register backedge_count, Register branch_bcp, Register Rtmp );272273#endif /* CC_INTERP */274// Object locking275void lock_object (Register lock_reg, Register obj_reg);276void unlock_object(Register lock_reg);277278#ifndef CC_INTERP279// Interpreter profiling operations280void set_method_data_pointer();281void set_method_data_pointer_for_bcp();282void test_method_data_pointer(Label& zero_continue);283void verify_method_data_pointer();284void test_invocation_counter_for_mdp(Register invocation_count, Register Rtmp, Label &profile_continue);285286void set_mdp_data_at(int constant, Register value);287void increment_mdp_data_at(Address counter, Register bumped_count,288bool decrement = false);289void increment_mdp_data_at(int constant, Register bumped_count,290bool decrement = false);291void increment_mdp_data_at(Register reg, int constant,292Register bumped_count, Register scratch2,293bool decrement = false);294void increment_mask_and_jump(Address counter_addr,295int increment, int mask,296Register scratch1, Register scratch2,297Condition cond, Label *where);298void set_mdp_flag_at(int flag_constant, Register scratch);299void test_mdp_data_at(int offset, Register value, Label& not_equal_continue,300Register scratch);301302void record_klass_in_profile(Register receiver, Register scratch, bool is_virtual_call);303void record_klass_in_profile_helper(Register receiver, Register scratch,304int start_row, Label& done, bool is_virtual_call);305306void update_mdp_by_offset(int offset_of_disp, Register scratch);307void update_mdp_by_offset(Register reg, int offset_of_disp,308Register scratch);309void update_mdp_by_constant(int constant);310void update_mdp_for_ret(TosState state, Register return_bci);311312void profile_taken_branch(Register scratch, Register bumped_count);313void profile_not_taken_branch(Register scratch);314void profile_call(Register scratch);315void profile_final_call(Register scratch);316void profile_virtual_call(Register receiver, Register scratch, bool receiver_can_be_null = false);317void profile_ret(TosState state, Register return_bci, Register scratch);318void profile_null_seen(Register scratch);319void profile_typecheck(Register klass, Register scratch);320void profile_typecheck_failed(Register scratch);321void profile_switch_default(Register scratch);322void profile_switch_case(Register index,323Register scratch1,324Register scratch2,325Register scratch3);326327void profile_obj_type(Register obj, const Address& mdo_addr, Register tmp);328void profile_arguments_type(Register callee, Register tmp1, Register tmp2, bool is_virtual);329void profile_return_type(Register ret, Register tmp1, Register tmp2);330void profile_parameters_type(Register tmp1, Register tmp2, Register tmp3, Register tmp4);331332// Debugging333void interp_verify_oop(Register reg, TosState state, const char * file, int line); // only if +VerifyOops && state == atos334void verify_oop_or_return_address(Register reg, Register rtmp); // for astore335void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU && (state == ftos || state == dtos)336337#endif /* CC_INTERP */338// support for JVMTI/Dtrace339typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;340void notify_method_entry();341void notify_method_exit(342bool save_result, TosState state, NotifyMethodExitMode mode);343344void save_return_value(TosState state, bool is_native_call);345void restore_return_value(TosState state, bool is_native_call);346347};348349#endif // CPU_SPARC_VM_INTERP_MASM_SPARC_HPP350351352