1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,1146 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "c1/c1_Defs.hpp" 1.30 +#include "c1/c1_MacroAssembler.hpp" 1.31 +#include "c1/c1_Runtime1.hpp" 1.32 +#include "interpreter/interpreter.hpp" 1.33 +#include "nativeInst_sparc.hpp" 1.34 +#include "oops/compiledICHolder.hpp" 1.35 +#include "oops/oop.inline.hpp" 1.36 +#include "prims/jvmtiExport.hpp" 1.37 +#include "register_sparc.hpp" 1.38 +#include "runtime/sharedRuntime.hpp" 1.39 +#include "runtime/signature.hpp" 1.40 +#include "runtime/vframeArray.hpp" 1.41 +#include "utilities/macros.hpp" 1.42 +#include "vmreg_sparc.inline.hpp" 1.43 +#if INCLUDE_ALL_GCS 1.44 +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" 1.45 +#endif 1.46 + 1.47 +// Implementation of StubAssembler 1.48 + 1.49 +int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry_point, int number_of_arguments) { 1.50 + // for sparc changing the number of arguments doesn't change 1.51 + // anything about the frame size so we'll always lie and claim that 1.52 + // we are only passing 1 argument. 1.53 + set_num_rt_args(1); 1.54 + 1.55 + assert_not_delayed(); 1.56 + // bang stack before going to runtime 1.57 + set(-os::vm_page_size() + STACK_BIAS, G3_scratch); 1.58 + st(G0, SP, G3_scratch); 1.59 + 1.60 + // debugging support 1.61 + assert(number_of_arguments >= 0 , "cannot have negative number of arguments"); 1.62 + 1.63 + set_last_Java_frame(SP, noreg); 1.64 + if (VerifyThread) mov(G2_thread, O0); // about to be smashed; pass early 1.65 + save_thread(L7_thread_cache); 1.66 + // do the call 1.67 + call(entry_point, relocInfo::runtime_call_type); 1.68 + if (!VerifyThread) { 1.69 + delayed()->mov(G2_thread, O0); // pass thread as first argument 1.70 + } else { 1.71 + delayed()->nop(); // (thread already passed) 1.72 + } 1.73 + int call_offset = offset(); // offset of return address 1.74 + restore_thread(L7_thread_cache); 1.75 + reset_last_Java_frame(); 1.76 + 1.77 + // check for pending exceptions 1.78 + { Label L; 1.79 + Address exception_addr(G2_thread, Thread::pending_exception_offset()); 1.80 + ld_ptr(exception_addr, Gtemp); 1.81 + br_null_short(Gtemp, pt, L); 1.82 + Address vm_result_addr(G2_thread, JavaThread::vm_result_offset()); 1.83 + st_ptr(G0, vm_result_addr); 1.84 + Address vm_result_addr_2(G2_thread, JavaThread::vm_result_2_offset()); 1.85 + st_ptr(G0, vm_result_addr_2); 1.86 + 1.87 + if (frame_size() == no_frame_size) { 1.88 + // we use O7 linkage so that forward_exception_entry has the issuing PC 1.89 + call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type); 1.90 + delayed()->restore(); 1.91 + } else if (_stub_id == Runtime1::forward_exception_id) { 1.92 + should_not_reach_here(); 1.93 + } else { 1.94 + AddressLiteral exc(Runtime1::entry_for(Runtime1::forward_exception_id)); 1.95 + jump_to(exc, G4); 1.96 + delayed()->nop(); 1.97 + } 1.98 + bind(L); 1.99 + } 1.100 + 1.101 + // get oop result if there is one and reset the value in the thread 1.102 + if (oop_result1->is_valid()) { // get oop result if there is one and reset it in the thread 1.103 + get_vm_result (oop_result1); 1.104 + } else { 1.105 + // be a little paranoid and clear the result 1.106 + Address vm_result_addr(G2_thread, JavaThread::vm_result_offset()); 1.107 + st_ptr(G0, vm_result_addr); 1.108 + } 1.109 + 1.110 + // get second result if there is one and reset the value in the thread 1.111 + if (metadata_result->is_valid()) { 1.112 + get_vm_result_2 (metadata_result); 1.113 + } else { 1.114 + // be a little paranoid and clear the result 1.115 + Address vm_result_addr_2(G2_thread, JavaThread::vm_result_2_offset()); 1.116 + st_ptr(G0, vm_result_addr_2); 1.117 + } 1.118 + 1.119 + return call_offset; 1.120 +} 1.121 + 1.122 + 1.123 +int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1) { 1.124 + // O0 is reserved for the thread 1.125 + mov(arg1, O1); 1.126 + return call_RT(oop_result1, metadata_result, entry, 1); 1.127 +} 1.128 + 1.129 + 1.130 +int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2) { 1.131 + // O0 is reserved for the thread 1.132 + mov(arg1, O1); 1.133 + mov(arg2, O2); assert(arg2 != O1, "smashed argument"); 1.134 + return call_RT(oop_result1, metadata_result, entry, 2); 1.135 +} 1.136 + 1.137 + 1.138 +int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2, Register arg3) { 1.139 + // O0 is reserved for the thread 1.140 + mov(arg1, O1); 1.141 + mov(arg2, O2); assert(arg2 != O1, "smashed argument"); 1.142 + mov(arg3, O3); assert(arg3 != O1 && arg3 != O2, "smashed argument"); 1.143 + return call_RT(oop_result1, metadata_result, entry, 3); 1.144 +} 1.145 + 1.146 + 1.147 +// Implementation of Runtime1 1.148 + 1.149 +#define __ sasm-> 1.150 + 1.151 +static int cpu_reg_save_offsets[FrameMap::nof_cpu_regs]; 1.152 +static int fpu_reg_save_offsets[FrameMap::nof_fpu_regs]; 1.153 +static int reg_save_size_in_words; 1.154 +static int frame_size_in_bytes = -1; 1.155 + 1.156 +static OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers) { 1.157 + assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words), 1.158 + "mismatch in calculation"); 1.159 + sasm->set_frame_size(frame_size_in_bytes / BytesPerWord); 1.160 + int frame_size_in_slots = frame_size_in_bytes / sizeof(jint); 1.161 + OopMap* oop_map = new OopMap(frame_size_in_slots, 0); 1.162 + 1.163 + int i; 1.164 + for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 1.165 + Register r = as_Register(i); 1.166 + if (r == G1 || r == G3 || r == G4 || r == G5) { 1.167 + int sp_offset = cpu_reg_save_offsets[i]; 1.168 + oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset), 1.169 + r->as_VMReg()); 1.170 + } 1.171 + } 1.172 + 1.173 + if (save_fpu_registers) { 1.174 + for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 1.175 + FloatRegister r = as_FloatRegister(i); 1.176 + int sp_offset = fpu_reg_save_offsets[i]; 1.177 + oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset), 1.178 + r->as_VMReg()); 1.179 + } 1.180 + } 1.181 + return oop_map; 1.182 +} 1.183 + 1.184 +static OopMap* save_live_registers(StubAssembler* sasm, bool save_fpu_registers = true) { 1.185 + assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words), 1.186 + "mismatch in calculation"); 1.187 + __ save_frame_c1(frame_size_in_bytes); 1.188 + 1.189 + // Record volatile registers as callee-save values in an OopMap so their save locations will be 1.190 + // propagated to the caller frame's RegisterMap during StackFrameStream construction (needed for 1.191 + // deoptimization; see compiledVFrame::create_stack_value). The caller's I, L and O registers 1.192 + // are saved in register windows - I's and L's in the caller's frame and O's in the stub frame 1.193 + // (as the stub's I's) when the runtime routine called by the stub creates its frame. 1.194 + // OopMap frame sizes are in c2 stack slot sizes (sizeof(jint)) 1.195 + 1.196 + int i; 1.197 + for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 1.198 + Register r = as_Register(i); 1.199 + if (r == G1 || r == G3 || r == G4 || r == G5) { 1.200 + int sp_offset = cpu_reg_save_offsets[i]; 1.201 + __ st_ptr(r, SP, (sp_offset * BytesPerWord) + STACK_BIAS); 1.202 + } 1.203 + } 1.204 + 1.205 + if (save_fpu_registers) { 1.206 + for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 1.207 + FloatRegister r = as_FloatRegister(i); 1.208 + int sp_offset = fpu_reg_save_offsets[i]; 1.209 + __ stf(FloatRegisterImpl::S, r, SP, (sp_offset * BytesPerWord) + STACK_BIAS); 1.210 + } 1.211 + } 1.212 + 1.213 + return generate_oop_map(sasm, save_fpu_registers); 1.214 +} 1.215 + 1.216 +static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) { 1.217 + for (int i = 0; i < FrameMap::nof_cpu_regs; i++) { 1.218 + Register r = as_Register(i); 1.219 + if (r == G1 || r == G3 || r == G4 || r == G5) { 1.220 + __ ld_ptr(SP, (cpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r); 1.221 + } 1.222 + } 1.223 + 1.224 + if (restore_fpu_registers) { 1.225 + for (int i = 0; i < FrameMap::nof_fpu_regs; i++) { 1.226 + FloatRegister r = as_FloatRegister(i); 1.227 + __ ldf(FloatRegisterImpl::S, SP, (fpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r); 1.228 + } 1.229 + } 1.230 +} 1.231 + 1.232 + 1.233 +void Runtime1::initialize_pd() { 1.234 + // compute word offsets from SP at which live (non-windowed) registers are captured by stub routines 1.235 + // 1.236 + // A stub routine will have a frame that is at least large enough to hold 1.237 + // a register window save area (obviously) and the volatile g registers 1.238 + // and floating registers. A user of save_live_registers can have a frame 1.239 + // that has more scratch area in it (although typically they will use L-regs). 1.240 + // in that case the frame will look like this (stack growing down) 1.241 + // 1.242 + // FP -> | | 1.243 + // | scratch mem | 1.244 + // | " " | 1.245 + // -------------- 1.246 + // | float regs | 1.247 + // | " " | 1.248 + // --------------- 1.249 + // | G regs | 1.250 + // | " " | 1.251 + // --------------- 1.252 + // | abi reg. | 1.253 + // | window save | 1.254 + // | area | 1.255 + // SP -> --------------- 1.256 + // 1.257 + int i; 1.258 + int sp_offset = round_to(frame::register_save_words, 2); // start doubleword aligned 1.259 + 1.260 + // only G int registers are saved explicitly; others are found in register windows 1.261 + for (i = 0; i < FrameMap::nof_cpu_regs; i++) { 1.262 + Register r = as_Register(i); 1.263 + if (r == G1 || r == G3 || r == G4 || r == G5) { 1.264 + cpu_reg_save_offsets[i] = sp_offset; 1.265 + sp_offset++; 1.266 + } 1.267 + } 1.268 + 1.269 + // all float registers are saved explicitly 1.270 + assert(FrameMap::nof_fpu_regs == 32, "double registers not handled here"); 1.271 + for (i = 0; i < FrameMap::nof_fpu_regs; i++) { 1.272 + fpu_reg_save_offsets[i] = sp_offset; 1.273 + sp_offset++; 1.274 + } 1.275 + reg_save_size_in_words = sp_offset - frame::memory_parameter_word_sp_offset; 1.276 + // this should match assembler::total_frame_size_in_bytes, which 1.277 + // isn't callable from this context. It's checked by an assert when 1.278 + // it's used though. 1.279 + frame_size_in_bytes = align_size_up(sp_offset * wordSize, 8); 1.280 +} 1.281 + 1.282 + 1.283 +OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) { 1.284 + // make a frame and preserve the caller's caller-save registers 1.285 + OopMap* oop_map = save_live_registers(sasm); 1.286 + int call_offset; 1.287 + if (!has_argument) { 1.288 + call_offset = __ call_RT(noreg, noreg, target); 1.289 + } else { 1.290 + call_offset = __ call_RT(noreg, noreg, target, G4); 1.291 + } 1.292 + OopMapSet* oop_maps = new OopMapSet(); 1.293 + oop_maps->add_gc_map(call_offset, oop_map); 1.294 + 1.295 + __ should_not_reach_here(); 1.296 + return oop_maps; 1.297 +} 1.298 + 1.299 + 1.300 +OopMapSet* Runtime1::generate_stub_call(StubAssembler* sasm, Register result, address target, 1.301 + Register arg1, Register arg2, Register arg3) { 1.302 + // make a frame and preserve the caller's caller-save registers 1.303 + OopMap* oop_map = save_live_registers(sasm); 1.304 + 1.305 + int call_offset; 1.306 + if (arg1 == noreg) { 1.307 + call_offset = __ call_RT(result, noreg, target); 1.308 + } else if (arg2 == noreg) { 1.309 + call_offset = __ call_RT(result, noreg, target, arg1); 1.310 + } else if (arg3 == noreg) { 1.311 + call_offset = __ call_RT(result, noreg, target, arg1, arg2); 1.312 + } else { 1.313 + call_offset = __ call_RT(result, noreg, target, arg1, arg2, arg3); 1.314 + } 1.315 + OopMapSet* oop_maps = NULL; 1.316 + 1.317 + oop_maps = new OopMapSet(); 1.318 + oop_maps->add_gc_map(call_offset, oop_map); 1.319 + restore_live_registers(sasm); 1.320 + 1.321 + __ ret(); 1.322 + __ delayed()->restore(); 1.323 + 1.324 + return oop_maps; 1.325 +} 1.326 + 1.327 + 1.328 +OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { 1.329 + // make a frame and preserve the caller's caller-save registers 1.330 + OopMap* oop_map = save_live_registers(sasm); 1.331 + 1.332 + // call the runtime patching routine, returns non-zero if nmethod got deopted. 1.333 + int call_offset = __ call_RT(noreg, noreg, target); 1.334 + OopMapSet* oop_maps = new OopMapSet(); 1.335 + oop_maps->add_gc_map(call_offset, oop_map); 1.336 + 1.337 + // re-execute the patched instruction or, if the nmethod was deoptmized, return to the 1.338 + // deoptimization handler entry that will cause re-execution of the current bytecode 1.339 + DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 1.340 + assert(deopt_blob != NULL, "deoptimization blob must have been created"); 1.341 + 1.342 + Label no_deopt; 1.343 + __ br_null_short(O0, Assembler::pt, no_deopt); 1.344 + 1.345 + // return to the deoptimization handler entry for unpacking and rexecute 1.346 + // if we simply returned the we'd deopt as if any call we patched had just 1.347 + // returned. 1.348 + 1.349 + restore_live_registers(sasm); 1.350 + 1.351 + AddressLiteral dest(deopt_blob->unpack_with_reexecution()); 1.352 + __ jump_to(dest, O0); 1.353 + __ delayed()->restore(); 1.354 + 1.355 + __ bind(no_deopt); 1.356 + restore_live_registers(sasm); 1.357 + __ ret(); 1.358 + __ delayed()->restore(); 1.359 + 1.360 + return oop_maps; 1.361 +} 1.362 + 1.363 +OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { 1.364 + 1.365 + OopMapSet* oop_maps = NULL; 1.366 + // for better readability 1.367 + const bool must_gc_arguments = true; 1.368 + const bool dont_gc_arguments = false; 1.369 + 1.370 + // stub code & info for the different stubs 1.371 + switch (id) { 1.372 + case forward_exception_id: 1.373 + { 1.374 + oop_maps = generate_handle_exception(id, sasm); 1.375 + } 1.376 + break; 1.377 + 1.378 + case new_instance_id: 1.379 + case fast_new_instance_id: 1.380 + case fast_new_instance_init_check_id: 1.381 + { 1.382 + Register G5_klass = G5; // Incoming 1.383 + Register O0_obj = O0; // Outgoing 1.384 + 1.385 + if (id == new_instance_id) { 1.386 + __ set_info("new_instance", dont_gc_arguments); 1.387 + } else if (id == fast_new_instance_id) { 1.388 + __ set_info("fast new_instance", dont_gc_arguments); 1.389 + } else { 1.390 + assert(id == fast_new_instance_init_check_id, "bad StubID"); 1.391 + __ set_info("fast new_instance init check", dont_gc_arguments); 1.392 + } 1.393 + 1.394 + if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) && 1.395 + UseTLAB && FastTLABRefill) { 1.396 + Label slow_path; 1.397 + Register G1_obj_size = G1; 1.398 + Register G3_t1 = G3; 1.399 + Register G4_t2 = G4; 1.400 + assert_different_registers(G5_klass, G1_obj_size, G3_t1, G4_t2); 1.401 + 1.402 + // Push a frame since we may do dtrace notification for the 1.403 + // allocation which requires calling out and we don't want 1.404 + // to stomp the real return address. 1.405 + __ save_frame(0); 1.406 + 1.407 + if (id == fast_new_instance_init_check_id) { 1.408 + // make sure the klass is initialized 1.409 + __ ldub(G5_klass, in_bytes(InstanceKlass::init_state_offset()), G3_t1); 1.410 + __ cmp(G3_t1, InstanceKlass::fully_initialized); 1.411 + __ br(Assembler::notEqual, false, Assembler::pn, slow_path); 1.412 + __ delayed()->nop(); 1.413 + } 1.414 +#ifdef ASSERT 1.415 + // assert object can be fast path allocated 1.416 + { 1.417 + Label ok, not_ok; 1.418 + __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); 1.419 + // make sure it's an instance (LH > 0) 1.420 + __ cmp_and_br_short(G1_obj_size, 0, Assembler::lessEqual, Assembler::pn, not_ok); 1.421 + __ btst(Klass::_lh_instance_slow_path_bit, G1_obj_size); 1.422 + __ br(Assembler::zero, false, Assembler::pn, ok); 1.423 + __ delayed()->nop(); 1.424 + __ bind(not_ok); 1.425 + __ stop("assert(can be fast path allocated)"); 1.426 + __ should_not_reach_here(); 1.427 + __ bind(ok); 1.428 + } 1.429 +#endif // ASSERT 1.430 + // if we got here then the TLAB allocation failed, so try 1.431 + // refilling the TLAB or allocating directly from eden. 1.432 + Label retry_tlab, try_eden; 1.433 + __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G5_klass 1.434 + 1.435 + __ bind(retry_tlab); 1.436 + 1.437 + // get the instance size 1.438 + __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); 1.439 + 1.440 + __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path); 1.441 + 1.442 + __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); 1.443 + __ verify_oop(O0_obj); 1.444 + __ mov(O0, I0); 1.445 + __ ret(); 1.446 + __ delayed()->restore(); 1.447 + 1.448 + __ bind(try_eden); 1.449 + // get the instance size 1.450 + __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); 1.451 + __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path); 1.452 + __ incr_allocated_bytes(G1_obj_size, G3_t1, G4_t2); 1.453 + 1.454 + __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); 1.455 + __ verify_oop(O0_obj); 1.456 + __ mov(O0, I0); 1.457 + __ ret(); 1.458 + __ delayed()->restore(); 1.459 + 1.460 + __ bind(slow_path); 1.461 + 1.462 + // pop this frame so generate_stub_call can push it's own 1.463 + __ restore(); 1.464 + } 1.465 + 1.466 + oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_instance), G5_klass); 1.467 + // I0->O0: new instance 1.468 + } 1.469 + 1.470 + break; 1.471 + 1.472 + case counter_overflow_id: 1.473 + // G4 contains bci, G5 contains method 1.474 + oop_maps = generate_stub_call(sasm, noreg, CAST_FROM_FN_PTR(address, counter_overflow), G4, G5); 1.475 + break; 1.476 + 1.477 + case new_type_array_id: 1.478 + case new_object_array_id: 1.479 + { 1.480 + Register G5_klass = G5; // Incoming 1.481 + Register G4_length = G4; // Incoming 1.482 + Register O0_obj = O0; // Outgoing 1.483 + 1.484 + Address klass_lh(G5_klass, Klass::layout_helper_offset()); 1.485 + assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise"); 1.486 + assert(Klass::_lh_header_size_mask == 0xFF, "bytewise"); 1.487 + // Use this offset to pick out an individual byte of the layout_helper: 1.488 + const int klass_lh_header_size_offset = ((BytesPerInt - 1) // 3 - 2 selects byte {0,1,0,0} 1.489 + - Klass::_lh_header_size_shift / BitsPerByte); 1.490 + 1.491 + if (id == new_type_array_id) { 1.492 + __ set_info("new_type_array", dont_gc_arguments); 1.493 + } else { 1.494 + __ set_info("new_object_array", dont_gc_arguments); 1.495 + } 1.496 + 1.497 +#ifdef ASSERT 1.498 + // assert object type is really an array of the proper kind 1.499 + { 1.500 + Label ok; 1.501 + Register G3_t1 = G3; 1.502 + __ ld(klass_lh, G3_t1); 1.503 + __ sra(G3_t1, Klass::_lh_array_tag_shift, G3_t1); 1.504 + int tag = ((id == new_type_array_id) 1.505 + ? Klass::_lh_array_tag_type_value 1.506 + : Klass::_lh_array_tag_obj_value); 1.507 + __ cmp_and_brx_short(G3_t1, tag, Assembler::equal, Assembler::pt, ok); 1.508 + __ stop("assert(is an array klass)"); 1.509 + __ should_not_reach_here(); 1.510 + __ bind(ok); 1.511 + } 1.512 +#endif // ASSERT 1.513 + 1.514 + if (UseTLAB && FastTLABRefill) { 1.515 + Label slow_path; 1.516 + Register G1_arr_size = G1; 1.517 + Register G3_t1 = G3; 1.518 + Register O1_t2 = O1; 1.519 + assert_different_registers(G5_klass, G4_length, G1_arr_size, G3_t1, O1_t2); 1.520 + 1.521 + // check that array length is small enough for fast path 1.522 + __ set(C1_MacroAssembler::max_array_allocation_length, G3_t1); 1.523 + __ cmp(G4_length, G3_t1); 1.524 + __ br(Assembler::greaterUnsigned, false, Assembler::pn, slow_path); 1.525 + __ delayed()->nop(); 1.526 + 1.527 + // if we got here then the TLAB allocation failed, so try 1.528 + // refilling the TLAB or allocating directly from eden. 1.529 + Label retry_tlab, try_eden; 1.530 + __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G4_length and G5_klass 1.531 + 1.532 + __ bind(retry_tlab); 1.533 + 1.534 + // get the allocation size: (length << (layout_helper & 0x1F)) + header_size 1.535 + __ ld(klass_lh, G3_t1); 1.536 + __ sll(G4_length, G3_t1, G1_arr_size); 1.537 + __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1); 1.538 + __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1); 1.539 + __ add(G1_arr_size, G3_t1, G1_arr_size); 1.540 + __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size); // align up 1.541 + __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); 1.542 + 1.543 + __ tlab_allocate(O0_obj, G1_arr_size, 0, G3_t1, slow_path); // preserves G1_arr_size 1.544 + 1.545 + __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); 1.546 + __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset); 1.547 + __ sub(G1_arr_size, G3_t1, O1_t2); // body length 1.548 + __ add(O0_obj, G3_t1, G3_t1); // body start 1.549 + __ initialize_body(G3_t1, O1_t2); 1.550 + __ verify_oop(O0_obj); 1.551 + __ retl(); 1.552 + __ delayed()->nop(); 1.553 + 1.554 + __ bind(try_eden); 1.555 + // get the allocation size: (length << (layout_helper & 0x1F)) + header_size 1.556 + __ ld(klass_lh, G3_t1); 1.557 + __ sll(G4_length, G3_t1, G1_arr_size); 1.558 + __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1); 1.559 + __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1); 1.560 + __ add(G1_arr_size, G3_t1, G1_arr_size); 1.561 + __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size); 1.562 + __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); 1.563 + 1.564 + __ eden_allocate(O0_obj, G1_arr_size, 0, G3_t1, O1_t2, slow_path); // preserves G1_arr_size 1.565 + __ incr_allocated_bytes(G1_arr_size, G3_t1, O1_t2); 1.566 + 1.567 + __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); 1.568 + __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset); 1.569 + __ sub(G1_arr_size, G3_t1, O1_t2); // body length 1.570 + __ add(O0_obj, G3_t1, G3_t1); // body start 1.571 + __ initialize_body(G3_t1, O1_t2); 1.572 + __ verify_oop(O0_obj); 1.573 + __ retl(); 1.574 + __ delayed()->nop(); 1.575 + 1.576 + __ bind(slow_path); 1.577 + } 1.578 + 1.579 + if (id == new_type_array_id) { 1.580 + oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_type_array), G5_klass, G4_length); 1.581 + } else { 1.582 + oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_object_array), G5_klass, G4_length); 1.583 + } 1.584 + // I0 -> O0: new array 1.585 + } 1.586 + break; 1.587 + 1.588 + case new_multi_array_id: 1.589 + { // O0: klass 1.590 + // O1: rank 1.591 + // O2: address of 1st dimension 1.592 + __ set_info("new_multi_array", dont_gc_arguments); 1.593 + oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_multi_array), I0, I1, I2); 1.594 + // I0 -> O0: new multi array 1.595 + } 1.596 + break; 1.597 + 1.598 + case register_finalizer_id: 1.599 + { 1.600 + __ set_info("register_finalizer", dont_gc_arguments); 1.601 + 1.602 + // load the klass and check the has finalizer flag 1.603 + Label register_finalizer; 1.604 + Register t = O1; 1.605 + __ load_klass(O0, t); 1.606 + __ ld(t, in_bytes(Klass::access_flags_offset()), t); 1.607 + __ set(JVM_ACC_HAS_FINALIZER, G3); 1.608 + __ andcc(G3, t, G0); 1.609 + __ br(Assembler::notZero, false, Assembler::pt, register_finalizer); 1.610 + __ delayed()->nop(); 1.611 + 1.612 + // do a leaf return 1.613 + __ retl(); 1.614 + __ delayed()->nop(); 1.615 + 1.616 + __ bind(register_finalizer); 1.617 + OopMap* oop_map = save_live_registers(sasm); 1.618 + int call_offset = __ call_RT(noreg, noreg, 1.619 + CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), I0); 1.620 + oop_maps = new OopMapSet(); 1.621 + oop_maps->add_gc_map(call_offset, oop_map); 1.622 + 1.623 + // Now restore all the live registers 1.624 + restore_live_registers(sasm); 1.625 + 1.626 + __ ret(); 1.627 + __ delayed()->restore(); 1.628 + } 1.629 + break; 1.630 + 1.631 + case throw_range_check_failed_id: 1.632 + { __ set_info("range_check_failed", dont_gc_arguments); // arguments will be discarded 1.633 + // G4: index 1.634 + oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); 1.635 + } 1.636 + break; 1.637 + 1.638 + case throw_index_exception_id: 1.639 + { __ set_info("index_range_check_failed", dont_gc_arguments); // arguments will be discarded 1.640 + // G4: index 1.641 + oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); 1.642 + } 1.643 + break; 1.644 + 1.645 + case throw_div0_exception_id: 1.646 + { __ set_info("throw_div0_exception", dont_gc_arguments); 1.647 + oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); 1.648 + } 1.649 + break; 1.650 + 1.651 + case throw_null_pointer_exception_id: 1.652 + { __ set_info("throw_null_pointer_exception", dont_gc_arguments); 1.653 + oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); 1.654 + } 1.655 + break; 1.656 + 1.657 + case handle_exception_id: 1.658 + { __ set_info("handle_exception", dont_gc_arguments); 1.659 + oop_maps = generate_handle_exception(id, sasm); 1.660 + } 1.661 + break; 1.662 + 1.663 + case handle_exception_from_callee_id: 1.664 + { __ set_info("handle_exception_from_callee", dont_gc_arguments); 1.665 + oop_maps = generate_handle_exception(id, sasm); 1.666 + } 1.667 + break; 1.668 + 1.669 + case unwind_exception_id: 1.670 + { 1.671 + // O0: exception 1.672 + // I7: address of call to this method 1.673 + 1.674 + __ set_info("unwind_exception", dont_gc_arguments); 1.675 + __ mov(Oexception, Oexception->after_save()); 1.676 + __ add(I7, frame::pc_return_offset, Oissuing_pc->after_save()); 1.677 + 1.678 + __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), 1.679 + G2_thread, Oissuing_pc->after_save()); 1.680 + __ verify_not_null_oop(Oexception->after_save()); 1.681 + 1.682 + // Restore SP from L7 if the exception PC is a method handle call site. 1.683 + __ mov(O0, G5); // Save the target address. 1.684 + __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), L0); 1.685 + __ tst(L0); // Condition codes are preserved over the restore. 1.686 + __ restore(); 1.687 + 1.688 + __ jmp(G5, 0); 1.689 + __ delayed()->movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP); // Restore SP if required. 1.690 + } 1.691 + break; 1.692 + 1.693 + case throw_array_store_exception_id: 1.694 + { 1.695 + __ set_info("throw_array_store_exception", dont_gc_arguments); 1.696 + oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true); 1.697 + } 1.698 + break; 1.699 + 1.700 + case throw_class_cast_exception_id: 1.701 + { 1.702 + // G4: object 1.703 + __ set_info("throw_class_cast_exception", dont_gc_arguments); 1.704 + oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); 1.705 + } 1.706 + break; 1.707 + 1.708 + case throw_incompatible_class_change_error_id: 1.709 + { 1.710 + __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments); 1.711 + oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); 1.712 + } 1.713 + break; 1.714 + 1.715 + case slow_subtype_check_id: 1.716 + { // Support for uint StubRoutine::partial_subtype_check( Klass sub, Klass super ); 1.717 + // Arguments : 1.718 + // 1.719 + // ret : G3 1.720 + // sub : G3, argument, destroyed 1.721 + // super: G1, argument, not changed 1.722 + // raddr: O7, blown by call 1.723 + Label miss; 1.724 + 1.725 + __ save_frame(0); // Blow no registers! 1.726 + 1.727 + __ check_klass_subtype_slow_path(G3, G1, L0, L1, L2, L4, NULL, &miss); 1.728 + 1.729 + __ mov(1, G3); 1.730 + __ ret(); // Result in G5 is 'true' 1.731 + __ delayed()->restore(); // free copy or add can go here 1.732 + 1.733 + __ bind(miss); 1.734 + __ mov(0, G3); 1.735 + __ ret(); // Result in G5 is 'false' 1.736 + __ delayed()->restore(); // free copy or add can go here 1.737 + } 1.738 + 1.739 + case monitorenter_nofpu_id: 1.740 + case monitorenter_id: 1.741 + { // G4: object 1.742 + // G5: lock address 1.743 + __ set_info("monitorenter", dont_gc_arguments); 1.744 + 1.745 + int save_fpu_registers = (id == monitorenter_id); 1.746 + // make a frame and preserve the caller's caller-save registers 1.747 + OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); 1.748 + 1.749 + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), G4, G5); 1.750 + 1.751 + oop_maps = new OopMapSet(); 1.752 + oop_maps->add_gc_map(call_offset, oop_map); 1.753 + restore_live_registers(sasm, save_fpu_registers); 1.754 + 1.755 + __ ret(); 1.756 + __ delayed()->restore(); 1.757 + } 1.758 + break; 1.759 + 1.760 + case monitorexit_nofpu_id: 1.761 + case monitorexit_id: 1.762 + { // G4: lock address 1.763 + // note: really a leaf routine but must setup last java sp 1.764 + // => use call_RT for now (speed can be improved by 1.765 + // doing last java sp setup manually) 1.766 + __ set_info("monitorexit", dont_gc_arguments); 1.767 + 1.768 + int save_fpu_registers = (id == monitorexit_id); 1.769 + // make a frame and preserve the caller's caller-save registers 1.770 + OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); 1.771 + 1.772 + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), G4); 1.773 + 1.774 + oop_maps = new OopMapSet(); 1.775 + oop_maps->add_gc_map(call_offset, oop_map); 1.776 + restore_live_registers(sasm, save_fpu_registers); 1.777 + 1.778 + __ ret(); 1.779 + __ delayed()->restore(); 1.780 + } 1.781 + break; 1.782 + 1.783 + case deoptimize_id: 1.784 + { 1.785 + __ set_info("deoptimize", dont_gc_arguments); 1.786 + OopMap* oop_map = save_live_registers(sasm); 1.787 + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, deoptimize)); 1.788 + oop_maps = new OopMapSet(); 1.789 + oop_maps->add_gc_map(call_offset, oop_map); 1.790 + restore_live_registers(sasm); 1.791 + DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 1.792 + assert(deopt_blob != NULL, "deoptimization blob must have been created"); 1.793 + AddressLiteral dest(deopt_blob->unpack_with_reexecution()); 1.794 + __ jump_to(dest, O0); 1.795 + __ delayed()->restore(); 1.796 + } 1.797 + break; 1.798 + 1.799 + case access_field_patching_id: 1.800 + { __ set_info("access_field_patching", dont_gc_arguments); 1.801 + oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); 1.802 + } 1.803 + break; 1.804 + 1.805 + case load_klass_patching_id: 1.806 + { __ set_info("load_klass_patching", dont_gc_arguments); 1.807 + oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); 1.808 + } 1.809 + break; 1.810 + 1.811 + case load_mirror_patching_id: 1.812 + { __ set_info("load_mirror_patching", dont_gc_arguments); 1.813 + oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); 1.814 + } 1.815 + break; 1.816 + 1.817 + case load_appendix_patching_id: 1.818 + { __ set_info("load_appendix_patching", dont_gc_arguments); 1.819 + oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); 1.820 + } 1.821 + break; 1.822 + 1.823 + case dtrace_object_alloc_id: 1.824 + { // O0: object 1.825 + __ set_info("dtrace_object_alloc", dont_gc_arguments); 1.826 + // we can't gc here so skip the oopmap but make sure that all 1.827 + // the live registers get saved. 1.828 + save_live_registers(sasm); 1.829 + 1.830 + __ save_thread(L7_thread_cache); 1.831 + __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), 1.832 + relocInfo::runtime_call_type); 1.833 + __ delayed()->mov(I0, O0); 1.834 + __ restore_thread(L7_thread_cache); 1.835 + 1.836 + restore_live_registers(sasm); 1.837 + __ ret(); 1.838 + __ delayed()->restore(); 1.839 + } 1.840 + break; 1.841 + 1.842 +#if INCLUDE_ALL_GCS 1.843 + case g1_pre_barrier_slow_id: 1.844 + { // G4: previous value of memory 1.845 + BarrierSet* bs = Universe::heap()->barrier_set(); 1.846 + if (bs->kind() != BarrierSet::G1SATBCTLogging) { 1.847 + __ save_frame(0); 1.848 + __ set((int)id, O1); 1.849 + __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), I0); 1.850 + __ should_not_reach_here(); 1.851 + break; 1.852 + } 1.853 + 1.854 + __ set_info("g1_pre_barrier_slow_id", dont_gc_arguments); 1.855 + 1.856 + Register pre_val = G4; 1.857 + Register tmp = G1_scratch; 1.858 + Register tmp2 = G3_scratch; 1.859 + 1.860 + Label refill, restart; 1.861 + bool with_frame = false; // I don't know if we can do with-frame. 1.862 + int satb_q_index_byte_offset = 1.863 + in_bytes(JavaThread::satb_mark_queue_offset() + 1.864 + PtrQueue::byte_offset_of_index()); 1.865 + int satb_q_buf_byte_offset = 1.866 + in_bytes(JavaThread::satb_mark_queue_offset() + 1.867 + PtrQueue::byte_offset_of_buf()); 1.868 + 1.869 + __ bind(restart); 1.870 + // Load the index into the SATB buffer. PtrQueue::_index is a 1.871 + // size_t so ld_ptr is appropriate 1.872 + __ ld_ptr(G2_thread, satb_q_index_byte_offset, tmp); 1.873 + 1.874 + // index == 0? 1.875 + __ cmp_and_brx_short(tmp, G0, Assembler::equal, Assembler::pn, refill); 1.876 + 1.877 + __ ld_ptr(G2_thread, satb_q_buf_byte_offset, tmp2); 1.878 + __ sub(tmp, oopSize, tmp); 1.879 + 1.880 + __ st_ptr(pre_val, tmp2, tmp); // [_buf + index] := <address_of_card> 1.881 + // Use return-from-leaf 1.882 + __ retl(); 1.883 + __ delayed()->st_ptr(tmp, G2_thread, satb_q_index_byte_offset); 1.884 + 1.885 + __ bind(refill); 1.886 + __ save_frame(0); 1.887 + 1.888 + __ mov(pre_val, L0); 1.889 + __ mov(tmp, L1); 1.890 + __ mov(tmp2, L2); 1.891 + 1.892 + __ call_VM_leaf(L7_thread_cache, 1.893 + CAST_FROM_FN_PTR(address, 1.894 + SATBMarkQueueSet::handle_zero_index_for_thread), 1.895 + G2_thread); 1.896 + 1.897 + __ mov(L0, pre_val); 1.898 + __ mov(L1, tmp); 1.899 + __ mov(L2, tmp2); 1.900 + 1.901 + __ br(Assembler::always, /*annul*/false, Assembler::pt, restart); 1.902 + __ delayed()->restore(); 1.903 + } 1.904 + break; 1.905 + 1.906 + case g1_post_barrier_slow_id: 1.907 + { 1.908 + BarrierSet* bs = Universe::heap()->barrier_set(); 1.909 + if (bs->kind() != BarrierSet::G1SATBCTLogging) { 1.910 + __ save_frame(0); 1.911 + __ set((int)id, O1); 1.912 + __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), I0); 1.913 + __ should_not_reach_here(); 1.914 + break; 1.915 + } 1.916 + 1.917 + __ set_info("g1_post_barrier_slow_id", dont_gc_arguments); 1.918 + 1.919 + Register addr = G4; 1.920 + Register cardtable = G5; 1.921 + Register tmp = G1_scratch; 1.922 + Register tmp2 = G3_scratch; 1.923 + jbyte* byte_map_base = ((CardTableModRefBS*)bs)->byte_map_base; 1.924 + 1.925 + Label not_already_dirty, restart, refill, young_card; 1.926 + 1.927 +#ifdef _LP64 1.928 + __ srlx(addr, CardTableModRefBS::card_shift, addr); 1.929 +#else 1.930 + __ srl(addr, CardTableModRefBS::card_shift, addr); 1.931 +#endif 1.932 + 1.933 + AddressLiteral rs(byte_map_base); 1.934 + __ set(rs, cardtable); // cardtable := <card table base> 1.935 + __ ldub(addr, cardtable, tmp); // tmp := [addr + cardtable] 1.936 + 1.937 + __ cmp_and_br_short(tmp, G1SATBCardTableModRefBS::g1_young_card_val(), Assembler::equal, Assembler::pt, young_card); 1.938 + 1.939 + __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); 1.940 + __ ldub(addr, cardtable, tmp); // tmp := [addr + cardtable] 1.941 + 1.942 + assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code"); 1.943 + __ cmp_and_br_short(tmp, G0, Assembler::notEqual, Assembler::pt, not_already_dirty); 1.944 + 1.945 + __ bind(young_card); 1.946 + // We didn't take the branch, so we're already dirty: return. 1.947 + // Use return-from-leaf 1.948 + __ retl(); 1.949 + __ delayed()->nop(); 1.950 + 1.951 + // Not dirty. 1.952 + __ bind(not_already_dirty); 1.953 + 1.954 + // Get cardtable + tmp into a reg by itself 1.955 + __ add(addr, cardtable, tmp2); 1.956 + 1.957 + // First, dirty it. 1.958 + __ stb(G0, tmp2, 0); // [cardPtr] := 0 (i.e., dirty). 1.959 + 1.960 + Register tmp3 = cardtable; 1.961 + Register tmp4 = tmp; 1.962 + 1.963 + // these registers are now dead 1.964 + addr = cardtable = tmp = noreg; 1.965 + 1.966 + int dirty_card_q_index_byte_offset = 1.967 + in_bytes(JavaThread::dirty_card_queue_offset() + 1.968 + PtrQueue::byte_offset_of_index()); 1.969 + int dirty_card_q_buf_byte_offset = 1.970 + in_bytes(JavaThread::dirty_card_queue_offset() + 1.971 + PtrQueue::byte_offset_of_buf()); 1.972 + 1.973 + __ bind(restart); 1.974 + 1.975 + // Get the index into the update buffer. PtrQueue::_index is 1.976 + // a size_t so ld_ptr is appropriate here. 1.977 + __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, tmp3); 1.978 + 1.979 + // index == 0? 1.980 + __ cmp_and_brx_short(tmp3, G0, Assembler::equal, Assembler::pn, refill); 1.981 + 1.982 + __ ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, tmp4); 1.983 + __ sub(tmp3, oopSize, tmp3); 1.984 + 1.985 + __ st_ptr(tmp2, tmp4, tmp3); // [_buf + index] := <address_of_card> 1.986 + // Use return-from-leaf 1.987 + __ retl(); 1.988 + __ delayed()->st_ptr(tmp3, G2_thread, dirty_card_q_index_byte_offset); 1.989 + 1.990 + __ bind(refill); 1.991 + __ save_frame(0); 1.992 + 1.993 + __ mov(tmp2, L0); 1.994 + __ mov(tmp3, L1); 1.995 + __ mov(tmp4, L2); 1.996 + 1.997 + __ call_VM_leaf(L7_thread_cache, 1.998 + CAST_FROM_FN_PTR(address, 1.999 + DirtyCardQueueSet::handle_zero_index_for_thread), 1.1000 + G2_thread); 1.1001 + 1.1002 + __ mov(L0, tmp2); 1.1003 + __ mov(L1, tmp3); 1.1004 + __ mov(L2, tmp4); 1.1005 + 1.1006 + __ br(Assembler::always, /*annul*/false, Assembler::pt, restart); 1.1007 + __ delayed()->restore(); 1.1008 + } 1.1009 + break; 1.1010 +#endif // INCLUDE_ALL_GCS 1.1011 + 1.1012 + case predicate_failed_trap_id: 1.1013 + { 1.1014 + __ set_info("predicate_failed_trap", dont_gc_arguments); 1.1015 + OopMap* oop_map = save_live_registers(sasm); 1.1016 + 1.1017 + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); 1.1018 + 1.1019 + oop_maps = new OopMapSet(); 1.1020 + oop_maps->add_gc_map(call_offset, oop_map); 1.1021 + 1.1022 + DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); 1.1023 + assert(deopt_blob != NULL, "deoptimization blob must have been created"); 1.1024 + restore_live_registers(sasm); 1.1025 + 1.1026 + AddressLiteral dest(deopt_blob->unpack_with_reexecution()); 1.1027 + __ jump_to(dest, O0); 1.1028 + __ delayed()->restore(); 1.1029 + } 1.1030 + break; 1.1031 + 1.1032 + default: 1.1033 + { __ set_info("unimplemented entry", dont_gc_arguments); 1.1034 + __ save_frame(0); 1.1035 + __ set((int)id, O1); 1.1036 + __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), O1); 1.1037 + __ should_not_reach_here(); 1.1038 + } 1.1039 + break; 1.1040 + } 1.1041 + return oop_maps; 1.1042 +} 1.1043 + 1.1044 + 1.1045 +OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { 1.1046 + __ block_comment("generate_handle_exception"); 1.1047 + 1.1048 + // Save registers, if required. 1.1049 + OopMapSet* oop_maps = new OopMapSet(); 1.1050 + OopMap* oop_map = NULL; 1.1051 + switch (id) { 1.1052 + case forward_exception_id: 1.1053 + // We're handling an exception in the context of a compiled frame. 1.1054 + // The registers have been saved in the standard places. Perform 1.1055 + // an exception lookup in the caller and dispatch to the handler 1.1056 + // if found. Otherwise unwind and dispatch to the callers 1.1057 + // exception handler. 1.1058 + oop_map = generate_oop_map(sasm, true); 1.1059 + 1.1060 + // transfer the pending exception to the exception_oop 1.1061 + __ ld_ptr(G2_thread, in_bytes(JavaThread::pending_exception_offset()), Oexception); 1.1062 + __ ld_ptr(Oexception, 0, G0); 1.1063 + __ st_ptr(G0, G2_thread, in_bytes(JavaThread::pending_exception_offset())); 1.1064 + __ add(I7, frame::pc_return_offset, Oissuing_pc); 1.1065 + break; 1.1066 + case handle_exception_id: 1.1067 + // At this point all registers MAY be live. 1.1068 + oop_map = save_live_registers(sasm); 1.1069 + __ mov(Oexception->after_save(), Oexception); 1.1070 + __ mov(Oissuing_pc->after_save(), Oissuing_pc); 1.1071 + break; 1.1072 + case handle_exception_from_callee_id: 1.1073 + // At this point all registers except exception oop (Oexception) 1.1074 + // and exception pc (Oissuing_pc) are dead. 1.1075 + oop_map = new OopMap(frame_size_in_bytes / sizeof(jint), 0); 1.1076 + sasm->set_frame_size(frame_size_in_bytes / BytesPerWord); 1.1077 + __ save_frame_c1(frame_size_in_bytes); 1.1078 + __ mov(Oexception->after_save(), Oexception); 1.1079 + __ mov(Oissuing_pc->after_save(), Oissuing_pc); 1.1080 + break; 1.1081 + default: ShouldNotReachHere(); 1.1082 + } 1.1083 + 1.1084 + __ verify_not_null_oop(Oexception); 1.1085 + 1.1086 +#ifdef ASSERT 1.1087 + // check that fields in JavaThread for exception oop and issuing pc are 1.1088 + // empty before writing to them 1.1089 + Label oop_empty; 1.1090 + Register scratch = I7; // We can use I7 here because it's overwritten later anyway. 1.1091 + __ ld_ptr(Address(G2_thread, JavaThread::exception_oop_offset()), scratch); 1.1092 + __ br_null(scratch, false, Assembler::pt, oop_empty); 1.1093 + __ delayed()->nop(); 1.1094 + __ stop("exception oop already set"); 1.1095 + __ bind(oop_empty); 1.1096 + 1.1097 + Label pc_empty; 1.1098 + __ ld_ptr(Address(G2_thread, JavaThread::exception_pc_offset()), scratch); 1.1099 + __ br_null(scratch, false, Assembler::pt, pc_empty); 1.1100 + __ delayed()->nop(); 1.1101 + __ stop("exception pc already set"); 1.1102 + __ bind(pc_empty); 1.1103 +#endif 1.1104 + 1.1105 + // save the exception and issuing pc in the thread 1.1106 + __ st_ptr(Oexception, G2_thread, in_bytes(JavaThread::exception_oop_offset())); 1.1107 + __ st_ptr(Oissuing_pc, G2_thread, in_bytes(JavaThread::exception_pc_offset())); 1.1108 + 1.1109 + // use the throwing pc as the return address to lookup (has bci & oop map) 1.1110 + __ mov(Oissuing_pc, I7); 1.1111 + __ sub(I7, frame::pc_return_offset, I7); 1.1112 + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc)); 1.1113 + oop_maps->add_gc_map(call_offset, oop_map); 1.1114 + 1.1115 + // Note: if nmethod has been deoptimized then regardless of 1.1116 + // whether it had a handler or not we will deoptimize 1.1117 + // by entering the deopt blob with a pending exception. 1.1118 + 1.1119 + // Restore the registers that were saved at the beginning, remove 1.1120 + // the frame and jump to the exception handler. 1.1121 + switch (id) { 1.1122 + case forward_exception_id: 1.1123 + case handle_exception_id: 1.1124 + restore_live_registers(sasm); 1.1125 + __ jmp(O0, 0); 1.1126 + __ delayed()->restore(); 1.1127 + break; 1.1128 + case handle_exception_from_callee_id: 1.1129 + // Restore SP from L7 if the exception PC is a method handle call site. 1.1130 + __ mov(O0, G5); // Save the target address. 1.1131 + __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), L0); 1.1132 + __ tst(L0); // Condition codes are preserved over the restore. 1.1133 + __ restore(); 1.1134 + 1.1135 + __ jmp(G5, 0); // jump to the exception handler 1.1136 + __ delayed()->movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP); // Restore SP if required. 1.1137 + break; 1.1138 + default: ShouldNotReachHere(); 1.1139 + } 1.1140 + 1.1141 + return oop_maps; 1.1142 +} 1.1143 + 1.1144 + 1.1145 +#undef __ 1.1146 + 1.1147 +const char *Runtime1::pd_name_for_address(address entry) { 1.1148 + return "<unknown function>"; 1.1149 +}