src/cpu/sparc/vm/interp_masm_sparc.hpp

Tue, 03 Aug 2010 08:13:38 -0400

author
bobv
date
Tue, 03 Aug 2010 08:13:38 -0400
changeset 2036
126ea7725993
parent 1934
e9ff18c4ace7
child 2138
d5d065957597
permissions
-rw-r--r--

6953477: Increase portability and flexibility of building Hotspot
Summary: A collection of portability improvements including shared code support for PPC, ARM platforms, software floating point, cross compilation support and improvements in error crash detail.
Reviewed-by: phh, never, coleenp, dholmes

duke@435 1 /*
trims@1907 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * 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
twisti@1730 124 void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2);
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_l( Register r = Otos_l1);
duke@435 153 void push_f(FloatRegister f = Ftos_f);
duke@435 154 void push_d(FloatRegister f = Ftos_d1);
duke@435 155
duke@435 156
duke@435 157 void pop (TosState state); // transition vtos -> state
duke@435 158 void push(TosState state); // transition state -> vtos
duke@435 159 void empty_expression_stack(); // resets both Lesp and SP
duke@435 160
duke@435 161 #ifdef ASSERT
duke@435 162 void verify_sp(Register Rsp, Register Rtemp);
duke@435 163 void verify_esp(Register Resp); // verify that Lesp points to a word in the temp stack
duke@435 164 #endif // ASSERT
duke@435 165
duke@435 166 public:
duke@435 167 void if_cmp(Condition cc, bool ptr_compare);
duke@435 168
duke@435 169 // Load values from bytecode stream:
duke@435 170
duke@435 171 enum signedOrNot { Signed, Unsigned };
duke@435 172 enum setCCOrNot { set_CC, dont_set_CC };
duke@435 173
duke@435 174 void get_2_byte_integer_at_bcp( int bcp_offset,
duke@435 175 Register Rtmp,
duke@435 176 Register Rdst,
duke@435 177 signedOrNot is_signed,
duke@435 178 setCCOrNot should_set_CC = dont_set_CC );
duke@435 179
duke@435 180 void get_4_byte_integer_at_bcp( int bcp_offset,
duke@435 181 Register Rtmp,
duke@435 182 Register Rdst,
duke@435 183 setCCOrNot should_set_CC = dont_set_CC );
duke@435 184
jrose@1920 185 void get_cache_and_index_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2));
jrose@1920 186 void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2));
jrose@1920 187 void get_cache_index_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2));
duke@435 188
duke@435 189
duke@435 190 // common code
duke@435 191
duke@435 192 void field_offset_at(int n, Register tmp, Register dest, Register base);
duke@435 193 int field_offset_at(Register object, address bcp, int offset);
duke@435 194 void fast_iaaccess(int n, address bcp);
duke@435 195 void fast_iagetfield(address bcp);
duke@435 196 void fast_iaputfield(address bcp, bool do_store_check );
duke@435 197
duke@435 198 void index_check(Register array, Register index, int index_shift, Register tmp, Register res);
duke@435 199 void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res);
duke@435 200
duke@435 201 void get_constant_pool(Register Rdst);
duke@435 202 void get_constant_pool_cache(Register Rdst);
duke@435 203 void get_cpool_and_tags(Register Rcpool, Register Rtags);
duke@435 204 void is_a(Label& L);
duke@435 205
duke@435 206 // Load compiled (i2c) or interpreter entry and call from interpreted
duke@435 207 void call_from_interpreter(Register target, Register scratch, Register Rret);
duke@435 208
duke@435 209 // --------------------------------------------------
duke@435 210
duke@435 211 void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true, bool install_monitor_exception = true);
duke@435 212
duke@435 213 void add_monitor_to_stack( bool stack_is_empty,
duke@435 214 Register Rtemp,
duke@435 215 Register Rtemp2 );
duke@435 216
duke@435 217 // Load/store aligned in _LP64 but unaligned otherwise
duke@435 218 // These only apply to the Interpreter expression stack and locals!
duke@435 219 void load_unaligned_double(Register r1, int offset, FloatRegister d);
duke@435 220 void store_unaligned_double(FloatRegister d, Register r1, int offset );
duke@435 221
duke@435 222 // Load/store aligned in _LP64 but unaligned otherwise
duke@435 223 void load_unaligned_long(Register r1, int offset, Register d);
duke@435 224 void store_unaligned_long(Register d, Register r1, int offset );
duke@435 225
duke@435 226 void access_local_int( Register index, Register dst );
duke@435 227 void access_local_ptr( Register index, Register dst );
duke@435 228 void access_local_returnAddress( Register index, Register dst );
duke@435 229 void access_local_long( Register index, Register dst );
duke@435 230 void access_local_float( Register index, FloatRegister dst );
duke@435 231 void access_local_double( Register index, FloatRegister dst );
duke@435 232 #ifdef ASSERT
duke@435 233 void check_for_regarea_stomp( Register Rindex, int offset, Register Rlimit, Register Rscratch, Register Rscratch1);
duke@435 234 #endif // ASSERT
duke@435 235 void store_local_int( Register index, Register src );
twisti@1861 236 void store_local_ptr( Register index, Register src );
twisti@1861 237 void store_local_ptr( int n, Register src );
duke@435 238 void store_local_long( Register index, Register src );
duke@435 239 void store_local_float( Register index, FloatRegister src );
duke@435 240 void store_local_double( Register index, FloatRegister src );
duke@435 241
twisti@1861 242 // Helpers for swap and dup
twisti@1861 243 void load_ptr(int n, Register val);
twisti@1861 244 void store_ptr(int n, Register val);
duke@435 245
twisti@1861 246 // Helper for getting receiver in register.
duke@435 247 void load_receiver(Register param_count, Register recv);
duke@435 248
duke@435 249 static int top_most_monitor_byte_offset(); // offset in bytes to top of monitor block
duke@435 250 Address top_most_monitor();
duke@435 251 void compute_stack_base( Register Rdest );
duke@435 252
duke@435 253 #endif /* CC_INTERP */
duke@435 254 void increment_invocation_counter( Register Rtmp, Register Rtmp2 );
duke@435 255 void increment_backedge_counter( Register Rtmp, Register Rtmp2 );
duke@435 256 #ifndef CC_INTERP
duke@435 257 void test_backedge_count_for_osr( Register backedge_count, Register branch_bcp, Register Rtmp );
duke@435 258
duke@435 259 #endif /* CC_INTERP */
duke@435 260 // Object locking
duke@435 261 void lock_object (Register lock_reg, Register obj_reg);
duke@435 262 void unlock_object(Register lock_reg);
duke@435 263
duke@435 264 #ifndef CC_INTERP
duke@435 265 // Interpreter profiling operations
duke@435 266 void set_method_data_pointer() { set_method_data_pointer_offset(noreg); }
duke@435 267 void set_method_data_pointer_for_bcp();
duke@435 268 void set_method_data_pointer_offset(Register mdi_reg);
duke@435 269 void test_method_data_pointer(Label& zero_continue);
duke@435 270 void verify_method_data_pointer();
duke@435 271 void test_invocation_counter_for_mdp(Register invocation_count, Register cur_bcp, Register Rtmp, Label &profile_continue);
duke@435 272
duke@435 273 void set_mdp_data_at(int constant, Register value);
duke@435 274 void increment_mdp_data_at(Address counter, Register bumped_count,
duke@435 275 bool decrement = false);
duke@435 276 void increment_mdp_data_at(int constant, Register bumped_count,
duke@435 277 bool decrement = false);
duke@435 278 void increment_mdp_data_at(Register reg, int constant,
duke@435 279 Register bumped_count, Register scratch2,
duke@435 280 bool decrement = false);
duke@435 281 void set_mdp_flag_at(int flag_constant, Register scratch);
duke@435 282 void test_mdp_data_at(int offset, Register value, Label& not_equal_continue,
duke@435 283 Register scratch);
duke@435 284
kvn@1641 285 void record_klass_in_profile(Register receiver, Register scratch, bool is_virtual_call);
duke@435 286 void record_klass_in_profile_helper(Register receiver, Register scratch,
kvn@1641 287 int start_row, Label& done, bool is_virtual_call);
duke@435 288
duke@435 289 void update_mdp_by_offset(int offset_of_disp, Register scratch);
duke@435 290 void update_mdp_by_offset(Register reg, int offset_of_disp,
duke@435 291 Register scratch);
duke@435 292 void update_mdp_by_constant(int constant);
duke@435 293 void update_mdp_for_ret(TosState state, Register return_bci);
duke@435 294
duke@435 295 void profile_taken_branch(Register scratch, Register bumped_count);
duke@435 296 void profile_not_taken_branch(Register scratch);
duke@435 297 void profile_call(Register scratch);
duke@435 298 void profile_final_call(Register scratch);
twisti@1858 299 void profile_virtual_call(Register receiver, Register scratch, bool receiver_can_be_null = false);
duke@435 300 void profile_ret(TosState state, Register return_bci, Register scratch);
duke@435 301 void profile_null_seen(Register scratch);
duke@435 302 void profile_typecheck(Register klass, Register scratch);
duke@435 303 void profile_typecheck_failed(Register scratch);
duke@435 304 void profile_switch_default(Register scratch);
duke@435 305 void profile_switch_case(Register index,
duke@435 306 Register scratch1,
duke@435 307 Register scratch2,
duke@435 308 Register scratch3);
duke@435 309
duke@435 310 // Debugging
duke@435 311 void interp_verify_oop(Register reg, TosState state, const char * file, int line); // only if +VerifyOops && state == atos
duke@435 312 void verify_oop_or_return_address(Register reg, Register rtmp); // for astore
duke@435 313 void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU && (state == ftos || state == dtos)
duke@435 314
duke@435 315 #endif /* CC_INTERP */
duke@435 316 // support for JVMTI/Dtrace
duke@435 317 typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;
duke@435 318 void notify_method_entry();
duke@435 319 void notify_method_exit(
duke@435 320 bool save_result, TosState state, NotifyMethodExitMode mode);
duke@435 321
duke@435 322 void save_return_value(TosState state, bool is_native_call);
duke@435 323 void restore_return_value(TosState state, bool is_native_call);
duke@435 324 };

mercurial