src/cpu/mips/vm/c1_CodeStubs_mips.cpp

Thu, 24 May 2018 19:49:50 +0800

author
aoqi
date
Thu, 24 May 2018 19:49:50 +0800
changeset 8865
ffcdff41a92f
parent 6880
52ea28d233d2
child 9127
0f3853aec741
permissions
-rw-r--r--

some C1 fix
Contributed-by: chenhaoxuan, zhaixiang, aoqi

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

mercurial