src/cpu/sparc/vm/interp_masm_sparc.hpp

Fri, 07 Nov 2008 09:29:38 -0800

author
kvn
date
Fri, 07 Nov 2008 09:29:38 -0800
changeset 855
a1980da045cc
parent 435
a61af66fc99e
child 1641
87684f1a88b5
permissions
-rw-r--r--

6462850: generate biased locking code in C2 ideal graph
Summary: Inline biased locking code in C2 ideal graph during macro nodes expansion
Reviewed-by: never

duke@435 1 /*
duke@435 2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // This file specializes the assember with interpreter-specific macros
duke@435 26
duke@435 27 REGISTER_DECLARATION( Register, Otos_i , O0); // tos for ints, etc
duke@435 28 REGISTER_DECLARATION( Register, Otos_l , O0); // for longs
duke@435 29 REGISTER_DECLARATION( Register, Otos_l1, O0); // for 1st part of longs
duke@435 30 REGISTER_DECLARATION( Register, Otos_l2, O1); // for 2nd part of longs
duke@435 31 REGISTER_DECLARATION(FloatRegister, Ftos_f , F0); // for floats
duke@435 32 REGISTER_DECLARATION(FloatRegister, Ftos_d , F0); // for doubles
duke@435 33 REGISTER_DECLARATION(FloatRegister, Ftos_d1, F0); // for 1st part of double
duke@435 34 REGISTER_DECLARATION(FloatRegister, Ftos_d2, F1); // for 2nd part of double
duke@435 35
duke@435 36 #ifndef DONT_USE_REGISTER_DEFINES
duke@435 37 #define Otos_i O0
duke@435 38 #define Otos_l O0
duke@435 39 #define Otos_l1 O0
duke@435 40 #define Otos_l2 O1
duke@435 41 #define Ftos_f F0
duke@435 42 #define Ftos_d F0
duke@435 43 #define Ftos_d1 F0
duke@435 44 #define Ftos_d2 F1
duke@435 45 #endif // DONT_USE_REGISTER_DEFINES
duke@435 46
duke@435 47 class InterpreterMacroAssembler: public MacroAssembler {
duke@435 48 protected:
duke@435 49 #ifndef CC_INTERP
duke@435 50 // Interpreter specific version of call_VM_base
duke@435 51 virtual void call_VM_leaf_base(
duke@435 52 Register java_thread,
duke@435 53 address entry_point,
duke@435 54 int number_of_arguments
duke@435 55 );
duke@435 56
duke@435 57 virtual void call_VM_base(
duke@435 58 Register oop_result,
duke@435 59 Register java_thread,
duke@435 60 Register last_java_sp,
duke@435 61 address entry_point,
duke@435 62 int number_of_arguments,
duke@435 63 bool check_exception=true
duke@435 64 );
duke@435 65
duke@435 66 virtual void check_and_handle_popframe(Register java_thread);
duke@435 67 virtual void check_and_handle_earlyret(Register java_thread);
duke@435 68
duke@435 69 // base routine for all dispatches
duke@435 70 void dispatch_base(TosState state, address* table);
duke@435 71 #endif /* CC_INTERP */
duke@435 72
duke@435 73 public:
duke@435 74 InterpreterMacroAssembler(CodeBuffer* c)
duke@435 75 : MacroAssembler(c) {}
duke@435 76
duke@435 77 #ifndef CC_INTERP
duke@435 78 virtual void load_earlyret_value(TosState state);
duke@435 79
duke@435 80 static const Address l_tmp ;
duke@435 81 static const Address d_tmp ;
duke@435 82 #endif /* CC_INTERP */
duke@435 83
duke@435 84 // helper routine for frame allocation/deallocation
duke@435 85 // compute the delta by which the caller's SP has to
duke@435 86 // be adjusted to accomodate for the non-argument
duke@435 87 // locals
duke@435 88 void compute_extra_locals_size_in_bytes(Register args_size, Register locals_size, Register delta);
duke@435 89
duke@435 90 #ifndef CC_INTERP
duke@435 91
duke@435 92 // dispatch routines
duke@435 93 void dispatch_prolog(TosState state, int step = 0);
duke@435 94 void dispatch_epilog(TosState state, int step = 0);
duke@435 95 void dispatch_only(TosState state);
duke@435 96 void dispatch_normal(TosState state);
duke@435 97 void dispatch_next(TosState state, int step = 0);
duke@435 98 void dispatch_next_noverify_oop(TosState state, int step = 0);
duke@435 99 void dispatch_via (TosState state, address* table);
duke@435 100
duke@435 101
duke@435 102 // Removes the current activation (incl. unlocking of monitors).
duke@435 103 // Additionally this code is used for earlyReturn in which case we
duke@435 104 // want to skip throwing an exception and installing an exception.
duke@435 105 void remove_activation(TosState state,
duke@435 106 bool throw_monitor_exception = true,
duke@435 107 bool install_monitor_exception = true);
duke@435 108
duke@435 109 protected:
duke@435 110 void dispatch_Lbyte_code(TosState state, address* table, int bcp_incr = 0, bool verify = true);
duke@435 111 #endif /* CC_INTERP */
duke@435 112
duke@435 113 public:
duke@435 114 // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls
duke@435 115 void super_call_VM(Register thread_cache,
duke@435 116 Register oop_result,
duke@435 117 Register last_java_sp,
duke@435 118 address entry_point,
duke@435 119 Register arg_1,
duke@435 120 Register arg_2,
duke@435 121 bool check_exception = true);
duke@435 122
duke@435 123 #ifndef CC_INTERP
duke@435 124 void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1);
duke@435 125
duke@435 126 // Generate a subtype check: branch to ok_is_subtype if sub_klass is
duke@435 127 // a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3.
duke@435 128 void gen_subtype_check( Register sub_klass, Register super_klass, Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype );
duke@435 129
duke@435 130 // helpers for tossing exceptions
duke@435 131 void throw_if_not_1_icc( Condition ok_condition, Label& ok );
duke@435 132 void throw_if_not_1_xcc( Condition ok_condition, Label& ok );
duke@435 133 void throw_if_not_1_x ( Condition ok_condition, Label& ok ); // chooses icc or xcc based on _LP64
duke@435 134
duke@435 135 void throw_if_not_2( address throw_entry_point, Register Rscratch, Label& ok);
duke@435 136
duke@435 137 void throw_if_not_icc( Condition ok_condition, address throw_entry_point, Register Rscratch );
duke@435 138 void throw_if_not_xcc( Condition ok_condition, address throw_entry_point, Register Rscratch );
duke@435 139 void throw_if_not_x ( Condition ok_condition, address throw_entry_point, Register Rscratch );
duke@435 140
duke@435 141 // helpers for expression stack
duke@435 142
duke@435 143 void pop_i( Register r = Otos_i);
duke@435 144 void pop_ptr( Register r = Otos_i, Register scratch = O4);
duke@435 145 void pop_l( Register r = Otos_l1);
duke@435 146 // G4_scratch and Lscratch are used at call sites!!
duke@435 147 void pop_f(FloatRegister f = Ftos_f, Register scratch = G1_scratch);
duke@435 148 void pop_d(FloatRegister f = Ftos_d1, Register scratch = G1_scratch);
duke@435 149
duke@435 150 void push_i( Register r = Otos_i);
duke@435 151 void push_ptr( Register r = Otos_i);
duke@435 152 void push_ptr( Register r, Register tag);
duke@435 153 void push_l( Register r = Otos_l1);
duke@435 154 void push_f(FloatRegister f = Ftos_f);
duke@435 155 void push_d(FloatRegister f = Ftos_d1);
duke@435 156
duke@435 157
duke@435 158 void pop (TosState state); // transition vtos -> state
duke@435 159 void push(TosState state); // transition state -> vtos
duke@435 160 void empty_expression_stack(); // resets both Lesp and SP
duke@435 161
duke@435 162 // Support for Tagged Stacks
duke@435 163 void tag_stack(frame::Tag t, Register r);
duke@435 164 void tag_stack(Register tag);
duke@435 165 void tag_local(frame::Tag t, Register src, Register base, int n = 0);
duke@435 166
duke@435 167 #ifdef ASSERT
duke@435 168 void verify_sp(Register Rsp, Register Rtemp);
duke@435 169 void verify_esp(Register Resp); // verify that Lesp points to a word in the temp stack
duke@435 170
duke@435 171 void verify_stack_tag(frame::Tag t, Register r, Register scratch = G0);
duke@435 172 void verify_local_tag(frame::Tag t, Register base, Register scr, int n = 0);
duke@435 173 #endif // ASSERT
duke@435 174
duke@435 175 public:
duke@435 176 void if_cmp(Condition cc, bool ptr_compare);
duke@435 177
duke@435 178 // Load values from bytecode stream:
duke@435 179
duke@435 180 enum signedOrNot { Signed, Unsigned };
duke@435 181 enum setCCOrNot { set_CC, dont_set_CC };
duke@435 182
duke@435 183 void get_2_byte_integer_at_bcp( int bcp_offset,
duke@435 184 Register Rtmp,
duke@435 185 Register Rdst,
duke@435 186 signedOrNot is_signed,
duke@435 187 setCCOrNot should_set_CC = dont_set_CC );
duke@435 188
duke@435 189 void get_4_byte_integer_at_bcp( int bcp_offset,
duke@435 190 Register Rtmp,
duke@435 191 Register Rdst,
duke@435 192 setCCOrNot should_set_CC = dont_set_CC );
duke@435 193
duke@435 194 void get_cache_and_index_at_bcp(Register cache, Register tmp, int bcp_offset);
duke@435 195 void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset);
duke@435 196
duke@435 197
duke@435 198 // common code
duke@435 199
duke@435 200 void field_offset_at(int n, Register tmp, Register dest, Register base);
duke@435 201 int field_offset_at(Register object, address bcp, int offset);
duke@435 202 void fast_iaaccess(int n, address bcp);
duke@435 203 void fast_iagetfield(address bcp);
duke@435 204 void fast_iaputfield(address bcp, bool do_store_check );
duke@435 205
duke@435 206 void index_check(Register array, Register index, int index_shift, Register tmp, Register res);
duke@435 207 void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res);
duke@435 208
duke@435 209 void get_constant_pool(Register Rdst);
duke@435 210 void get_constant_pool_cache(Register Rdst);
duke@435 211 void get_cpool_and_tags(Register Rcpool, Register Rtags);
duke@435 212 void is_a(Label& L);
duke@435 213
duke@435 214 // Load compiled (i2c) or interpreter entry and call from interpreted
duke@435 215 void call_from_interpreter(Register target, Register scratch, Register Rret);
duke@435 216
duke@435 217 // --------------------------------------------------
duke@435 218
duke@435 219 void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true, bool install_monitor_exception = true);
duke@435 220
duke@435 221 void add_monitor_to_stack( bool stack_is_empty,
duke@435 222 Register Rtemp,
duke@435 223 Register Rtemp2 );
duke@435 224
duke@435 225 // Load/store aligned in _LP64 but unaligned otherwise
duke@435 226 // These only apply to the Interpreter expression stack and locals!
duke@435 227 void load_unaligned_double(Register r1, int offset, FloatRegister d);
duke@435 228 void store_unaligned_double(FloatRegister d, Register r1, int offset );
duke@435 229
duke@435 230 // Load/store aligned in _LP64 but unaligned otherwise
duke@435 231 void load_unaligned_long(Register r1, int offset, Register d);
duke@435 232 void store_unaligned_long(Register d, Register r1, int offset );
duke@435 233
duke@435 234 void access_local_int( Register index, Register dst );
duke@435 235 void access_local_ptr( Register index, Register dst );
duke@435 236 void access_local_returnAddress( Register index, Register dst );
duke@435 237 void access_local_long( Register index, Register dst );
duke@435 238 void access_local_float( Register index, FloatRegister dst );
duke@435 239 void access_local_double( Register index, FloatRegister dst );
duke@435 240 #ifdef ASSERT
duke@435 241 void check_for_regarea_stomp( Register Rindex, int offset, Register Rlimit, Register Rscratch, Register Rscratch1);
duke@435 242 #endif // ASSERT
duke@435 243 void store_local_int( Register index, Register src );
duke@435 244 void store_local_ptr( Register index, Register src, Register tag = Otos_l2 );
duke@435 245 void store_local_ptr( int n, Register src, Register tag = Otos_l2 );
duke@435 246 void store_local_long( Register index, Register src );
duke@435 247 void store_local_float( Register index, FloatRegister src );
duke@435 248 void store_local_double( Register index, FloatRegister src );
duke@435 249
duke@435 250 // Tagged stack helpers for swap and dup
duke@435 251 void load_ptr_and_tag(int n, Register val, Register tag);
duke@435 252 void store_ptr_and_tag(int n, Register val, Register tag);
duke@435 253
duke@435 254 // Tagged stack helper for getting receiver in register.
duke@435 255 void load_receiver(Register param_count, Register recv);
duke@435 256
duke@435 257 static int top_most_monitor_byte_offset(); // offset in bytes to top of monitor block
duke@435 258 Address top_most_monitor();
duke@435 259 void compute_stack_base( Register Rdest );
duke@435 260
duke@435 261 #endif /* CC_INTERP */
duke@435 262 void increment_invocation_counter( Register Rtmp, Register Rtmp2 );
duke@435 263 void increment_backedge_counter( Register Rtmp, Register Rtmp2 );
duke@435 264 #ifndef CC_INTERP
duke@435 265 void test_backedge_count_for_osr( Register backedge_count, Register branch_bcp, Register Rtmp );
duke@435 266
duke@435 267 #endif /* CC_INTERP */
duke@435 268 // Object locking
duke@435 269 void lock_object (Register lock_reg, Register obj_reg);
duke@435 270 void unlock_object(Register lock_reg);
duke@435 271
duke@435 272 #ifndef CC_INTERP
duke@435 273 // Interpreter profiling operations
duke@435 274 void set_method_data_pointer() { set_method_data_pointer_offset(noreg); }
duke@435 275 void set_method_data_pointer_for_bcp();
duke@435 276 void set_method_data_pointer_offset(Register mdi_reg);
duke@435 277 void test_method_data_pointer(Label& zero_continue);
duke@435 278 void verify_method_data_pointer();
duke@435 279 void test_invocation_counter_for_mdp(Register invocation_count, Register cur_bcp, Register Rtmp, Label &profile_continue);
duke@435 280
duke@435 281 void set_mdp_data_at(int constant, Register value);
duke@435 282 void increment_mdp_data_at(Address counter, Register bumped_count,
duke@435 283 bool decrement = false);
duke@435 284 void increment_mdp_data_at(int constant, Register bumped_count,
duke@435 285 bool decrement = false);
duke@435 286 void increment_mdp_data_at(Register reg, int constant,
duke@435 287 Register bumped_count, Register scratch2,
duke@435 288 bool decrement = false);
duke@435 289 void set_mdp_flag_at(int flag_constant, Register scratch);
duke@435 290 void test_mdp_data_at(int offset, Register value, Label& not_equal_continue,
duke@435 291 Register scratch);
duke@435 292
duke@435 293 void record_klass_in_profile(Register receiver, Register scratch);
duke@435 294 void record_klass_in_profile_helper(Register receiver, Register scratch,
duke@435 295 int start_row, Label& done);
duke@435 296
duke@435 297 void update_mdp_by_offset(int offset_of_disp, Register scratch);
duke@435 298 void update_mdp_by_offset(Register reg, int offset_of_disp,
duke@435 299 Register scratch);
duke@435 300 void update_mdp_by_constant(int constant);
duke@435 301 void update_mdp_for_ret(TosState state, Register return_bci);
duke@435 302
duke@435 303 void profile_taken_branch(Register scratch, Register bumped_count);
duke@435 304 void profile_not_taken_branch(Register scratch);
duke@435 305 void profile_call(Register scratch);
duke@435 306 void profile_final_call(Register scratch);
duke@435 307 void profile_virtual_call(Register receiver, Register scratch);
duke@435 308 void profile_ret(TosState state, Register return_bci, Register scratch);
duke@435 309 void profile_null_seen(Register scratch);
duke@435 310 void profile_typecheck(Register klass, Register scratch);
duke@435 311 void profile_typecheck_failed(Register scratch);
duke@435 312 void profile_switch_default(Register scratch);
duke@435 313 void profile_switch_case(Register index,
duke@435 314 Register scratch1,
duke@435 315 Register scratch2,
duke@435 316 Register scratch3);
duke@435 317
duke@435 318 // Debugging
duke@435 319 void interp_verify_oop(Register reg, TosState state, const char * file, int line); // only if +VerifyOops && state == atos
duke@435 320 void verify_oop_or_return_address(Register reg, Register rtmp); // for astore
duke@435 321 void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU && (state == ftos || state == dtos)
duke@435 322
duke@435 323 #endif /* CC_INTERP */
duke@435 324 // support for JVMTI/Dtrace
duke@435 325 typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;
duke@435 326 void notify_method_entry();
duke@435 327 void notify_method_exit(
duke@435 328 bool save_result, TosState state, NotifyMethodExitMode mode);
duke@435 329
duke@435 330 void save_return_value(TosState state, bool is_native_call);
duke@435 331 void restore_return_value(TosState state, bool is_native_call);
duke@435 332 };

mercurial