c1_Runtime1_ppc.cpp revision 13249:a2753984d2c1
1256949Sganbold/* 2266337Sian * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. 3256949Sganbold * Copyright (c) 2012, 2015 SAP SE. All rights reserved. 4256949Sganbold * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5256949Sganbold * 6256949Sganbold * This code is free software; you can redistribute it and/or modify it 7256949Sganbold * under the terms of the GNU General Public License version 2 only, as 8256949Sganbold * published by the Free Software Foundation. 9256949Sganbold * 10256949Sganbold * This code is distributed in the hope that it will be useful, but WITHOUT 11256949Sganbold * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12256949Sganbold * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13256949Sganbold * version 2 for more details (a copy is included in the LICENSE file that 14256949Sganbold * accompanied this code). 15256949Sganbold * 16256949Sganbold * You should have received a copy of the GNU General Public License version 17256949Sganbold * 2 along with this work; if not, write to the Free Software Foundation, 18256949Sganbold * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19256949Sganbold * 20256949Sganbold * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21256949Sganbold * or visit www.oracle.com if you need additional information or have any 22256949Sganbold * questions. 23256949Sganbold * 24256949Sganbold */ 25256949Sganbold 26256949Sganbold#include "precompiled.hpp" 27256949Sganbold#include "c1/c1_Defs.hpp" 28256949Sganbold#include "c1/c1_MacroAssembler.hpp" 29256949Sganbold#include "c1/c1_Runtime1.hpp" 30256949Sganbold#include "interpreter/interpreter.hpp" 31256949Sganbold#include "nativeInst_ppc.hpp" 32256949Sganbold#include "oops/compiledICHolder.hpp" 33256949Sganbold#include "oops/oop.inline.hpp" 34256949Sganbold#include "prims/jvmtiExport.hpp" 35256949Sganbold#include "register_ppc.hpp" 36256949Sganbold#include "runtime/sharedRuntime.hpp" 37256949Sganbold#include "runtime/signature.hpp" 38256949Sganbold#include "runtime/vframeArray.hpp" 39256949Sganbold#include "utilities/align.hpp" 40256949Sganbold#include "utilities/macros.hpp" 41256949Sganbold#include "vmreg_ppc.inline.hpp" 42256949Sganbold#if INCLUDE_ALL_GCS 43256949Sganbold#include "gc/g1/g1SATBCardTableModRefBS.hpp" 44256949Sganbold#endif 45256949Sganbold 46256949Sganbold// Implementation of StubAssembler 47256949Sganbold 48256949Sganboldint StubAssembler::call_RT(Register oop_result1, Register metadata_result, 49256949Sganbold address entry_point, int number_of_arguments) { 50256949Sganbold set_num_rt_args(0); // Nothing on stack 51256949Sganbold assert(!(oop_result1->is_valid() || metadata_result->is_valid()) || 52256949Sganbold oop_result1 != metadata_result, "registers must be different"); 53256949Sganbold 54256949Sganbold // Currently no stack banging. We assume that there are enough 55256949Sganbold // StackShadowPages (which have been banged in generate_stack_overflow_check) 56256949Sganbold // for the stub frame and the runtime frames. 57256949Sganbold 58256949Sganbold set_last_Java_frame(R1_SP, noreg); 59256949Sganbold 60256949Sganbold // ARG1 must hold thread address. 61256949Sganbold mr(R3_ARG1, R16_thread); 62256949Sganbold 63256949Sganbold address return_pc = call_c_with_frame_resize(entry_point, /*No resize, we have a C compatible frame.*/0); 64256949Sganbold 65256949Sganbold reset_last_Java_frame(); 66256949Sganbold 67256949Sganbold // Check for pending exceptions. 68256949Sganbold { 69256949Sganbold ld(R0, in_bytes(Thread::pending_exception_offset()), R16_thread); 70256949Sganbold cmpdi(CCR0, R0, 0); 71256949Sganbold 72256949Sganbold // This used to conditionally jump to forward_exception however it is 73256949Sganbold // possible if we relocate that the branch will not reach. So we must jump 74256949Sganbold // around so we can always reach. 75256949Sganbold 76256949Sganbold Label ok; 77256949Sganbold beq(CCR0, ok); 78256949Sganbold 79256949Sganbold // Make sure that the vm_results are cleared. 80256949Sganbold if (oop_result1->is_valid() || metadata_result->is_valid()) { 81256949Sganbold li(R0, 0); 82256949Sganbold if (oop_result1->is_valid()) { 83256949Sganbold std(R0, in_bytes(JavaThread::vm_result_offset()), R16_thread); 84256949Sganbold } 85256949Sganbold if (metadata_result->is_valid()) { 86256949Sganbold std(R0, in_bytes(JavaThread::vm_result_2_offset()), R16_thread); 87256949Sganbold } 88256949Sganbold } 89273650Sian 90273650Sian if (frame_size() == no_frame_size) { 91273650Sian ShouldNotReachHere(); // We always have a frame size. 92273650Sian //pop_frame(); // pop the stub frame 93273650Sian //ld(R0, _abi(lr), R1_SP); 94273650Sian //mtlr(R0); 95273650Sian //load_const_optimized(R0, StubRoutines::forward_exception_entry()); 96273650Sian //mtctr(R0); 97273650Sian //bctr(); 98273650Sian } else if (_stub_id == Runtime1::forward_exception_id) { 99273650Sian should_not_reach_here(); 100273650Sian } else { 101273650Sian // keep stub frame for next call_RT 102273650Sian //load_const_optimized(R0, Runtime1::entry_for(Runtime1::forward_exception_id)); 103273650Sian add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(Runtime1::entry_for(Runtime1::forward_exception_id))); 104273650Sian mtctr(R0); 105273650Sian bctr(); 106273650Sian } 107273650Sian 108273650Sian bind(ok); 109256949Sganbold } 110256949Sganbold 111256949Sganbold // Get oop results if there are any and reset the values in the thread. 112256949Sganbold if (oop_result1->is_valid()) { 113256949Sganbold get_vm_result(oop_result1); 114256949Sganbold } 115256949Sganbold if (metadata_result->is_valid()) { 116256949Sganbold get_vm_result_2(metadata_result); 117256949Sganbold } 118256949Sganbold 119256949Sganbold return (int)(return_pc - code_section()->start()); 120256949Sganbold} 121256949Sganbold 122256949Sganbold 123256949Sganboldint StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1) { 124256949Sganbold mr_if_needed(R4_ARG2, arg1); 125256949Sganbold return call_RT(oop_result1, metadata_result, entry, 1); 126256949Sganbold} 127256949Sganbold 128256949Sganbold 129256949Sganboldint StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2) { 130256949Sganbold mr_if_needed(R4_ARG2, arg1); 131256949Sganbold mr_if_needed(R5_ARG3, arg2); assert(arg2 != R4_ARG2, "smashed argument"); 132256949Sganbold return call_RT(oop_result1, metadata_result, entry, 2); 133256949Sganbold} 134256949Sganbold 135256949Sganbold 136256949Sganboldint StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2, Register arg3) { 137256949Sganbold mr_if_needed(R4_ARG2, arg1); 138256949Sganbold mr_if_needed(R5_ARG3, arg2); assert(arg2 != R4_ARG2, "smashed argument"); 139256949Sganbold mr_if_needed(R6_ARG4, arg3); assert(arg3 != R4_ARG2 && arg3 != R5_ARG3, "smashed argument"); 140256949Sganbold return call_RT(oop_result1, metadata_result, entry, 3); 141256949Sganbold} 142256949Sganbold 143256949Sganbold 144256949Sganbold// Implementation of Runtime1 145256949Sganbold 146256949Sganbold#define __ sasm-> 147256949Sganbold 148256949Sganboldstatic int cpu_reg_save_offsets[FrameMap::nof_cpu_regs]; 149256949Sganboldstatic int fpu_reg_save_offsets[FrameMap::nof_fpu_regs]; 150256949Sganboldstatic int frame_size_in_bytes = -1; 151256949Sganbold 152256949Sganboldstatic OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers) { 153256949Sganbold assert(frame_size_in_bytes > frame::abi_reg_args_size, "init"); 154256949Sganbold sasm->set_frame_size(frame_size_in_bytes / BytesPerWord); 155256949Sganbold int frame_size_in_slots = frame_size_in_bytes / sizeof(jint); 156256949Sganbold OopMap* oop_map = new OopMap(frame_size_in_slots, 0); 157256949Sganbold 158256949Sganbold int i; 159256949Sganbold for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 160256949Sganbold Register r = as_Register(i); 161256949Sganbold if (FrameMap::reg_needs_save(r)) { 162256949Sganbold int sp_offset = cpu_reg_save_offsets[i]; 163256949Sganbold oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset>>2), r->as_VMReg()); 164256949Sganbold oop_map->set_callee_saved(VMRegImpl::stack2reg((sp_offset>>2) + 1), r->as_VMReg()->next()); 165256949Sganbold } 166256949Sganbold } 167256949Sganbold 168256949Sganbold if (save_fpu_registers) { 169256949Sganbold for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 170256949Sganbold FloatRegister r = as_FloatRegister(i); 171256949Sganbold int sp_offset = fpu_reg_save_offsets[i]; 172256949Sganbold oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset>>2), r->as_VMReg()); 173256949Sganbold oop_map->set_callee_saved(VMRegImpl::stack2reg((sp_offset>>2) + 1), r->as_VMReg()->next()); 174256949Sganbold } 175256949Sganbold } 176256949Sganbold 177256949Sganbold return oop_map; 178256949Sganbold} 179256949Sganbold 180256949Sganboldstatic OopMap* save_live_registers(StubAssembler* sasm, bool save_fpu_registers = true, 181256949Sganbold Register ret_pc = noreg, int stack_preserve = 0) { 182256949Sganbold if (ret_pc == noreg) { 183256949Sganbold ret_pc = R0; 184256949Sganbold __ mflr(ret_pc); 185256949Sganbold } 186256949Sganbold __ std(ret_pc, _abi(lr), R1_SP); // C code needs pc in C1 method. 187256949Sganbold __ push_frame(frame_size_in_bytes + stack_preserve, R0); 188256949Sganbold 189256949Sganbold // Record volatile registers as callee-save values in an OopMap so 190256949Sganbold // their save locations will be propagated to the caller frame's 191256949Sganbold // RegisterMap during StackFrameStream construction (needed for 192256949Sganbold // deoptimization; see compiledVFrame::create_stack_value). 193256949Sganbold // OopMap frame sizes are in c2 stack slot sizes (sizeof(jint)). 194256949Sganbold 195256949Sganbold int i; 196256949Sganbold for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 197256949Sganbold Register r = as_Register(i); 198256949Sganbold if (FrameMap::reg_needs_save(r)) { 199256949Sganbold int sp_offset = cpu_reg_save_offsets[i]; 200256949Sganbold __ std(r, sp_offset + STACK_BIAS, R1_SP); 201256949Sganbold } 202256949Sganbold } 203256949Sganbold 204256949Sganbold if (save_fpu_registers) { 205256949Sganbold for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 206256949Sganbold FloatRegister r = as_FloatRegister(i); 207256949Sganbold int sp_offset = fpu_reg_save_offsets[i]; 208256949Sganbold __ stfd(r, sp_offset + STACK_BIAS, R1_SP); 209256949Sganbold } 210256949Sganbold } 211256949Sganbold 212256949Sganbold return generate_oop_map(sasm, save_fpu_registers); 213256949Sganbold} 214256949Sganbold 215256949Sganboldstatic void restore_live_registers(StubAssembler* sasm, Register result1, Register result2, 216256949Sganbold bool restore_fpu_registers = true) { 217256949Sganbold for (int i = 0; i < FrameMap::nof_cpu_regs; i++) { 218256949Sganbold Register r = as_Register(i); 219256949Sganbold if (FrameMap::reg_needs_save(r) && r != result1 && r != result2) { 220256949Sganbold int sp_offset = cpu_reg_save_offsets[i]; 221256949Sganbold __ ld(r, sp_offset + STACK_BIAS, R1_SP); 222256949Sganbold } 223256949Sganbold } 224256949Sganbold 225256949Sganbold if (restore_fpu_registers) { 226256949Sganbold for (int i = 0; i < FrameMap::nof_fpu_regs; i++) { 227256949Sganbold FloatRegister r = as_FloatRegister(i); 228256949Sganbold int sp_offset = fpu_reg_save_offsets[i]; 229256949Sganbold __ lfd(r, sp_offset + STACK_BIAS, R1_SP); 230256949Sganbold } 231256949Sganbold } 232256949Sganbold 233256949Sganbold __ pop_frame(); 234256949Sganbold __ ld(R0, _abi(lr), R1_SP); 235256949Sganbold __ mtlr(R0); 236256949Sganbold} 237256949Sganbold 238256949Sganbold 239256949Sganboldvoid Runtime1::initialize_pd() { 240256949Sganbold int i; 241256949Sganbold int sp_offset = frame::abi_reg_args_size; 242256949Sganbold 243256949Sganbold for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 244256949Sganbold Register r = as_Register(i); 245256949Sganbold if (FrameMap::reg_needs_save(r)) { 246256949Sganbold cpu_reg_save_offsets[i] = sp_offset; 247256949Sganbold sp_offset += BytesPerWord; 248256949Sganbold } 249256949Sganbold } 250256949Sganbold 251256949Sganbold for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 252256949Sganbold fpu_reg_save_offsets[i] = sp_offset; 253256949Sganbold sp_offset += BytesPerWord; 254256949Sganbold } 255256949Sganbold frame_size_in_bytes = align_up(sp_offset, frame::alignment_in_bytes); 256256949Sganbold} 257256949Sganbold 258256949Sganbold 259256949SganboldOopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) { 260256949Sganbold // Make a frame and preserve the caller's caller-save registers. 261256949Sganbold OopMap* oop_map = save_live_registers(sasm); 262256949Sganbold 263256949Sganbold int call_offset; 264256949Sganbold if (!has_argument) { 265256949Sganbold call_offset = __ call_RT(noreg, noreg, target); 266256949Sganbold } else { 267256949Sganbold call_offset = __ call_RT(noreg, noreg, target, R4_ARG2); 268256949Sganbold } 269256949Sganbold OopMapSet* oop_maps = new OopMapSet(); 270256949Sganbold oop_maps->add_gc_map(call_offset, oop_map); 271256949Sganbold 272256949Sganbold __ should_not_reach_here(); 273256949Sganbold return oop_maps; 274256949Sganbold} 275256949Sganbold 276256949Sganboldstatic OopMapSet* generate_exception_throw_with_stack_parms(StubAssembler* sasm, address target, 277256949Sganbold int stack_parms) { 278256949Sganbold // Make a frame and preserve the caller's caller-save registers. 279256949Sganbold const int parm_size_in_bytes = align_up(stack_parms << LogBytesPerWord, frame::alignment_in_bytes); 280256949Sganbold const int padding = parm_size_in_bytes - (stack_parms << LogBytesPerWord); 281256949Sganbold OopMap* oop_map = save_live_registers(sasm, true, noreg, parm_size_in_bytes); 282256949Sganbold 283256949Sganbold int call_offset = 0; 284256949Sganbold switch (stack_parms) { 285256949Sganbold case 3: 286256949Sganbold __ ld(R6_ARG4, frame_size_in_bytes + padding + 16, R1_SP); 287256949Sganbold case 2: 288256949Sganbold __ ld(R5_ARG3, frame_size_in_bytes + padding + 8, R1_SP); 289256949Sganbold case 1: 290256949Sganbold __ ld(R4_ARG2, frame_size_in_bytes + padding + 0, R1_SP); 291256949Sganbold call_offset = __ call_RT(noreg, noreg, target); 292256949Sganbold break; 293256949Sganbold default: Unimplemented(); break; 294256949Sganbold } 295256949Sganbold OopMapSet* oop_maps = new OopMapSet(); 296256949Sganbold oop_maps->add_gc_map(call_offset, oop_map); 297256949Sganbold 298256949Sganbold __ should_not_reach_here(); 299256949Sganbold return oop_maps; 300256949Sganbold} 301256949Sganbold 302256949Sganbold 303256949SganboldOopMapSet* Runtime1::generate_stub_call(StubAssembler* sasm, Register result, address target, 304256949Sganbold Register arg1, Register arg2, Register arg3) { 305256949Sganbold // Make a frame and preserve the caller's caller-save registers. 306256949Sganbold OopMap* oop_map = save_live_registers(sasm); 307256949Sganbold 308256949Sganbold int call_offset; 309256949Sganbold if (arg1 == noreg) { 310256949Sganbold call_offset = __ call_RT(result, noreg, target); 311256949Sganbold } else if (arg2 == noreg) { 312256949Sganbold call_offset = __ call_RT(result, noreg, target, arg1); 313256949Sganbold } else if (arg3 == noreg) { 314256949Sganbold call_offset = __ call_RT(result, noreg, target, arg1, arg2); 315256949Sganbold } else { 316256949Sganbold call_offset = __ call_RT(result, noreg, target, arg1, arg2, arg3); 317256949Sganbold } 318256949Sganbold OopMapSet* oop_maps = new OopMapSet(); 319256949Sganbold oop_maps->add_gc_map(call_offset, oop_map); 320256949Sganbold 321256949Sganbold restore_live_registers(sasm, result, noreg); 322256949Sganbold __ blr(); 323256949Sganbold return oop_maps; 324256949Sganbold} 325256949Sganbold 326256949Sganboldstatic OopMapSet* stub_call_with_stack_parms(StubAssembler* sasm, Register result, address target, 327256949Sganbold int stack_parms, bool do_return = true) { 328256949Sganbold // Make a frame and preserve the caller's caller-save registers. 329256949Sganbold const int parm_size_in_bytes = align_up(stack_parms << LogBytesPerWord, frame::alignment_in_bytes); 330256949Sganbold const int padding = parm_size_in_bytes - (stack_parms << LogBytesPerWord); 331256949Sganbold OopMap* oop_map = save_live_registers(sasm, true, noreg, parm_size_in_bytes); 332256949Sganbold 333256949Sganbold int call_offset = 0; 334256949Sganbold switch (stack_parms) { 335256949Sganbold case 3: 336256949Sganbold __ ld(R6_ARG4, frame_size_in_bytes + padding + 16, R1_SP); 337256949Sganbold case 2: 338256949Sganbold __ ld(R5_ARG3, frame_size_in_bytes + padding + 8, R1_SP); 339256949Sganbold case 1: 340256949Sganbold __ ld(R4_ARG2, frame_size_in_bytes + padding + 0, R1_SP); 341256949Sganbold call_offset = __ call_RT(result, noreg, target); 342256949Sganbold break; 343256949Sganbold default: Unimplemented(); break; 344256949Sganbold } 345256949Sganbold OopMapSet* oop_maps = new OopMapSet(); 346256949Sganbold oop_maps->add_gc_map(call_offset, oop_map); 347256949Sganbold 348256949Sganbold restore_live_registers(sasm, result, noreg); 349256949Sganbold if (do_return) __ blr(); 350256949Sganbold return oop_maps; 351256949Sganbold} 352256949Sganbold 353256949Sganbold 354256949SganboldOopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { 355256949Sganbold // Make a frame and preserve the caller's caller-save registers. 356256949Sganbold OopMap* oop_map = save_live_registers(sasm); 357256949Sganbold 358256949Sganbold // Call the runtime patching routine, returns non-zero if nmethod got deopted. 359256949Sganbold int call_offset = __ call_RT(noreg, noreg, target); 360256949Sganbold OopMapSet* oop_maps = new OopMapSet(); 361256949Sganbold oop_maps->add_gc_map(call_offset, oop_map); 362256949Sganbold __ cmpdi(CCR0, R3_RET, 0); 363256949Sganbold 364256949Sganbold // Re-execute the patched instruction or, if the nmethod was deoptmized, 365256949Sganbold // return to the deoptimization handler entry that will cause re-execution 366256949Sganbold // of the current bytecode. 367256949Sganbold DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 368256949Sganbold assert(deopt_blob != NULL, "deoptimization blob must have been created"); 369256949Sganbold 370256949Sganbold // Return to the deoptimization handler entry for unpacking and rexecute. 371256949Sganbold // If we simply returned the we'd deopt as if any call we patched had just 372256949Sganbold // returned. 373256949Sganbold 374256949Sganbold restore_live_registers(sasm, noreg, noreg); 375256949Sganbold // Return if patching routine returned 0. 376256949Sganbold __ bclr(Assembler::bcondCRbiIs1, Assembler::bi0(CCR0, Assembler::equal), Assembler::bhintbhBCLRisReturn); 377256949Sganbold 378256949Sganbold address stub = deopt_blob->unpack_with_reexecution(); 379256949Sganbold //__ load_const_optimized(R0, stub); 380256949Sganbold __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); 381256949Sganbold __ mtctr(R0); 382256949Sganbold __ bctr(); 383256949Sganbold 384256949Sganbold return oop_maps; 385256949Sganbold} 386256949Sganbold 387256949SganboldOopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { 388256949Sganbold OopMapSet* oop_maps = NULL; 389256949Sganbold 390256949Sganbold // For better readability. 391256949Sganbold const bool must_gc_arguments = true; 392256949Sganbold const bool dont_gc_arguments = false; 393256949Sganbold 394256949Sganbold // Stub code & info for the different stubs. 395256949Sganbold switch (id) { 396256949Sganbold case forward_exception_id: 397256949Sganbold { 398256949Sganbold oop_maps = generate_handle_exception(id, sasm); 399256949Sganbold } 400256949Sganbold break; 401256949Sganbold 402256949Sganbold case new_instance_id: 403256949Sganbold case fast_new_instance_id: 404256949Sganbold case fast_new_instance_init_check_id: 405256949Sganbold { 406256949Sganbold if (id == new_instance_id) { 407256949Sganbold __ set_info("new_instance", dont_gc_arguments); 408256949Sganbold } else if (id == fast_new_instance_id) { 409256949Sganbold __ set_info("fast new_instance", dont_gc_arguments); 410256949Sganbold } else { 411256949Sganbold assert(id == fast_new_instance_init_check_id, "bad StubID"); 412256949Sganbold __ set_info("fast new_instance init check", dont_gc_arguments); 413256949Sganbold } 414256949Sganbold // We don't support eden allocation. 415256949Sganbold// if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) && 416256949Sganbold// UseTLAB && FastTLABRefill) { 417256949Sganbold// if (id == fast_new_instance_init_check_id) { 418256949Sganbold// // make sure the klass is initialized 419256949Sganbold// __ lbz(R0, in_bytes(InstanceKlass::init_state_offset()), R3_ARG1); 420256949Sganbold// __ cmpwi(CCR0, R0, InstanceKlass::fully_initialized); 421256949Sganbold// __ bne(CCR0, slow_path); 422256949Sganbold// } 423256949Sganbold//#ifdef ASSERT 424256949Sganbold// // assert object can be fast path allocated 425256949Sganbold// { 426256949Sganbold// Label ok, not_ok; 427256949Sganbold// __ lwz(R0, in_bytes(Klass::layout_helper_offset()), R3_ARG1); 428256949Sganbold// // make sure it's an instance (LH > 0) 429256949Sganbold// __ cmpwi(CCR0, R0, 0); 430266152Sian// __ ble(CCR0, not_ok); 431266152Sian// __ testbitdi(CCR0, R0, R0, Klass::_lh_instance_slow_path_bit); 432266152Sian// __ beq(CCR0, ok); 433256949Sganbold// 434256949Sganbold// __ bind(not_ok); 435256949Sganbold// __ stop("assert(can be fast path allocated)"); 436256949Sganbold// __ bind(ok); 437256949Sganbold// } 438256949Sganbold//#endif // ASSERT 439256949Sganbold// // We don't support eden allocation. 440256949Sganbold// __ bind(slow_path); 441256949Sganbold// } 442256949Sganbold oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_instance), R4_ARG2); 443256949Sganbold } 444256949Sganbold break; 445256949Sganbold 446256949Sganbold case counter_overflow_id: 447256949Sganbold // Bci and method are on stack. 448273650Sian oop_maps = stub_call_with_stack_parms(sasm, noreg, CAST_FROM_FN_PTR(address, counter_overflow), 2); 449273650Sian break; 450273650Sian 451256949Sganbold case new_type_array_id: 452256949Sganbold case new_object_array_id: 453256949Sganbold { 454256949Sganbold if (id == new_type_array_id) { 455256949Sganbold __ set_info("new_type_array", dont_gc_arguments); 456256949Sganbold } else { 457256949Sganbold __ set_info("new_object_array", dont_gc_arguments); 458256949Sganbold } 459256949Sganbold 460256949Sganbold#ifdef ASSERT 461256949Sganbold // Assert object type is really an array of the proper kind. 462256949Sganbold { 463256949Sganbold int tag = (id == new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value; 464256949Sganbold Label ok; 465256949Sganbold __ lwz(R0, in_bytes(Klass::layout_helper_offset()), R4_ARG2); 466256949Sganbold __ srawi(R0, R0, Klass::_lh_array_tag_shift); 467256949Sganbold __ cmpwi(CCR0, R0, tag); 468256949Sganbold __ beq(CCR0, ok); 469256949Sganbold __ stop("assert(is an array klass)"); 470256949Sganbold __ should_not_reach_here(); 471256949Sganbold __ bind(ok); 472256949Sganbold } 473256949Sganbold#endif // ASSERT 474256949Sganbold 475256949Sganbold // We don't support eden allocation. 476256949Sganbold 477256949Sganbold if (id == new_type_array_id) { 478256949Sganbold oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_type_array), R4_ARG2, R5_ARG3); 479256949Sganbold } else { 480256949Sganbold oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_object_array), R4_ARG2, R5_ARG3); 481256949Sganbold } 482256949Sganbold } 483256949Sganbold break; 484256949Sganbold 485256949Sganbold case new_multi_array_id: 486256949Sganbold { 487256949Sganbold // R4: klass 488256949Sganbold // R5: rank 489256949Sganbold // R6: address of 1st dimension 490256949Sganbold __ set_info("new_multi_array", dont_gc_arguments); 491256949Sganbold oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_multi_array), R4_ARG2, R5_ARG3, R6_ARG4); 492256949Sganbold } 493278782Sloos break; 494278782Sloos 495273650Sian case register_finalizer_id: 496273650Sian { 497273650Sian __ set_info("register_finalizer", dont_gc_arguments); 498273650Sian // This code is called via rt_call. Hence, caller-save registers have been saved. 499273650Sian Register t = R11_scratch1; 500256949Sganbold 501256949Sganbold // Load the klass and check the has finalizer flag. 502256949Sganbold __ load_klass(t, R3_ARG1); 503256949Sganbold __ lwz(t, in_bytes(Klass::access_flags_offset()), t); 504256949Sganbold __ testbitdi(CCR0, R0, t, exact_log2(JVM_ACC_HAS_FINALIZER)); 505256949Sganbold // Return if has_finalizer bit == 0 (CR0.eq). 506256949Sganbold __ bclr(Assembler::bcondCRbiIs1, Assembler::bi0(CCR0, Assembler::equal), Assembler::bhintbhBCLRisReturn); 507256949Sganbold 508256949Sganbold __ mflr(R0); 509256949Sganbold __ std(R0, _abi(lr), R1_SP); 510256949Sganbold __ push_frame(frame::abi_reg_args_size, R0); // Empty dummy frame (no callee-save regs). 511256949Sganbold sasm->set_frame_size(frame::abi_reg_args_size / BytesPerWord); 512256949Sganbold OopMap* oop_map = new OopMap(frame::abi_reg_args_size / sizeof(jint), 0); 513256949Sganbold int call_offset = __ call_RT(noreg, noreg, 514256949Sganbold CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), R3_ARG1); 515256949Sganbold oop_maps = new OopMapSet(); 516256949Sganbold oop_maps->add_gc_map(call_offset, oop_map); 517256949Sganbold 518256949Sganbold __ pop_frame(); 519256949Sganbold __ ld(R0, _abi(lr), R1_SP); 520256949Sganbold __ mtlr(R0); 521256949Sganbold __ blr(); 522256949Sganbold } 523256949Sganbold break; 524256949Sganbold 525256949Sganbold case throw_range_check_failed_id: 526256949Sganbold { 527256949Sganbold __ set_info("range_check_failed", dont_gc_arguments); // Arguments will be discarded. 528256949Sganbold __ std(R0, -8, R1_SP); // Pass index on stack. 529256949Sganbold oop_maps = generate_exception_throw_with_stack_parms(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), 1); 530256949Sganbold } 531256949Sganbold break; 532256949Sganbold 533256949Sganbold case throw_index_exception_id: 534256949Sganbold { 535256949Sganbold __ set_info("index_range_check_failed", dont_gc_arguments); // Arguments will be discarded. 536256949Sganbold oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); 537256949Sganbold } 538256949Sganbold break; 539256949Sganbold 540256949Sganbold case throw_div0_exception_id: 541256949Sganbold { 542256949Sganbold __ set_info("throw_div0_exception", dont_gc_arguments); 543256949Sganbold oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); 544256949Sganbold } 545273650Sian break; 546273650Sian 547273650Sian case throw_null_pointer_exception_id: 548273650Sian { 549273650Sian __ set_info("throw_null_pointer_exception", dont_gc_arguments); 550273650Sian oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); 551273650Sian } 552273650Sian break; 553273650Sian 554273650Sian case handle_exception_nofpu_id: 555273650Sian case handle_exception_id: 556273650Sian { 557273650Sian __ set_info("handle_exception", dont_gc_arguments); 558273650Sian oop_maps = generate_handle_exception(id, sasm); 559273650Sian } 560273650Sian break; 561273650Sian 562273650Sian case handle_exception_from_callee_id: 563273650Sian { 564273650Sian __ set_info("handle_exception_from_callee", dont_gc_arguments); 565273650Sian oop_maps = generate_handle_exception(id, sasm); 566273650Sian } 567273650Sian break; 568273650Sian 569273650Sian case unwind_exception_id: 570273650Sian { 571273650Sian const Register Rexception = R3 /*LIRGenerator::exceptionOopOpr()*/, 572273650Sian Rexception_pc = R4 /*LIRGenerator::exceptionPcOpr()*/, 573273650Sian Rexception_save = R31, Rcaller_sp = R30; 574273650Sian __ set_info("unwind_exception", dont_gc_arguments); 575273650Sian 576273650Sian __ ld(Rcaller_sp, 0, R1_SP); 577273650Sian __ push_frame_reg_args(0, R0); // dummy frame for C call 578273650Sian __ mr(Rexception_save, Rexception); // save over C call 579273650Sian __ ld(Rexception_pc, _abi(lr), Rcaller_sp); // return pc 580273650Sian __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), R16_thread, Rexception_pc); 581273650Sian __ verify_not_null_oop(Rexception_save); 582273650Sian __ mtctr(R3_RET); 583273650Sian __ ld(Rexception_pc, _abi(lr), Rcaller_sp); // return pc 584273650Sian __ mr(R1_SP, Rcaller_sp); // Pop both frames at once. 585273650Sian __ mr(Rexception, Rexception_save); // restore 586273650Sian __ mtlr(Rexception_pc); 587273650Sian __ bctr(); 588273650Sian } 589273650Sian break; 590273650Sian 591273650Sian case throw_array_store_exception_id: 592273650Sian { 593273650Sian __ set_info("throw_array_store_exception", dont_gc_arguments); 594273650Sian oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true); 595273650Sian } 596273650Sian break; 597273650Sian 598273650Sian case throw_class_cast_exception_id: 599273650Sian { 600273650Sian __ set_info("throw_class_cast_exception", dont_gc_arguments); 601273650Sian oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); 602273650Sian } 603273650Sian break; 604273650Sian 605273650Sian case throw_incompatible_class_change_error_id: 606273650Sian { 607273650Sian __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments); 608273650Sian oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); 609273650Sian } 610273650Sian break; 611273650Sian 612273650Sian case slow_subtype_check_id: 613273650Sian { // Support for uint StubRoutine::partial_subtype_check( Klass sub, Klass super ); 614273650Sian const Register sub_klass = R5, 615273650Sian super_klass = R4, 616273650Sian temp1_reg = R6, 617273650Sian temp2_reg = R0; 618273650Sian __ check_klass_subtype_slow_path(sub_klass, super_klass, temp1_reg, temp2_reg); // returns with CR0.eq if successful 619273650Sian __ crandc(CCR0, Assembler::equal, CCR0, Assembler::equal); // failed: CR0.ne 620273650Sian __ blr(); 621273650Sian } 622273650Sian break; 623273650Sian 624273650Sian case monitorenter_nofpu_id: 625273650Sian case monitorenter_id: 626273650Sian { 627273650Sian __ set_info("monitorenter", dont_gc_arguments); 628273650Sian 629273650Sian int save_fpu_registers = (id == monitorenter_id); 630273650Sian // Make a frame and preserve the caller's caller-save registers. 631273650Sian OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); 632273650Sian 633273650Sian int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), R4_ARG2, R5_ARG3); 634273650Sian 635273650Sian oop_maps = new OopMapSet(); 636273650Sian oop_maps->add_gc_map(call_offset, oop_map); 637273650Sian 638273650Sian restore_live_registers(sasm, noreg, noreg, save_fpu_registers); 639273650Sian __ blr(); 640273650Sian } 641273650Sian break; 642273650Sian 643273650Sian case monitorexit_nofpu_id: 644273650Sian case monitorexit_id: 645273652Sian { 646273650Sian // note: Really a leaf routine but must setup last java sp 647273650Sian // => use call_RT for now (speed can be improved by 648273650Sian // doing last java sp setup manually). 649273650Sian __ set_info("monitorexit", dont_gc_arguments); 650273650Sian 651273650Sian int save_fpu_registers = (id == monitorexit_id); 652273650Sian // Make a frame and preserve the caller's caller-save registers. 653273650Sian OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); 654273650Sian 655273650Sian int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), R4_ARG2); 656273650Sian 657273650Sian oop_maps = new OopMapSet(); 658273650Sian oop_maps->add_gc_map(call_offset, oop_map); 659273650Sian 660273650Sian restore_live_registers(sasm, noreg, noreg, save_fpu_registers); 661273650Sian __ blr(); 662273650Sian } 663 break; 664 665 case deoptimize_id: 666 { 667 __ set_info("deoptimize", dont_gc_arguments); 668 __ std(R0, -8, R1_SP); // Pass trap_request on stack. 669 oop_maps = stub_call_with_stack_parms(sasm, noreg, CAST_FROM_FN_PTR(address, deoptimize), 1, /*do_return*/ false); 670 671 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 672 assert(deopt_blob != NULL, "deoptimization blob must have been created"); 673 address stub = deopt_blob->unpack_with_reexecution(); 674 //__ load_const_optimized(R0, stub); 675 __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); 676 __ mtctr(R0); 677 __ bctr(); 678 } 679 break; 680 681 case access_field_patching_id: 682 { 683 __ set_info("access_field_patching", dont_gc_arguments); 684 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); 685 } 686 break; 687 688 case load_klass_patching_id: 689 { 690 __ set_info("load_klass_patching", dont_gc_arguments); 691 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); 692 } 693 break; 694 695 case load_mirror_patching_id: 696 { 697 __ set_info("load_mirror_patching", dont_gc_arguments); 698 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); 699 } 700 break; 701 702 case load_appendix_patching_id: 703 { 704 __ set_info("load_appendix_patching", dont_gc_arguments); 705 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); 706 } 707 break; 708 709 case dtrace_object_alloc_id: 710 { // O0: object 711 __ unimplemented("stub dtrace_object_alloc_id"); 712 __ set_info("dtrace_object_alloc", dont_gc_arguments); 713// // We can't gc here so skip the oopmap but make sure that all 714// // the live registers get saved. 715// save_live_registers(sasm); 716// 717// __ save_thread(L7_thread_cache); 718// __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), 719// relocInfo::runtime_call_type); 720// __ delayed()->mov(I0, O0); 721// __ restore_thread(L7_thread_cache); 722// 723// restore_live_registers(sasm); 724// __ ret(); 725// __ delayed()->restore(); 726 } 727 break; 728 729#if INCLUDE_ALL_GCS 730 case g1_pre_barrier_slow_id: 731 { 732 BarrierSet* bs = Universe::heap()->barrier_set(); 733 if (bs->kind() != BarrierSet::G1SATBCTLogging) { 734 goto unimplemented_entry; 735 } 736 737 __ set_info("g1_pre_barrier_slow_id", dont_gc_arguments); 738 739 // Using stack slots: pre_val (pre-pushed), spill tmp, spill tmp2. 740 const int stack_slots = 3; 741 Register pre_val = R0; // previous value of memory 742 Register tmp = R14; 743 Register tmp2 = R15; 744 745 Label refill, restart, marking_not_active; 746 int satb_q_active_byte_offset = 747 in_bytes(JavaThread::satb_mark_queue_offset() + 748 SATBMarkQueue::byte_offset_of_active()); 749 int satb_q_index_byte_offset = 750 in_bytes(JavaThread::satb_mark_queue_offset() + 751 SATBMarkQueue::byte_offset_of_index()); 752 int satb_q_buf_byte_offset = 753 in_bytes(JavaThread::satb_mark_queue_offset() + 754 SATBMarkQueue::byte_offset_of_buf()); 755 756 // Spill 757 __ std(tmp, -16, R1_SP); 758 __ std(tmp2, -24, R1_SP); 759 760 // Is marking still active? 761 if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { 762 __ lwz(tmp, satb_q_active_byte_offset, R16_thread); 763 } else { 764 assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); 765 __ lbz(tmp, satb_q_active_byte_offset, R16_thread); 766 } 767 __ cmpdi(CCR0, tmp, 0); 768 __ beq(CCR0, marking_not_active); 769 770 __ bind(restart); 771 // Load the index into the SATB buffer. SATBMarkQueue::_index is a 772 // size_t so ld_ptr is appropriate. 773 __ ld(tmp, satb_q_index_byte_offset, R16_thread); 774 775 // index == 0? 776 __ cmpdi(CCR0, tmp, 0); 777 __ beq(CCR0, refill); 778 779 __ ld(tmp2, satb_q_buf_byte_offset, R16_thread); 780 __ ld(pre_val, -8, R1_SP); // Load from stack. 781 __ addi(tmp, tmp, -oopSize); 782 783 __ std(tmp, satb_q_index_byte_offset, R16_thread); 784 __ stdx(pre_val, tmp2, tmp); // [_buf + index] := <address_of_card> 785 786 __ bind(marking_not_active); 787 // Restore temp registers and return-from-leaf. 788 __ ld(tmp2, -24, R1_SP); 789 __ ld(tmp, -16, R1_SP); 790 __ blr(); 791 792 __ bind(refill); 793 const int nbytes_save = (MacroAssembler::num_volatile_regs + stack_slots) * BytesPerWord; 794 __ save_volatile_gprs(R1_SP, -nbytes_save); // except R0 795 __ mflr(R0); 796 __ std(R0, _abi(lr), R1_SP); 797 __ push_frame_reg_args(nbytes_save, R0); // dummy frame for C call 798 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread), R16_thread); 799 __ pop_frame(); 800 __ ld(R0, _abi(lr), R1_SP); 801 __ mtlr(R0); 802 __ restore_volatile_gprs(R1_SP, -nbytes_save); // except R0 803 __ b(restart); 804 } 805 break; 806 807 case g1_post_barrier_slow_id: 808 { 809 BarrierSet* bs = Universe::heap()->barrier_set(); 810 if (bs->kind() != BarrierSet::G1SATBCTLogging) { 811 goto unimplemented_entry; 812 } 813 814 __ set_info("g1_post_barrier_slow_id", dont_gc_arguments); 815 816 // Using stack slots: spill addr, spill tmp2 817 const int stack_slots = 2; 818 Register tmp = R0; 819 Register addr = R14; 820 Register tmp2 = R15; 821 jbyte* byte_map_base = ((CardTableModRefBS*)bs)->byte_map_base; 822 823 Label restart, refill, ret; 824 825 // Spill 826 __ std(addr, -8, R1_SP); 827 __ std(tmp2, -16, R1_SP); 828 829 __ srdi(addr, R0, CardTableModRefBS::card_shift); // Addr is passed in R0. 830 __ load_const_optimized(/*cardtable*/ tmp2, byte_map_base, tmp); 831 __ add(addr, tmp2, addr); 832 __ lbz(tmp, 0, addr); // tmp := [addr + cardtable] 833 834 // Return if young card. 835 __ cmpwi(CCR0, tmp, G1SATBCardTableModRefBS::g1_young_card_val()); 836 __ beq(CCR0, ret); 837 838 // Return if sequential consistent value is already dirty. 839 __ membar(Assembler::StoreLoad); 840 __ lbz(tmp, 0, addr); // tmp := [addr + cardtable] 841 842 __ cmpwi(CCR0, tmp, G1SATBCardTableModRefBS::dirty_card_val()); 843 __ beq(CCR0, ret); 844 845 // Not dirty. 846 847 // First, dirty it. 848 __ li(tmp, G1SATBCardTableModRefBS::dirty_card_val()); 849 __ stb(tmp, 0, addr); 850 851 int dirty_card_q_index_byte_offset = 852 in_bytes(JavaThread::dirty_card_queue_offset() + 853 DirtyCardQueue::byte_offset_of_index()); 854 int dirty_card_q_buf_byte_offset = 855 in_bytes(JavaThread::dirty_card_queue_offset() + 856 DirtyCardQueue::byte_offset_of_buf()); 857 858 __ bind(restart); 859 860 // Get the index into the update buffer. DirtyCardQueue::_index is 861 // a size_t so ld_ptr is appropriate here. 862 __ ld(tmp2, dirty_card_q_index_byte_offset, R16_thread); 863 864 // index == 0? 865 __ cmpdi(CCR0, tmp2, 0); 866 __ beq(CCR0, refill); 867 868 __ ld(tmp, dirty_card_q_buf_byte_offset, R16_thread); 869 __ addi(tmp2, tmp2, -oopSize); 870 871 __ std(tmp2, dirty_card_q_index_byte_offset, R16_thread); 872 __ add(tmp2, tmp, tmp2); 873 __ std(addr, 0, tmp2); // [_buf + index] := <address_of_card> 874 875 // Restore temp registers and return-from-leaf. 876 __ bind(ret); 877 __ ld(tmp2, -16, R1_SP); 878 __ ld(addr, -8, R1_SP); 879 __ blr(); 880 881 __ bind(refill); 882 const int nbytes_save = (MacroAssembler::num_volatile_regs + stack_slots) * BytesPerWord; 883 __ save_volatile_gprs(R1_SP, -nbytes_save); // except R0 884 __ mflr(R0); 885 __ std(R0, _abi(lr), R1_SP); 886 __ push_frame_reg_args(nbytes_save, R0); // dummy frame for C call 887 __ call_VM_leaf(CAST_FROM_FN_PTR(address, DirtyCardQueueSet::handle_zero_index_for_thread), R16_thread); 888 __ pop_frame(); 889 __ ld(R0, _abi(lr), R1_SP); 890 __ mtlr(R0); 891 __ restore_volatile_gprs(R1_SP, -nbytes_save); // except R0 892 __ b(restart); 893 } 894 break; 895#endif // INCLUDE_ALL_GCS 896 897 case predicate_failed_trap_id: 898 { 899 __ set_info("predicate_failed_trap", dont_gc_arguments); 900 OopMap* oop_map = save_live_registers(sasm); 901 902 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); 903 904 oop_maps = new OopMapSet(); 905 oop_maps->add_gc_map(call_offset, oop_map); 906 907 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 908 assert(deopt_blob != NULL, "deoptimization blob must have been created"); 909 restore_live_registers(sasm, noreg, noreg); 910 911 address stub = deopt_blob->unpack_with_reexecution(); 912 //__ load_const_optimized(R0, stub); 913 __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); 914 __ mtctr(R0); 915 __ bctr(); 916 } 917 break; 918 919 default: 920 unimplemented_entry: 921 { 922 __ set_info("unimplemented entry", dont_gc_arguments); 923 __ mflr(R0); 924 __ std(R0, _abi(lr), R1_SP); 925 __ push_frame(frame::abi_reg_args_size, R0); // empty dummy frame 926 sasm->set_frame_size(frame::abi_reg_args_size / BytesPerWord); 927 OopMap* oop_map = new OopMap(frame::abi_reg_args_size / sizeof(jint), 0); 928 929 __ load_const_optimized(R4_ARG2, (int)id); 930 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), R4_ARG2); 931 932 oop_maps = new OopMapSet(); 933 oop_maps->add_gc_map(call_offset, oop_map); 934 __ should_not_reach_here(); 935 } 936 break; 937 } 938 return oop_maps; 939} 940 941 942OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { 943 __ block_comment("generate_handle_exception"); 944 945 // Save registers, if required. 946 OopMapSet* oop_maps = new OopMapSet(); 947 OopMap* oop_map = NULL; 948 const Register Rexception = R3 /*LIRGenerator::exceptionOopOpr()*/, 949 Rexception_pc = R4 /*LIRGenerator::exceptionPcOpr()*/; 950 951 switch (id) { 952 case forward_exception_id: 953 // We're handling an exception in the context of a compiled frame. 954 // The registers have been saved in the standard places. Perform 955 // an exception lookup in the caller and dispatch to the handler 956 // if found. Otherwise unwind and dispatch to the callers 957 // exception handler. 958 oop_map = generate_oop_map(sasm, true); 959 // Transfer the pending exception to the exception_oop. 960 // Also load the PC which is typically at SP + frame_size_in_bytes + _abi(lr), 961 // but we support additional slots in the frame for parameter passing. 962 __ ld(Rexception_pc, 0, R1_SP); 963 __ ld(Rexception, in_bytes(JavaThread::pending_exception_offset()), R16_thread); 964 __ li(R0, 0); 965 __ ld(Rexception_pc, _abi(lr), Rexception_pc); 966 __ std(R0, in_bytes(JavaThread::pending_exception_offset()), R16_thread); 967 break; 968 case handle_exception_nofpu_id: 969 case handle_exception_id: 970 // At this point all registers MAY be live. 971 oop_map = save_live_registers(sasm, id != handle_exception_nofpu_id, Rexception_pc); 972 break; 973 case handle_exception_from_callee_id: 974 // At this point all registers except exception oop and exception pc are dead. 975 oop_map = new OopMap(frame_size_in_bytes / sizeof(jint), 0); 976 sasm->set_frame_size(frame_size_in_bytes / BytesPerWord); 977 __ std(Rexception_pc, _abi(lr), R1_SP); 978 __ push_frame(frame_size_in_bytes, R0); 979 break; 980 default: ShouldNotReachHere(); 981 } 982 983 __ verify_not_null_oop(Rexception); 984 985#ifdef ASSERT 986 // Check that fields in JavaThread for exception oop and issuing pc are 987 // empty before writing to them. 988 __ ld(R0, in_bytes(JavaThread::exception_oop_offset()), R16_thread); 989 __ cmpdi(CCR0, R0, 0); 990 __ asm_assert_eq("exception oop already set", 0x963); 991 __ ld(R0, in_bytes(JavaThread::exception_pc_offset() ), R16_thread); 992 __ cmpdi(CCR0, R0, 0); 993 __ asm_assert_eq("exception pc already set", 0x962); 994#endif 995 996 // Save the exception and issuing pc in the thread. 997 __ std(Rexception, in_bytes(JavaThread::exception_oop_offset()), R16_thread); 998 __ std(Rexception_pc, in_bytes(JavaThread::exception_pc_offset() ), R16_thread); 999 1000 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc)); 1001 oop_maps->add_gc_map(call_offset, oop_map); 1002 1003 __ mtctr(R3_RET); 1004 1005 // Note: if nmethod has been deoptimized then regardless of 1006 // whether it had a handler or not we will deoptimize 1007 // by entering the deopt blob with a pending exception. 1008 1009 // Restore the registers that were saved at the beginning, remove 1010 // the frame and jump to the exception handler. 1011 switch (id) { 1012 case forward_exception_id: 1013 case handle_exception_nofpu_id: 1014 case handle_exception_id: 1015 restore_live_registers(sasm, noreg, noreg, id != handle_exception_nofpu_id); 1016 __ bctr(); 1017 break; 1018 case handle_exception_from_callee_id: { 1019 __ pop_frame(); 1020 __ ld(Rexception_pc, _abi(lr), R1_SP); 1021 __ mtlr(Rexception_pc); 1022 __ bctr(); 1023 break; 1024 } 1025 default: ShouldNotReachHere(); 1026 } 1027 1028 return oop_maps; 1029} 1030 1031const char *Runtime1::pd_name_for_address(address entry) { 1032 return "<unknown function>"; 1033} 1034 1035#undef __ 1036