annotate src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp @ 50643:2f79462aab9b

8201593: Print array length in ArrayIndexOutOfBoundsException. Reviewed-by: dholmes, mdoerr, smonteith, shade, rriggs
author goetz
date Mon, 07 May 2018 09:11:21 +0200
parents 4bb58f644e4e
children f6641fcf7b7e
rev   line source
duke@1 1 /*
eosterlund@49812 2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #include "precompiled.hpp"
stefank@7397 26 #include "c1/c1_CodeStubs.hpp"
stefank@7397 27 #include "c1/c1_FrameMap.hpp"
stefank@7397 28 #include "c1/c1_LIRAssembler.hpp"
stefank@7397 29 #include "c1/c1_MacroAssembler.hpp"
stefank@7397 30 #include "c1/c1_Runtime1.hpp"
stefank@7397 31 #include "nativeInst_x86.hpp"
stefank@7397 32 #include "runtime/sharedRuntime.hpp"
stefank@46625 33 #include "utilities/align.hpp"
jprovino@15482 34 #include "utilities/macros.hpp"
stefank@7397 35 #include "vmreg_x86.inline.hpp"
duke@1 36
duke@1 37
duke@1 38 #define __ ce->masm()->
duke@1 39
duke@1 40 float ConversionStub::float_zero = 0.0;
duke@1 41 double ConversionStub::double_zero = 0.0;
duke@1 42
duke@1 43 void ConversionStub::emit_code(LIR_Assembler* ce) {
duke@1 44 __ bind(_entry);
duke@1 45 assert(bytecode() == Bytecodes::_f2i || bytecode() == Bytecodes::_d2i, "other conversions do not require stub");
duke@1 46
duke@1 47
duke@1 48 if (input()->is_single_xmm()) {
duke@1 49 __ comiss(input()->as_xmm_float_reg(),
duke@1 50 ExternalAddress((address)&float_zero));
duke@1 51 } else if (input()->is_double_xmm()) {
duke@1 52 __ comisd(input()->as_xmm_double_reg(),
duke@1 53 ExternalAddress((address)&double_zero));
duke@1 54 } else {
never@1066 55 LP64_ONLY(ShouldNotReachHere());
never@1066 56 __ push(rax);
duke@1 57 __ ftst();
duke@1 58 __ fnstsw_ax();
duke@1 59 __ sahf();
never@1066 60 __ pop(rax);
duke@1 61 }
duke@1 62
duke@1 63 Label NaN, do_return;
duke@1 64 __ jccb(Assembler::parity, NaN);
duke@1 65 __ jccb(Assembler::below, do_return);
duke@1 66
duke@1 67 // input is > 0 -> return maxInt
duke@1 68 // result register already contains 0x80000000, so subtracting 1 gives 0x7fffffff
duke@1 69 __ decrement(result()->as_register());
duke@1 70 __ jmpb(do_return);
duke@1 71
duke@1 72 // input is NaN -> return 0
duke@1 73 __ bind(NaN);
never@1066 74 __ xorptr(result()->as_register(), result()->as_register());
duke@1 75
duke@1 76 __ bind(do_return);
duke@1 77 __ jmp(_continuation);
duke@1 78 }
duke@1 79
duke@1 80 void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
duke@1 81 __ bind(_entry);
mdoerr@34200 82 Metadata *m = _method->as_constant_ptr()->as_metadata();
mdoerr@34200 83 ce->store_parameter(m, 1);
duke@1 84 ce->store_parameter(_bci, 0);
duke@1 85 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id)));
duke@1 86 ce->add_call_info_here(_info);
duke@1 87 ce->verify_oop_map(_info);
duke@1 88 __ jmp(_continuation);
duke@1 89 }
duke@1 90
goetz@50643 91 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
goetz@50643 92 : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) {
roland@6745 93 assert(info != NULL, "must have info");
roland@6745 94 _info = new CodeEmitInfo(info);
duke@1 95 }
duke@1 96
goetz@50643 97 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
goetz@50643 98 : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) {
goetz@50643 99 assert(info != NULL, "must have info");
goetz@50643 100 _info = new CodeEmitInfo(info);
goetz@50643 101 }
duke@1 102
duke@1 103 void RangeCheckStub::emit_code(LIR_Assembler* ce) {
duke@1 104 __ bind(_entry);
roland@16611 105 if (_info->deoptimize_on_exception()) {
roland@16611 106 address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
roland@16611 107 __ call(RuntimeAddress(a));
roland@16611 108 ce->add_call_info_here(_info);
roland@16611 109 ce->verify_oop_map(_info);
roland@16611 110 debug_only(__ should_not_reach_here());
roland@16611 111 return;
roland@16611 112 }
roland@16611 113
duke@1 114 // pass the array index on stack because all registers must be preserved
duke@1 115 if (_index->is_cpu_register()) {
duke@1 116 ce->store_parameter(_index->as_register(), 0);
duke@1 117 } else {
duke@1 118 ce->store_parameter(_index->as_jint(), 0);
duke@1 119 }
duke@1 120 Runtime1::StubID stub_id;
duke@1 121 if (_throw_index_out_of_bounds_exception) {
duke@1 122 stub_id = Runtime1::throw_index_exception_id;
duke@1 123 } else {
duke@1 124 stub_id = Runtime1::throw_range_check_failed_id;
goetz@50643 125 ce->store_parameter(_array->as_pointer_register(), 1);
duke@1 126 }
duke@1 127 __ call(RuntimeAddress(Runtime1::entry_for(stub_id)));
duke@1 128 ce->add_call_info_here(_info);
roland@16611 129 ce->verify_oop_map(_info);
duke@1 130 debug_only(__ should_not_reach_here());
duke@1 131 }
duke@1 132
roland@16611 133 PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) {
roland@16611 134 _info = new CodeEmitInfo(info);
roland@16611 135 }
roland@16611 136
roland@16611 137 void PredicateFailedStub::emit_code(LIR_Assembler* ce) {
roland@16611 138 __ bind(_entry);
roland@16611 139 address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
roland@16611 140 __ call(RuntimeAddress(a));
roland@16611 141 ce->add_call_info_here(_info);
roland@16611 142 ce->verify_oop_map(_info);
roland@16611 143 debug_only(__ should_not_reach_here());
roland@16611 144 }
duke@1 145
duke@1 146 void DivByZeroStub::emit_code(LIR_Assembler* ce) {
duke@1 147 if (_offset != -1) {
duke@1 148 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
duke@1 149 }
duke@1 150 __ bind(_entry);
duke@1 151 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_div0_exception_id)));
duke@1 152 ce->add_call_info_here(_info);
duke@1 153 debug_only(__ should_not_reach_here());
duke@1 154 }
duke@1 155
duke@1 156
duke@1 157 // Implementation of NewInstanceStub
duke@1 158
duke@1 159 NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) {
duke@1 160 _result = result;
duke@1 161 _klass = klass;
duke@1 162 _klass_reg = klass_reg;
duke@1 163 _info = new CodeEmitInfo(info);
duke@1 164 assert(stub_id == Runtime1::new_instance_id ||
duke@1 165 stub_id == Runtime1::fast_new_instance_id ||
duke@1 166 stub_id == Runtime1::fast_new_instance_init_check_id,
duke@1 167 "need new_instance id");
duke@1 168 _stub_id = stub_id;
duke@1 169 }
duke@1 170
duke@1 171
duke@1 172 void NewInstanceStub::emit_code(LIR_Assembler* ce) {
duke@1 173 assert(__ rsp_offset() == 0, "frame size should be fixed");
duke@1 174 __ bind(_entry);
never@1066 175 __ movptr(rdx, _klass_reg->as_register());
duke@1 176 __ call(RuntimeAddress(Runtime1::entry_for(_stub_id)));
duke@1 177 ce->add_call_info_here(_info);
duke@1 178 ce->verify_oop_map(_info);
duke@1 179 assert(_result->as_register() == rax, "result must in rax,");
duke@1 180 __ jmp(_continuation);
duke@1 181 }
duke@1 182
duke@1 183
duke@1 184 // Implementation of NewTypeArrayStub
duke@1 185
duke@1 186 NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
duke@1 187 _klass_reg = klass_reg;
duke@1 188 _length = length;
duke@1 189 _result = result;
duke@1 190 _info = new CodeEmitInfo(info);
duke@1 191 }
duke@1 192
duke@1 193
duke@1 194 void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
duke@1 195 assert(__ rsp_offset() == 0, "frame size should be fixed");
duke@1 196 __ bind(_entry);
duke@1 197 assert(_length->as_register() == rbx, "length must in rbx,");
duke@1 198 assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
duke@1 199 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id)));
duke@1 200 ce->add_call_info_here(_info);
duke@1 201 ce->verify_oop_map(_info);
duke@1 202 assert(_result->as_register() == rax, "result must in rax,");
duke@1 203 __ jmp(_continuation);
duke@1 204 }
duke@1 205
duke@1 206
duke@1 207 // Implementation of NewObjectArrayStub
duke@1 208
duke@1 209 NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
duke@1 210 _klass_reg = klass_reg;
duke@1 211 _result = result;
duke@1 212 _length = length;
duke@1 213 _info = new CodeEmitInfo(info);
duke@1 214 }
duke@1 215
duke@1 216
duke@1 217 void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
duke@1 218 assert(__ rsp_offset() == 0, "frame size should be fixed");
duke@1 219 __ bind(_entry);
duke@1 220 assert(_length->as_register() == rbx, "length must in rbx,");
duke@1 221 assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
duke@1 222 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id)));
duke@1 223 ce->add_call_info_here(_info);
duke@1 224 ce->verify_oop_map(_info);
duke@1 225 assert(_result->as_register() == rax, "result must in rax,");
duke@1 226 __ jmp(_continuation);
duke@1 227 }
duke@1 228
duke@1 229
duke@1 230 // Implementation of MonitorAccessStubs
duke@1 231
duke@1 232 MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
duke@1 233 : MonitorAccessStub(obj_reg, lock_reg)
duke@1 234 {
duke@1 235 _info = new CodeEmitInfo(info);
duke@1 236 }
duke@1 237
duke@1 238
duke@1 239 void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
duke@1 240 assert(__ rsp_offset() == 0, "frame size should be fixed");
duke@1 241 __ bind(_entry);
duke@1 242 ce->store_parameter(_obj_reg->as_register(), 1);
duke@1 243 ce->store_parameter(_lock_reg->as_register(), 0);
duke@1 244 Runtime1::StubID enter_id;
duke@1 245 if (ce->compilation()->has_fpu_code()) {
duke@1 246 enter_id = Runtime1::monitorenter_id;
duke@1 247 } else {
duke@1 248 enter_id = Runtime1::monitorenter_nofpu_id;
duke@1 249 }
duke@1 250 __ call(RuntimeAddress(Runtime1::entry_for(enter_id)));
duke@1 251 ce->add_call_info_here(_info);
duke@1 252 ce->verify_oop_map(_info);
duke@1 253 __ jmp(_continuation);
duke@1 254 }
duke@1 255
duke@1 256
duke@1 257 void MonitorExitStub::emit_code(LIR_Assembler* ce) {
duke@1 258 __ bind(_entry);
duke@1 259 if (_compute_lock) {
duke@1 260 // lock_reg was destroyed by fast unlocking attempt => recompute it
duke@1 261 ce->monitor_address(_monitor_ix, _lock_reg);
duke@1 262 }
duke@1 263 ce->store_parameter(_lock_reg->as_register(), 0);
duke@1 264 // note: non-blocking leaf routine => no call info needed
duke@1 265 Runtime1::StubID exit_id;
duke@1 266 if (ce->compilation()->has_fpu_code()) {
duke@1 267 exit_id = Runtime1::monitorexit_id;
duke@1 268 } else {
duke@1 269 exit_id = Runtime1::monitorexit_nofpu_id;
duke@1 270 }
duke@1 271 __ call(RuntimeAddress(Runtime1::entry_for(exit_id)));
duke@1 272 __ jmp(_continuation);
duke@1 273 }
duke@1 274
duke@1 275
duke@1 276 // Implementation of patching:
duke@1 277 // - Copy the code at given offset to an inlined buffer (first the bytes, then the number of bytes)
duke@1 278 // - Replace original code with a call to the stub
duke@1 279 // At Runtime:
duke@1 280 // - call to stub, jump to runtime
duke@1 281 // - in runtime: preserve all registers (rspecially objects, i.e., source and destination object)
duke@1 282 // - in runtime: after initializing class, restore original code, reexecute instruction
duke@1 283
duke@1 284 int PatchingStub::_patch_info_offset = -NativeGeneralJump::instruction_size;
duke@1 285
duke@1 286 void PatchingStub::align_patch_site(MacroAssembler* masm) {
duke@1 287 // We're patching a 5-7 byte instruction on intel and we need to
duke@1 288 // make sure that we don't see a piece of the instruction. It
duke@1 289 // appears mostly impossible on Intel to simply invalidate other
duke@1 290 // processors caches and since they may do aggressive prefetch it's
duke@1 291 // very hard to make a guess about what code might be in the icache.
duke@1 292 // Force the instruction to be double word aligned so that it
duke@1 293 // doesn't span a cache line.
stefank@46620 294 masm->align(align_up((int)NativeGeneralJump::instruction_size, wordSize));
duke@1 295 }
duke@1 296
duke@1 297 void PatchingStub::emit_code(LIR_Assembler* ce) {
duke@1 298 assert(NativeCall::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF, "not enough room for call");
duke@1 299
duke@1 300 Label call_patch;
duke@1 301
duke@1 302 // static field accesses have special semantics while the class
duke@1 303 // initializer is being run so we emit a test which can be used to
duke@1 304 // check that this code is being executed by the initializing
duke@1 305 // thread.
duke@1 306 address being_initialized_entry = __ pc();
duke@1 307 if (CommentedAssembly) {
duke@1 308 __ block_comment(" patch template");
duke@1 309 }
duke@1 310 if (_id == load_klass_id) {
duke@1 311 // produce a copy of the load klass instruction for use by the being initialized case
coleenp@13728 312 #ifdef ASSERT
duke@1 313 address start = __ pc();
coleenp@13728 314 #endif
coleenp@13728 315 Metadata* o = NULL;
coleenp@13728 316 __ mov_metadata(_obj, o);
coleenp@13728 317 #ifdef ASSERT
coleenp@13728 318 for (int i = 0; i < _bytes_to_copy; i++) {
coleenp@13728 319 address ptr = (address)(_pc_start + i);
coleenp@13728 320 int a_byte = (*ptr) & 0xFF;
coleenp@13728 321 assert(a_byte == *start++, "should be the same code");
coleenp@13728 322 }
coleenp@13728 323 #endif
coleenp@13728 324 } else if (_id == load_mirror_id) {
coleenp@13728 325 // produce a copy of the load mirror instruction for use by the being
coleenp@13728 326 // initialized case
coleenp@13728 327 #ifdef ASSERT
coleenp@13728 328 address start = __ pc();
coleenp@13728 329 #endif
duke@1 330 jobject o = NULL;
duke@1 331 __ movoop(_obj, o);
duke@1 332 #ifdef ASSERT
duke@1 333 for (int i = 0; i < _bytes_to_copy; i++) {
duke@1 334 address ptr = (address)(_pc_start + i);
duke@1 335 int a_byte = (*ptr) & 0xFF;
duke@1 336 assert(a_byte == *start++, "should be the same code");
duke@1 337 }
duke@1 338 #endif
duke@1 339 } else {
duke@1 340 // make a copy the code which is going to be patched.
twisti@14837 341 for (int i = 0; i < _bytes_to_copy; i++) {
duke@1 342 address ptr = (address)(_pc_start + i);
duke@1 343 int a_byte = (*ptr) & 0xFF;
twisti@14837 344 __ emit_int8(a_byte);
duke@1 345 *ptr = 0x90; // make the site look like a nop
duke@1 346 }
duke@1 347 }
duke@1 348
duke@1 349 address end_of_patch = __ pc();
duke@1 350 int bytes_to_skip = 0;
coleenp@13728 351 if (_id == load_mirror_id) {
duke@1 352 int offset = __ offset();
duke@1 353 if (CommentedAssembly) {
duke@1 354 __ block_comment(" being_initialized check");
duke@1 355 }
duke@1 356 assert(_obj != noreg, "must be a valid register");
duke@1 357 Register tmp = rax;
never@8725 358 Register tmp2 = rbx;
never@1066 359 __ push(tmp);
never@8725 360 __ push(tmp2);
iveresov@9120 361 // Load without verification to keep code size small. We need it because
iveresov@9120 362 // begin_initialized_entry_offset has to fit in a byte. Also, we know it's not null.
coleenp@13728 363 __ movptr(tmp2, Address(_obj, java_lang_Class::klass_offset_in_bytes()));
duke@1 364 __ get_thread(tmp);
coleenp@13728 365 __ cmpptr(tmp, Address(tmp2, InstanceKlass::init_thread_offset()));
never@8725 366 __ pop(tmp2);
never@1066 367 __ pop(tmp);
duke@1 368 __ jcc(Assembler::notEqual, call_patch);
duke@1 369
duke@1 370 // access_field patches may execute the patched code before it's
duke@1 371 // copied back into place so we need to jump back into the main
duke@1 372 // code of the nmethod to continue execution.
duke@1 373 __ jmp(_patch_site_continuation);
duke@1 374
duke@1 375 // make sure this extra code gets skipped
duke@1 376 bytes_to_skip += __ offset() - offset;
duke@1 377 }
duke@1 378 if (CommentedAssembly) {
duke@1 379 __ block_comment("patch data encoded as movl");
duke@1 380 }
duke@1 381 // Now emit the patch record telling the runtime how to find the
duke@1 382 // pieces of the patch. We only need 3 bytes but for readability of
duke@1 383 // the disassembly we make the data look like a movl reg, imm32,
duke@1 384 // which requires 5 bytes
duke@1 385 int sizeof_patch_record = 5;
duke@1 386 bytes_to_skip += sizeof_patch_record;
duke@1 387
duke@1 388 // emit the offsets needed to find the code to patch
duke@1 389 int being_initialized_entry_offset = __ pc() - being_initialized_entry + sizeof_patch_record;
duke@1 390
twisti@14837 391 __ emit_int8((unsigned char)0xB8);
twisti@14837 392 __ emit_int8(0);
twisti@14837 393 __ emit_int8(being_initialized_entry_offset);
twisti@14837 394 __ emit_int8(bytes_to_skip);
twisti@14837 395 __ emit_int8(_bytes_to_copy);
duke@1 396 address patch_info_pc = __ pc();
duke@1 397 assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info");
duke@1 398
duke@1 399 address entry = __ pc();
duke@1 400 NativeGeneralJump::insert_unconditional((address)_pc_start, entry);
duke@1 401 address target = NULL;
coleenp@13728 402 relocInfo::relocType reloc_type = relocInfo::none;
duke@1 403 switch (_id) {
duke@1 404 case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
coleenp@13728 405 case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break;
coleenp@13728 406 case load_mirror_id: target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break;
roland@19710 407 case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break;
duke@1 408 default: ShouldNotReachHere();
duke@1 409 }
duke@1 410 __ bind(call_patch);
duke@1 411
duke@1 412 if (CommentedAssembly) {
duke@1 413 __ block_comment("patch entry point");
duke@1 414 }
duke@1 415 __ call(RuntimeAddress(target));
duke@1 416 assert(_patch_info_offset == (patch_info_pc - __ pc()), "must not change");
duke@1 417 ce->add_call_info_here(_info);
duke@1 418 int jmp_off = __ offset();
duke@1 419 __ jmp(_patch_site_entry);
duke@1 420 // Add enough nops so deoptimization can overwrite the jmp above with a call
shade@32203 421 // and not destroy the world. We cannot use fat nops here, since the concurrent
shade@32203 422 // code rewrite may transiently create the illegal instruction sequence.
duke@1 423 for (int j = __ offset() ; j < jmp_off + 5 ; j++ ) {
duke@1 424 __ nop();
duke@1 425 }
roland@19710 426 if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
duke@1 427 CodeSection* cs = __ code_section();
duke@1 428 RelocIterator iter(cs, (address)_pc_start, (address)(_pc_start + 1));
coleenp@13728 429 relocInfo::change_reloc_info_for_address(&iter, (address) _pc_start, reloc_type, relocInfo::none);
duke@1 430 }
duke@1 431 }
duke@1 432
duke@1 433
twisti@5046 434 void DeoptimizeStub::emit_code(LIR_Assembler* ce) {
twisti@5046 435 __ bind(_entry);
iveresov@24442 436 ce->store_parameter(_trap_request, 0);
twisti@10972 437 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::deoptimize_id)));
twisti@5046 438 ce->add_call_info_here(_info);
twisti@10972 439 DEBUG_ONLY(__ should_not_reach_here());
twisti@5046 440 }
twisti@5046 441
twisti@5046 442
duke@1 443 void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) {
roland@16611 444 address a;
roland@16611 445 if (_info->deoptimize_on_exception()) {
roland@16611 446 // Deoptimize, do not throw the exception, because it is probably wrong to do it here.
roland@16611 447 a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
roland@16611 448 } else {
roland@16611 449 a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id);
roland@16611 450 }
roland@16611 451
duke@1 452 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
duke@1 453 __ bind(_entry);
roland@16611 454 __ call(RuntimeAddress(a));
duke@1 455 ce->add_call_info_here(_info);
roland@16611 456 ce->verify_oop_map(_info);
duke@1 457 debug_only(__ should_not_reach_here());
duke@1 458 }
duke@1 459
duke@1 460
duke@1 461 void SimpleExceptionStub::emit_code(LIR_Assembler* ce) {
duke@1 462 assert(__ rsp_offset() == 0, "frame size should be fixed");
duke@1 463
duke@1 464 __ bind(_entry);
duke@1 465 // pass the object on stack because all registers must be preserved
duke@1 466 if (_obj->is_cpu_register()) {
duke@1 467 ce->store_parameter(_obj->as_register(), 0);
duke@1 468 }
duke@1 469 __ call(RuntimeAddress(Runtime1::entry_for(_stub)));
duke@1 470 ce->add_call_info_here(_info);
duke@1 471 debug_only(__ should_not_reach_here());
duke@1 472 }
duke@1 473
duke@1 474
duke@1 475 void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
duke@1 476 //---------------slow case: call to native-----------------
duke@1 477 __ bind(_entry);
duke@1 478 // Figure out where the args should go
coleenp@13728 479 // This should really convert the IntrinsicID to the Method* and signature
duke@1 480 // but I don't know how to do that.
duke@1 481 //
duke@1 482 VMRegPair args[5];
duke@1 483 BasicType signature[5] = { T_OBJECT, T_INT, T_OBJECT, T_INT, T_INT};
duke@1 484 SharedRuntime::java_calling_convention(signature, args, 5, true);
duke@1 485
duke@1 486 // push parameters
duke@1 487 // (src, src_pos, dest, destPos, length)
duke@1 488 Register r[5];
duke@1 489 r[0] = src()->as_register();
duke@1 490 r[1] = src_pos()->as_register();
duke@1 491 r[2] = dst()->as_register();
duke@1 492 r[3] = dst_pos()->as_register();
duke@1 493 r[4] = length()->as_register();
duke@1 494
duke@1 495 // next registers will get stored on the stack
duke@1 496 for (int i = 0; i < 5 ; i++ ) {
duke@1 497 VMReg r_1 = args[i].first();
duke@1 498 if (r_1->is_stack()) {
duke@1 499 int st_off = r_1->reg2stack() * wordSize;
never@1066 500 __ movptr (Address(rsp, st_off), r[i]);
duke@1 501 } else {
duke@1 502 assert(r[i] == args[i].first()->as_Register(), "Wrong register for arg ");
duke@1 503 }
duke@1 504 }
duke@1 505
duke@1 506 ce->align_call(lir_static_call);
duke@1 507
duke@1 508 ce->emit_static_call_stub();
thartmann@32082 509 if (ce->compilation()->bailed_out()) {
thartmann@32082 510 return; // CodeCache is full
thartmann@32082 511 }
duke@1 512 AddressLiteral resolve(SharedRuntime::get_resolve_static_call_stub(),
duke@1 513 relocInfo::static_call_type);
duke@1 514 __ call(resolve);
duke@1 515 ce->add_call_info_here(info());
duke@1 516
duke@1 517 #ifndef PRODUCT
never@1066 518 __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
duke@1 519 #endif
duke@1 520
duke@1 521 __ jmp(_continuation);
duke@1 522 }
duke@1 523
duke@1 524 #undef __