src/cpu/x86/vm/c1_CodeStubs_x86.cpp

Thu, 27 Oct 2011 04:43:37 -0700

author
twisti
date
Thu, 27 Oct 2011 04:43:37 -0700
changeset 3244
cec1757a0134
parent 2792
527b586edf24
child 3391
069ab3f976d3
permissions
-rw-r--r--

7102657: JSR 292: C1 deoptimizes unlinked invokedynamic call sites infinitely
Reviewed-by: never, bdelsart

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

mercurial