src/cpu/sparc/vm/interp_masm_sparc.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial