src/cpu/sparc/vm/interp_masm_sparc.hpp

changeset 435
a61af66fc99e
child 1641
87684f1a88b5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cpu/sparc/vm/interp_masm_sparc.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,332 @@
     1.4 +/*
     1.5 + * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// This file specializes the assember with interpreter-specific macros
    1.29 +
    1.30 +REGISTER_DECLARATION(     Register, Otos_i , O0); // tos for ints, etc
    1.31 +REGISTER_DECLARATION(     Register, Otos_l , O0); // for longs
    1.32 +REGISTER_DECLARATION(     Register, Otos_l1, O0); // for 1st part of longs
    1.33 +REGISTER_DECLARATION(     Register, Otos_l2, O1); // for 2nd part of longs
    1.34 +REGISTER_DECLARATION(FloatRegister, Ftos_f , F0); // for floats
    1.35 +REGISTER_DECLARATION(FloatRegister, Ftos_d , F0); // for doubles
    1.36 +REGISTER_DECLARATION(FloatRegister, Ftos_d1, F0); // for 1st part of double
    1.37 +REGISTER_DECLARATION(FloatRegister, Ftos_d2, F1); // for 2nd part of double
    1.38 +
    1.39 +#ifndef DONT_USE_REGISTER_DEFINES
    1.40 +#define Otos_i  O0
    1.41 +#define Otos_l  O0
    1.42 +#define Otos_l1 O0
    1.43 +#define Otos_l2 O1
    1.44 +#define Ftos_f  F0
    1.45 +#define Ftos_d  F0
    1.46 +#define Ftos_d1 F0
    1.47 +#define Ftos_d2 F1
    1.48 +#endif // DONT_USE_REGISTER_DEFINES
    1.49 +
    1.50 +class InterpreterMacroAssembler: public MacroAssembler {
    1.51 + protected:
    1.52 +#ifndef CC_INTERP
    1.53 +  // Interpreter specific version of call_VM_base
    1.54 +    virtual void call_VM_leaf_base(
    1.55 +    Register java_thread,
    1.56 +    address  entry_point,
    1.57 +    int      number_of_arguments
    1.58 +  );
    1.59 +
    1.60 +  virtual void call_VM_base(
    1.61 +    Register        oop_result,
    1.62 +    Register        java_thread,
    1.63 +    Register        last_java_sp,
    1.64 +    address         entry_point,
    1.65 +    int             number_of_arguments,
    1.66 +    bool            check_exception=true
    1.67 +  );
    1.68 +
    1.69 +  virtual void check_and_handle_popframe(Register java_thread);
    1.70 +  virtual void check_and_handle_earlyret(Register java_thread);
    1.71 +
    1.72 +  // base routine for all dispatches
    1.73 +  void dispatch_base(TosState state, address* table);
    1.74 +#endif /* CC_INTERP */
    1.75 +
    1.76 + public:
    1.77 +  InterpreterMacroAssembler(CodeBuffer* c)
    1.78 +    : MacroAssembler(c) {}
    1.79 +
    1.80 +#ifndef CC_INTERP
    1.81 +  virtual void load_earlyret_value(TosState state);
    1.82 +
    1.83 +  static const Address l_tmp ;
    1.84 +  static const Address d_tmp ;
    1.85 +#endif /* CC_INTERP */
    1.86 +
    1.87 +  // helper routine for frame allocation/deallocation
    1.88 +  // compute the delta by which the caller's SP has to
    1.89 +  // be adjusted to accomodate for the non-argument
    1.90 +  // locals
    1.91 +  void compute_extra_locals_size_in_bytes(Register args_size, Register locals_size, Register delta);
    1.92 +
    1.93 +#ifndef CC_INTERP
    1.94 +
    1.95 +  // dispatch routines
    1.96 +  void dispatch_prolog(TosState state, int step = 0);
    1.97 +  void dispatch_epilog(TosState state, int step = 0);
    1.98 +  void dispatch_only(TosState state);
    1.99 +  void dispatch_normal(TosState state);
   1.100 +  void dispatch_next(TosState state, int step = 0);
   1.101 +  void dispatch_next_noverify_oop(TosState state, int step = 0);
   1.102 +  void dispatch_via (TosState state, address* table);
   1.103 +
   1.104 +
   1.105 +  // Removes the current activation (incl. unlocking of monitors).
   1.106 +  // Additionally this code is used for earlyReturn in which case we
   1.107 +  // want to skip throwing an exception and installing an exception.
   1.108 +  void remove_activation(TosState state,
   1.109 +                         bool throw_monitor_exception = true,
   1.110 +                         bool install_monitor_exception = true);
   1.111 +
   1.112 + protected:
   1.113 +  void dispatch_Lbyte_code(TosState state, address* table, int bcp_incr = 0, bool verify = true);
   1.114 +#endif /* CC_INTERP */
   1.115 +
   1.116 + public:
   1.117 +  // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls
   1.118 +  void super_call_VM(Register thread_cache,
   1.119 +                     Register oop_result,
   1.120 +                     Register last_java_sp,
   1.121 +                     address entry_point,
   1.122 +                     Register arg_1,
   1.123 +                     Register arg_2,
   1.124 +                     bool check_exception = true);
   1.125 +
   1.126 +#ifndef CC_INTERP
   1.127 +  void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1);
   1.128 +
   1.129 +  // Generate a subtype check: branch to ok_is_subtype if sub_klass is
   1.130 +  // a subtype of super_klass.  Blows registers tmp1, tmp2 and tmp3.
   1.131 +  void gen_subtype_check( Register sub_klass, Register super_klass, Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype );
   1.132 +
   1.133 +  // helpers for tossing exceptions
   1.134 +  void throw_if_not_1_icc( Condition ok_condition, Label& ok );
   1.135 +  void throw_if_not_1_xcc( Condition ok_condition, Label& ok );
   1.136 +  void throw_if_not_1_x  ( Condition ok_condition, Label& ok ); // chooses icc or xcc based on _LP64
   1.137 +
   1.138 +  void throw_if_not_2( address throw_entry_point, Register Rscratch, Label& ok);
   1.139 +
   1.140 +  void throw_if_not_icc( Condition ok_condition, address throw_entry_point, Register Rscratch );
   1.141 +  void throw_if_not_xcc( Condition ok_condition, address throw_entry_point, Register Rscratch );
   1.142 +  void throw_if_not_x  ( Condition ok_condition, address throw_entry_point, Register Rscratch );
   1.143 +
   1.144 +  // helpers for expression stack
   1.145 +
   1.146 +  void pop_i(     Register r = Otos_i);
   1.147 +  void pop_ptr(   Register r = Otos_i, Register scratch = O4);
   1.148 +  void pop_l(     Register r = Otos_l1);
   1.149 +  // G4_scratch and Lscratch are used at call sites!!
   1.150 +  void pop_f(FloatRegister f = Ftos_f,  Register scratch = G1_scratch);
   1.151 +  void pop_d(FloatRegister f = Ftos_d1, Register scratch = G1_scratch);
   1.152 +
   1.153 +  void push_i(     Register r = Otos_i);
   1.154 +  void push_ptr(   Register r = Otos_i);
   1.155 +  void push_ptr(   Register r, Register tag);
   1.156 +  void push_l(     Register r = Otos_l1);
   1.157 +  void push_f(FloatRegister f = Ftos_f);
   1.158 +  void push_d(FloatRegister f = Ftos_d1);
   1.159 +
   1.160 +
   1.161 +  void pop (TosState state);           // transition vtos -> state
   1.162 +  void push(TosState state);           // transition state -> vtos
   1.163 +  void empty_expression_stack();       // resets both Lesp and SP
   1.164 +
   1.165 +  // Support for Tagged Stacks
   1.166 +  void tag_stack(frame::Tag t, Register r);
   1.167 +  void tag_stack(Register tag);
   1.168 +  void tag_local(frame::Tag t, Register src, Register base, int n = 0);
   1.169 +
   1.170 +#ifdef ASSERT
   1.171 +  void verify_sp(Register Rsp, Register Rtemp);
   1.172 +  void verify_esp(Register Resp);      // verify that Lesp points to a word in the temp stack
   1.173 +
   1.174 +  void verify_stack_tag(frame::Tag t, Register r, Register scratch = G0);
   1.175 +  void verify_local_tag(frame::Tag t, Register base, Register scr, int n = 0);
   1.176 +#endif // ASSERT
   1.177 +
   1.178 + public:
   1.179 +  void if_cmp(Condition cc, bool ptr_compare);
   1.180 +
   1.181 +  // Load values from bytecode stream:
   1.182 +
   1.183 +  enum signedOrNot { Signed, Unsigned };
   1.184 +  enum setCCOrNot  { set_CC,  dont_set_CC };
   1.185 +
   1.186 +  void get_2_byte_integer_at_bcp( int         bcp_offset,
   1.187 +                                  Register    Rtmp,
   1.188 +                                  Register    Rdst,
   1.189 +                                  signedOrNot is_signed,
   1.190 +                                  setCCOrNot  should_set_CC = dont_set_CC );
   1.191 +
   1.192 +  void get_4_byte_integer_at_bcp( int        bcp_offset,
   1.193 +                                  Register   Rtmp,
   1.194 +                                  Register   Rdst,
   1.195 +                                  setCCOrNot should_set_CC = dont_set_CC );
   1.196 +
   1.197 +  void get_cache_and_index_at_bcp(Register cache, Register tmp, int bcp_offset);
   1.198 +  void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset);
   1.199 +
   1.200 +
   1.201 +  // common code
   1.202 +
   1.203 +  void field_offset_at(int n, Register tmp, Register dest, Register base);
   1.204 +  int  field_offset_at(Register object, address bcp, int offset);
   1.205 +  void fast_iaaccess(int n, address bcp);
   1.206 +  void fast_iagetfield(address bcp);
   1.207 +  void fast_iaputfield(address bcp, bool do_store_check );
   1.208 +
   1.209 +  void index_check(Register array, Register index, int index_shift, Register tmp, Register res);
   1.210 +  void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res);
   1.211 +
   1.212 +  void get_constant_pool(Register Rdst);
   1.213 +  void get_constant_pool_cache(Register Rdst);
   1.214 +  void get_cpool_and_tags(Register Rcpool, Register Rtags);
   1.215 +  void is_a(Label& L);
   1.216 +
   1.217 +  // Load compiled (i2c) or interpreter entry and call from interpreted
   1.218 +  void call_from_interpreter(Register target, Register scratch, Register Rret);
   1.219 +
   1.220 +  // --------------------------------------------------
   1.221 +
   1.222 +  void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true, bool install_monitor_exception = true);
   1.223 +
   1.224 +  void add_monitor_to_stack( bool stack_is_empty,
   1.225 +                             Register Rtemp,
   1.226 +                             Register Rtemp2 );
   1.227 +
   1.228 +  // Load/store aligned in _LP64 but unaligned otherwise
   1.229 +  // These only apply to the Interpreter expression stack and locals!
   1.230 +  void  load_unaligned_double(Register r1, int offset,  FloatRegister d);
   1.231 +  void store_unaligned_double(FloatRegister d, Register r1, int offset );
   1.232 +
   1.233 +  // Load/store aligned in _LP64 but unaligned otherwise
   1.234 +  void  load_unaligned_long(Register r1, int offset,  Register d);
   1.235 +  void store_unaligned_long(Register d, Register r1, int offset );
   1.236 +
   1.237 +  void access_local_int( Register index, Register dst );
   1.238 +  void access_local_ptr( Register index, Register dst );
   1.239 +  void access_local_returnAddress( Register index, Register dst );
   1.240 +  void access_local_long( Register index, Register dst );
   1.241 +  void access_local_float( Register index, FloatRegister dst );
   1.242 +  void access_local_double( Register index, FloatRegister dst );
   1.243 +#ifdef ASSERT
   1.244 +  void check_for_regarea_stomp( Register Rindex, int offset, Register Rlimit, Register Rscratch, Register Rscratch1);
   1.245 +#endif // ASSERT
   1.246 +  void store_local_int( Register index, Register src );
   1.247 +  void store_local_ptr( Register index, Register src, Register tag = Otos_l2 );
   1.248 +  void store_local_ptr( int n, Register src, Register tag = Otos_l2 );
   1.249 +  void store_local_long( Register index, Register src );
   1.250 +  void store_local_float( Register index, FloatRegister src );
   1.251 +  void store_local_double( Register index, FloatRegister src );
   1.252 +
   1.253 +  // Tagged stack helpers for swap and dup
   1.254 +  void load_ptr_and_tag(int n, Register val, Register tag);
   1.255 +  void store_ptr_and_tag(int n, Register val, Register tag);
   1.256 +
   1.257 +  // Tagged stack helper for getting receiver in register.
   1.258 +  void load_receiver(Register param_count, Register recv);
   1.259 +
   1.260 +  static int top_most_monitor_byte_offset(); // offset in bytes to top of monitor block
   1.261 +  Address top_most_monitor();
   1.262 +  void compute_stack_base( Register Rdest );
   1.263 +
   1.264 +#endif /* CC_INTERP */
   1.265 +  void increment_invocation_counter( Register Rtmp, Register Rtmp2 );
   1.266 +  void increment_backedge_counter( Register Rtmp, Register Rtmp2 );
   1.267 +#ifndef CC_INTERP
   1.268 +  void test_backedge_count_for_osr( Register backedge_count, Register branch_bcp, Register Rtmp );
   1.269 +
   1.270 +#endif /* CC_INTERP */
   1.271 +  // Object locking
   1.272 +  void lock_object  (Register lock_reg, Register obj_reg);
   1.273 +  void unlock_object(Register lock_reg);
   1.274 +
   1.275 +#ifndef CC_INTERP
   1.276 +  // Interpreter profiling operations
   1.277 +  void set_method_data_pointer() { set_method_data_pointer_offset(noreg); }
   1.278 +  void set_method_data_pointer_for_bcp();
   1.279 +  void set_method_data_pointer_offset(Register mdi_reg);
   1.280 +  void test_method_data_pointer(Label& zero_continue);
   1.281 +  void verify_method_data_pointer();
   1.282 +  void test_invocation_counter_for_mdp(Register invocation_count, Register cur_bcp, Register Rtmp, Label &profile_continue);
   1.283 +
   1.284 +  void set_mdp_data_at(int constant, Register value);
   1.285 +  void increment_mdp_data_at(Address counter, Register bumped_count,
   1.286 +                             bool decrement = false);
   1.287 +  void increment_mdp_data_at(int constant, Register bumped_count,
   1.288 +                             bool decrement = false);
   1.289 +  void increment_mdp_data_at(Register reg, int constant,
   1.290 +                             Register bumped_count, Register scratch2,
   1.291 +                             bool decrement = false);
   1.292 +  void set_mdp_flag_at(int flag_constant, Register scratch);
   1.293 +  void test_mdp_data_at(int offset, Register value, Label& not_equal_continue,
   1.294 +                        Register scratch);
   1.295 +
   1.296 +  void record_klass_in_profile(Register receiver, Register scratch);
   1.297 +  void record_klass_in_profile_helper(Register receiver, Register scratch,
   1.298 +                                      int start_row, Label& done);
   1.299 +
   1.300 +  void update_mdp_by_offset(int offset_of_disp, Register scratch);
   1.301 +  void update_mdp_by_offset(Register reg, int offset_of_disp,
   1.302 +                            Register scratch);
   1.303 +  void update_mdp_by_constant(int constant);
   1.304 +  void update_mdp_for_ret(TosState state, Register return_bci);
   1.305 +
   1.306 +  void profile_taken_branch(Register scratch, Register bumped_count);
   1.307 +  void profile_not_taken_branch(Register scratch);
   1.308 +  void profile_call(Register scratch);
   1.309 +  void profile_final_call(Register scratch);
   1.310 +  void profile_virtual_call(Register receiver, Register scratch);
   1.311 +  void profile_ret(TosState state, Register return_bci, Register scratch);
   1.312 +  void profile_null_seen(Register scratch);
   1.313 +  void profile_typecheck(Register klass, Register scratch);
   1.314 +  void profile_typecheck_failed(Register scratch);
   1.315 +  void profile_switch_default(Register scratch);
   1.316 +  void profile_switch_case(Register index,
   1.317 +                           Register scratch1,
   1.318 +                           Register scratch2,
   1.319 +                           Register scratch3);
   1.320 +
   1.321 +  // Debugging
   1.322 +  void interp_verify_oop(Register reg, TosState state, const char * file, int line);    // only if +VerifyOops && state == atos
   1.323 +  void verify_oop_or_return_address(Register reg, Register rtmp); // for astore
   1.324 +  void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU  && (state == ftos || state == dtos)
   1.325 +
   1.326 +#endif /* CC_INTERP */
   1.327 +  // support for JVMTI/Dtrace
   1.328 +  typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;
   1.329 +  void notify_method_entry();
   1.330 +  void notify_method_exit(
   1.331 +    bool save_result, TosState state, NotifyMethodExitMode mode);
   1.332 +
   1.333 +  void save_return_value(TosState state, bool is_native_call);
   1.334 +  void restore_return_value(TosState state, bool is_native_call);
   1.335 +};

mercurial