c1_Runtime1_sparc.cpp revision 5776:de6a9e811145
1241310Sdteske/* 2222417Sjulian * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 3222417Sjulian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4222417Sjulian * 5222417Sjulian * This code is free software; you can redistribute it and/or modify it 6222417Sjulian * under the terms of the GNU General Public License version 2 only, as 7222417Sjulian * published by the Free Software Foundation. 8222417Sjulian * 9222417Sjulian * This code is distributed in the hope that it will be useful, but WITHOUT 10222417Sjulian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11222417Sjulian * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12222417Sjulian * version 2 for more details (a copy is included in the LICENSE file that 13222417Sjulian * accompanied this code). 14222417Sjulian * 15222417Sjulian * You should have received a copy of the GNU General Public License version 16222417Sjulian * 2 along with this work; if not, write to the Free Software Foundation, 17222417Sjulian * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18222417Sjulian * 19222417Sjulian * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20222417Sjulian * or visit www.oracle.com if you need additional information or have any 21222417Sjulian * questions. 22222417Sjulian * 23222417Sjulian */ 24222417Sjulian 25222417Sjulian#include "precompiled.hpp" 26222417Sjulian#include "c1/c1_Defs.hpp" 27222417Sjulian#include "c1/c1_MacroAssembler.hpp" 28222417Sjulian#include "c1/c1_Runtime1.hpp" 29242667Sdteske#include "interpreter/interpreter.hpp" 30242667Sdteske#include "nativeInst_sparc.hpp" 31241523Sdteske#include "oops/compiledICHolder.hpp" 32241523Sdteske#include "oops/oop.inline.hpp" 33241523Sdteske#include "prims/jvmtiExport.hpp" 34243114Sdteske#include "register_sparc.hpp" 35243114Sdteske#include "runtime/sharedRuntime.hpp" 36243114Sdteske#include "runtime/signature.hpp" 37243114Sdteske#include "runtime/vframeArray.hpp" 38222417Sjulian#include "utilities/macros.hpp" 39222417Sjulian#include "vmreg_sparc.inline.hpp" 40222417Sjulian#if INCLUDE_ALL_GCS 41222417Sjulian#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" 42222417Sjulian#endif 43222417Sjulian 44222417Sjulian// Implementation of StubAssembler 45222417Sjulian 46222417Sjulianint StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry_point, int number_of_arguments) { 47222417Sjulian // for sparc changing the number of arguments doesn't change 48222417Sjulian // anything about the frame size so we'll always lie and claim that 49222417Sjulian // we are only passing 1 argument. 50222417Sjulian set_num_rt_args(1); 51222417Sjulian 52222417Sjulian assert_not_delayed(); 53222417Sjulian // bang stack before going to runtime 54222417Sjulian set(-os::vm_page_size() + STACK_BIAS, G3_scratch); 55222417Sjulian st(G0, SP, G3_scratch); 56222417Sjulian 57222417Sjulian // debugging support 58222417Sjulian assert(number_of_arguments >= 0 , "cannot have negative number of arguments"); 59222417Sjulian 60222417Sjulian set_last_Java_frame(SP, noreg); 61222417Sjulian if (VerifyThread) mov(G2_thread, O0); // about to be smashed; pass early 62222417Sjulian save_thread(L7_thread_cache); 63222417Sjulian // do the call 64222417Sjulian call(entry_point, relocInfo::runtime_call_type); 65243114Sdteske if (!VerifyThread) { 66243114Sdteske delayed()->mov(G2_thread, O0); // pass thread as first argument 67243114Sdteske } else { 68243114Sdteske delayed()->nop(); // (thread already passed) 69243114Sdteske } 70243114Sdteske int call_offset = offset(); // offset of return address 71243114Sdteske restore_thread(L7_thread_cache); 72243114Sdteske reset_last_Java_frame(); 73243114Sdteske 74243114Sdteske // check for pending exceptions 75243114Sdteske { Label L; 76243114Sdteske Address exception_addr(G2_thread, Thread::pending_exception_offset()); 77243114Sdteske ld_ptr(exception_addr, Gtemp); 78243114Sdteske br_null_short(Gtemp, pt, L); 79243114Sdteske Address vm_result_addr(G2_thread, JavaThread::vm_result_offset()); 80243114Sdteske st_ptr(G0, vm_result_addr); 81243114Sdteske Address vm_result_addr_2(G2_thread, JavaThread::vm_result_2_offset()); 82243114Sdteske st_ptr(G0, vm_result_addr_2); 83243114Sdteske 84243114Sdteske if (frame_size() == no_frame_size) { 85243114Sdteske // we use O7 linkage so that forward_exception_entry has the issuing PC 86243114Sdteske call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type); 87243114Sdteske delayed()->restore(); 88243114Sdteske } else if (_stub_id == Runtime1::forward_exception_id) { 89243114Sdteske should_not_reach_here(); 90243114Sdteske } else { 91243114Sdteske AddressLiteral exc(Runtime1::entry_for(Runtime1::forward_exception_id)); 92243114Sdteske jump_to(exc, G4); 93243114Sdteske delayed()->nop(); 94243114Sdteske } 95241523Sdteske bind(L); 96243114Sdteske } 97241523Sdteske 98241523Sdteske // get oop result if there is one and reset the value in the thread 99241523Sdteske if (oop_result1->is_valid()) { // get oop result if there is one and reset it in the thread 100241523Sdteske get_vm_result (oop_result1); 101222417Sjulian } else { 102222417Sjulian // be a little paranoid and clear the result 103222417Sjulian Address vm_result_addr(G2_thread, JavaThread::vm_result_offset()); 104222417Sjulian st_ptr(G0, vm_result_addr); 105222417Sjulian } 106243114Sdteske 107243114Sdteske // get second result if there is one and reset the value in the thread 108222417Sjulian if (metadata_result->is_valid()) { 109243114Sdteske get_vm_result_2 (metadata_result); 110222417Sjulian } else { 111222417Sjulian // be a little paranoid and clear the result 112222417Sjulian Address vm_result_addr_2(G2_thread, JavaThread::vm_result_2_offset()); 113222417Sjulian st_ptr(G0, vm_result_addr_2); 114222417Sjulian } 115222417Sjulian 116222417Sjulian return call_offset; 117243114Sdteske} 118243114Sdteske 119243114Sdteske 120243114Sdteskeint StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1) { 121243114Sdteske // O0 is reserved for the thread 122243114Sdteske mov(arg1, O1); 123243114Sdteske return call_RT(oop_result1, metadata_result, entry, 1); 124243114Sdteske} 125243114Sdteske 126243114Sdteske 127243114Sdteskeint StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2) { 128243114Sdteske // O0 is reserved for the thread 129243114Sdteske mov(arg1, O1); 130243114Sdteske mov(arg2, O2); assert(arg2 != O1, "smashed argument"); 131243114Sdteske return call_RT(oop_result1, metadata_result, entry, 2); 132243114Sdteske} 133243114Sdteske 134243114Sdteske 135241523Sdteskeint StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2, Register arg3) { 136243114Sdteske // O0 is reserved for the thread 137241523Sdteske mov(arg1, O1); 138241523Sdteske mov(arg2, O2); assert(arg2 != O1, "smashed argument"); 139241523Sdteske mov(arg3, O3); assert(arg3 != O1 && arg3 != O2, "smashed argument"); 140241523Sdteske return call_RT(oop_result1, metadata_result, entry, 3); 141222417Sjulian} 142222417Sjulian 143222417Sjulian 144222417Sjulian// Implementation of Runtime1 145222417Sjulian 146222417Sjulian#define __ sasm-> 147243114Sdteske 148243114Sdteskestatic int cpu_reg_save_offsets[FrameMap::nof_cpu_regs]; 149222417Sjulianstatic int fpu_reg_save_offsets[FrameMap::nof_fpu_regs]; 150243114Sdteskestatic int reg_save_size_in_words; 151222417Sjulianstatic int frame_size_in_bytes = -1; 152222417Sjulian 153222417Sjulianstatic OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers) { 154222417Sjulian assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words), 155222417Sjulian "mismatch in calculation"); 156243114Sdteske sasm->set_frame_size(frame_size_in_bytes / BytesPerWord); 157243114Sdteske int frame_size_in_slots = frame_size_in_bytes / sizeof(jint); 158243114Sdteske OopMap* oop_map = new OopMap(frame_size_in_slots, 0); 159243114Sdteske 160243114Sdteske int i; 161243114Sdteske for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 162243114Sdteske Register r = as_Register(i); 163243114Sdteske if (r == G1 || r == G3 || r == G4 || r == G5) { 164243114Sdteske int sp_offset = cpu_reg_save_offsets[i]; 165243114Sdteske oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset), 166243114Sdteske r->as_VMReg()); 167243114Sdteske } 168243114Sdteske } 169243114Sdteske 170243114Sdteske if (save_fpu_registers) { 171243114Sdteske for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 172243114Sdteske FloatRegister r = as_FloatRegister(i); 173243114Sdteske int sp_offset = fpu_reg_save_offsets[i]; 174241523Sdteske oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset), 175243114Sdteske r->as_VMReg()); 176241523Sdteske } 177241523Sdteske } 178241523Sdteske return oop_map; 179241523Sdteske} 180222417Sjulian 181222417Sjulianstatic OopMap* save_live_registers(StubAssembler* sasm, bool save_fpu_registers = true) { 182222417Sjulian assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words), 183222417Sjulian "mismatch in calculation"); 184222417Sjulian __ save_frame_c1(frame_size_in_bytes); 185222417Sjulian 186243114Sdteske // Record volatile registers as callee-save values in an OopMap so their save locations will be 187243114Sdteske // propagated to the caller frame's RegisterMap during StackFrameStream construction (needed for 188222417Sjulian // deoptimization; see compiledVFrame::create_stack_value). The caller's I, L and O registers 189243114Sdteske // are saved in register windows - I's and L's in the caller's frame and O's in the stub frame 190222417Sjulian // (as the stub's I's) when the runtime routine called by the stub creates its frame. 191222417Sjulian // OopMap frame sizes are in c2 stack slot sizes (sizeof(jint)) 192222417Sjulian 193222417Sjulian int i; 194222417Sjulian for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 195243114Sdteske Register r = as_Register(i); 196243114Sdteske if (r == G1 || r == G3 || r == G4 || r == G5) { 197243114Sdteske int sp_offset = cpu_reg_save_offsets[i]; 198243114Sdteske __ st_ptr(r, SP, (sp_offset * BytesPerWord) + STACK_BIAS); 199222417Sjulian } 200222417Sjulian } 201222417Sjulian 202222417Sjulian if (save_fpu_registers) { 203222417Sjulian for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 204222417Sjulian FloatRegister r = as_FloatRegister(i); 205222417Sjulian int sp_offset = fpu_reg_save_offsets[i]; 206222417Sjulian __ stf(FloatRegisterImpl::S, r, SP, (sp_offset * BytesPerWord) + STACK_BIAS); 207222417Sjulian } 208222417Sjulian } 209222417Sjulian 210222417Sjulian return generate_oop_map(sasm, save_fpu_registers); 211243114Sdteske} 212243114Sdteske 213243114Sdteskestatic void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) { 214243114Sdteske for (int i = 0; i < FrameMap::nof_cpu_regs; i++) { 215241523Sdteske Register r = as_Register(i); 216243114Sdteske if (r == G1 || r == G3 || r == G4 || r == G5) { 217241523Sdteske __ ld_ptr(SP, (cpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r); 218241523Sdteske } 219241523Sdteske } 220241523Sdteske 221241523Sdteske if (restore_fpu_registers) { 222241523Sdteske for (int i = 0; i < FrameMap::nof_fpu_regs; i++) { 223241523Sdteske FloatRegister r = as_FloatRegister(i); 224241523Sdteske __ ldf(FloatRegisterImpl::S, SP, (fpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r); 225241523Sdteske } 226241523Sdteske } 227241523Sdteske} 228243114Sdteske 229243114Sdteske 230243114Sdteskevoid Runtime1::initialize_pd() { 231243114Sdteske // compute word offsets from SP at which live (non-windowed) registers are captured by stub routines 232241523Sdteske // 233241523Sdteske // A stub routine will have a frame that is at least large enough to hold 234241523Sdteske // a register window save area (obviously) and the volatile g registers 235241523Sdteske // and floating registers. A user of save_live_registers can have a frame 236241523Sdteske // that has more scratch area in it (although typically they will use L-regs). 237222417Sjulian // in that case the frame will look like this (stack growing down) 238222417Sjulian // 239222417Sjulian // FP -> | | 240222417Sjulian // | scratch mem | 241222417Sjulian // | " " | 242222417Sjulian // -------------- 243243114Sdteske // | float regs | 244241523Sdteske // | " " | 245222417Sjulian // --------------- 246222417Sjulian // | G regs | 247222417Sjulian // | " " | 248243114Sdteske // --------------- 249243114Sdteske // | abi reg. | 250222417Sjulian // | window save | 251222417Sjulian // | area | 252222417Sjulian // SP -> --------------- 253222417Sjulian // 254243114Sdteske int i; 255243114Sdteske int sp_offset = round_to(frame::register_save_words, 2); // start doubleword aligned 256243114Sdteske 257243114Sdteske // only G int registers are saved explicitly; others are found in register windows 258241523Sdteske for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 259241523Sdteske Register r = as_Register(i); 260241523Sdteske if (r == G1 || r == G3 || r == G4 || r == G5) { 261241523Sdteske cpu_reg_save_offsets[i] = sp_offset; 262241523Sdteske sp_offset++; 263222417Sjulian } 264222417Sjulian } 265222417Sjulian 266222417Sjulian // all float registers are saved explicitly 267222417Sjulian assert(FrameMap::nof_fpu_regs == 32, "double registers not handled here"); 268222417Sjulian for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 269243114Sdteske fpu_reg_save_offsets[i] = sp_offset; 270241523Sdteske sp_offset++; 271222417Sjulian } 272222417Sjulian reg_save_size_in_words = sp_offset - frame::memory_parameter_word_sp_offset; 273241367Sdteske // this should match assembler::total_frame_size_in_bytes, which 274243114Sdteske // isn't callable from this context. It's checked by an assert when 275243114Sdteske // it's used though. 276222417Sjulian frame_size_in_bytes = align_size_up(sp_offset * wordSize, 8); 277222417Sjulian} 278222417Sjulian 279242667Sdteske 280243114SdteskeOopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) { 281243114Sdteske // make a frame and preserve the caller's caller-save registers 282243114Sdteske OopMap* oop_map = save_live_registers(sasm); 283243114Sdteske int call_offset; 284242667Sdteske if (!has_argument) { 285242667Sdteske call_offset = __ call_RT(noreg, noreg, target); 286242667Sdteske } else { 287242667Sdteske call_offset = __ call_RT(noreg, noreg, target, G4); 288242667Sdteske } 289242667Sdteske OopMapSet* oop_maps = new OopMapSet(); 290 oop_maps->add_gc_map(call_offset, oop_map); 291 292 __ should_not_reach_here(); 293 return oop_maps; 294} 295 296 297OopMapSet* Runtime1::generate_stub_call(StubAssembler* sasm, Register result, address target, 298 Register arg1, Register arg2, Register arg3) { 299 // make a frame and preserve the caller's caller-save registers 300 OopMap* oop_map = save_live_registers(sasm); 301 302 int call_offset; 303 if (arg1 == noreg) { 304 call_offset = __ call_RT(result, noreg, target); 305 } else if (arg2 == noreg) { 306 call_offset = __ call_RT(result, noreg, target, arg1); 307 } else if (arg3 == noreg) { 308 call_offset = __ call_RT(result, noreg, target, arg1, arg2); 309 } else { 310 call_offset = __ call_RT(result, noreg, target, arg1, arg2, arg3); 311 } 312 OopMapSet* oop_maps = NULL; 313 314 oop_maps = new OopMapSet(); 315 oop_maps->add_gc_map(call_offset, oop_map); 316 restore_live_registers(sasm); 317 318 __ ret(); 319 __ delayed()->restore(); 320 321 return oop_maps; 322} 323 324 325OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { 326 // make a frame and preserve the caller's caller-save registers 327 OopMap* oop_map = save_live_registers(sasm); 328 329 // call the runtime patching routine, returns non-zero if nmethod got deopted. 330 int call_offset = __ call_RT(noreg, noreg, target); 331 OopMapSet* oop_maps = new OopMapSet(); 332 oop_maps->add_gc_map(call_offset, oop_map); 333 334 // re-execute the patched instruction or, if the nmethod was deoptmized, return to the 335 // deoptimization handler entry that will cause re-execution of the current bytecode 336 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 337 assert(deopt_blob != NULL, "deoptimization blob must have been created"); 338 339 Label no_deopt; 340 __ br_null_short(O0, Assembler::pt, no_deopt); 341 342 // return to the deoptimization handler entry for unpacking and rexecute 343 // if we simply returned the we'd deopt as if any call we patched had just 344 // returned. 345 346 restore_live_registers(sasm); 347 348 AddressLiteral dest(deopt_blob->unpack_with_reexecution()); 349 __ jump_to(dest, O0); 350 __ delayed()->restore(); 351 352 __ bind(no_deopt); 353 restore_live_registers(sasm); 354 __ ret(); 355 __ delayed()->restore(); 356 357 return oop_maps; 358} 359 360OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { 361 362 OopMapSet* oop_maps = NULL; 363 // for better readability 364 const bool must_gc_arguments = true; 365 const bool dont_gc_arguments = false; 366 367 // stub code & info for the different stubs 368 switch (id) { 369 case forward_exception_id: 370 { 371 oop_maps = generate_handle_exception(id, sasm); 372 } 373 break; 374 375 case new_instance_id: 376 case fast_new_instance_id: 377 case fast_new_instance_init_check_id: 378 { 379 Register G5_klass = G5; // Incoming 380 Register O0_obj = O0; // Outgoing 381 382 if (id == new_instance_id) { 383 __ set_info("new_instance", dont_gc_arguments); 384 } else if (id == fast_new_instance_id) { 385 __ set_info("fast new_instance", dont_gc_arguments); 386 } else { 387 assert(id == fast_new_instance_init_check_id, "bad StubID"); 388 __ set_info("fast new_instance init check", dont_gc_arguments); 389 } 390 391 if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) && 392 UseTLAB && FastTLABRefill) { 393 Label slow_path; 394 Register G1_obj_size = G1; 395 Register G3_t1 = G3; 396 Register G4_t2 = G4; 397 assert_different_registers(G5_klass, G1_obj_size, G3_t1, G4_t2); 398 399 // Push a frame since we may do dtrace notification for the 400 // allocation which requires calling out and we don't want 401 // to stomp the real return address. 402 __ save_frame(0); 403 404 if (id == fast_new_instance_init_check_id) { 405 // make sure the klass is initialized 406 __ ldub(G5_klass, in_bytes(InstanceKlass::init_state_offset()), G3_t1); 407 __ cmp(G3_t1, InstanceKlass::fully_initialized); 408 __ br(Assembler::notEqual, false, Assembler::pn, slow_path); 409 __ delayed()->nop(); 410 } 411#ifdef ASSERT 412 // assert object can be fast path allocated 413 { 414 Label ok, not_ok; 415 __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); 416 // make sure it's an instance (LH > 0) 417 __ cmp_and_br_short(G1_obj_size, 0, Assembler::lessEqual, Assembler::pn, not_ok); 418 __ btst(Klass::_lh_instance_slow_path_bit, G1_obj_size); 419 __ br(Assembler::zero, false, Assembler::pn, ok); 420 __ delayed()->nop(); 421 __ bind(not_ok); 422 __ stop("assert(can be fast path allocated)"); 423 __ should_not_reach_here(); 424 __ bind(ok); 425 } 426#endif // ASSERT 427 // if we got here then the TLAB allocation failed, so try 428 // refilling the TLAB or allocating directly from eden. 429 Label retry_tlab, try_eden; 430 __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G5_klass 431 432 __ bind(retry_tlab); 433 434 // get the instance size 435 __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); 436 437 __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path); 438 439 __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); 440 __ verify_oop(O0_obj); 441 __ mov(O0, I0); 442 __ ret(); 443 __ delayed()->restore(); 444 445 __ bind(try_eden); 446 // get the instance size 447 __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); 448 __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path); 449 __ incr_allocated_bytes(G1_obj_size, G3_t1, G4_t2); 450 451 __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); 452 __ verify_oop(O0_obj); 453 __ mov(O0, I0); 454 __ ret(); 455 __ delayed()->restore(); 456 457 __ bind(slow_path); 458 459 // pop this frame so generate_stub_call can push it's own 460 __ restore(); 461 } 462 463 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_instance), G5_klass); 464 // I0->O0: new instance 465 } 466 467 break; 468 469 case counter_overflow_id: 470 // G4 contains bci, G5 contains method 471 oop_maps = generate_stub_call(sasm, noreg, CAST_FROM_FN_PTR(address, counter_overflow), G4, G5); 472 break; 473 474 case new_type_array_id: 475 case new_object_array_id: 476 { 477 Register G5_klass = G5; // Incoming 478 Register G4_length = G4; // Incoming 479 Register O0_obj = O0; // Outgoing 480 481 Address klass_lh(G5_klass, Klass::layout_helper_offset()); 482 assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise"); 483 assert(Klass::_lh_header_size_mask == 0xFF, "bytewise"); 484 // Use this offset to pick out an individual byte of the layout_helper: 485 const int klass_lh_header_size_offset = ((BytesPerInt - 1) // 3 - 2 selects byte {0,1,0,0} 486 - Klass::_lh_header_size_shift / BitsPerByte); 487 488 if (id == new_type_array_id) { 489 __ set_info("new_type_array", dont_gc_arguments); 490 } else { 491 __ set_info("new_object_array", dont_gc_arguments); 492 } 493 494#ifdef ASSERT 495 // assert object type is really an array of the proper kind 496 { 497 Label ok; 498 Register G3_t1 = G3; 499 __ ld(klass_lh, G3_t1); 500 __ sra(G3_t1, Klass::_lh_array_tag_shift, G3_t1); 501 int tag = ((id == new_type_array_id) 502 ? Klass::_lh_array_tag_type_value 503 : Klass::_lh_array_tag_obj_value); 504 __ cmp_and_brx_short(G3_t1, tag, Assembler::equal, Assembler::pt, ok); 505 __ stop("assert(is an array klass)"); 506 __ should_not_reach_here(); 507 __ bind(ok); 508 } 509#endif // ASSERT 510 511 if (UseTLAB && FastTLABRefill) { 512 Label slow_path; 513 Register G1_arr_size = G1; 514 Register G3_t1 = G3; 515 Register O1_t2 = O1; 516 assert_different_registers(G5_klass, G4_length, G1_arr_size, G3_t1, O1_t2); 517 518 // check that array length is small enough for fast path 519 __ set(C1_MacroAssembler::max_array_allocation_length, G3_t1); 520 __ cmp(G4_length, G3_t1); 521 __ br(Assembler::greaterUnsigned, false, Assembler::pn, slow_path); 522 __ delayed()->nop(); 523 524 // if we got here then the TLAB allocation failed, so try 525 // refilling the TLAB or allocating directly from eden. 526 Label retry_tlab, try_eden; 527 __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G4_length and G5_klass 528 529 __ bind(retry_tlab); 530 531 // get the allocation size: (length << (layout_helper & 0x1F)) + header_size 532 __ ld(klass_lh, G3_t1); 533 __ sll(G4_length, G3_t1, G1_arr_size); 534 __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1); 535 __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1); 536 __ add(G1_arr_size, G3_t1, G1_arr_size); 537 __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size); // align up 538 __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); 539 540 __ tlab_allocate(O0_obj, G1_arr_size, 0, G3_t1, slow_path); // preserves G1_arr_size 541 542 __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); 543 __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset); 544 __ sub(G1_arr_size, G3_t1, O1_t2); // body length 545 __ add(O0_obj, G3_t1, G3_t1); // body start 546 __ initialize_body(G3_t1, O1_t2); 547 __ verify_oop(O0_obj); 548 __ retl(); 549 __ delayed()->nop(); 550 551 __ bind(try_eden); 552 // get the allocation size: (length << (layout_helper & 0x1F)) + header_size 553 __ ld(klass_lh, G3_t1); 554 __ sll(G4_length, G3_t1, G1_arr_size); 555 __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1); 556 __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1); 557 __ add(G1_arr_size, G3_t1, G1_arr_size); 558 __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size); 559 __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); 560 561 __ eden_allocate(O0_obj, G1_arr_size, 0, G3_t1, O1_t2, slow_path); // preserves G1_arr_size 562 __ incr_allocated_bytes(G1_arr_size, G3_t1, O1_t2); 563 564 __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); 565 __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset); 566 __ sub(G1_arr_size, G3_t1, O1_t2); // body length 567 __ add(O0_obj, G3_t1, G3_t1); // body start 568 __ initialize_body(G3_t1, O1_t2); 569 __ verify_oop(O0_obj); 570 __ retl(); 571 __ delayed()->nop(); 572 573 __ bind(slow_path); 574 } 575 576 if (id == new_type_array_id) { 577 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_type_array), G5_klass, G4_length); 578 } else { 579 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_object_array), G5_klass, G4_length); 580 } 581 // I0 -> O0: new array 582 } 583 break; 584 585 case new_multi_array_id: 586 { // O0: klass 587 // O1: rank 588 // O2: address of 1st dimension 589 __ set_info("new_multi_array", dont_gc_arguments); 590 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_multi_array), I0, I1, I2); 591 // I0 -> O0: new multi array 592 } 593 break; 594 595 case register_finalizer_id: 596 { 597 __ set_info("register_finalizer", dont_gc_arguments); 598 599 // load the klass and check the has finalizer flag 600 Label register_finalizer; 601 Register t = O1; 602 __ load_klass(O0, t); 603 __ ld(t, in_bytes(Klass::access_flags_offset()), t); 604 __ set(JVM_ACC_HAS_FINALIZER, G3); 605 __ andcc(G3, t, G0); 606 __ br(Assembler::notZero, false, Assembler::pt, register_finalizer); 607 __ delayed()->nop(); 608 609 // do a leaf return 610 __ retl(); 611 __ delayed()->nop(); 612 613 __ bind(register_finalizer); 614 OopMap* oop_map = save_live_registers(sasm); 615 int call_offset = __ call_RT(noreg, noreg, 616 CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), I0); 617 oop_maps = new OopMapSet(); 618 oop_maps->add_gc_map(call_offset, oop_map); 619 620 // Now restore all the live registers 621 restore_live_registers(sasm); 622 623 __ ret(); 624 __ delayed()->restore(); 625 } 626 break; 627 628 case throw_range_check_failed_id: 629 { __ set_info("range_check_failed", dont_gc_arguments); // arguments will be discarded 630 // G4: index 631 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); 632 } 633 break; 634 635 case throw_index_exception_id: 636 { __ set_info("index_range_check_failed", dont_gc_arguments); // arguments will be discarded 637 // G4: index 638 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); 639 } 640 break; 641 642 case throw_div0_exception_id: 643 { __ set_info("throw_div0_exception", dont_gc_arguments); 644 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); 645 } 646 break; 647 648 case throw_null_pointer_exception_id: 649 { __ set_info("throw_null_pointer_exception", dont_gc_arguments); 650 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); 651 } 652 break; 653 654 case handle_exception_id: 655 { __ set_info("handle_exception", dont_gc_arguments); 656 oop_maps = generate_handle_exception(id, sasm); 657 } 658 break; 659 660 case handle_exception_from_callee_id: 661 { __ set_info("handle_exception_from_callee", dont_gc_arguments); 662 oop_maps = generate_handle_exception(id, sasm); 663 } 664 break; 665 666 case unwind_exception_id: 667 { 668 // O0: exception 669 // I7: address of call to this method 670 671 __ set_info("unwind_exception", dont_gc_arguments); 672 __ mov(Oexception, Oexception->after_save()); 673 __ add(I7, frame::pc_return_offset, Oissuing_pc->after_save()); 674 675 __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), 676 G2_thread, Oissuing_pc->after_save()); 677 __ verify_not_null_oop(Oexception->after_save()); 678 679 // Restore SP from L7 if the exception PC is a method handle call site. 680 __ mov(O0, G5); // Save the target address. 681 __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), L0); 682 __ tst(L0); // Condition codes are preserved over the restore. 683 __ restore(); 684 685 __ jmp(G5, 0); 686 __ delayed()->movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP); // Restore SP if required. 687 } 688 break; 689 690 case throw_array_store_exception_id: 691 { 692 __ set_info("throw_array_store_exception", dont_gc_arguments); 693 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true); 694 } 695 break; 696 697 case throw_class_cast_exception_id: 698 { 699 // G4: object 700 __ set_info("throw_class_cast_exception", dont_gc_arguments); 701 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); 702 } 703 break; 704 705 case throw_incompatible_class_change_error_id: 706 { 707 __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments); 708 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); 709 } 710 break; 711 712 case slow_subtype_check_id: 713 { // Support for uint StubRoutine::partial_subtype_check( Klass sub, Klass super ); 714 // Arguments : 715 // 716 // ret : G3 717 // sub : G3, argument, destroyed 718 // super: G1, argument, not changed 719 // raddr: O7, blown by call 720 Label miss; 721 722 __ save_frame(0); // Blow no registers! 723 724 __ check_klass_subtype_slow_path(G3, G1, L0, L1, L2, L4, NULL, &miss); 725 726 __ mov(1, G3); 727 __ ret(); // Result in G5 is 'true' 728 __ delayed()->restore(); // free copy or add can go here 729 730 __ bind(miss); 731 __ mov(0, G3); 732 __ ret(); // Result in G5 is 'false' 733 __ delayed()->restore(); // free copy or add can go here 734 } 735 736 case monitorenter_nofpu_id: 737 case monitorenter_id: 738 { // G4: object 739 // G5: lock address 740 __ set_info("monitorenter", dont_gc_arguments); 741 742 int save_fpu_registers = (id == monitorenter_id); 743 // make a frame and preserve the caller's caller-save registers 744 OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); 745 746 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), G4, G5); 747 748 oop_maps = new OopMapSet(); 749 oop_maps->add_gc_map(call_offset, oop_map); 750 restore_live_registers(sasm, save_fpu_registers); 751 752 __ ret(); 753 __ delayed()->restore(); 754 } 755 break; 756 757 case monitorexit_nofpu_id: 758 case monitorexit_id: 759 { // G4: lock address 760 // note: really a leaf routine but must setup last java sp 761 // => use call_RT for now (speed can be improved by 762 // doing last java sp setup manually) 763 __ set_info("monitorexit", dont_gc_arguments); 764 765 int save_fpu_registers = (id == monitorexit_id); 766 // make a frame and preserve the caller's caller-save registers 767 OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); 768 769 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), G4); 770 771 oop_maps = new OopMapSet(); 772 oop_maps->add_gc_map(call_offset, oop_map); 773 restore_live_registers(sasm, save_fpu_registers); 774 775 __ ret(); 776 __ delayed()->restore(); 777 } 778 break; 779 780 case deoptimize_id: 781 { 782 __ set_info("deoptimize", dont_gc_arguments); 783 OopMap* oop_map = save_live_registers(sasm); 784 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, deoptimize)); 785 oop_maps = new OopMapSet(); 786 oop_maps->add_gc_map(call_offset, oop_map); 787 restore_live_registers(sasm); 788 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 789 assert(deopt_blob != NULL, "deoptimization blob must have been created"); 790 AddressLiteral dest(deopt_blob->unpack_with_reexecution()); 791 __ jump_to(dest, O0); 792 __ delayed()->restore(); 793 } 794 break; 795 796 case access_field_patching_id: 797 { __ set_info("access_field_patching", dont_gc_arguments); 798 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); 799 } 800 break; 801 802 case load_klass_patching_id: 803 { __ set_info("load_klass_patching", dont_gc_arguments); 804 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); 805 } 806 break; 807 808 case load_mirror_patching_id: 809 { __ set_info("load_mirror_patching", dont_gc_arguments); 810 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); 811 } 812 break; 813 814 case load_appendix_patching_id: 815 { __ set_info("load_appendix_patching", dont_gc_arguments); 816 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); 817 } 818 break; 819 820 case dtrace_object_alloc_id: 821 { // O0: object 822 __ set_info("dtrace_object_alloc", dont_gc_arguments); 823 // we can't gc here so skip the oopmap but make sure that all 824 // the live registers get saved. 825 save_live_registers(sasm); 826 827 __ save_thread(L7_thread_cache); 828 __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), 829 relocInfo::runtime_call_type); 830 __ delayed()->mov(I0, O0); 831 __ restore_thread(L7_thread_cache); 832 833 restore_live_registers(sasm); 834 __ ret(); 835 __ delayed()->restore(); 836 } 837 break; 838 839#if INCLUDE_ALL_GCS 840 case g1_pre_barrier_slow_id: 841 { // G4: previous value of memory 842 BarrierSet* bs = Universe::heap()->barrier_set(); 843 if (bs->kind() != BarrierSet::G1SATBCTLogging) { 844 __ save_frame(0); 845 __ set((int)id, O1); 846 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), I0); 847 __ should_not_reach_here(); 848 break; 849 } 850 851 __ set_info("g1_pre_barrier_slow_id", dont_gc_arguments); 852 853 Register pre_val = G4; 854 Register tmp = G1_scratch; 855 Register tmp2 = G3_scratch; 856 857 Label refill, restart; 858 bool with_frame = false; // I don't know if we can do with-frame. 859 int satb_q_index_byte_offset = 860 in_bytes(JavaThread::satb_mark_queue_offset() + 861 PtrQueue::byte_offset_of_index()); 862 int satb_q_buf_byte_offset = 863 in_bytes(JavaThread::satb_mark_queue_offset() + 864 PtrQueue::byte_offset_of_buf()); 865 866 __ bind(restart); 867 // Load the index into the SATB buffer. PtrQueue::_index is a 868 // size_t so ld_ptr is appropriate 869 __ ld_ptr(G2_thread, satb_q_index_byte_offset, tmp); 870 871 // index == 0? 872 __ cmp_and_brx_short(tmp, G0, Assembler::equal, Assembler::pn, refill); 873 874 __ ld_ptr(G2_thread, satb_q_buf_byte_offset, tmp2); 875 __ sub(tmp, oopSize, tmp); 876 877 __ st_ptr(pre_val, tmp2, tmp); // [_buf + index] := <address_of_card> 878 // Use return-from-leaf 879 __ retl(); 880 __ delayed()->st_ptr(tmp, G2_thread, satb_q_index_byte_offset); 881 882 __ bind(refill); 883 __ save_frame(0); 884 885 __ mov(pre_val, L0); 886 __ mov(tmp, L1); 887 __ mov(tmp2, L2); 888 889 __ call_VM_leaf(L7_thread_cache, 890 CAST_FROM_FN_PTR(address, 891 SATBMarkQueueSet::handle_zero_index_for_thread), 892 G2_thread); 893 894 __ mov(L0, pre_val); 895 __ mov(L1, tmp); 896 __ mov(L2, tmp2); 897 898 __ br(Assembler::always, /*annul*/false, Assembler::pt, restart); 899 __ delayed()->restore(); 900 } 901 break; 902 903 case g1_post_barrier_slow_id: 904 { 905 BarrierSet* bs = Universe::heap()->barrier_set(); 906 if (bs->kind() != BarrierSet::G1SATBCTLogging) { 907 __ save_frame(0); 908 __ set((int)id, O1); 909 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), I0); 910 __ should_not_reach_here(); 911 break; 912 } 913 914 __ set_info("g1_post_barrier_slow_id", dont_gc_arguments); 915 916 Register addr = G4; 917 Register cardtable = G5; 918 Register tmp = G1_scratch; 919 Register tmp2 = G3_scratch; 920 jbyte* byte_map_base = ((CardTableModRefBS*)bs)->byte_map_base; 921 922 Label not_already_dirty, restart, refill, young_card; 923 924#ifdef _LP64 925 __ srlx(addr, CardTableModRefBS::card_shift, addr); 926#else 927 __ srl(addr, CardTableModRefBS::card_shift, addr); 928#endif 929 930 AddressLiteral rs(byte_map_base); 931 __ set(rs, cardtable); // cardtable := <card table base> 932 __ ldub(addr, cardtable, tmp); // tmp := [addr + cardtable] 933 934 __ cmp_and_br_short(tmp, G1SATBCardTableModRefBS::g1_young_card_val(), Assembler::equal, Assembler::pt, young_card); 935 936 __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); 937 __ ldub(addr, cardtable, tmp); // tmp := [addr + cardtable] 938 939 assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code"); 940 __ cmp_and_br_short(tmp, G0, Assembler::notEqual, Assembler::pt, not_already_dirty); 941 942 __ bind(young_card); 943 // We didn't take the branch, so we're already dirty: return. 944 // Use return-from-leaf 945 __ retl(); 946 __ delayed()->nop(); 947 948 // Not dirty. 949 __ bind(not_already_dirty); 950 951 // Get cardtable + tmp into a reg by itself 952 __ add(addr, cardtable, tmp2); 953 954 // First, dirty it. 955 __ stb(G0, tmp2, 0); // [cardPtr] := 0 (i.e., dirty). 956 957 Register tmp3 = cardtable; 958 Register tmp4 = tmp; 959 960 // these registers are now dead 961 addr = cardtable = tmp = noreg; 962 963 int dirty_card_q_index_byte_offset = 964 in_bytes(JavaThread::dirty_card_queue_offset() + 965 PtrQueue::byte_offset_of_index()); 966 int dirty_card_q_buf_byte_offset = 967 in_bytes(JavaThread::dirty_card_queue_offset() + 968 PtrQueue::byte_offset_of_buf()); 969 970 __ bind(restart); 971 972 // Get the index into the update buffer. PtrQueue::_index is 973 // a size_t so ld_ptr is appropriate here. 974 __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, tmp3); 975 976 // index == 0? 977 __ cmp_and_brx_short(tmp3, G0, Assembler::equal, Assembler::pn, refill); 978 979 __ ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, tmp4); 980 __ sub(tmp3, oopSize, tmp3); 981 982 __ st_ptr(tmp2, tmp4, tmp3); // [_buf + index] := <address_of_card> 983 // Use return-from-leaf 984 __ retl(); 985 __ delayed()->st_ptr(tmp3, G2_thread, dirty_card_q_index_byte_offset); 986 987 __ bind(refill); 988 __ save_frame(0); 989 990 __ mov(tmp2, L0); 991 __ mov(tmp3, L1); 992 __ mov(tmp4, L2); 993 994 __ call_VM_leaf(L7_thread_cache, 995 CAST_FROM_FN_PTR(address, 996 DirtyCardQueueSet::handle_zero_index_for_thread), 997 G2_thread); 998 999 __ mov(L0, tmp2); 1000 __ mov(L1, tmp3); 1001 __ mov(L2, tmp4); 1002 1003 __ br(Assembler::always, /*annul*/false, Assembler::pt, restart); 1004 __ delayed()->restore(); 1005 } 1006 break; 1007#endif // INCLUDE_ALL_GCS 1008 1009 case predicate_failed_trap_id: 1010 { 1011 __ set_info("predicate_failed_trap", dont_gc_arguments); 1012 OopMap* oop_map = save_live_registers(sasm); 1013 1014 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); 1015 1016 oop_maps = new OopMapSet(); 1017 oop_maps->add_gc_map(call_offset, oop_map); 1018 1019 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 1020 assert(deopt_blob != NULL, "deoptimization blob must have been created"); 1021 restore_live_registers(sasm); 1022 1023 AddressLiteral dest(deopt_blob->unpack_with_reexecution()); 1024 __ jump_to(dest, O0); 1025 __ delayed()->restore(); 1026 } 1027 break; 1028 1029 default: 1030 { __ set_info("unimplemented entry", dont_gc_arguments); 1031 __ save_frame(0); 1032 __ set((int)id, O1); 1033 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), O1); 1034 __ should_not_reach_here(); 1035 } 1036 break; 1037 } 1038 return oop_maps; 1039} 1040 1041 1042OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { 1043 __ block_comment("generate_handle_exception"); 1044 1045 // Save registers, if required. 1046 OopMapSet* oop_maps = new OopMapSet(); 1047 OopMap* oop_map = NULL; 1048 switch (id) { 1049 case forward_exception_id: 1050 // We're handling an exception in the context of a compiled frame. 1051 // The registers have been saved in the standard places. Perform 1052 // an exception lookup in the caller and dispatch to the handler 1053 // if found. Otherwise unwind and dispatch to the callers 1054 // exception handler. 1055 oop_map = generate_oop_map(sasm, true); 1056 1057 // transfer the pending exception to the exception_oop 1058 __ ld_ptr(G2_thread, in_bytes(JavaThread::pending_exception_offset()), Oexception); 1059 __ ld_ptr(Oexception, 0, G0); 1060 __ st_ptr(G0, G2_thread, in_bytes(JavaThread::pending_exception_offset())); 1061 __ add(I7, frame::pc_return_offset, Oissuing_pc); 1062 break; 1063 case handle_exception_id: 1064 // At this point all registers MAY be live. 1065 oop_map = save_live_registers(sasm); 1066 __ mov(Oexception->after_save(), Oexception); 1067 __ mov(Oissuing_pc->after_save(), Oissuing_pc); 1068 break; 1069 case handle_exception_from_callee_id: 1070 // At this point all registers except exception oop (Oexception) 1071 // and exception pc (Oissuing_pc) are dead. 1072 oop_map = new OopMap(frame_size_in_bytes / sizeof(jint), 0); 1073 sasm->set_frame_size(frame_size_in_bytes / BytesPerWord); 1074 __ save_frame_c1(frame_size_in_bytes); 1075 __ mov(Oexception->after_save(), Oexception); 1076 __ mov(Oissuing_pc->after_save(), Oissuing_pc); 1077 break; 1078 default: ShouldNotReachHere(); 1079 } 1080 1081 __ verify_not_null_oop(Oexception); 1082 1083#ifdef ASSERT 1084 // check that fields in JavaThread for exception oop and issuing pc are 1085 // empty before writing to them 1086 Label oop_empty; 1087 Register scratch = I7; // We can use I7 here because it's overwritten later anyway. 1088 __ ld_ptr(Address(G2_thread, JavaThread::exception_oop_offset()), scratch); 1089 __ br_null(scratch, false, Assembler::pt, oop_empty); 1090 __ delayed()->nop(); 1091 __ stop("exception oop already set"); 1092 __ bind(oop_empty); 1093 1094 Label pc_empty; 1095 __ ld_ptr(Address(G2_thread, JavaThread::exception_pc_offset()), scratch); 1096 __ br_null(scratch, false, Assembler::pt, pc_empty); 1097 __ delayed()->nop(); 1098 __ stop("exception pc already set"); 1099 __ bind(pc_empty); 1100#endif 1101 1102 // save the exception and issuing pc in the thread 1103 __ st_ptr(Oexception, G2_thread, in_bytes(JavaThread::exception_oop_offset())); 1104 __ st_ptr(Oissuing_pc, G2_thread, in_bytes(JavaThread::exception_pc_offset())); 1105 1106 // use the throwing pc as the return address to lookup (has bci & oop map) 1107 __ mov(Oissuing_pc, I7); 1108 __ sub(I7, frame::pc_return_offset, I7); 1109 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc)); 1110 oop_maps->add_gc_map(call_offset, oop_map); 1111 1112 // Note: if nmethod has been deoptimized then regardless of 1113 // whether it had a handler or not we will deoptimize 1114 // by entering the deopt blob with a pending exception. 1115 1116 // Restore the registers that were saved at the beginning, remove 1117 // the frame and jump to the exception handler. 1118 switch (id) { 1119 case forward_exception_id: 1120 case handle_exception_id: 1121 restore_live_registers(sasm); 1122 __ jmp(O0, 0); 1123 __ delayed()->restore(); 1124 break; 1125 case handle_exception_from_callee_id: 1126 // Restore SP from L7 if the exception PC is a method handle call site. 1127 __ mov(O0, G5); // Save the target address. 1128 __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), L0); 1129 __ tst(L0); // Condition codes are preserved over the restore. 1130 __ restore(); 1131 1132 __ jmp(G5, 0); // jump to the exception handler 1133 __ delayed()->movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP); // Restore SP if required. 1134 break; 1135 default: ShouldNotReachHere(); 1136 } 1137 1138 return oop_maps; 1139} 1140 1141 1142#undef __ 1143 1144const char *Runtime1::pd_name_for_address(address entry) { 1145 return "<unknown function>"; 1146} 1147