src/cpu/x86/vm/c1_CodeStubs_x86.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6198
55fb97c4c58d
parent 0
f90c822e73f8
child 8604
04d83ba48607
permissions
-rw-r--r--

merge

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

mercurial