src/cpu/mips/vm/c1_Runtime1_mips.cpp

Thu, 11 Oct 2018 09:53:13 +0800

author
huangxuguang
date
Thu, 11 Oct 2018 09:53:13 +0800
changeset 9251
1ccc5a3b3671
parent 9248
610b27224729
child 9459
814e9e335067
permissions
-rw-r--r--

#7569 update copyright time of files modified in 2017 and 2018
Reviewed-by: aoqi

aoqi@1 1 /*
aoqi@1 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
huangxuguang@9251 3 * Copyright (c) 2015, 2018, Loongson Technology. All rights reserved.
aoqi@1 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@1 5 *
aoqi@1 6 * This code is free software; you can redistribute it and/or modify it
aoqi@1 7 * under the terms of the GNU General Public License version 2 only, as
aoqi@1 8 * published by the Free Software Foundation.
aoqi@1 9 *
aoqi@1 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@1 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@1 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@1 13 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@1 14 * accompanied this code).
aoqi@1 15 *
aoqi@1 16 * You should have received a copy of the GNU General Public License version
aoqi@1 17 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@1 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@1 19 *
aoqi@1 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@1 21 * or visit www.oracle.com if you need additional information or have any
aoqi@1 22 * questions.
aoqi@1 23 *
aoqi@1 24 */
aoqi@1 25
aoqi@1 26 #include "precompiled.hpp"
aoqi@1 27 #include "asm/assembler.hpp"
aoqi@1 28 #include "c1/c1_Defs.hpp"
aoqi@1 29 #include "c1/c1_MacroAssembler.hpp"
aoqi@1 30 #include "c1/c1_Runtime1.hpp"
aoqi@1 31 #include "interpreter/interpreter.hpp"
aoqi@1 32 #include "nativeInst_mips.hpp"
aoqi@1 33 #include "oops/compiledICHolder.hpp"
aoqi@1 34 #include "oops/oop.inline.hpp"
aoqi@1 35 #include "prims/jvmtiExport.hpp"
aoqi@1 36 #include "register_mips.hpp"
aoqi@1 37 #include "runtime/sharedRuntime.hpp"
aoqi@1 38 #include "runtime/signature.hpp"
aoqi@1 39 #include "runtime/vframeArray.hpp"
aoqi@6880 40 #include "utilities/macros.hpp"
aoqi@1 41 #include "vmreg_mips.inline.hpp"
aoqi@6880 42 #if INCLUDE_ALL_GCS
aoqi@6880 43 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
aoqi@6880 44 #endif
aoqi@1 45
aoqi@1 46
aoqi@1 47 // Implementation of StubAssembler
aoqi@1 48 // this method will preserve the stack space for arguments as indicated by args_size
aoqi@1 49 // for stack alignment consideration, you cannot call this with argument in stack.
aoqi@1 50 // if you need >3 arguments, you must implement this method yourself.
fujie@9153 51 int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, int args_size) {
aoqi@6880 52 // i use S7 for edi.
aoqi@6880 53 // setup registers
aoqi@6880 54 const Register thread = TREG; // is callee-saved register (Visual C++ calling conventions)
fujie@9153 55 assert(!(oop_result1->is_valid() || metadata_result->is_valid()) || oop_result1 != metadata_result, "registers must be different");
fujie@9153 56 assert(oop_result1 != thread && metadata_result != thread, "registers must be different");
aoqi@6880 57 assert(args_size >= 0, "illegal args_size");
fujie@9153 58 bool align_stack = false;
fujie@9153 59 #ifdef _LP64
fujie@9153 60 // At a method handle call, the stack may not be properly aligned
fujie@9153 61 // when returning with an exception.
fujie@9153 62 align_stack = (stub_id() == Runtime1::handle_exception_from_callee_id);
fujie@9153 63 #endif
aoqi@1 64
aoqi@6880 65 set_num_rt_args(1 + args_size);
aoqi@1 66
aoqi@1 67
aoqi@6880 68 // push java thread (becomes first argument of C function)
aoqi@6880 69 get_thread(thread);
aoqi@6880 70 move(A0, thread);
aoqi@1 71
fujie@9153 72 if(!align_stack) {
fujie@9153 73 set_last_Java_frame(thread, NOREG, FP, NULL);
fujie@9153 74 } else {
fujie@9153 75 address the_pc = pc();
fujie@9153 76 set_last_Java_frame(thread, NOREG, FP, the_pc);
fujie@9153 77 move(AT, -(StackAlignmentInBytes));
fujie@9153 78 andr(SP, SP, AT);
fujie@9153 79 }
aoqi@1 80
aoqi@6880 81 relocate(relocInfo::internal_pc_type);
aoqi@6880 82 {
aoqi@1 83 #ifndef _LP64
aoqi@6880 84 int save_pc = (int)pc() + 12 + NativeCall::return_address_offset;
aoqi@6880 85 lui(AT, Assembler::split_high(save_pc));
aoqi@6880 86 addiu(AT, AT, Assembler::split_low(save_pc));
aoqi@1 87 #else
aoqi@6880 88 uintptr_t save_pc = (uintptr_t)pc() + NativeMovConstReg::instruction_size + 1 * BytesPerInstWord + NativeCall::return_address_offset_long;
aoqi@6880 89 li48(AT, save_pc);
aoqi@1 90 #endif
aoqi@6880 91 }
aoqi@6880 92 st_ptr(AT, thread, in_bytes(JavaThread::last_Java_pc_offset()));
aoqi@1 93
aoqi@6880 94 // do the call
aoqi@6880 95 #ifndef _LP64
aoqi@6880 96 lui(T9, Assembler::split_high((int)entry));
aoqi@6880 97 addiu(T9, T9, Assembler::split_low((int)entry));
aoqi@6880 98 #else
aoqi@6880 99 li48(T9, (intptr_t)entry);
aoqi@1 100 #endif
aoqi@6880 101 jalr(T9);
aoqi@6880 102 delayed()->nop();
fujie@9161 103
fujie@9161 104 int call_offset = offset();
aoqi@6880 105
aoqi@6880 106 // verify callee-saved register
aoqi@6880 107 #ifdef ASSERT
aoqi@6880 108 guarantee(thread != V0, "change this code");
aoqi@6880 109 push(V0);
aoqi@6880 110 {
aoqi@6880 111 Label L;
aoqi@6880 112 get_thread(V0);
aoqi@6880 113 beq(thread, V0, L);
aoqi@6880 114 delayed()->nop();
aoqi@6880 115 int3();
aoqi@6880 116 stop("StubAssembler::call_RT: edi not callee saved?");
aoqi@6880 117 bind(L);
aoqi@6880 118 }
aoqi@6880 119 super_pop(V0);
aoqi@1 120 #endif
aoqi@6880 121 // discard thread and arguments
aoqi@9228 122 ld_ptr(SP, thread, in_bytes(JavaThread::last_Java_sp_offset()));
fujie@9171 123 reset_last_Java_frame(thread, true);
aoqi@6880 124 // check for pending exceptions
aoqi@6880 125 {
aoqi@6880 126 Label L;
aoqi@6880 127 ld_ptr(AT, thread, in_bytes(Thread::pending_exception_offset()));
aoqi@6880 128 beq(AT, R0, L);
aoqi@6880 129 delayed()->nop();
aoqi@6880 130 // exception pending => remove activation and forward to exception handler
aoqi@6880 131 // make sure that the vm_results are cleared
aoqi@6880 132 if (oop_result1->is_valid()) {
aoqi@6880 133 st_ptr(R0, thread, in_bytes(JavaThread::vm_result_offset()));
aoqi@6880 134 }
fujie@9153 135 if (metadata_result->is_valid()) {
aoqi@6880 136 st_ptr(R0, thread, in_bytes(JavaThread::vm_result_2_offset()));
aoqi@6880 137 }
aoqi@6880 138 // the leave() in x86 just pops ebp and remains the return address on the top
aoqi@6880 139 // of stack
aoqi@6880 140 // the return address will be needed by forward_exception_entry()
aoqi@6880 141 if (frame_size() == no_frame_size) {
aoqi@6880 142 addiu(SP, FP, wordSize);
aoqi@6880 143 ld_ptr(FP, SP, (-1) * wordSize);
aoqi@6880 144 jmp(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
aoqi@6880 145 delayed()->nop();
aoqi@6880 146 } else if (_stub_id == Runtime1::forward_exception_id) {
aoqi@6880 147 should_not_reach_here();
aoqi@6880 148 } else {
aoqi@8865 149 jmp(Runtime1::entry_for(Runtime1::forward_exception_id), relocInfo::runtime_call_type);
aoqi@6880 150 delayed()->nop();
aoqi@6880 151 }
aoqi@6880 152 bind(L);
aoqi@6880 153 }
aoqi@6880 154 // get oop results if there are any and reset the values in the thread
aoqi@6880 155 if (oop_result1->is_valid()) {
aoqi@6880 156 ld_ptr(oop_result1, thread, in_bytes(JavaThread::vm_result_offset()));
aoqi@6880 157 st_ptr(R0, thread, in_bytes(JavaThread::vm_result_offset()));
aoqi@6880 158 verify_oop(oop_result1);
aoqi@6880 159 }
fujie@9153 160 if (metadata_result->is_valid()) {
fujie@9153 161 ld_ptr(metadata_result, thread, in_bytes(JavaThread::vm_result_2_offset()));
aoqi@6880 162 st_ptr(R0, thread, in_bytes(JavaThread::vm_result_2_offset()));
fujie@9153 163 verify_oop(metadata_result);
aoqi@6880 164 }
aoqi@6880 165 return call_offset;
aoqi@1 166 }
aoqi@1 167
aoqi@1 168
fujie@9153 169 int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1) {
aoqi@6880 170 if (arg1 != A1) move(A1, arg1);
fujie@9153 171 return call_RT(oop_result1, metadata_result, entry, 1);
aoqi@1 172 }
aoqi@1 173
aoqi@1 174
fujie@9153 175 int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2) {
aoqi@6880 176 if (arg1!=A1) move(A1, arg1);
aoqi@6880 177 if (arg2!=A2) move(A2, arg2); assert(arg2 != A1, "smashed argument");
fujie@9153 178 return call_RT(oop_result1, metadata_result, entry, 2);
aoqi@1 179 }
aoqi@1 180
aoqi@1 181
fujie@9153 182 int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2, Register arg3) {
aoqi@6880 183 if (arg1!=A1) move(A1, arg1);
aoqi@6880 184 if (arg2!=A2) move(A2, arg2); assert(arg2 != A1, "smashed argument");
aoqi@6880 185 if (arg3!=A3) move(A3, arg3); assert(arg3 != A1 && arg3 != A2, "smashed argument");
fujie@9153 186 return call_RT(oop_result1, metadata_result, entry, 3);
aoqi@1 187 }
aoqi@1 188
aoqi@1 189
aoqi@1 190 // Implementation of StubFrame
aoqi@1 191
aoqi@1 192 class StubFrame: public StackObj {
aoqi@6880 193 private:
aoqi@6880 194 StubAssembler* _sasm;
aoqi@1 195
aoqi@6880 196 public:
aoqi@6880 197 StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments);
aoqi@6880 198 void load_argument(int offset_in_words, Register reg);
aoqi@6880 199
aoqi@6880 200 ~StubFrame();
aoqi@1 201 };
aoqi@1 202
aoqi@1 203
aoqi@1 204 #define __ _sasm->
aoqi@1 205
aoqi@1 206 StubFrame::StubFrame(StubAssembler* sasm, const char* name, bool must_gc_arguments) {
aoqi@6880 207 _sasm = sasm;
aoqi@6880 208 __ set_info(name, must_gc_arguments);
aoqi@6880 209 __ enter();
aoqi@1 210 }
aoqi@1 211
aoqi@1 212
aoqi@1 213 //FIXME, I have no idea the frame architecture of mips
aoqi@1 214 // load parameters that were stored with LIR_Assembler::store_parameter
aoqi@6880 215 // Note: offsets for store_parameter and load_argument must match
aoqi@1 216 void StubFrame::load_argument(int offset_in_words, Register reg) {
aoqi@6880 217 //ebp + 0: link
aoqi@6880 218 // + 1: return address
aoqi@6880 219 // + 2: argument with offset 0
aoqi@6880 220 // + 3: argument with offset 1
aoqi@6880 221 // + 4: ...
aoqi@6880 222 __ ld_ptr(reg, Address(FP, (offset_in_words + 2) * BytesPerWord));
aoqi@1 223 }
aoqi@6880 224
aoqi@6880 225
aoqi@1 226 StubFrame::~StubFrame() {
aoqi@6880 227 __ leave();
aoqi@6880 228 __ jr(RA);
aoqi@6880 229 __ delayed()->nop();
aoqi@1 230 }
aoqi@1 231
aoqi@1 232 #undef __
aoqi@1 233
aoqi@1 234
aoqi@1 235 // Implementation of Runtime1
aoqi@1 236
aoqi@1 237 #define __ sasm->
aoqi@1 238
aoqi@1 239 //static OopMap* save_live_registers(MacroAssembler* sasm, int num_rt_args);
aoqi@1 240 //static void restore_live_registers(MacroAssembler* sasm);
aoqi@1 241 //DeoptimizationBlob* SharedRuntime::_deopt_blob = NULL;
aoqi@1 242 /*
aoqi@1 243 const int fpu_stack_as_doubles_size_in_words = 16;
aoqi@1 244 const int fpu_stack_as_doubles_size = 64;
aoqi@1 245 */
aoqi@1 246 const int float_regs_as_doubles_size_in_words = 16;
aoqi@1 247
aoqi@6880 248 //FIXME,
aoqi@1 249 // Stack layout for saving/restoring all the registers needed during a runtime
aoqi@1 250 // call (this includes deoptimization)
aoqi@1 251 // Note: note that users of this frame may well have arguments to some runtime
aoqi@1 252 // while these values are on the stack. These positions neglect those arguments
aoqi@1 253 // but the code in save_live_registers will take the argument count into
aoqi@1 254 // account.
aoqi@1 255 //
aoqi@1 256 #ifdef _LP64
aoqi@1 257 #define SLOT2(x) x,
aoqi@1 258 #define SLOT_PER_WORD 2
aoqi@1 259 #else
aoqi@1 260 #define SLOT2(x)
aoqi@1 261 #define SLOT_PER_WORD 1
aoqi@1 262 #endif // _LP64
aoqi@1 263
aoqi@1 264 enum reg_save_layout {
aoqi@1 265 #ifndef _LP64
aoqi@1 266 T0_off = 0,
aoqi@1 267 S0_off = T0_off + SLOT_PER_WORD * 8,
aoqi@1 268 #else
aoqi@1 269 A4_off = 0,
aoqi@1 270 S0_off = A4_off + SLOT_PER_WORD * 8,
aoqi@1 271 #endif
aoqi@1 272 FP_off = S0_off + SLOT_PER_WORD * 8, SLOT2(FPH_off)
aoqi@1 273 T8_off, SLOT2(T8H_off)
aoqi@1 274 T9_off, SLOT2(T9H_off)
aoqi@1 275 SP_off, SLOT2(SPH_off)
aoqi@1 276 V0_off, SLOT2(V0H_off)
aoqi@1 277 V1_off, SLOT2(V1H_off)
aoqi@1 278 A0_off, SLOT2(A0H_off)
aoqi@1 279 A1_off, SLOT2(A1H_off)
aoqi@1 280 A2_off, SLOT2(A2H_off)
aoqi@1 281 A3_off, SLOT2(A3H_off)
aoqi@1 282
aoqi@1 283 // Float registers
aoqi@1 284 /* FIXME: Jin: In MIPS64, F0~23 are all caller-saved registers */
aoqi@1 285 F0_off, SLOT2( F0H_off)
aoqi@1 286 F1_off, SLOT2( F1H_off)
aoqi@1 287 F2_off, SLOT2( F2H_off)
aoqi@1 288 F3_off, SLOT2( F3H_off)
aoqi@1 289 F4_off, SLOT2( F4H_off)
aoqi@1 290 F5_off, SLOT2( F5H_off)
aoqi@1 291 F6_off, SLOT2( F6H_off)
aoqi@1 292 F7_off, SLOT2( F7H_off)
aoqi@1 293 F8_off, SLOT2( F8H_off)
aoqi@1 294 F9_off, SLOT2( F9H_off)
aoqi@1 295 F10_off, SLOT2( F10H_off)
aoqi@1 296 F11_off, SLOT2( F11H_off)
aoqi@1 297 F12_off, SLOT2( F12H_off)
aoqi@1 298 F13_off, SLOT2( F13H_off)
aoqi@1 299 F14_off, SLOT2( F14H_off)
aoqi@1 300 F15_off, SLOT2( F15H_off)
aoqi@1 301 F16_off, SLOT2( F16H_off)
aoqi@1 302 F17_off, SLOT2( F17H_off)
aoqi@1 303 F18_off, SLOT2( F18H_off)
aoqi@1 304 F19_off, SLOT2( F19H_off)
aoqi@1 305
aoqi@1 306 GP_off, SLOT2( GPH_off)
aoqi@1 307 //temp_2_off,
aoqi@1 308 temp_1_off, SLOT2(temp_1H_off)
aoqi@1 309 saved_fp_off, SLOT2(saved_fpH_off)
aoqi@1 310 return_off, SLOT2(returnH_off)
aoqi@1 311
aoqi@1 312 reg_save_frame_size,
aoqi@1 313
aoqi@1 314 // illegal instruction handler
aoqi@1 315 continue_dest_off = temp_1_off,
aoqi@1 316
aoqi@1 317 // deoptimization equates
aoqi@1 318 //deopt_type = temp_2_off, // slot for type of deopt in progress
aoqi@1 319 ret_type = temp_1_off // slot for return type
aoqi@1 320 };
aoqi@1 321
aoqi@6880 322
aoqi@6880 323
aoqi@1 324 // Save off registers which might be killed by calls into the runtime.
aoqi@1 325 // Tries to smart of about FP registers. In particular we separate
aoqi@1 326 // saving and describing the FPU registers for deoptimization since we
aoqi@1 327 // have to save the FPU registers twice if we describe them and on P4
aoqi@1 328 // saving FPU registers which don't contain anything appears
aoqi@1 329 // expensive. The deopt blob is the only thing which needs to
aoqi@1 330 // describe FPU registers. In all other cases it should be sufficient
aoqi@1 331 // to simply save their current value.
aoqi@1 332 static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args,
aoqi@6880 333 bool save_fpu_registers = true, bool describe_fpu_registers = false) {
aoqi@1 334
aoqi@8865 335 LP64_ONLY(num_rt_args = 0);
aoqi@8865 336 LP64_ONLY(assert((reg_save_frame_size * VMRegImpl::stack_slot_size) % 16 == 0, "must be 16 byte aligned");)
aoqi@8865 337 int frame_size_in_slots = reg_save_frame_size + num_rt_args * wordSize / VMRegImpl::slots_per_word; // args + thread
aoqi@8865 338 sasm->set_frame_size(frame_size_in_slots / VMRegImpl::slots_per_word);
aoqi@1 339
aoqi@1 340 // record saved value locations in an OopMap
aoqi@6880 341 // locations are offsets from sp after runtime call; num_rt_args is number of arguments
aoqi@1 342 // in call, including thread
aoqi@1 343 OopMap* map = new OopMap(reg_save_frame_size, 0);
aoqi@6880 344
aoqi@1 345 map->set_callee_saved(VMRegImpl::stack2reg(V0_off + num_rt_args), V0->as_VMReg());
aoqi@1 346 map->set_callee_saved(VMRegImpl::stack2reg(V1_off + num_rt_args), V1->as_VMReg());
aoqi@1 347 #ifdef _LP64
aoqi@1 348 map->set_callee_saved(VMRegImpl::stack2reg(V0H_off + num_rt_args), V0->as_VMReg()->next());
aoqi@1 349 map->set_callee_saved(VMRegImpl::stack2reg(V1H_off + num_rt_args), V1->as_VMReg()->next());
aoqi@1 350 #endif
aoqi@1 351
aoqi@1 352 int i = 0;
aoqi@1 353 #ifndef _LP64
aoqi@1 354 for (Register r = T0; r != T7->successor(); r = r->successor() ) {
aoqi@1 355 map->set_callee_saved(VMRegImpl::stack2reg(T0_off + num_rt_args + i++), r->as_VMReg());
aoqi@1 356 }
aoqi@1 357 #else
aoqi@1 358 for (Register r = A4; r != T3->successor(); r = r->successor() ) {
aoqi@1 359 map->set_callee_saved(VMRegImpl::stack2reg(A4_off + num_rt_args + i++), r->as_VMReg());
aoqi@1 360 map->set_callee_saved(VMRegImpl::stack2reg(A4_off + num_rt_args + i++), r->as_VMReg()->next());
aoqi@1 361 }
aoqi@1 362 #endif
aoqi@1 363
aoqi@1 364 i = 0;
aoqi@1 365 for (Register r = S0; r != S7->successor(); r = r->successor() ) {
aoqi@1 366 map->set_callee_saved(VMRegImpl::stack2reg(S0_off + num_rt_args + i++), r->as_VMReg());
aoqi@1 367 #ifdef _LP64
aoqi@1 368 map->set_callee_saved(VMRegImpl::stack2reg(S0_off + num_rt_args + i++), r->as_VMReg()->next());
aoqi@1 369 #endif
aoqi@1 370 }
aoqi@1 371
aoqi@1 372 map->set_callee_saved(VMRegImpl::stack2reg(FP_off + num_rt_args), FP->as_VMReg());
aoqi@1 373 map->set_callee_saved(VMRegImpl::stack2reg(GP_off + num_rt_args), GP->as_VMReg());
aoqi@1 374 map->set_callee_saved(VMRegImpl::stack2reg(T8_off + num_rt_args), T8->as_VMReg());
aoqi@1 375 map->set_callee_saved(VMRegImpl::stack2reg(T9_off + num_rt_args), T9->as_VMReg());
aoqi@1 376 map->set_callee_saved(VMRegImpl::stack2reg(A0_off + num_rt_args), A0->as_VMReg());
aoqi@1 377 map->set_callee_saved(VMRegImpl::stack2reg(A1_off + num_rt_args), A1->as_VMReg());
aoqi@1 378 map->set_callee_saved(VMRegImpl::stack2reg(A2_off + num_rt_args), A2->as_VMReg());
aoqi@1 379 map->set_callee_saved(VMRegImpl::stack2reg(A3_off + num_rt_args), A3->as_VMReg());
aoqi@1 380
aoqi@1 381 map->set_callee_saved(VMRegImpl::stack2reg(F0_off + num_rt_args), F0->as_VMReg());
aoqi@1 382 map->set_callee_saved(VMRegImpl::stack2reg(F1_off + num_rt_args), F1->as_VMReg());
aoqi@1 383 map->set_callee_saved(VMRegImpl::stack2reg(F2_off + num_rt_args), F2->as_VMReg());
aoqi@1 384 map->set_callee_saved(VMRegImpl::stack2reg(F3_off + num_rt_args), F1->as_VMReg());
aoqi@1 385 map->set_callee_saved(VMRegImpl::stack2reg(F4_off + num_rt_args), F4->as_VMReg());
aoqi@1 386 map->set_callee_saved(VMRegImpl::stack2reg(F5_off + num_rt_args), F4->as_VMReg());
aoqi@1 387 map->set_callee_saved(VMRegImpl::stack2reg(F6_off + num_rt_args), F4->as_VMReg());
aoqi@1 388 map->set_callee_saved(VMRegImpl::stack2reg(F7_off + num_rt_args), F4->as_VMReg());
aoqi@1 389 map->set_callee_saved(VMRegImpl::stack2reg(F8_off + num_rt_args), F4->as_VMReg());
aoqi@1 390 map->set_callee_saved(VMRegImpl::stack2reg(F9_off + num_rt_args), F4->as_VMReg());
aoqi@1 391 map->set_callee_saved(VMRegImpl::stack2reg(F10_off + num_rt_args), F4->as_VMReg());
aoqi@1 392 map->set_callee_saved(VMRegImpl::stack2reg(F11_off + num_rt_args), F4->as_VMReg());
aoqi@1 393 map->set_callee_saved(VMRegImpl::stack2reg(F12_off + num_rt_args), F12->as_VMReg());
aoqi@1 394 map->set_callee_saved(VMRegImpl::stack2reg(F13_off + num_rt_args), F13->as_VMReg());
aoqi@1 395 map->set_callee_saved(VMRegImpl::stack2reg(F14_off + num_rt_args), F14->as_VMReg());
aoqi@1 396 map->set_callee_saved(VMRegImpl::stack2reg(F15_off + num_rt_args), F15->as_VMReg());
aoqi@1 397 map->set_callee_saved(VMRegImpl::stack2reg(F16_off + num_rt_args), F16->as_VMReg());
aoqi@1 398 map->set_callee_saved(VMRegImpl::stack2reg(F17_off + num_rt_args), F17->as_VMReg());
aoqi@1 399 map->set_callee_saved(VMRegImpl::stack2reg(F18_off + num_rt_args), F18->as_VMReg());
aoqi@1 400 map->set_callee_saved(VMRegImpl::stack2reg(F19_off + num_rt_args), F19->as_VMReg());
aoqi@1 401
aoqi@1 402 #ifdef _LP64
aoqi@1 403 map->set_callee_saved(VMRegImpl::stack2reg(FPH_off + num_rt_args), FP->as_VMReg()->next());
aoqi@1 404 map->set_callee_saved(VMRegImpl::stack2reg(GPH_off + num_rt_args), GP->as_VMReg()->next());
aoqi@1 405 map->set_callee_saved(VMRegImpl::stack2reg(T8H_off + num_rt_args), T8->as_VMReg()->next());
aoqi@1 406 map->set_callee_saved(VMRegImpl::stack2reg(T9H_off + num_rt_args), T9->as_VMReg()->next());
aoqi@1 407 map->set_callee_saved(VMRegImpl::stack2reg(A0H_off + num_rt_args), A0->as_VMReg()->next());
aoqi@1 408 map->set_callee_saved(VMRegImpl::stack2reg(A1H_off + num_rt_args), A1->as_VMReg()->next());
aoqi@1 409 map->set_callee_saved(VMRegImpl::stack2reg(A2H_off + num_rt_args), A2->as_VMReg()->next());
aoqi@1 410 map->set_callee_saved(VMRegImpl::stack2reg(A3H_off + num_rt_args), A3->as_VMReg()->next());
aoqi@1 411 #endif
aoqi@1 412 return map;
aoqi@1 413 }
aoqi@1 414
aoqi@8865 415 static OopMap* save_live_registers(StubAssembler* sasm, int num_rt_args,
aoqi@8865 416 bool save_fpu_registers = true,
aoqi@1 417 bool describe_fpu_registers = false) {
aoqi@1 418 //const int reg_save_frame_size = return_off + 1 + num_rt_args;
aoqi@1 419 __ block_comment("save_live_registers");
aoqi@1 420
aoqi@6880 421 // save all register state - int, fpu
aoqi@1 422 __ addi(SP, SP, -(reg_save_frame_size / SLOT_PER_WORD - 2)* wordSize);
aoqi@6880 423
aoqi@1 424 #ifndef _LP64
aoqi@1 425 for (Register r = T0; r != T7->successor(); r = r->successor() ) {
aoqi@1 426 __ sw(r, SP, (r->encoding() - T0->encoding() + T0_off / SLOT_PER_WORD) * wordSize);
aoqi@1 427 #else
aoqi@1 428 for (Register r = A4; r != T3->successor(); r = r->successor() ) {
aoqi@1 429 __ sd(r, SP, (r->encoding() - A4->encoding() + A4_off / SLOT_PER_WORD) * wordSize);
aoqi@1 430 #endif
aoqi@1 431 }
aoqi@1 432 for (Register r = S0; r != S7->successor(); r = r->successor() ) {
aoqi@1 433 __ st_ptr(r, SP, (r->encoding() - S0->encoding() + S0_off / SLOT_PER_WORD) * wordSize);
aoqi@1 434 }
aoqi@1 435 __ st_ptr(FP, SP, FP_off * wordSize / SLOT_PER_WORD);
aoqi@1 436 __ st_ptr(GP, SP, GP_off * wordSize / SLOT_PER_WORD);
aoqi@1 437 __ st_ptr(T8, SP, T8_off * wordSize / SLOT_PER_WORD);
aoqi@1 438 __ st_ptr(T9, SP, T9_off * wordSize / SLOT_PER_WORD);
aoqi@1 439 __ st_ptr(A0, SP, A0_off * wordSize / SLOT_PER_WORD);
aoqi@1 440 __ st_ptr(A1, SP, A1_off * wordSize / SLOT_PER_WORD);
aoqi@1 441 __ st_ptr(A2, SP, A2_off * wordSize / SLOT_PER_WORD);
aoqi@1 442 __ st_ptr(A3, SP, A3_off * wordSize / SLOT_PER_WORD);
aoqi@1 443 __ st_ptr(V0, SP, V0_off * wordSize / SLOT_PER_WORD);
aoqi@6880 444 __ st_ptr(V1, SP, V1_off * wordSize / SLOT_PER_WORD);
aoqi@1 445
aoqi@6880 446 __ sdc1(F0, SP, F0_off * wordSize / SLOT_PER_WORD);
aoqi@6880 447 __ sdc1(F1, SP, F1_off * wordSize / SLOT_PER_WORD);
aoqi@6880 448 __ sdc1(F2, SP, F2_off * wordSize / SLOT_PER_WORD);
aoqi@6880 449 __ sdc1(F3, SP, F3_off * wordSize / SLOT_PER_WORD);
aoqi@6880 450 __ sdc1(F4, SP, F4_off * wordSize / SLOT_PER_WORD);
aoqi@6880 451 __ sdc1(F5, SP, F5_off * wordSize / SLOT_PER_WORD);
aoqi@6880 452 __ sdc1(F6, SP, F6_off * wordSize / SLOT_PER_WORD);
aoqi@6880 453 __ sdc1(F7, SP, F7_off * wordSize / SLOT_PER_WORD);
aoqi@6880 454 __ sdc1(F8, SP, F8_off * wordSize / SLOT_PER_WORD);
aoqi@6880 455 __ sdc1(F9, SP, F9_off * wordSize / SLOT_PER_WORD);
aoqi@6880 456 __ sdc1(F10, SP, F10_off * wordSize / SLOT_PER_WORD);
aoqi@6880 457 __ sdc1(F11, SP, F11_off * wordSize / SLOT_PER_WORD);
aoqi@6880 458 __ sdc1(F12, SP, F12_off * wordSize / SLOT_PER_WORD);
aoqi@6880 459 __ sdc1(F13, SP, F13_off * wordSize / SLOT_PER_WORD);
aoqi@6880 460 __ sdc1(F14, SP, F14_off * wordSize / SLOT_PER_WORD);
aoqi@6880 461 __ sdc1(F15, SP, F15_off * wordSize / SLOT_PER_WORD);
aoqi@6880 462 __ sdc1(F16, SP, F16_off * wordSize / SLOT_PER_WORD);
aoqi@6880 463 __ sdc1(F17, SP, F17_off * wordSize / SLOT_PER_WORD);
aoqi@6880 464 __ sdc1(F18, SP, F18_off * wordSize / SLOT_PER_WORD);
aoqi@6880 465 __ sdc1(F19, SP, F19_off * wordSize / SLOT_PER_WORD);
aoqi@1 466
aoqi@1 467 return generate_oop_map(sasm, num_rt_args, save_fpu_registers, describe_fpu_registers);
aoqi@1 468 }
aoqi@1 469
aoqi@1 470 static void restore_fpu(StubAssembler* sasm, bool restore_fpu_registers = true) {
aoqi@1 471 //static void restore_live_registers(MacroAssembler* sasm) {
aoqi@1 472 #ifndef _LP64
aoqi@1 473 for (Register r = T0; r != T7->successor(); r = r->successor() ) {
aoqi@1 474 __ lw(r, SP, (r->encoding() - T0->encoding() + T0_off / SLOT_PER_WORD) * wordSize);
aoqi@1 475 #else
aoqi@1 476 for (Register r = A4; r != T3->successor(); r = r->successor() ) {
aoqi@1 477 __ ld(r, SP, (r->encoding() - A4->encoding() + A4_off / SLOT_PER_WORD) * wordSize);
aoqi@1 478 #endif
aoqi@1 479 }
aoqi@1 480 for (Register r = S0; r != S7->successor(); r = r->successor() ) {
aoqi@1 481 __ ld_ptr(r, SP, (r->encoding() - S0->encoding() + S0_off / SLOT_PER_WORD) * wordSize);
aoqi@1 482 }
aoqi@1 483 __ ld_ptr(FP, SP, FP_off * wordSize / SLOT_PER_WORD);
aoqi@1 484 __ ld_ptr(GP, SP, GP_off * wordSize / SLOT_PER_WORD);
aoqi@1 485
aoqi@1 486 __ ld_ptr(T8, SP, T8_off * wordSize / SLOT_PER_WORD);
aoqi@1 487 __ ld_ptr(T9, SP, T9_off * wordSize / SLOT_PER_WORD);
aoqi@1 488 __ ld_ptr(A0, SP, A0_off * wordSize / SLOT_PER_WORD);
aoqi@1 489 __ ld_ptr(A1, SP, A1_off * wordSize / SLOT_PER_WORD);
aoqi@1 490 __ ld_ptr(A2, SP, A2_off * wordSize / SLOT_PER_WORD);
aoqi@1 491 __ ld_ptr(A3, SP, A3_off * wordSize / SLOT_PER_WORD);
aoqi@1 492
aoqi@1 493 __ ld_ptr(V0, SP, V0_off * wordSize / SLOT_PER_WORD);
aoqi@6880 494 __ ld_ptr(V1, SP, V1_off * wordSize / SLOT_PER_WORD);
aoqi@1 495
aoqi@1 496 __ ldc1(F0, SP, F0_off * wordSize / SLOT_PER_WORD);
aoqi@1 497 __ ldc1(F1, SP, F1_off * wordSize / SLOT_PER_WORD);
aoqi@1 498 __ ldc1(F2, SP, F2_off * wordSize / SLOT_PER_WORD);
aoqi@1 499 __ ldc1(F3, SP, F3_off * wordSize / SLOT_PER_WORD);
aoqi@1 500 __ ldc1(F4, SP, F4_off * wordSize / SLOT_PER_WORD);
aoqi@1 501 __ ldc1(F5, SP, F5_off * wordSize / SLOT_PER_WORD);
aoqi@1 502 __ ldc1(F6, SP, F6_off * wordSize / SLOT_PER_WORD);
aoqi@1 503 __ ldc1(F7, SP, F7_off * wordSize / SLOT_PER_WORD);
aoqi@1 504 __ ldc1(F8, SP, F8_off * wordSize / SLOT_PER_WORD);
aoqi@1 505 __ ldc1(F9, SP, F9_off * wordSize / SLOT_PER_WORD);
aoqi@1 506 __ ldc1(F10, SP, F10_off * wordSize / SLOT_PER_WORD);
aoqi@1 507 __ ldc1(F11, SP, F11_off * wordSize / SLOT_PER_WORD);
aoqi@1 508 __ ldc1(F12, SP, F12_off * wordSize / SLOT_PER_WORD);
aoqi@1 509 __ ldc1(F13, SP, F13_off * wordSize / SLOT_PER_WORD);
aoqi@1 510 __ ldc1(F14, SP, F14_off * wordSize / SLOT_PER_WORD);
aoqi@1 511 __ ldc1(F15, SP, F15_off * wordSize / SLOT_PER_WORD);
aoqi@1 512 __ ldc1(F16, SP, F16_off * wordSize / SLOT_PER_WORD);
aoqi@1 513 __ ldc1(F17, SP, F17_off * wordSize / SLOT_PER_WORD);
aoqi@1 514 __ ldc1(F18, SP, F18_off * wordSize / SLOT_PER_WORD);
aoqi@1 515 __ ldc1(F19, SP, F19_off * wordSize / SLOT_PER_WORD);
aoqi@1 516
aoqi@1 517 __ addiu(SP, SP, (reg_save_frame_size / SLOT_PER_WORD - 2) * wordSize);
aoqi@1 518 }
aoqi@1 519
aoqi@1 520 static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
aoqi@1 521 __ block_comment("restore_live_registers");
aoqi@1 522 restore_fpu(sasm, restore_fpu_registers);
aoqi@1 523 }
aoqi@1 524
aoqi@6880 525 static void restore_live_registers_except_V0(StubAssembler* sasm, bool restore_fpu_registers = true) {
aoqi@1 526 //static void restore_live_registers(MacroAssembler* sasm) {
aoqi@1 527 //FIXME , maybe V1 need to be saved too
aoqi@1 528 __ block_comment("restore_live_registers except V0");
aoqi@1 529 #ifndef _LP64
aoqi@1 530 for (Register r = T0; r != T7->successor(); r = r->successor() ) {
aoqi@6880 531 __ lw(r, SP, (r->encoding() - T0->encoding() + T0_off / SLOT_PER_WORD) * wordSize);
aoqi@1 532 #else
aoqi@1 533 for (Register r = A4; r != T3->successor(); r = r->successor() ) {
aoqi@6880 534 __ ld(r, SP, (r->encoding() - A4->encoding() + A4_off / SLOT_PER_WORD) * wordSize);
aoqi@1 535 #endif
aoqi@1 536 }
aoqi@1 537 for (Register r = S0; r != S7->successor(); r = r->successor() ) {
aoqi@6880 538 __ ld_ptr(r, SP, (r->encoding() - S0->encoding() + S0_off / SLOT_PER_WORD) * wordSize);
aoqi@1 539 }
aoqi@1 540 __ ld_ptr(FP, SP, FP_off * wordSize / SLOT_PER_WORD);
aoqi@1 541 __ ld_ptr(GP, SP, GP_off * wordSize / SLOT_PER_WORD);
aoqi@1 542
aoqi@1 543 __ ld_ptr(T8, SP, T8_off * wordSize / SLOT_PER_WORD);
aoqi@1 544 __ ld_ptr(T9, SP, T9_off * wordSize / SLOT_PER_WORD);
aoqi@1 545 __ ld_ptr(A0, SP, A0_off * wordSize / SLOT_PER_WORD);
aoqi@1 546 __ ld_ptr(A1, SP, A1_off * wordSize / SLOT_PER_WORD);
aoqi@1 547 __ ld_ptr(A2, SP, A2_off * wordSize / SLOT_PER_WORD);
aoqi@1 548 __ ld_ptr(A3, SP, A3_off * wordSize / SLOT_PER_WORD);
aoqi@1 549
aoqi@1 550 #if 1
aoqi@1 551 __ ldc1(F0, SP, F0_off * wordSize / SLOT_PER_WORD);
aoqi@1 552 __ ldc1(F1, SP, F1_off * wordSize / SLOT_PER_WORD);
aoqi@1 553 __ ldc1(F2, SP, F2_off * wordSize / SLOT_PER_WORD);
aoqi@1 554 __ ldc1(F3, SP, F3_off * wordSize / SLOT_PER_WORD);
aoqi@1 555 __ ldc1(F4, SP, F4_off * wordSize / SLOT_PER_WORD);
aoqi@1 556 __ ldc1(F5, SP, F5_off * wordSize / SLOT_PER_WORD);
aoqi@1 557 __ ldc1(F6, SP, F6_off * wordSize / SLOT_PER_WORD);
aoqi@1 558 __ ldc1(F7, SP, F7_off * wordSize / SLOT_PER_WORD);
aoqi@1 559 __ ldc1(F8, SP, F8_off * wordSize / SLOT_PER_WORD);
aoqi@1 560 __ ldc1(F9, SP, F9_off * wordSize / SLOT_PER_WORD);
aoqi@1 561 __ ldc1(F10, SP, F10_off * wordSize / SLOT_PER_WORD);
aoqi@1 562 __ ldc1(F11, SP, F11_off * wordSize / SLOT_PER_WORD);
aoqi@1 563 __ ldc1(F12, SP, F12_off * wordSize / SLOT_PER_WORD);
aoqi@1 564 __ ldc1(F13, SP, F13_off * wordSize / SLOT_PER_WORD);
aoqi@1 565 __ ldc1(F14, SP, F14_off * wordSize / SLOT_PER_WORD);
aoqi@1 566 __ ldc1(F15, SP, F15_off * wordSize / SLOT_PER_WORD);
aoqi@1 567 __ ldc1(F16, SP, F16_off * wordSize / SLOT_PER_WORD);
aoqi@1 568 __ ldc1(F17, SP, F17_off * wordSize / SLOT_PER_WORD);
aoqi@1 569 __ ldc1(F18, SP, F18_off * wordSize / SLOT_PER_WORD);
aoqi@1 570 __ ldc1(F19, SP, F19_off * wordSize / SLOT_PER_WORD);
aoqi@1 571 #endif
aoqi@1 572
aoqi@6880 573 __ ld_ptr(V1, SP, V1_off * wordSize / SLOT_PER_WORD);
aoqi@1 574
aoqi@1 575 __ addiu(SP, SP, (reg_save_frame_size / SLOT_PER_WORD - 2) * wordSize);
aoqi@1 576 }
aoqi@1 577
aoqi@1 578 void Runtime1::initialize_pd() {
aoqi@1 579 // nothing to do
aoqi@1 580 }
aoqi@1 581
aoqi@1 582 // target: the entry point of the method that creates and posts the exception oop
aoqi@1 583 // has_argument: true if the exception needs an argument (passed on stack because registers must be preserved)
aoqi@1 584 OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) {
aoqi@6880 585 // preserve all registers
aoqi@6880 586 OopMap* oop_map = save_live_registers(sasm, 0);
aoqi@1 587
aoqi@6880 588 // now all registers are saved and can be used freely
aoqi@6880 589 // verify that no old value is used accidentally
aoqi@6880 590 //all reigster are saved , I think mips do not need this
aoqi@1 591
aoqi@6880 592 // registers used by this stub
aoqi@6880 593 const Register temp_reg = T3;
aoqi@6880 594 // load argument for exception that is passed as an argument into the stub
aoqi@6880 595 if (has_argument) {
aoqi@6880 596 __ ld_ptr(temp_reg, Address(FP, 2*BytesPerWord));
aoqi@6880 597 }
aoqi@6880 598 int call_offset;
aoqi@6880 599 if (has_argument)
aoqi@6880 600 call_offset = __ call_RT(noreg, noreg, target, temp_reg);
aoqi@1 601 else
aoqi@6880 602 call_offset = __ call_RT(noreg, noreg, target);
aoqi@1 603
aoqi@6880 604 OopMapSet* oop_maps = new OopMapSet();
aoqi@6880 605 oop_maps->add_gc_map(call_offset, oop_map);
aoqi@1 606
aoqi@6880 607 __ stop("should not reach here");
aoqi@6880 608
aoqi@6880 609 return oop_maps;
aoqi@1 610 }
aoqi@1 611
aoqi@1 612 OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) {
aoqi@8865 613 __ block_comment("generate_handle_exception");
aoqi@8865 614
aoqi@8865 615 // incoming parameters
aoqi@6880 616 const Register exception_oop = V0;
aoqi@6880 617 const Register exception_pc = V1;
aoqi@6880 618 // other registers used in this stub
aoqi@8865 619 const Register thread = TREG;
aoqi@8865 620 #ifndef OPT_THREAD
aoqi@8865 621 __ get_thread(thread);
aoqi@8865 622 #endif
aoqi@1 623 // Save registers, if required.
aoqi@8865 624 OopMapSet* oop_maps = new OopMapSet();
aoqi@8865 625 OopMap* oop_map = NULL;
aoqi@8865 626 switch (id) {
aoqi@8865 627 case forward_exception_id:
aoqi@8865 628 // We're handling an exception in the context of a compiled frame.
aoqi@8865 629 // The registers have been saved in the standard places. Perform
aoqi@8865 630 // an exception lookup in the caller and dispatch to the handler
aoqi@8865 631 // if found. Otherwise unwind and dispatch to the callers
aoqi@8865 632 // exception handler.
aoqi@8865 633 oop_map = generate_oop_map(sasm, 1 /*thread*/);
aoqi@6880 634
aoqi@8865 635 // load and clear pending exception oop into RAX
aoqi@8865 636 __ ld_ptr(exception_oop, Address(thread, Thread::pending_exception_offset()));
aoqi@8865 637 __ st_ptr(R0, Address(thread, Thread::pending_exception_offset()));
aoqi@6880 638
aoqi@8865 639 // load issuing PC (the return address for this stub) into rdx
aoqi@8865 640 __ ld_ptr(exception_pc, Address(FP, 1*BytesPerWord));
aoqi@6880 641
aoqi@8865 642 // make sure that the vm_results are cleared (may be unnecessary)
aoqi@8865 643 __ st_ptr(R0, Address(thread, JavaThread::vm_result_offset()));
aoqi@8865 644 __ st_ptr(R0, Address(thread, JavaThread::vm_result_2_offset()));
aoqi@8865 645 break;
aoqi@8865 646 case handle_exception_nofpu_id:
aoqi@8865 647 case handle_exception_id:
aoqi@8865 648 // At this point all registers MAY be live.
aoqi@8865 649 oop_map = save_live_registers(sasm, 1 /*thread*/, id != handle_exception_nofpu_id);
aoqi@8865 650 break;
aoqi@8865 651 case handle_exception_from_callee_id: {
aoqi@8865 652 // At this point all registers except exception oop (RAX) and
aoqi@8865 653 // exception pc (RDX) are dead.
aoqi@8865 654 const int frame_size = 2 /*BP, return address*/ NOT_LP64(+ 1 /*thread*/);
aoqi@8865 655 oop_map = new OopMap(frame_size * VMRegImpl::slots_per_word, 0);
aoqi@8865 656 sasm->set_frame_size(frame_size);
aoqi@8865 657 break;
aoqi@8865 658 }
aoqi@8865 659 default: ShouldNotReachHere();
aoqi@8865 660 }
aoqi@1 661
aoqi@1 662 #ifdef TIERED
aoqi@6880 663 // C2 can leave the fpu stack dirty
aoqi@6880 664 __ empty_FPU_stack();
aoqi@1 665 #endif // TIERED
aoqi@1 666
aoqi@6880 667 // verify that only V0 and V1 is valid at this time
aoqi@6880 668 // verify that V0 contains a valid exception
aoqi@6880 669 __ verify_not_null_oop(exception_oop);
aoqi@1 670
aoqi@6880 671 // load address of JavaThread object for thread-local data
aoqi@6880 672 __ get_thread(thread);
aoqi@1 673
aoqi@1 674 #ifdef ASSERT
aoqi@6880 675 // check that fields in JavaThread for exception oop and issuing pc are
aoqi@6880 676 // empty before writing to them
aoqi@6880 677 Label oop_empty;
aoqi@6880 678 __ ld_ptr(AT, Address(thread, in_bytes(JavaThread::exception_oop_offset())));
aoqi@6880 679 __ beq(AT, R0, oop_empty);
aoqi@6880 680 __ delayed()->nop();
aoqi@6880 681 __ stop("exception oop already set");
aoqi@6880 682 __ bind(oop_empty);
fujie@9207 683
aoqi@6880 684 Label pc_empty;
aoqi@6880 685 __ ld_ptr(AT, Address(thread, in_bytes(JavaThread::exception_pc_offset())));
aoqi@6880 686 __ beq(AT, R0, pc_empty);
aoqi@6880 687 __ delayed()->nop();
aoqi@6880 688 __ stop("exception pc already set");
aoqi@6880 689 __ bind(pc_empty);
aoqi@1 690 #endif
aoqi@1 691
aoqi@6880 692 // save exception oop and issuing pc into JavaThread
aoqi@6880 693 // (exception handler will load it from here)
aoqi@6880 694 __ st_ptr(exception_oop, Address(thread, in_bytes(JavaThread::exception_oop_offset())));
aoqi@6880 695 __ st_ptr(exception_pc, Address(thread, in_bytes(JavaThread::exception_pc_offset())));
aoqi@1 696
aoqi@8865 697 // patch throwing pc into return address (has bci & oop map)
aoqi@8865 698 __ st_ptr(exception_pc, Address(FP, 1*BytesPerWord));
aoqi@1 699
aoqi@6880 700 // compute the exception handler.
aoqi@6880 701 // the exception oop and the throwing pc are read from the fields in JavaThread
fujie@9161 702 __ block_comment(";; will call_RT exception_handler_for_pc");
aoqi@8865 703 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc));
aoqi@6880 704 oop_maps->add_gc_map(call_offset, oop_map);
fujie@9161 705 __ block_comment(";; end of call_RT exception_handler_for_pc");
fujie@9207 706
aoqi@6880 707 // V0: handler address or NULL if no handler exists
aoqi@6880 708 // will be the deopt blob if nmethod was deoptimized while we looked up
aoqi@6880 709 // handler regardless of whether handler existed in the nmethod.
aoqi@1 710
aoqi@6880 711 // only V0 is valid at this time, all other registers have been destroyed by the
aoqi@6880 712 // runtime call
aoqi@1 713
aoqi@6880 714 // patch the return address -> the stub will directly return to the exception handler
aoqi@8865 715 __ st_ptr(V0, Address(FP, 1 * BytesPerWord));
aoqi@1 716
aoqi@8865 717 switch (id) {
aoqi@8865 718 case forward_exception_id:
aoqi@8865 719 case handle_exception_nofpu_id:
aoqi@8865 720 case handle_exception_id:
aoqi@8865 721 // Restore the registers that were saved at the beginning.
aoqi@8865 722 restore_live_registers(sasm, id != handle_exception_nofpu_id);
aoqi@8865 723 break;
aoqi@8865 724 case handle_exception_from_callee_id:
aoqi@8865 725 // WIN64_ONLY: No need to add frame::arg_reg_save_area_bytes to SP
aoqi@8865 726 // since we do a leave anyway.
aoqi@1 727
aoqi@8865 728 // Pop the return address since we are possibly changing SP (restoring from BP).
fujie@9207 729 __ move(SP, FP);
fujie@9207 730 __ pop(FP);
fujie@9207 731 __ pop(RA);
aoqi@8865 732 __ jr(RA); // jump to exception handler
aoqi@8865 733 __ delayed()->nop();
aoqi@8865 734 break;
aoqi@8865 735 default: ShouldNotReachHere();
aoqi@8865 736 }
aoqi@1 737
aoqi@8865 738 return oop_maps;
aoqi@8865 739 }
aoqi@1 740
aoqi@1 741
aoqi@1 742
aoqi@1 743
aoqi@1 744
aoqi@1 745 void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
aoqi@6880 746 // incoming parameters
aoqi@6880 747 const Register exception_oop = V0;
aoqi@8865 748 // callee-saved copy of exception_oop during runtime call
aoqi@8865 749 const Register exception_oop_callee_saved = S0;
aoqi@6880 750 // other registers used in this stub
aoqi@6880 751 const Register exception_pc = V1;
aoqi@6880 752 const Register handler_addr = T3;
aoqi@8865 753 const Register thread = TREG;
aoqi@1 754
aoqi@6880 755 // verify that only eax is valid at this time
aoqi@6880 756 // __ invalidate_registers(false, true, true, true, true, true);
aoqi@1 757
aoqi@1 758 #ifdef ASSERT
aoqi@6880 759 // check that fields in JavaThread for exception oop and issuing pc are empty
aoqi@6880 760 __ get_thread(thread);
aoqi@6880 761 Label oop_empty;
aoqi@6880 762 __ ld_ptr(AT, thread, in_bytes(JavaThread::exception_oop_offset()));
aoqi@6880 763 __ beq(AT, R0, oop_empty);
aoqi@6880 764 __ delayed()->nop();
aoqi@6880 765 __ stop("exception oop must be empty");
aoqi@6880 766 __ bind(oop_empty);
aoqi@1 767
aoqi@6880 768 Label pc_empty;
aoqi@6880 769 __ ld_ptr(AT, thread, in_bytes(JavaThread::exception_pc_offset()));
aoqi@8865 770 __ beq(AT, R0, pc_empty);
aoqi@6880 771 __ delayed()->nop();
aoqi@6880 772 __ stop("exception pc must be empty");
aoqi@6880 773 __ bind(pc_empty);
aoqi@1 774 #endif
aoqi@6880 775 // clear the FPU stack in case any FPU results are left behind
aoqi@6880 776 __ empty_FPU_stack();
aoqi@1 777
aoqi@8865 778 // save exception_oop in callee-saved register to preserve it during runtime calls
aoqi@8865 779 __ verify_not_null_oop(exception_oop);
aoqi@8865 780 __ move(exception_oop_callee_saved, exception_oop);
aoqi@8865 781
aoqi@8865 782 #ifndef OPT_THREAD
aoqi@8865 783 __ get_thread(thread);
aoqi@8865 784 #endif
fujie@9207 785 // Get return address (is in RA after leave).
aoqi@8865 786
fujie@9207 787 __ move(exception_pc, RA);
fujie@9207 788 __ push(RA);
aoqi@1 789
aoqi@6880 790 // search the exception handler address of the caller (using the return address)
aoqi@8865 791 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), thread, exception_pc);
aoqi@8865 792 // V0: exception handler address of the caller
aoqi@1 793
aoqi@6880 794 // only eax is valid at this time, all other registers have been destroyed by the call
aoqi@1 795
aoqi@6880 796 // move result of call into correct register
aoqi@6880 797 __ move(handler_addr, V0);
aoqi@1 798
aoqi@8865 799 // Restore exception oop to V0 (required convention of exception handler).
aoqi@8865 800 __ move(exception_oop, exception_oop_callee_saved);
aoqi@8865 801
aoqi@8865 802 // verify that there is really a valid exception in V0
aoqi@6880 803 __ verify_oop(exception_oop);
aoqi@1 804
aoqi@6880 805 // get throwing pc (= return address).
aoqi@8865 806 // V1 has been destroyed by the call, so it must be set again
aoqi@6880 807 // the pop is also necessary to simulate the effect of a ret(0)
aoqi@6880 808 __ super_pop(exception_pc);
aoqi@1 809
aoqi@6880 810 // continue at exception handler (return address removed)
aoqi@6880 811 // note: do *not* remove arguments when unwinding the
aoqi@6880 812 // activation since the caller assumes having
aoqi@6880 813 // all arguments on the stack when entering the
aoqi@6880 814 // runtime to determine the exception handler
aoqi@6880 815 // (GC happens at call site with arguments!)
aoqi@8865 816 // V0: exception oop
aoqi@8865 817 // V1: throwing pc
aoqi@8865 818 // T3: exception handler
aoqi@6880 819 __ jr(handler_addr);
aoqi@6880 820 __ delayed()->nop();
aoqi@1 821 }
aoqi@1 822
aoqi@1 823
aoqi@1 824
aoqi@1 825
aoqi@1 826 //static address deopt_with_exception_entry_for_patch = NULL;
aoqi@1 827
aoqi@1 828 OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
aoqi@1 829
aoqi@6880 830 // use the maximum number of runtime-arguments here because it is difficult to
aoqi@6880 831 // distinguish each RT-Call.
aoqi@6880 832 // Note: This number affects also the RT-Call in generate_handle_exception because
aoqi@6880 833 // the oop-map is shared for all calls.
aoqi@1 834
aoqi@6880 835 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
aoqi@6880 836 assert(deopt_blob != NULL, "deoptimization blob must have been created");
aoqi@6880 837 // assert(deopt_with_exception_entry_for_patch != NULL,
aoqi@6880 838 // "deoptimization blob must have been created");
aoqi@6880 839
aoqi@6880 840 //OopMap* oop_map = save_live_registers(sasm, num_rt_args);
aoqi@6880 841 OopMap* oop_map = save_live_registers(sasm, 0);
aoqi@6880 842 const Register thread = T8;
aoqi@6880 843 // push java thread (becomes first argument of C function)
aoqi@6880 844 __ get_thread(thread);
aoqi@6880 845 __ move(A0, thread);
aoqi@1 846
aoqi@1 847
aoqi@6880 848 /*
aoqi@6880 849 * NOTE: this frame should be compiled frame, but at this point, the pc in frame-anchor
aoqi@6880 850 * is contained in interpreter. It should be wrong, and should be cleared but is not.
aoqi@6880 851 * even if we cleared the wrong pc in anchor, the default way to get caller pc in class frame
aoqi@6880 852 * is not right. It depends on that the caller pc is stored in *(sp - 1) but it's not the case
aoqi@1 853 */
aoqi@6880 854 __ set_last_Java_frame(thread, NOREG, FP, NULL);
aoqi@6880 855 NOT_LP64(__ addiu(SP, SP, (-1) * wordSize));
aoqi@6880 856 __ move(AT, -(StackAlignmentInBytes));
aoqi@6880 857 __ andr(SP, SP, AT);
aoqi@6880 858 __ relocate(relocInfo::internal_pc_type);
aoqi@6880 859 {
aoqi@1 860 #ifndef _LP64
aoqi@6880 861 int save_pc = (int)__ pc() + 12 + NativeCall::return_address_offset;
aoqi@6880 862 __ lui(AT, Assembler::split_high(save_pc));
aoqi@6880 863 __ addiu(AT, AT, Assembler::split_low(save_pc));
aoqi@1 864 #else
aoqi@6880 865 uintptr_t save_pc = (uintptr_t)__ pc() + NativeMovConstReg::instruction_size + 1 * BytesPerInstWord + NativeCall::return_address_offset_long;
aoqi@6880 866 __ li48(AT, save_pc);
aoqi@1 867 #endif
aoqi@6880 868 }
aoqi@6880 869 __ st_ptr(AT, thread, in_bytes(JavaThread::last_Java_pc_offset()));
aoqi@1 870
aoqi@6880 871 // do the call
aoqi@1 872 #ifndef _LP64
aoqi@6880 873 __ lui(T9, Assembler::split_high((int)target));
aoqi@6880 874 __ addiu(T9, T9, Assembler::split_low((int)target));
aoqi@1 875 #else
aoqi@6880 876 __ li48(T9, (intptr_t)target);
aoqi@1 877 #endif
aoqi@6880 878 __ jalr(T9);
aoqi@6880 879 __ delayed()->nop();
aoqi@6880 880 OopMapSet* oop_maps = new OopMapSet();
aoqi@6880 881 oop_maps->add_gc_map(__ offset(), oop_map);
aoqi@1 882
aoqi@6880 883 __ get_thread(thread);
aoqi@1 884
aoqi@6880 885 __ ld_ptr (SP, thread, in_bytes(JavaThread::last_Java_sp_offset()));
fujie@9171 886 __ reset_last_Java_frame(thread, true);
aoqi@6880 887 // discard thread arg
aoqi@6880 888 // check for pending exceptions
aoqi@6880 889 {
aoqi@6880 890 Label L, skip;
aoqi@6880 891 //Label no_deopt;
aoqi@6880 892 __ ld_ptr(AT, thread, in_bytes(Thread::pending_exception_offset()));
aoqi@6880 893 __ beq(AT, R0, L);
aoqi@6880 894 __ delayed()->nop();
aoqi@6880 895 // exception pending => remove activation and forward to exception handler
aoqi@1 896
aoqi@8865 897 __ bne(V0, R0, skip);
aoqi@6880 898 __ delayed()->nop();
aoqi@6880 899 __ jmp(Runtime1::entry_for(Runtime1::forward_exception_id),
aoqi@6880 900 relocInfo::runtime_call_type);
aoqi@6880 901 __ delayed()->nop();
aoqi@6880 902 __ bind(skip);
aoqi@1 903
aoqi@6880 904 // the deopt blob expects exceptions in the special fields of
aoqi@6880 905 // JavaThread, so copy and clear pending exception.
aoqi@1 906
aoqi@6880 907 // load and clear pending exception
aoqi@6880 908 __ ld_ptr(V0, Address(thread,in_bytes(Thread::pending_exception_offset())));
aoqi@6880 909 __ st_ptr(R0, Address(thread, in_bytes(Thread::pending_exception_offset())));
aoqi@1 910
aoqi@6880 911 // check that there is really a valid exception
aoqi@6880 912 __ verify_not_null_oop(V0);
aoqi@6880 913
aoqi@6880 914 // load throwing pc: this is the return address of the stub
aoqi@6880 915 __ ld_ptr(V1, Address(SP, return_off * BytesPerWord));
aoqi@1 916
aoqi@1 917
aoqi@1 918 #ifdef ASSERT
aoqi@6880 919 // check that fields in JavaThread for exception oop and issuing pc are empty
aoqi@6880 920 Label oop_empty;
aoqi@6880 921 __ ld_ptr(AT, Address(thread, in_bytes(JavaThread::exception_oop_offset())));
aoqi@6880 922 __ beq(AT,R0,oop_empty);
aoqi@6880 923 __ delayed()->nop();
aoqi@6880 924 __ stop("exception oop must be empty");
aoqi@6880 925 __ bind(oop_empty);
aoqi@1 926
aoqi@6880 927 Label pc_empty;
aoqi@6880 928 __ ld_ptr(AT, Address(thread, in_bytes(JavaThread::exception_pc_offset())));
aoqi@6880 929 __ beq(AT,R0,pc_empty);
aoqi@6880 930 __ delayed()->nop();
aoqi@6880 931 __ stop("exception pc must be empty");
aoqi@6880 932 __ bind(pc_empty);
aoqi@1 933 #endif
aoqi@1 934
aoqi@6880 935 // store exception oop and throwing pc to JavaThread
aoqi@6880 936 __ st_ptr(V0,Address(thread, in_bytes(JavaThread::exception_oop_offset())));
aoqi@6880 937 __ st_ptr(V1,Address(thread, in_bytes(JavaThread::exception_pc_offset())));
aoqi@1 938
aoqi@6880 939 restore_live_registers(sasm);
aoqi@1 940
aoqi@6880 941 __ leave();
aoqi@1 942
aoqi@6880 943 // Forward the exception directly to deopt blob. We can blow no
aoqi@6880 944 // registers and must leave throwing pc on the stack. A patch may
aoqi@6880 945 // have values live in registers so the entry point with the
aoqi@6880 946 // exception in tls.
aoqi@6880 947 __ jmp(deopt_blob->unpack_with_exception_in_tls(), relocInfo::runtime_call_type);
aoqi@6880 948 __ delayed()->nop();
aoqi@1 949
aoqi@6880 950 __ bind(L);
aoqi@6880 951 }
aoqi@1 952
aoqi@6880 953 // Runtime will return true if the nmethod has been deoptimized during
aoqi@6880 954 // the patching process. In that case we must do a deopt reexecute instead.
aoqi@1 955
aoqi@6880 956 Label reexecuteEntry, cont;
aoqi@1 957
aoqi@6880 958 __ beq(V0, R0, cont); // have we deoptimized?
aoqi@6880 959 __ delayed()->nop();
aoqi@1 960
aoqi@6880 961 // Will reexecute. Proper return address is already on the stack we just restore
aoqi@6880 962 // registers, pop all of our frame but the return address and jump to the deopt blob
aoqi@6880 963 restore_live_registers(sasm);
aoqi@1 964
aoqi@6880 965 __ leave();
aoqi@6880 966 __ jmp(deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type);
aoqi@6880 967 __ delayed()->nop();
aoqi@1 968
aoqi@6880 969 __ bind(cont);
aoqi@6880 970 restore_live_registers(sasm);
aoqi@1 971
aoqi@6880 972 __ leave();
aoqi@6880 973 __ jr(RA);
aoqi@6880 974 __ delayed()->nop();
aoqi@6880 975
aoqi@6880 976 return oop_maps;
aoqi@1 977 }
aoqi@1 978
aoqi@1 979
aoqi@1 980 OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
aoqi@6880 981 // for better readability
aoqi@6880 982 const bool must_gc_arguments = true;
aoqi@6880 983 const bool dont_gc_arguments = false;
aoqi@1 984
aoqi@1 985
aoqi@6880 986 // default value; overwritten for some optimized stubs that are called
aoqi@6880 987 // from methods that do not use the fpu
aoqi@6880 988 bool save_fpu_registers = true;
aoqi@1 989
aoqi@1 990
aoqi@6880 991 // stub code & info for the different stubs
aoqi@6880 992 OopMapSet* oop_maps = NULL;
aoqi@1 993
aoqi@1 994 switch (id) {
aoqi@1 995 case forward_exception_id:
aoqi@1 996 {
aoqi@8865 997 oop_maps = generate_handle_exception(id, sasm);
aoqi@8865 998 __ leave();
aoqi@8865 999 __ jr(RA);
aoqi@8865 1000 __ delayed()->nop();
aoqi@1 1001 }
aoqi@1 1002 break;
aoqi@1 1003
aoqi@1 1004 case new_instance_id:
aoqi@1 1005 case fast_new_instance_id:
aoqi@1 1006 case fast_new_instance_init_check_id:
aoqi@1 1007 {
aoqi@1 1008 Register klass = A4; // Incoming
aoqi@1 1009 Register obj = V0; // Result
aoqi@1 1010
aoqi@1 1011 if (id == new_instance_id) {
aoqi@1 1012 __ set_info("new_instance", dont_gc_arguments);
aoqi@1 1013 } else if (id == fast_new_instance_id) {
aoqi@1 1014 __ set_info("fast new_instance", dont_gc_arguments);
aoqi@1 1015 } else {
aoqi@1 1016 assert(id == fast_new_instance_init_check_id, "bad StubID");
aoqi@1 1017 __ set_info("fast new_instance init check", dont_gc_arguments);
aoqi@1 1018 }
aoqi@1 1019
aoqi@6880 1020 if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id)
aoqi@1 1021 && UseTLAB && FastTLABRefill) {
aoqi@1 1022 Label slow_path;
aoqi@1 1023 Register obj_size = T0;
aoqi@1 1024 Register t1 = T2;
aoqi@1 1025 Register t2 = T3;
aoqi@1 1026 assert_different_registers(klass, obj, obj_size, t1, t2);
aoqi@1 1027 if (id == fast_new_instance_init_check_id) {
aoqi@1 1028 // make sure the klass is initialized
aoqi@8865 1029 __ ld_ptr(AT, Address(klass, in_bytes(InstanceKlass::init_state_offset())));
aoqi@1 1030 __ move(t1, InstanceKlass::fully_initialized);
aoqi@1 1031 __ bne(AT, t1, slow_path);
aoqi@1 1032 __ delayed()->nop();
aoqi@1 1033 }
aoqi@1 1034 #ifdef ASSERT
aoqi@1 1035 // assert object can be fast path allocated
aoqi@1 1036 {
aoqi@1 1037 Label ok, not_ok;
aoqi@1 1038 __ lw(obj_size, klass, in_bytes(Klass::layout_helper_offset()));
aoqi@1 1039 __ blez(obj_size, not_ok);
aoqi@1 1040 __ delayed()->nop();
aoqi@1 1041 __ andi(t1 , obj_size, Klass::_lh_instance_slow_path_bit);
aoqi@1 1042 __ beq(t1, R0, ok);
aoqi@1 1043 __ delayed()->nop();
aoqi@1 1044 __ bind(not_ok);
aoqi@1 1045 __ stop("assert(can be fast path allocated)");
aoqi@1 1046 __ should_not_reach_here();
aoqi@1 1047 __ bind(ok);
aoqi@1 1048 }
aoqi@1 1049 #endif // ASSERT
aoqi@1 1050 // if we got here then the TLAB allocation failed, so try
aoqi@1 1051 // refilling the TLAB or allocating directly from eden.
aoqi@6880 1052
aoqi@1 1053 Label retry_tlab, try_eden;
aoqi@1 1054 __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy edx (klass)
aoqi@6880 1055
aoqi@1 1056 __ bind(retry_tlab);
aoqi@6880 1057
aoqi@1 1058 // get the instance size
aoqi@1 1059 __ lw(obj_size, klass, in_bytes(Klass::layout_helper_offset()));
aoqi@1 1060 __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path);
aoqi@1 1061 __ initialize_object(obj, klass, obj_size, 0, t1, t2);
aoqi@1 1062 __ verify_oop(obj);
aoqi@1 1063 __ jr(RA);
aoqi@1 1064 __ delayed()->nop();
aoqi@6880 1065
wangxue@9205 1066 #ifndef OPT_THREAD
wangxue@9205 1067 const Register thread = T8;
wangxue@9205 1068 __ get_thread(thread);
wangxue@9205 1069 #else
wangxue@9205 1070 const Register thread = TREG;
wangxue@9205 1071 #endif
wangxue@9205 1072
aoqi@1 1073 __ bind(try_eden);
aoqi@1 1074
aoqi@6880 1075 // get the instance size
aoqi@1 1076 __ lw(obj_size, klass, in_bytes(Klass::layout_helper_offset()));
aoqi@1 1077 __ eden_allocate(obj, obj_size, 0, t1, t2, slow_path);
wangxue@9205 1078 __ incr_allocated_bytes(thread, obj_size, 0);
wangxue@9205 1079
aoqi@1 1080 __ initialize_object(obj, klass, obj_size, 0, t1, t2);
aoqi@1 1081 __ verify_oop(obj);
aoqi@1 1082 __ jr(RA);
aoqi@1 1083 __ delayed()->nop();
aoqi@6880 1084
aoqi@1 1085 __ bind(slow_path);
aoqi@1 1086 }
aoqi@1 1087 __ enter();
aoqi@1 1088 OopMap* map = save_live_registers(sasm, 0);
aoqi@1 1089 int call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_instance), klass);
aoqi@1 1090 oop_maps = new OopMapSet();
aoqi@1 1091 oop_maps->add_gc_map(call_offset, map);
aoqi@1 1092 restore_live_registers_except_V0(sasm);
aoqi@1 1093 __ verify_oop(obj);
aoqi@1 1094 __ leave();
aoqi@1 1095 __ jr(RA);
aoqi@1 1096 __ delayed()->nop();
aoqi@6880 1097
aoqi@1 1098 // V0: new instance
aoqi@1 1099 }
aoqi@1 1100 break;
aoqi@1 1101
aoqi@1 1102
aoqi@1 1103 #ifdef TIERED
aoqi@1 1104 //FIXME, I hava no idea which register to use
aoqi@1 1105 case counter_overflow_id:
aoqi@1 1106 {
aoqi@1 1107 #ifndef _LP64
aoqi@1 1108 Register bci = T5;
aoqi@1 1109 #else
aoqi@1 1110 Register bci = A5;
aoqi@1 1111 #endif
aoqi@8865 1112 Register method = AT;
aoqi@1 1113 __ enter();
aoqi@1 1114 OopMap* map = save_live_registers(sasm, 0);
aoqi@1 1115 // Retrieve bci
aoqi@1 1116 __ lw(bci, Address(FP, 2*BytesPerWord));// FIXME:wuhui.ebp==??
aoqi@8865 1117 __ ld(method, Address(FP, 3*BytesPerWord));
aoqi@8865 1118 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, counter_overflow), bci, method);
aoqi@1 1119 oop_maps = new OopMapSet();
aoqi@1 1120 oop_maps->add_gc_map(call_offset, map);
aoqi@1 1121 restore_live_registers(sasm);
aoqi@1 1122 __ leave();
aoqi@6880 1123 __ jr(RA);
aoqi@6880 1124 __ delayed()->nop();
aoqi@1 1125 }
aoqi@1 1126 break;
aoqi@1 1127 #endif // TIERED
aoqi@1 1128
aoqi@1 1129
aoqi@1 1130
aoqi@1 1131 case new_type_array_id:
aoqi@1 1132 case new_object_array_id:
aoqi@6880 1133 {
aoqi@6880 1134 // i use T2 as length register, T4 as klass register, V0 as result register.
aoqi@1 1135 // MUST accord with NewTypeArrayStub::emit_code, NewObjectArrayStub::emit_code
aoqi@1 1136 Register length = T2; // Incoming
aoqi@1 1137 #ifndef _LP64
aoqi@1 1138 Register klass = T4; // Incoming
aoqi@1 1139 #else
aoqi@1 1140 Register klass = A4; // Incoming
aoqi@1 1141 #endif
aoqi@1 1142 Register obj = V0; // Result
aoqi@6880 1143
aoqi@1 1144 if (id == new_type_array_id) {
aoqi@1 1145 __ set_info("new_type_array", dont_gc_arguments);
aoqi@1 1146 } else {
aoqi@1 1147 __ set_info("new_object_array", dont_gc_arguments);
aoqi@1 1148 }
aoqi@6880 1149
aoqi@1 1150 if (UseTLAB && FastTLABRefill) {
aoqi@1 1151 Register arr_size = T0;
aoqi@6880 1152 Register t1 = T1;
aoqi@1 1153 Register t2 = T3;
aoqi@1 1154 Label slow_path;
aoqi@1 1155 assert_different_registers(length, klass, obj, arr_size, t1, t2);
aoqi@6880 1156
aoqi@1 1157 // check that array length is small enough for fast path
aoqi@1 1158 __ move(AT, C1_MacroAssembler::max_array_allocation_length);
aoqi@1 1159 __ sltu(AT, AT, length);
aoqi@1 1160 __ bne(AT, R0, slow_path);
aoqi@1 1161 __ delayed()->nop();
aoqi@1 1162
aoqi@1 1163 // if we got here then the TLAB allocation failed, so try
aoqi@1 1164 // refilling the TLAB or allocating directly from eden.
aoqi@1 1165 Label retry_tlab, try_eden;
aoqi@6880 1166 //T0,T1,T5,T8 have changed!
aoqi@1 1167 __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves T2 & T4
aoqi@6880 1168
aoqi@1 1169 __ bind(retry_tlab);
aoqi@6880 1170
aoqi@1 1171 // get the allocation size: (length << (layout_helper & 0x1F)) + header_size
aoqi@6880 1172 __ lw(t1, klass, in_bytes(Klass::layout_helper_offset()));
aoqi@1 1173 __ andi(AT, t1, 0x1f);
aoqi@1 1174 __ sllv(arr_size, length, AT);
aoqi@1 1175 __ srl(t1, t1, Klass::_lh_header_size_shift);
aoqi@1 1176 __ andi(t1, t1, Klass::_lh_header_size_mask);
aoqi@1 1177 __ add(arr_size, t1, arr_size);
aoqi@1 1178 __ addi(arr_size, arr_size, MinObjAlignmentInBytesMask); // align up
aoqi@1 1179 __ move(AT, ~MinObjAlignmentInBytesMask);
aoqi@1 1180 __ andr(arr_size, arr_size, AT);
aoqi@6880 1181
aoqi@6880 1182
aoqi@1 1183 __ tlab_allocate(obj, arr_size, 0, t1, t2, slow_path); // preserves arr_size
aoqi@1 1184 __ initialize_header(obj, klass, length,t1,t2);
aoqi@6880 1185 __ lbu(t1, Address(klass, in_bytes(Klass::layout_helper_offset())
aoqi@1 1186 + (Klass::_lh_header_size_shift / BitsPerByte)));
aoqi@1 1187 assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
aoqi@1 1188 assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise");
aoqi@1 1189 __ andi(t1, t1, Klass::_lh_header_size_mask);
aoqi@1 1190 __ sub(arr_size, arr_size, t1); // body length
aoqi@1 1191 __ add(t1, t1, obj); // body start
aoqi@1 1192 __ initialize_body(t1, arr_size, 0, t2);
aoqi@1 1193 __ verify_oop(obj);
aoqi@1 1194 __ jr(RA);
aoqi@1 1195 __ delayed()->nop();
aoqi@6880 1196
wangxue@9205 1197 #ifndef OPT_THREAD
wangxue@9205 1198 const Register thread = T8;
wangxue@9205 1199 __ get_thread(thread);
wangxue@9205 1200 #else
wangxue@9205 1201 const Register thread = TREG;
wangxue@9205 1202 #endif
wangxue@9205 1203
aoqi@1 1204 __ bind(try_eden);
aoqi@1 1205 // get the allocation size: (length << (layout_helper & 0x1F)) + header_size
aoqi@6880 1206 __ lw(t1, klass, in_bytes(Klass::layout_helper_offset()));
aoqi@1 1207 __ andi(AT, t1, 0x1f);
aoqi@1 1208 __ sllv(arr_size, length, AT);
aoqi@1 1209 __ srl(t1, t1, Klass::_lh_header_size_shift);
aoqi@1 1210 __ andi(t1, t1, Klass::_lh_header_size_mask);
aoqi@1 1211 __ add(arr_size, t1, arr_size);
aoqi@1 1212 __ addi(arr_size, arr_size, MinObjAlignmentInBytesMask); // align up
aoqi@1 1213 __ move(AT, ~MinObjAlignmentInBytesMask);
aoqi@1 1214 __ andr(arr_size, arr_size, AT);
aoqi@1 1215 __ eden_allocate(obj, arr_size, 0, t1, t2, slow_path); // preserves arr_size
wangxue@9205 1216 __ incr_allocated_bytes(thread, arr_size, 0);
wangxue@9205 1217
aoqi@1 1218 __ initialize_header(obj, klass, length,t1,t2);
aoqi@1 1219 __ lbu(t1, Address(klass, in_bytes(Klass::layout_helper_offset())
aoqi@1 1220 + (Klass::_lh_header_size_shift / BitsPerByte)));
aoqi@1 1221 __ andi(t1, t1, Klass::_lh_header_size_mask);
aoqi@1 1222 __ sub(arr_size, arr_size, t1); // body length
aoqi@1 1223 __ add(t1, t1, obj); // body start
aoqi@6880 1224
aoqi@1 1225 __ initialize_body(t1, arr_size, 0, t2);
aoqi@1 1226 __ verify_oop(obj);
aoqi@1 1227 __ jr(RA);
aoqi@1 1228 __ delayed()->nop();
aoqi@1 1229 __ bind(slow_path);
aoqi@1 1230 }
aoqi@6880 1231
aoqi@6880 1232
aoqi@1 1233 __ enter();
aoqi@1 1234 OopMap* map = save_live_registers(sasm, 0);
aoqi@1 1235 int call_offset;
aoqi@1 1236 if (id == new_type_array_id) {
aoqi@6880 1237 call_offset = __ call_RT(obj, noreg,
aoqi@1 1238 CAST_FROM_FN_PTR(address, new_type_array), klass, length);
aoqi@1 1239 } else {
aoqi@6880 1240 call_offset = __ call_RT(obj, noreg,
aoqi@1 1241 CAST_FROM_FN_PTR(address, new_object_array), klass, length);
aoqi@1 1242 }
aoqi@6880 1243
aoqi@1 1244 oop_maps = new OopMapSet();
aoqi@1 1245 oop_maps->add_gc_map(call_offset, map);
aoqi@1 1246 restore_live_registers_except_V0(sasm);
aoqi@1 1247 __ verify_oop(obj);
aoqi@6880 1248 __ leave();
aoqi@1 1249 __ jr(RA);
aoqi@1 1250 __ delayed()->nop();
aoqi@1 1251 }
aoqi@1 1252 break;
aoqi@1 1253
aoqi@1 1254 case new_multi_array_id:
aoqi@6880 1255 {
aoqi@6880 1256 StubFrame f(sasm, "new_multi_array", dont_gc_arguments);
aoqi@6880 1257 //refer to c1_LIRGenerate_mips.cpp:do_NewmultiArray
aoqi@6880 1258 // V0: klass
aoqi@6880 1259 // T2: rank
aoqi@6880 1260 // T0: address of 1st dimension
aoqi@6880 1261 //__ call_RT(V0, noreg, CAST_FROM_FN_PTR(address, new_multi_array), A1, A2, A3);
aoqi@6880 1262 //OopMap* map = save_live_registers(sasm, 4);
aoqi@6880 1263 OopMap* map = save_live_registers(sasm, 0);
aoqi@6880 1264 int call_offset = __ call_RT(V0, noreg, CAST_FROM_FN_PTR(address, new_multi_array),
aoqi@6880 1265 V0,T2,T0);
aoqi@6880 1266 oop_maps = new OopMapSet();
aoqi@6880 1267 oop_maps->add_gc_map(call_offset, map);
aoqi@6880 1268 //FIXME
aoqi@6880 1269 restore_live_registers_except_V0(sasm);
aoqi@6880 1270 // V0: new multi array
aoqi@6880 1271 __ verify_oop(V0);
aoqi@1 1272 }
aoqi@1 1273 break;
aoqi@1 1274
aoqi@6880 1275
aoqi@1 1276 case register_finalizer_id:
aoqi@1 1277 {
aoqi@6880 1278 __ set_info("register_finalizer", dont_gc_arguments);
aoqi@1 1279
aoqi@6880 1280 // The object is passed on the stack and we haven't pushed a
aoqi@6880 1281 // frame yet so it's one work away from top of stack.
aoqi@1 1282 //reference to LIRGenerator::do_RegisterFinalizer, call_runtime
aoqi@6880 1283 __ move(V0, A0);
aoqi@6880 1284 __ verify_oop(V0);
aoqi@6880 1285 // load the klass and check the has finalizer flag
aoqi@6880 1286 Label register_finalizer;
aoqi@1 1287 #ifndef _LP64
aoqi@6880 1288 Register t = T5;
aoqi@1 1289 #else
aoqi@6880 1290 Register t = A5;
aoqi@1 1291 #endif
aoqi@6880 1292 //__ ld_ptr(t, Address(V0, oopDesc::klass_offset_in_bytes()));
aoqi@6880 1293 __ load_klass(t, V0);
aoqi@6880 1294 __ lw(t, Address(t, Klass::access_flags_offset()));
aoqi@6880 1295 __ move(AT, JVM_ACC_HAS_FINALIZER);
aoqi@6880 1296 __ andr(AT, AT, t);
aoqi@1 1297
aoqi@6880 1298 __ bne(AT, R0, register_finalizer);
aoqi@6880 1299 __ delayed()->nop();
aoqi@6880 1300 __ jr(RA);
aoqi@6880 1301 __ delayed()->nop();
aoqi@6880 1302 __ bind(register_finalizer);
aoqi@6880 1303 __ enter();
aoqi@6880 1304 OopMap* map = save_live_registers(sasm, 0 /*num_rt_args */);
aoqi@6880 1305
aoqi@6880 1306 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address,
aoqi@6880 1307 SharedRuntime::register_finalizer), V0);
aoqi@6880 1308 oop_maps = new OopMapSet();
aoqi@1 1309 oop_maps->add_gc_map(call_offset, map);
aoqi@1 1310
aoqi@6880 1311 // Now restore all the live registers
aoqi@6880 1312 restore_live_registers(sasm);
aoqi@1 1313
aoqi@6880 1314 __ leave();
aoqi@6880 1315 __ jr(RA);
aoqi@6880 1316 __ delayed()->nop();
aoqi@1 1317 }
aoqi@1 1318 break;
aoqi@1 1319
aoqi@6880 1320 // case range_check_failed_id:
aoqi@6880 1321 case throw_range_check_failed_id:
aoqi@8865 1322 {
aoqi@8865 1323 StubFrame f(sasm, "range_check_failed", dont_gc_arguments);
aoqi@6880 1324 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address,
aoqi@1 1325 throw_range_check_exception),true);
aoqi@1 1326 }
aoqi@1 1327 break;
aoqi@1 1328
aoqi@1 1329 case throw_index_exception_id:
aoqi@6880 1330 {
aoqi@6880 1331 // i use A1 as the index register, for this will be the first argument, see call_RT
aoqi@6880 1332 StubFrame f(sasm, "index_range_check_failed", dont_gc_arguments);
aoqi@6880 1333 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address,
aoqi@6880 1334 throw_index_exception), true);
aoqi@1 1335 }
aoqi@1 1336 break;
aoqi@1 1337
aoqi@6880 1338 case throw_div0_exception_id:
aoqi@1 1339 { StubFrame f(sasm, "throw_div0_exception", dont_gc_arguments);
aoqi@6880 1340 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address,
aoqi@6880 1341 throw_div0_exception), false);
aoqi@1 1342 }
aoqi@1 1343 break;
aoqi@1 1344
aoqi@6880 1345 case throw_null_pointer_exception_id:
aoqi@8865 1346 {
aoqi@8865 1347 StubFrame f(sasm, "throw_null_pointer_exception", dont_gc_arguments);
aoqi@6880 1348 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address,
aoqi@6880 1349 throw_null_pointer_exception),false);
aoqi@1 1350 }
aoqi@1 1351 break;
aoqi@1 1352
aoqi@8865 1353 case handle_exception_nofpu_id:
aoqi@6880 1354 save_fpu_registers = false;
aoqi@6880 1355 // fall through
aoqi@6880 1356 case handle_exception_id:
aoqi@6880 1357 {
aoqi@6880 1358 StubFrame f(sasm, "handle_exception", dont_gc_arguments);
aoqi@6880 1359 //OopMap* oop_map = save_live_registers(sasm, 1, save_fpu_registers);
aoqi@6880 1360 oop_maps = generate_handle_exception(id, sasm);
aoqi@6880 1361 }
aoqi@6880 1362 break;
aoqi@8865 1363 case handle_exception_from_callee_id:
aoqi@8865 1364 {
aoqi@8865 1365 StubFrame f(sasm, "handle_exception_from_callee", dont_gc_arguments);
aoqi@8865 1366 oop_maps = generate_handle_exception(id, sasm);
aoqi@8865 1367 }
aoqi@8865 1368 break;
aoqi@6880 1369 case unwind_exception_id:
aoqi@6880 1370 {
aoqi@6880 1371 __ set_info("unwind_exception", dont_gc_arguments);
aoqi@6880 1372 generate_unwind_exception(sasm);
aoqi@6880 1373 }
aoqi@6880 1374 break;
aoqi@1 1375
aoqi@1 1376
aoqi@6880 1377 case throw_array_store_exception_id:
aoqi@8865 1378 {
aoqi@8865 1379 StubFrame f(sasm, "throw_array_store_exception", dont_gc_arguments);
aoqi@6880 1380 // tos + 0: link
aoqi@6880 1381 // + 1: return address
aoqi@6880 1382 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address,
wangxue@9248 1383 throw_array_store_exception), true);
aoqi@6880 1384 }
aoqi@6880 1385 break;
aoqi@1 1386
aoqi@6880 1387 case throw_class_cast_exception_id:
aoqi@8865 1388 {
aoqi@8865 1389 StubFrame f(sasm, "throw_class_cast_exception", dont_gc_arguments);
aoqi@6880 1390 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address,
aoqi@8865 1391 throw_class_cast_exception), true);
aoqi@6880 1392 }
aoqi@6880 1393 break;
aoqi@1 1394
aoqi@6880 1395 case throw_incompatible_class_change_error_id:
aoqi@6880 1396 {
aoqi@8865 1397 StubFrame f(sasm, "throw_incompatible_class_cast_exception", dont_gc_arguments);
aoqi@8865 1398 oop_maps = generate_exception_throw(sasm,
aoqi@8865 1399 CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false);
aoqi@6880 1400 }
aoqi@6880 1401 break;
aoqi@1 1402
aoqi@6880 1403 case slow_subtype_check_id:
aoqi@6880 1404 {
aoqi@6880 1405 //actually , We do not use it
aoqi@6880 1406 // A0:klass_RInfo sub
aoqi@6880 1407 // A1:k->encoding() super
aoqi@6880 1408 __ set_info("slow_subtype_check", dont_gc_arguments);
aoqi@6880 1409 __ st_ptr(T0, SP, (-1) * wordSize);
aoqi@6880 1410 __ st_ptr(T1, SP, (-2) * wordSize);
aoqi@6880 1411 __ addiu(SP, SP, (-2) * wordSize);
aoqi@1 1412
fujie@9132 1413 Label miss;
fujie@9132 1414 __ check_klass_subtype_slow_path(A0, A1, T0, T1, NULL, &miss);
aoqi@1 1415
aoqi@6880 1416 __ addiu(V0, R0, 1);
aoqi@6880 1417 __ addiu(SP, SP, 2 * wordSize);
aoqi@6880 1418 __ ld_ptr(T0, SP, (-1) * wordSize);
aoqi@6880 1419 __ ld_ptr(T1, SP, (-2) * wordSize);
aoqi@6880 1420 __ jr(RA);
aoqi@6880 1421 __ delayed()->nop();
aoqi@1 1422
aoqi@1 1423
aoqi@6880 1424 __ bind(miss);
aoqi@6880 1425 __ move(V0, R0);
aoqi@6880 1426 __ addiu(SP, SP, 2 * wordSize);
aoqi@6880 1427 __ ld_ptr(T0, SP, (-1) * wordSize);
aoqi@6880 1428 __ ld_ptr(T1, SP, (-2) * wordSize);
aoqi@6880 1429 __ jr(RA);
aoqi@6880 1430 __ delayed()->nop();
aoqi@6880 1431 }
aoqi@6880 1432 break;
aoqi@1 1433
aoqi@1 1434 case monitorenter_nofpu_id:
aoqi@1 1435 save_fpu_registers = false;// fall through
aoqi@1 1436
aoqi@6880 1437 case monitorenter_id:
aoqi@1 1438 {
aoqi@6880 1439 StubFrame f(sasm, "monitorenter", dont_gc_arguments);
aoqi@6880 1440 OopMap* map = save_live_registers(sasm, 0, save_fpu_registers);
aoqi@1 1441
aoqi@6880 1442 f.load_argument(1, V0); // V0: object
aoqi@1 1443 #ifndef _LP64
aoqi@6880 1444 f.load_argument(0, T6); // T6: lock address
aoqi@6880 1445 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address,
aoqi@6880 1446 monitorenter), V0, T6);
aoqi@1 1447 #else
aoqi@6880 1448 f.load_argument(0, A6); // A6: lock address
aoqi@6880 1449 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address,
aoqi@6880 1450 monitorenter), V0, A6);
aoqi@1 1451 #endif
aoqi@1 1452
aoqi@6880 1453 oop_maps = new OopMapSet();
aoqi@6880 1454 oop_maps->add_gc_map(call_offset, map);
aoqi@6880 1455 restore_live_registers(sasm, save_fpu_registers);
aoqi@6880 1456 }
aoqi@6880 1457 break;
aoqi@1 1458
aoqi@6880 1459 case monitorexit_nofpu_id:
aoqi@6880 1460 save_fpu_registers = false;
aoqi@6880 1461 // fall through
aoqi@6880 1462 case monitorexit_id:
aoqi@6880 1463 {
aoqi@1 1464 StubFrame f(sasm, "monitorexit", dont_gc_arguments);
aoqi@1 1465 OopMap* map = save_live_registers(sasm, 0, save_fpu_registers);
aoqi@6880 1466
aoqi@1 1467 #ifndef _LP64
aoqi@1 1468 f.load_argument(0, T6); // eax: lock address
aoqi@1 1469 #else
aoqi@1 1470 f.load_argument(0, A6); // A6: lock address
aoqi@1 1471 #endif
aoqi@1 1472 // note: really a leaf routine but must setup last java sp
aoqi@1 1473 // => use call_RT for now (speed can be improved by
aoqi@1 1474 // doing last java sp setup manually)
aoqi@1 1475 #ifndef _LP64
aoqi@6880 1476 int call_offset = __ call_RT(noreg, noreg,
aoqi@6880 1477 CAST_FROM_FN_PTR(address, monitorexit), T6);
aoqi@1 1478 #else
aoqi@6880 1479 int call_offset = __ call_RT(noreg, noreg,
aoqi@6880 1480 CAST_FROM_FN_PTR(address, monitorexit), A6);
aoqi@1 1481 #endif
aoqi@1 1482 oop_maps = new OopMapSet();
aoqi@1 1483 oop_maps->add_gc_map(call_offset, map);
aoqi@1 1484 restore_live_registers(sasm, save_fpu_registers);
aoqi@6880 1485
aoqi@1 1486 }
aoqi@1 1487 break;
aoqi@6880 1488 // case init_check_patching_id:
aoqi@6880 1489 case access_field_patching_id:
aoqi@6880 1490 {
aoqi@1 1491 StubFrame f(sasm, "access_field_patching", dont_gc_arguments);
aoqi@1 1492 // we should set up register map
aoqi@1 1493 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching));
aoqi@1 1494
aoqi@1 1495 }
aoqi@1 1496 break;
aoqi@1 1497
aoqi@6880 1498 case load_klass_patching_id:
aoqi@6880 1499 {
aoqi@6880 1500 StubFrame f(sasm, "load_klass_patching", dont_gc_arguments);
aoqi@6880 1501 // we should set up register map
aoqi@6880 1502 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address,
aoqi@6880 1503 move_klass_patching));
aoqi@6880 1504 }
aoqi@6880 1505 break;
aoqi@6880 1506 /* case jvmti_exception_throw_id:
aoqi@6880 1507 {
aoqi@6880 1508 // V0: exception oop
aoqi@6880 1509 // V1: exception pc
aoqi@6880 1510 StubFrame f(sasm, "jvmti_exception_throw", dont_gc_arguments);
aoqi@6880 1511 // Preserve all registers across this potentially blocking call
aoqi@6880 1512 const int num_rt_args = 2; // thread, exception oop
aoqi@6880 1513 //OopMap* map = save_live_registers(sasm, num_rt_args);
aoqi@6880 1514 OopMap* map = save_live_registers(sasm, 0);
aoqi@6880 1515 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address,
aoqi@6880 1516 Runtime1::post_jvmti_exception_throw), V0);
aoqi@6880 1517 oop_maps = new OopMapSet();
aoqi@6880 1518 oop_maps->add_gc_map(call_offset, map);
aoqi@6880 1519 restore_live_registers(sasm);
aoqi@6880 1520 }*/
aoqi@8865 1521 case load_mirror_patching_id:
aoqi@8865 1522 {
aoqi@8865 1523 StubFrame f(sasm, "load_mirror_patching" , dont_gc_arguments);
aoqi@8865 1524 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching));
aoqi@8865 1525 }
aoqi@6880 1526 break;
aoqi@8865 1527
aoqi@8865 1528 case load_appendix_patching_id:
aoqi@8865 1529 {
aoqi@8865 1530 StubFrame f(sasm, "load_appendix_patching", dont_gc_arguments);
aoqi@8865 1531 // we should set up register map
aoqi@8865 1532 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching));
aoqi@8865 1533 }
aoqi@8865 1534 break;
aoqi@8865 1535
aoqi@6880 1536 case dtrace_object_alloc_id:
aoqi@6880 1537 {
aoqi@6880 1538 // V0:object
aoqi@6880 1539 StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments);
aoqi@6880 1540 // we can't gc here so skip the oopmap but make sure that all
aoqi@6880 1541 // the live registers get saved.
aoqi@6880 1542 save_live_registers(sasm, 0);
aoqi@1 1543
aoqi@6880 1544 __ push_reg(V0);
aoqi@8865 1545 __ move(A0, V0);
aoqi@6880 1546 __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc),
aoqi@6880 1547 relocInfo::runtime_call_type);
fujie@9134 1548 __ delayed()->nop();
aoqi@6880 1549 __ super_pop(V0);
aoqi@1 1550
aoqi@6880 1551 restore_live_registers(sasm);
aoqi@6880 1552 }
aoqi@6880 1553 break;
aoqi@8865 1554
aoqi@6880 1555 case fpu2long_stub_id:
aoqi@6880 1556 {
aoqi@8865 1557 //FIXME, I hava no idea how to port this
aoqi@8865 1558 //tty->print_cr("fpu2long_stub_id unimplemented yet!");
aoqi@6880 1559 }
aoqi@8865 1560 break;
aoqi@8865 1561
aoqi@8865 1562 case deoptimize_id:
aoqi@8865 1563 {
aoqi@8865 1564 StubFrame f(sasm, "deoptimize", dont_gc_arguments);
aoqi@8865 1565 const int num_rt_args = 1; // thread
aoqi@8865 1566 OopMap* oop_map = save_live_registers(sasm, num_rt_args);
aoqi@8865 1567 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, deoptimize));
aoqi@8865 1568 oop_maps = new OopMapSet();
aoqi@8865 1569 oop_maps->add_gc_map(call_offset, oop_map);
aoqi@8865 1570 restore_live_registers(sasm);
aoqi@8865 1571 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
aoqi@8865 1572 assert(deopt_blob != NULL, "deoptimization blob must have been created");
aoqi@8865 1573 __ leave();
aoqi@8865 1574 __ jmp(deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type);
zhaixiang@9135 1575 __ delayed()->nop();
aoqi@8865 1576 }
aoqi@8865 1577 break;
aoqi@8865 1578
aoqi@8865 1579 case predicate_failed_trap_id:
aoqi@8865 1580 {
aoqi@8865 1581 StubFrame f(sasm, "predicate_failed_trap", dont_gc_arguments);
aoqi@8865 1582
aoqi@8865 1583 OopMap* map = save_live_registers(sasm, 1);
aoqi@8865 1584
aoqi@8865 1585 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap));
aoqi@8865 1586 oop_maps = new OopMapSet();
aoqi@8865 1587 oop_maps->add_gc_map(call_offset, map);
aoqi@8865 1588 restore_live_registers(sasm);
aoqi@8865 1589 __ leave();
aoqi@8865 1590 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
aoqi@8865 1591 assert(deopt_blob != NULL, "deoptimization blob must have been created");
aoqi@8865 1592
aoqi@8865 1593 __ jmp(deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type);
zhaixiang@9135 1594 __ delayed()->nop();
aoqi@8865 1595 }
aoqi@8865 1596 break;
aoqi@8865 1597
aoqi@6880 1598 default:
aoqi@8865 1599 {
aoqi@8865 1600 StubFrame f(sasm, "unimplemented entry", dont_gc_arguments);
aoqi@6880 1601 __ move(A1, (int)id);
aoqi@6880 1602 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), A1);
aoqi@6880 1603 __ should_not_reach_here();
aoqi@6880 1604 }
aoqi@6880 1605 break;
aoqi@6880 1606 }
aoqi@6880 1607 return oop_maps;
aoqi@1 1608 }
aoqi@1 1609
aoqi@1 1610 #undef __
aoqi@1 1611
aoqi@1 1612 const char *Runtime1::pd_name_for_address(address entry) {
aoqi@1 1613 return "<unknown function>";
aoqi@1 1614 }

mercurial