1 /* 2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2014, Red Hat Inc. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #include "precompiled.hpp" 27 #include "interp_masm_aarch64.hpp" 28 #include "interpreter/interpreter.hpp" 29 #include "interpreter/interpreterRuntime.hpp" 30 #include "logging/log.hpp" 31 #include "oops/arrayOop.hpp" 32 #include "oops/markOop.hpp" 33 #include "oops/method.hpp" 34 #include "oops/methodData.hpp" 35 #include "prims/jvmtiExport.hpp" 36 #include "prims/jvmtiThreadState.hpp" 37 #include "runtime/basicLock.hpp" 38 #include "runtime/biasedLocking.hpp" 39 #include "runtime/safepointMechanism.hpp" 40 #include "runtime/sharedRuntime.hpp" 41 #include "runtime/thread.inline.hpp" 42 43 44 void InterpreterMacroAssembler::narrow(Register result) { 45 46 // Get method->_constMethod->_result_type 47 ldr(rscratch1, Address(rfp, frame::interpreter_frame_method_offset * wordSize)); 48 ldr(rscratch1, Address(rscratch1, Method::const_offset())); 49 ldrb(rscratch1, Address(rscratch1, ConstMethod::result_type_offset())); 50 51 Label done, notBool, notByte, notChar; 52 53 // common case first 54 cmpw(rscratch1, T_INT); 55 br(Assembler::EQ, done); 56 57 // mask integer result to narrower return type. 58 cmpw(rscratch1, T_BOOLEAN); 59 br(Assembler::NE, notBool); 60 andw(result, result, 0x1); 61 b(done); 62 63 bind(notBool); 64 cmpw(rscratch1, T_BYTE); 65 br(Assembler::NE, notByte); 66 sbfx(result, result, 0, 8); 67 b(done); 68 69 bind(notByte); 70 cmpw(rscratch1, T_CHAR); 71 br(Assembler::NE, notChar); 72 ubfx(result, result, 0, 16); // truncate upper 16 bits 73 b(done); 74 75 bind(notChar); 76 sbfx(result, result, 0, 16); // sign-extend short 77 78 // Nothing to do for T_INT 79 bind(done); 80 } 81 82 void InterpreterMacroAssembler::jump_to_entry(address entry) { 83 assert(entry, "Entry must have been generated by now"); 84 b(entry); 85 } 86 87 void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) { 88 if (JvmtiExport::can_pop_frame()) { 89 Label L; 90 // Initiate popframe handling only if it is not already being 91 // processed. If the flag has the popframe_processing bit set, it 92 // means that this code is called *during* popframe handling - we 93 // don't want to reenter. 94 // This method is only called just after the call into the vm in 95 // call_VM_base, so the arg registers are available. 96 ldrw(rscratch1, Address(rthread, JavaThread::popframe_condition_offset())); 97 tbz(rscratch1, exact_log2(JavaThread::popframe_pending_bit), L); 98 tbnz(rscratch1, exact_log2(JavaThread::popframe_processing_bit), L); 99 // Call Interpreter::remove_activation_preserving_args_entry() to get the 100 // address of the same-named entrypoint in the generated interpreter code. 101 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry)); 102 br(r0); 103 bind(L); 104 } 105 } 106 107 108 void InterpreterMacroAssembler::load_earlyret_value(TosState state) { 109 ldr(r2, Address(rthread, JavaThread::jvmti_thread_state_offset())); 110 const Address tos_addr(r2, JvmtiThreadState::earlyret_tos_offset()); 111 const Address oop_addr(r2, JvmtiThreadState::earlyret_oop_offset()); 112 const Address val_addr(r2, JvmtiThreadState::earlyret_value_offset()); 113 switch (state) { 114 case atos: ldr(r0, oop_addr); 115 str(zr, oop_addr); 116 verify_oop(r0, state); break; 117 case ltos: ldr(r0, val_addr); break; 118 case btos: // fall through 119 case ztos: // fall through 120 case ctos: // fall through 121 case stos: // fall through 122 case itos: ldrw(r0, val_addr); break; 123 case ftos: ldrs(v0, val_addr); break; 124 case dtos: ldrd(v0, val_addr); break; 125 case vtos: /* nothing to do */ break; 126 default : ShouldNotReachHere(); 127 } 128 // Clean up tos value in the thread object 129 movw(rscratch1, (int) ilgl); 130 strw(rscratch1, tos_addr); 131 strw(zr, val_addr); 132 } 133 134 135 void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) { 136 if (JvmtiExport::can_force_early_return()) { 137 Label L; 138 ldr(rscratch1, Address(rthread, JavaThread::jvmti_thread_state_offset())); 139 cbz(rscratch1, L); // if (thread->jvmti_thread_state() == NULL) exit; 140 141 // Initiate earlyret handling only if it is not already being processed. 142 // If the flag has the earlyret_processing bit set, it means that this code 143 // is called *during* earlyret handling - we don't want to reenter. 144 ldrw(rscratch1, Address(rscratch1, JvmtiThreadState::earlyret_state_offset())); 145 cmpw(rscratch1, JvmtiThreadState::earlyret_pending); 146 br(Assembler::NE, L); 147 148 // Call Interpreter::remove_activation_early_entry() to get the address of the 149 // same-named entrypoint in the generated interpreter code. 150 ldr(rscratch1, Address(rthread, JavaThread::jvmti_thread_state_offset())); 151 ldrw(rscratch1, Address(rscratch1, JvmtiThreadState::earlyret_tos_offset())); 152 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), rscratch1); 153 br(r0); 154 bind(L); 155 } 156 } 157 158 void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp( 159 Register reg, 160 int bcp_offset) { 161 assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode"); 162 ldrh(reg, Address(rbcp, bcp_offset)); 163 rev16(reg, reg); 164 } 165 166 void InterpreterMacroAssembler::get_dispatch() { 167 unsigned long offset; 168 adrp(rdispatch, ExternalAddress((address)Interpreter::dispatch_table()), offset); 169 lea(rdispatch, Address(rdispatch, offset)); 170 } 171 172 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index, 173 int bcp_offset, 174 size_t index_size) { 175 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); 176 if (index_size == sizeof(u2)) { 177 load_unsigned_short(index, Address(rbcp, bcp_offset)); 178 } else if (index_size == sizeof(u4)) { 179 // assert(EnableInvokeDynamic, "giant index used only for JSR 292"); 180 ldrw(index, Address(rbcp, bcp_offset)); 181 // Check if the secondary index definition is still ~x, otherwise 182 // we have to change the following assembler code to calculate the 183 // plain index. 184 assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line"); 185 eonw(index, index, zr); // convert to plain index 186 } else if (index_size == sizeof(u1)) { 187 load_unsigned_byte(index, Address(rbcp, bcp_offset)); 188 } else { 189 ShouldNotReachHere(); 190 } 191 } 192 193 // Return 194 // Rindex: index into constant pool 195 // Rcache: address of cache entry - ConstantPoolCache::base_offset() 196 // 197 // A caller must add ConstantPoolCache::base_offset() to Rcache to get 198 // the true address of the cache entry. 199 // 200 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, 201 Register index, 202 int bcp_offset, 203 size_t index_size) { 204 assert_different_registers(cache, index); 205 assert_different_registers(cache, rcpool); 206 get_cache_index_at_bcp(index, bcp_offset, index_size); 207 assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below"); 208 // convert from field index to ConstantPoolCacheEntry 209 // aarch64 already has the cache in rcpool so there is no need to 210 // install it in cache. instead we pre-add the indexed offset to 211 // rcpool and return it in cache. All clients of this method need to 212 // be modified accordingly. 213 add(cache, rcpool, index, Assembler::LSL, 5); 214 } 215 216 217 void InterpreterMacroAssembler::get_cache_and_index_and_bytecode_at_bcp(Register cache, 218 Register index, 219 Register bytecode, 220 int byte_no, 221 int bcp_offset, 222 size_t index_size) { 223 get_cache_and_index_at_bcp(cache, index, bcp_offset, index_size); 224 // We use a 32-bit load here since the layout of 64-bit words on 225 // little-endian machines allow us that. 226 // n.b. unlike x86 cache already includes the index offset 227 lea(bytecode, Address(cache, 228 ConstantPoolCache::base_offset() 229 + ConstantPoolCacheEntry::indices_offset())); 230 ldarw(bytecode, bytecode); 231 const int shift_count = (1 + byte_no) * BitsPerByte; 232 ubfx(bytecode, bytecode, shift_count, BitsPerByte); 233 } 234 235 void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache, 236 Register tmp, 237 int bcp_offset, 238 size_t index_size) { 239 assert(cache != tmp, "must use different register"); 240 get_cache_index_at_bcp(tmp, bcp_offset, index_size); 241 assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below"); 242 // convert from field index to ConstantPoolCacheEntry index 243 // and from word offset to byte offset 244 assert(exact_log2(in_bytes(ConstantPoolCacheEntry::size_in_bytes())) == 2 + LogBytesPerWord, "else change next line"); 245 ldr(cache, Address(rfp, frame::interpreter_frame_cache_offset * wordSize)); 246 // skip past the header 247 add(cache, cache, in_bytes(ConstantPoolCache::base_offset())); 248 add(cache, cache, tmp, Assembler::LSL, 2 + LogBytesPerWord); // construct pointer to cache entry 249 } 250 251 void InterpreterMacroAssembler::get_method_counters(Register method, 252 Register mcs, Label& skip) { 253 Label has_counters; 254 ldr(mcs, Address(method, Method::method_counters_offset())); 255 cbnz(mcs, has_counters); 256 call_VM(noreg, CAST_FROM_FN_PTR(address, 257 InterpreterRuntime::build_method_counters), method); 258 ldr(mcs, Address(method, Method::method_counters_offset())); 259 cbz(mcs, skip); // No MethodCounters allocated, OutOfMemory 260 bind(has_counters); 261 } 262 263 // Load object from cpool->resolved_references(index) 264 void InterpreterMacroAssembler::load_resolved_reference_at_index( 265 Register result, Register index) { 266 assert_different_registers(result, index); 267 // convert from field index to resolved_references() index and from 268 // word index to byte offset. Since this is a java object, it can be compressed 269 Register tmp = index; // reuse 270 lslw(tmp, tmp, LogBytesPerHeapOop); 271 272 get_constant_pool(result); 273 // load pointer for resolved_references[] objArray 274 ldr(result, Address(result, ConstantPool::cache_offset_in_bytes())); 275 ldr(result, Address(result, ConstantPoolCache::resolved_references_offset_in_bytes())); 276 resolve_oop_handle(result); 277 // Add in the index 278 add(result, result, tmp); 279 load_heap_oop(result, Address(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT))); 280 } 281 282 void InterpreterMacroAssembler::load_resolved_klass_at_offset( 283 Register cpool, Register index, Register klass, Register temp) { 284 add(temp, cpool, index, LSL, LogBytesPerWord); 285 ldrh(temp, Address(temp, sizeof(ConstantPool))); // temp = resolved_klass_index 286 ldr(klass, Address(cpool, ConstantPool::resolved_klasses_offset_in_bytes())); // klass = cpool->_resolved_klasses 287 add(klass, klass, temp, LSL, LogBytesPerWord); 288 ldr(klass, Address(klass, Array<Klass*>::base_offset_in_bytes())); 289 } 290 291 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a 292 // subtype of super_klass. 293 // 294 // Args: 295 // r0: superklass 296 // Rsub_klass: subklass 297 // 298 // Kills: 299 // r2, r5 300 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, 301 Label& ok_is_subtype) { 302 assert(Rsub_klass != r0, "r0 holds superklass"); 303 assert(Rsub_klass != r2, "r2 holds 2ndary super array length"); 304 assert(Rsub_klass != r5, "r5 holds 2ndary super array scan ptr"); 305 306 // Profile the not-null value's klass. 307 profile_typecheck(r2, Rsub_klass, r5); // blows r2, reloads r5 308 309 // Do the check. 310 check_klass_subtype(Rsub_klass, r0, r2, ok_is_subtype); // blows r2 311 312 // Profile the failure of the check. 313 profile_typecheck_failed(r2); // blows r2 314 } 315 316 // Java Expression Stack 317 318 void InterpreterMacroAssembler::pop_ptr(Register r) { 319 ldr(r, post(esp, wordSize)); 320 } 321 322 void InterpreterMacroAssembler::pop_i(Register r) { 323 ldrw(r, post(esp, wordSize)); 324 } 325 326 void InterpreterMacroAssembler::pop_l(Register r) { 327 ldr(r, post(esp, 2 * Interpreter::stackElementSize)); 328 } 329 330 void InterpreterMacroAssembler::push_ptr(Register r) { 331 str(r, pre(esp, -wordSize)); 332 } 333 334 void InterpreterMacroAssembler::push_i(Register r) { 335 str(r, pre(esp, -wordSize)); 336 } 337 338 void InterpreterMacroAssembler::push_l(Register r) { 339 str(zr, pre(esp, -wordSize)); 340 str(r, pre(esp, - wordSize)); 341 } 342 343 void InterpreterMacroAssembler::pop_f(FloatRegister r) { 344 ldrs(r, post(esp, wordSize)); 345 } 346 347 void InterpreterMacroAssembler::pop_d(FloatRegister r) { 348 ldrd(r, post(esp, 2 * Interpreter::stackElementSize)); 349 } 350 351 void InterpreterMacroAssembler::push_f(FloatRegister r) { 352 strs(r, pre(esp, -wordSize)); 353 } 354 355 void InterpreterMacroAssembler::push_d(FloatRegister r) { 356 strd(r, pre(esp, 2* -wordSize)); 357 } 358 359 void InterpreterMacroAssembler::pop(TosState state) { 360 switch (state) { 361 case atos: pop_ptr(); break; 362 case btos: 363 case ztos: 364 case ctos: 365 case stos: 366 case itos: pop_i(); break; 367 case ltos: pop_l(); break; 368 case ftos: pop_f(); break; 369 case dtos: pop_d(); break; 370 case vtos: /* nothing to do */ break; 371 default: ShouldNotReachHere(); 372 } 373 verify_oop(r0, state); 374 } 375 376 void InterpreterMacroAssembler::push(TosState state) { 377 verify_oop(r0, state); 378 switch (state) { 379 case atos: push_ptr(); break; 380 case btos: 381 case ztos: 382 case ctos: 383 case stos: 384 case itos: push_i(); break; 385 case ltos: push_l(); break; 386 case ftos: push_f(); break; 387 case dtos: push_d(); break; 388 case vtos: /* nothing to do */ break; 389 default : ShouldNotReachHere(); 390 } 391 } 392 393 // Helpers for swap and dup 394 void InterpreterMacroAssembler::load_ptr(int n, Register val) { 395 ldr(val, Address(esp, Interpreter::expr_offset_in_bytes(n))); 396 } 397 398 void InterpreterMacroAssembler::store_ptr(int n, Register val) { 399 str(val, Address(esp, Interpreter::expr_offset_in_bytes(n))); 400 } 401 402 403 void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() { 404 // set sender sp 405 mov(r13, sp); 406 // record last_sp 407 str(esp, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize)); 408 } 409 410 // Jump to from_interpreted entry of a call unless single stepping is possible 411 // in this thread in which case we must call the i2i entry 412 void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) { 413 prepare_to_jump_from_interpreted(); 414 415 if (JvmtiExport::can_post_interpreter_events()) { 416 Label run_compiled_code; 417 // JVMTI events, such as single-stepping, are implemented partly by avoiding running 418 // compiled code in threads for which the event is enabled. Check here for 419 // interp_only_mode if these events CAN be enabled. 420 ldrw(rscratch1, Address(rthread, JavaThread::interp_only_mode_offset())); 421 cbzw(rscratch1, run_compiled_code); 422 ldr(rscratch1, Address(method, Method::interpreter_entry_offset())); 423 br(rscratch1); 424 bind(run_compiled_code); 425 } 426 427 ldr(rscratch1, Address(method, Method::from_interpreted_offset())); 428 br(rscratch1); 429 } 430 431 // The following two routines provide a hook so that an implementation 432 // can schedule the dispatch in two parts. amd64 does not do this. 433 void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) { 434 } 435 436 void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) { 437 dispatch_next(state, step); 438 } 439 440 void InterpreterMacroAssembler::dispatch_base(TosState state, 441 address* table, 442 bool verifyoop, 443 bool generate_poll) { 444 if (VerifyActivationFrameSize) { 445 Unimplemented(); 446 } 447 if (verifyoop) { 448 verify_oop(r0, state); 449 } 450 451 Label safepoint; 452 address* const safepoint_table = Interpreter::safept_table(state); 453 bool needs_thread_local_poll = generate_poll && 454 SafepointMechanism::uses_thread_local_poll() && table != safepoint_table; 455 456 if (needs_thread_local_poll) { 457 NOT_PRODUCT(block_comment("Thread-local Safepoint poll")); 458 ldr(rscratch2, Address(rthread, Thread::polling_page_offset())); 459 tbnz(rscratch2, exact_log2(SafepointMechanism::poll_bit()), safepoint); 460 } 461 462 if (table == Interpreter::dispatch_table(state)) { 463 addw(rscratch2, rscratch1, Interpreter::distance_from_dispatch_table(state)); 464 ldr(rscratch2, Address(rdispatch, rscratch2, Address::uxtw(3))); 465 } else { 466 mov(rscratch2, (address)table); 467 ldr(rscratch2, Address(rscratch2, rscratch1, Address::uxtw(3))); 468 } 469 br(rscratch2); 470 471 if (needs_thread_local_poll) { 472 bind(safepoint); 473 lea(rscratch2, ExternalAddress((address)safepoint_table)); 474 ldr(rscratch2, Address(rscratch2, rscratch1, Address::uxtw(3))); 475 br(rscratch2); 476 } 477 } 478 479 void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) { 480 dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll); 481 } 482 483 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) { 484 dispatch_base(state, Interpreter::normal_table(state)); 485 } 486 487 void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) { 488 dispatch_base(state, Interpreter::normal_table(state), false); 489 } 490 491 492 void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) { 493 // load next bytecode 494 ldrb(rscratch1, Address(pre(rbcp, step))); 495 dispatch_base(state, Interpreter::dispatch_table(state), generate_poll); 496 } 497 498 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) { 499 // load current bytecode 500 ldrb(rscratch1, Address(rbcp, 0)); 501 dispatch_base(state, table); 502 } 503 504 // remove activation 505 // 506 // Unlock the receiver if this is a synchronized method. 507 // Unlock any Java monitors from syncronized blocks. 508 // Remove the activation from the stack. 509 // 510 // If there are locked Java monitors 511 // If throw_monitor_exception 512 // throws IllegalMonitorStateException 513 // Else if install_monitor_exception 514 // installs IllegalMonitorStateException 515 // Else 516 // no error processing 517 void InterpreterMacroAssembler::remove_activation( 518 TosState state, 519 bool throw_monitor_exception, 520 bool install_monitor_exception, 521 bool notify_jvmdi) { 522 // Note: Registers r3 xmm0 may be in use for the 523 // result check if synchronized method 524 Label unlocked, unlock, no_unlock; 525 526 // get the value of _do_not_unlock_if_synchronized into r3 527 const Address do_not_unlock_if_synchronized(rthread, 528 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); 529 ldrb(r3, do_not_unlock_if_synchronized); 530 strb(zr, do_not_unlock_if_synchronized); // reset the flag 531 532 // get method access flags 533 ldr(r1, Address(rfp, frame::interpreter_frame_method_offset * wordSize)); 534 ldr(r2, Address(r1, Method::access_flags_offset())); 535 tbz(r2, exact_log2(JVM_ACC_SYNCHRONIZED), unlocked); 536 537 // Don't unlock anything if the _do_not_unlock_if_synchronized flag 538 // is set. 539 cbnz(r3, no_unlock); 540 541 // unlock monitor 542 push(state); // save result 543 544 // BasicObjectLock will be first in list, since this is a 545 // synchronized method. However, need to check that the object has 546 // not been unlocked by an explicit monitorexit bytecode. 547 const Address monitor(rfp, frame::interpreter_frame_initial_sp_offset * 548 wordSize - (int) sizeof(BasicObjectLock)); 549 // We use c_rarg1 so that if we go slow path it will be the correct 550 // register for unlock_object to pass to VM directly 551 lea(c_rarg1, monitor); // address of first monitor 552 553 ldr(r0, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes())); 554 cbnz(r0, unlock); 555 556 pop(state); 557 if (throw_monitor_exception) { 558 // Entry already unlocked, need to throw exception 559 call_VM(noreg, CAST_FROM_FN_PTR(address, 560 InterpreterRuntime::throw_illegal_monitor_state_exception)); 561 should_not_reach_here(); 562 } else { 563 // Monitor already unlocked during a stack unroll. If requested, 564 // install an illegal_monitor_state_exception. Continue with 565 // stack unrolling. 566 if (install_monitor_exception) { 567 call_VM(noreg, CAST_FROM_FN_PTR(address, 568 InterpreterRuntime::new_illegal_monitor_state_exception)); 569 } 570 b(unlocked); 571 } 572 573 bind(unlock); 574 unlock_object(c_rarg1); 575 pop(state); 576 577 // Check that for block-structured locking (i.e., that all locked 578 // objects has been unlocked) 579 bind(unlocked); 580 581 // r0: Might contain return value 582 583 // Check that all monitors are unlocked 584 { 585 Label loop, exception, entry, restart; 586 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; 587 const Address monitor_block_top( 588 rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize); 589 const Address monitor_block_bot( 590 rfp, frame::interpreter_frame_initial_sp_offset * wordSize); 591 592 bind(restart); 593 // We use c_rarg1 so that if we go slow path it will be the correct 594 // register for unlock_object to pass to VM directly 595 ldr(c_rarg1, monitor_block_top); // points to current entry, starting 596 // with top-most entry 597 lea(r19, monitor_block_bot); // points to word before bottom of 598 // monitor block 599 b(entry); 600 601 // Entry already locked, need to throw exception 602 bind(exception); 603 604 if (throw_monitor_exception) { 605 // Throw exception 606 MacroAssembler::call_VM(noreg, 607 CAST_FROM_FN_PTR(address, InterpreterRuntime:: 608 throw_illegal_monitor_state_exception)); 609 should_not_reach_here(); 610 } else { 611 // Stack unrolling. Unlock object and install illegal_monitor_exception. 612 // Unlock does not block, so don't have to worry about the frame. 613 // We don't have to preserve c_rarg1 since we are going to throw an exception. 614 615 push(state); 616 unlock_object(c_rarg1); 617 pop(state); 618 619 if (install_monitor_exception) { 620 call_VM(noreg, CAST_FROM_FN_PTR(address, 621 InterpreterRuntime:: 622 new_illegal_monitor_state_exception)); 623 } 624 625 b(restart); 626 } 627 628 bind(loop); 629 // check if current entry is used 630 ldr(rscratch1, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes())); 631 cbnz(rscratch1, exception); 632 633 add(c_rarg1, c_rarg1, entry_size); // otherwise advance to next entry 634 bind(entry); 635 cmp(c_rarg1, r19); // check if bottom reached 636 br(Assembler::NE, loop); // if not at bottom then check this entry 637 } 638 639 bind(no_unlock); 640 641 // jvmti support 642 if (notify_jvmdi) { 643 notify_method_exit(state, NotifyJVMTI); // preserve TOSCA 644 } else { 645 notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA 646 } 647 648 // remove activation 649 // get sender esp 650 ldr(esp, 651 Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize)); 652 if (StackReservedPages > 0) { 653 // testing if reserved zone needs to be re-enabled 654 Label no_reserved_zone_enabling; 655 656 ldr(rscratch1, Address(rthread, JavaThread::reserved_stack_activation_offset())); 657 cmp(esp, rscratch1); 658 br(Assembler::LS, no_reserved_zone_enabling); 659 660 call_VM_leaf( 661 CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread); 662 call_VM(noreg, CAST_FROM_FN_PTR(address, 663 InterpreterRuntime::throw_delayed_StackOverflowError)); 664 should_not_reach_here(); 665 666 bind(no_reserved_zone_enabling); 667 } 668 // remove frame anchor 669 leave(); 670 // If we're returning to interpreted code we will shortly be 671 // adjusting SP to allow some space for ESP. If we're returning to 672 // compiled code the saved sender SP was saved in sender_sp, so this 673 // restores it. 674 andr(sp, esp, -16); 675 } 676 677 // Lock object 678 // 679 // Args: 680 // c_rarg1: BasicObjectLock to be used for locking 681 // 682 // Kills: 683 // r0 684 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, .. (param regs) 685 // rscratch1, rscratch2 (scratch regs) 686 void InterpreterMacroAssembler::lock_object(Register lock_reg) 687 { 688 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1"); 689 if (UseHeavyMonitors) { 690 call_VM(noreg, 691 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), 692 lock_reg); 693 } else { 694 Label done; 695 696 const Register swap_reg = r0; 697 const Register tmp = c_rarg2; 698 const Register obj_reg = c_rarg3; // Will contain the oop 699 700 const int obj_offset = BasicObjectLock::obj_offset_in_bytes(); 701 const int lock_offset = BasicObjectLock::lock_offset_in_bytes (); 702 const int mark_offset = lock_offset + 703 BasicLock::displaced_header_offset_in_bytes(); 704 705 Label slow_case; 706 707 // Load object pointer into obj_reg %c_rarg3 708 ldr(obj_reg, Address(lock_reg, obj_offset)); 709 710 if (UseBiasedLocking) { 711 biased_locking_enter(lock_reg, obj_reg, swap_reg, tmp, false, done, &slow_case); 712 } 713 714 // Load (object->mark() | 1) into swap_reg 715 ldr(rscratch1, Address(obj_reg, oopDesc::mark_offset_in_bytes())); 716 orr(swap_reg, rscratch1, 1); 717 718 // Save (object->mark() | 1) into BasicLock's displaced header 719 str(swap_reg, Address(lock_reg, mark_offset)); 720 721 assert(lock_offset == 0, 722 "displached header must be first word in BasicObjectLock"); 723 724 Label fail; 725 if (PrintBiasedLockingStatistics) { 726 Label fast; 727 cmpxchg_obj_header(swap_reg, lock_reg, obj_reg, rscratch1, fast, &fail); 728 bind(fast); 729 atomic_incw(Address((address)BiasedLocking::fast_path_entry_count_addr()), 730 rscratch2, rscratch1, tmp); 731 b(done); 732 bind(fail); 733 } else { 734 cmpxchg_obj_header(swap_reg, lock_reg, obj_reg, rscratch1, done, /*fallthrough*/NULL); 735 } 736 737 // Test if the oopMark is an obvious stack pointer, i.e., 738 // 1) (mark & 7) == 0, and 739 // 2) rsp <= mark < mark + os::pagesize() 740 // 741 // These 3 tests can be done by evaluating the following 742 // expression: ((mark - rsp) & (7 - os::vm_page_size())), 743 // assuming both stack pointer and pagesize have their 744 // least significant 3 bits clear. 745 // NOTE: the oopMark is in swap_reg %r0 as the result of cmpxchg 746 // NOTE2: aarch64 does not like to subtract sp from rn so take a 747 // copy 748 mov(rscratch1, sp); 749 sub(swap_reg, swap_reg, rscratch1); 750 ands(swap_reg, swap_reg, (unsigned long)(7 - os::vm_page_size())); 751 752 // Save the test result, for recursive case, the result is zero 753 str(swap_reg, Address(lock_reg, mark_offset)); 754 755 if (PrintBiasedLockingStatistics) { 756 br(Assembler::NE, slow_case); 757 atomic_incw(Address((address)BiasedLocking::fast_path_entry_count_addr()), 758 rscratch2, rscratch1, tmp); 759 } 760 br(Assembler::EQ, done); 761 762 bind(slow_case); 763 764 // Call the runtime routine for slow case 765 call_VM(noreg, 766 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), 767 lock_reg); 768 769 bind(done); 770 } 771 } 772 773 774 // Unlocks an object. Used in monitorexit bytecode and 775 // remove_activation. Throws an IllegalMonitorException if object is 776 // not locked by current thread. 777 // 778 // Args: 779 // c_rarg1: BasicObjectLock for lock 780 // 781 // Kills: 782 // r0 783 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, ... (param regs) 784 // rscratch1, rscratch2 (scratch regs) 785 void InterpreterMacroAssembler::unlock_object(Register lock_reg) 786 { 787 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be rarg1"); 788 789 if (UseHeavyMonitors) { 790 call_VM(noreg, 791 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), 792 lock_reg); 793 } else { 794 Label done; 795 796 const Register swap_reg = r0; 797 const Register header_reg = c_rarg2; // Will contain the old oopMark 798 const Register obj_reg = c_rarg3; // Will contain the oop 799 800 save_bcp(); // Save in case of exception 801 802 // Convert from BasicObjectLock structure to object and BasicLock 803 // structure Store the BasicLock address into %r0 804 lea(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset_in_bytes())); 805 806 // Load oop into obj_reg(%c_rarg3) 807 ldr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes())); 808 809 // Free entry 810 str(zr, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes())); 811 812 if (UseBiasedLocking) { 813 biased_locking_exit(obj_reg, header_reg, done); 814 } 815 816 // Load the old header from BasicLock structure 817 ldr(header_reg, Address(swap_reg, 818 BasicLock::displaced_header_offset_in_bytes())); 819 820 // Test for recursion 821 cbz(header_reg, done); 822 823 // Atomic swap back the old header 824 cmpxchg_obj_header(swap_reg, header_reg, obj_reg, rscratch1, done, /*fallthrough*/NULL); 825 826 // Call the runtime routine for slow case. 827 str(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes())); // restore obj 828 call_VM(noreg, 829 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), 830 lock_reg); 831 832 bind(done); 833 834 restore_bcp(); 835 } 836 } 837 838 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, 839 Label& zero_continue) { 840 assert(ProfileInterpreter, "must be profiling interpreter"); 841 ldr(mdp, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize)); 842 cbz(mdp, zero_continue); 843 } 844 845 // Set the method data pointer for the current bcp. 846 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { 847 assert(ProfileInterpreter, "must be profiling interpreter"); 848 Label set_mdp; 849 stp(r0, r1, Address(pre(sp, -2 * wordSize))); 850 851 // Test MDO to avoid the call if it is NULL. 852 ldr(r0, Address(rmethod, in_bytes(Method::method_data_offset()))); 853 cbz(r0, set_mdp); 854 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rmethod, rbcp); 855 // r0: mdi 856 // mdo is guaranteed to be non-zero here, we checked for it before the call. 857 ldr(r1, Address(rmethod, in_bytes(Method::method_data_offset()))); 858 lea(r1, Address(r1, in_bytes(MethodData::data_offset()))); 859 add(r0, r1, r0); 860 str(r0, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize)); 861 bind(set_mdp); 862 ldp(r0, r1, Address(post(sp, 2 * wordSize))); 863 } 864 865 void InterpreterMacroAssembler::verify_method_data_pointer() { 866 assert(ProfileInterpreter, "must be profiling interpreter"); 867 #ifdef ASSERT 868 Label verify_continue; 869 stp(r0, r1, Address(pre(sp, -2 * wordSize))); 870 stp(r2, r3, Address(pre(sp, -2 * wordSize))); 871 test_method_data_pointer(r3, verify_continue); // If mdp is zero, continue 872 get_method(r1); 873 874 // If the mdp is valid, it will point to a DataLayout header which is 875 // consistent with the bcp. The converse is highly probable also. 876 ldrsh(r2, Address(r3, in_bytes(DataLayout::bci_offset()))); 877 ldr(rscratch1, Address(r1, Method::const_offset())); 878 add(r2, r2, rscratch1, Assembler::LSL); 879 lea(r2, Address(r2, ConstMethod::codes_offset())); 880 cmp(r2, rbcp); 881 br(Assembler::EQ, verify_continue); 882 // r1: method 883 // rbcp: bcp // rbcp == 22 884 // r3: mdp 885 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp), 886 r1, rbcp, r3); 887 bind(verify_continue); 888 ldp(r2, r3, Address(post(sp, 2 * wordSize))); 889 ldp(r0, r1, Address(post(sp, 2 * wordSize))); 890 #endif // ASSERT 891 } 892 893 894 void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, 895 int constant, 896 Register value) { 897 assert(ProfileInterpreter, "must be profiling interpreter"); 898 Address data(mdp_in, constant); 899 str(value, data); 900 } 901 902 903 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, 904 int constant, 905 bool decrement) { 906 increment_mdp_data_at(mdp_in, noreg, constant, decrement); 907 } 908 909 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, 910 Register reg, 911 int constant, 912 bool decrement) { 913 assert(ProfileInterpreter, "must be profiling interpreter"); 914 // %%% this does 64bit counters at best it is wasting space 915 // at worst it is a rare bug when counters overflow 916 917 assert_different_registers(rscratch2, rscratch1, mdp_in, reg); 918 919 Address addr1(mdp_in, constant); 920 Address addr2(rscratch2, reg, Address::lsl(0)); 921 Address &addr = addr1; 922 if (reg != noreg) { 923 lea(rscratch2, addr1); 924 addr = addr2; 925 } 926 927 if (decrement) { 928 // Decrement the register. Set condition codes. 929 // Intel does this 930 // addptr(data, (int32_t) -DataLayout::counter_increment); 931 // If the decrement causes the counter to overflow, stay negative 932 // Label L; 933 // jcc(Assembler::negative, L); 934 // addptr(data, (int32_t) DataLayout::counter_increment); 935 // so we do this 936 ldr(rscratch1, addr); 937 subs(rscratch1, rscratch1, (unsigned)DataLayout::counter_increment); 938 Label L; 939 br(Assembler::LO, L); // skip store if counter underflow 940 str(rscratch1, addr); 941 bind(L); 942 } else { 943 assert(DataLayout::counter_increment == 1, 944 "flow-free idiom only works with 1"); 945 // Intel does this 946 // Increment the register. Set carry flag. 947 // addptr(data, DataLayout::counter_increment); 948 // If the increment causes the counter to overflow, pull back by 1. 949 // sbbptr(data, (int32_t)0); 950 // so we do this 951 ldr(rscratch1, addr); 952 adds(rscratch1, rscratch1, DataLayout::counter_increment); 953 Label L; 954 br(Assembler::CS, L); // skip store if counter overflow 955 str(rscratch1, addr); 956 bind(L); 957 } 958 } 959 960 void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in, 961 int flag_byte_constant) { 962 assert(ProfileInterpreter, "must be profiling interpreter"); 963 int header_offset = in_bytes(DataLayout::header_offset()); 964 int header_bits = DataLayout::flag_mask_to_header_mask(flag_byte_constant); 965 // Set the flag 966 ldr(rscratch1, Address(mdp_in, header_offset)); 967 orr(rscratch1, rscratch1, header_bits); 968 str(rscratch1, Address(mdp_in, header_offset)); 969 } 970 971 972 void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in, 973 int offset, 974 Register value, 975 Register test_value_out, 976 Label& not_equal_continue) { 977 assert(ProfileInterpreter, "must be profiling interpreter"); 978 if (test_value_out == noreg) { 979 ldr(rscratch1, Address(mdp_in, offset)); 980 cmp(value, rscratch1); 981 } else { 982 // Put the test value into a register, so caller can use it: 983 ldr(test_value_out, Address(mdp_in, offset)); 984 cmp(value, test_value_out); 985 } 986 br(Assembler::NE, not_equal_continue); 987 } 988 989 990 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, 991 int offset_of_disp) { 992 assert(ProfileInterpreter, "must be profiling interpreter"); 993 ldr(rscratch1, Address(mdp_in, offset_of_disp)); 994 add(mdp_in, mdp_in, rscratch1, LSL); 995 str(mdp_in, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize)); 996 } 997 998 999 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, 1000 Register reg, 1001 int offset_of_disp) { 1002 assert(ProfileInterpreter, "must be profiling interpreter"); 1003 lea(rscratch1, Address(mdp_in, offset_of_disp)); 1004 ldr(rscratch1, Address(rscratch1, reg, Address::lsl(0))); 1005 add(mdp_in, mdp_in, rscratch1, LSL); 1006 str(mdp_in, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize)); 1007 } 1008 1009 1010 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, 1011 int constant) { 1012 assert(ProfileInterpreter, "must be profiling interpreter"); 1013 add(mdp_in, mdp_in, (unsigned)constant); 1014 str(mdp_in, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize)); 1015 } 1016 1017 1018 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) { 1019 assert(ProfileInterpreter, "must be profiling interpreter"); 1020 // save/restore across call_VM 1021 stp(zr, return_bci, Address(pre(sp, -2 * wordSize))); 1022 call_VM(noreg, 1023 CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), 1024 return_bci); 1025 ldp(zr, return_bci, Address(post(sp, 2 * wordSize))); 1026 } 1027 1028 1029 void InterpreterMacroAssembler::profile_taken_branch(Register mdp, 1030 Register bumped_count) { 1031 if (ProfileInterpreter) { 1032 Label profile_continue; 1033 1034 // If no method data exists, go to profile_continue. 1035 // Otherwise, assign to mdp 1036 test_method_data_pointer(mdp, profile_continue); 1037 1038 // We are taking a branch. Increment the taken count. 1039 // We inline increment_mdp_data_at to return bumped_count in a register 1040 //increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset())); 1041 Address data(mdp, in_bytes(JumpData::taken_offset())); 1042 ldr(bumped_count, data); 1043 assert(DataLayout::counter_increment == 1, 1044 "flow-free idiom only works with 1"); 1045 // Intel does this to catch overflow 1046 // addptr(bumped_count, DataLayout::counter_increment); 1047 // sbbptr(bumped_count, 0); 1048 // so we do this 1049 adds(bumped_count, bumped_count, DataLayout::counter_increment); 1050 Label L; 1051 br(Assembler::CS, L); // skip store if counter overflow 1052 str(bumped_count, data); 1053 bind(L); 1054 // The method data pointer needs to be updated to reflect the new target. 1055 update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset())); 1056 bind(profile_continue); 1057 } 1058 } 1059 1060 1061 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) { 1062 if (ProfileInterpreter) { 1063 Label profile_continue; 1064 1065 // If no method data exists, go to profile_continue. 1066 test_method_data_pointer(mdp, profile_continue); 1067 1068 // We are taking a branch. Increment the not taken count. 1069 increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset())); 1070 1071 // The method data pointer needs to be updated to correspond to 1072 // the next bytecode 1073 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size())); 1074 bind(profile_continue); 1075 } 1076 } 1077 1078 1079 void InterpreterMacroAssembler::profile_call(Register mdp) { 1080 if (ProfileInterpreter) { 1081 Label profile_continue; 1082 1083 // If no method data exists, go to profile_continue. 1084 test_method_data_pointer(mdp, profile_continue); 1085 1086 // We are making a call. Increment the count. 1087 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1088 1089 // The method data pointer needs to be updated to reflect the new target. 1090 update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size())); 1091 bind(profile_continue); 1092 } 1093 } 1094 1095 void InterpreterMacroAssembler::profile_final_call(Register mdp) { 1096 if (ProfileInterpreter) { 1097 Label profile_continue; 1098 1099 // If no method data exists, go to profile_continue. 1100 test_method_data_pointer(mdp, profile_continue); 1101 1102 // We are making a call. Increment the count. 1103 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1104 1105 // The method data pointer needs to be updated to reflect the new target. 1106 update_mdp_by_constant(mdp, 1107 in_bytes(VirtualCallData:: 1108 virtual_call_data_size())); 1109 bind(profile_continue); 1110 } 1111 } 1112 1113 1114 void InterpreterMacroAssembler::profile_virtual_call(Register receiver, 1115 Register mdp, 1116 Register reg2, 1117 bool receiver_can_be_null) { 1118 if (ProfileInterpreter) { 1119 Label profile_continue; 1120 1121 // If no method data exists, go to profile_continue. 1122 test_method_data_pointer(mdp, profile_continue); 1123 1124 Label skip_receiver_profile; 1125 if (receiver_can_be_null) { 1126 Label not_null; 1127 // We are making a call. Increment the count for null receiver. 1128 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1129 b(skip_receiver_profile); 1130 bind(not_null); 1131 } 1132 1133 // Record the receiver type. 1134 record_klass_in_profile(receiver, mdp, reg2, true); 1135 bind(skip_receiver_profile); 1136 1137 // The method data pointer needs to be updated to reflect the new target. 1138 #if INCLUDE_JVMCI 1139 if (MethodProfileWidth == 0) { 1140 update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); 1141 } 1142 #else // INCLUDE_JVMCI 1143 update_mdp_by_constant(mdp, 1144 in_bytes(VirtualCallData:: 1145 virtual_call_data_size())); 1146 #endif // INCLUDE_JVMCI 1147 bind(profile_continue); 1148 } 1149 } 1150 1151 #if INCLUDE_JVMCI 1152 void InterpreterMacroAssembler::profile_called_method(Register method, Register mdp, Register reg2) { 1153 assert_different_registers(method, mdp, reg2); 1154 if (ProfileInterpreter && MethodProfileWidth > 0) { 1155 Label profile_continue; 1156 1157 // If no method data exists, go to profile_continue. 1158 test_method_data_pointer(mdp, profile_continue); 1159 1160 Label done; 1161 record_item_in_profile_helper(method, mdp, reg2, 0, done, MethodProfileWidth, 1162 &VirtualCallData::method_offset, &VirtualCallData::method_count_offset, in_bytes(VirtualCallData::nonprofiled_receiver_count_offset())); 1163 bind(done); 1164 1165 update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); 1166 bind(profile_continue); 1167 } 1168 } 1169 #endif // INCLUDE_JVMCI 1170 1171 // This routine creates a state machine for updating the multi-row 1172 // type profile at a virtual call site (or other type-sensitive bytecode). 1173 // The machine visits each row (of receiver/count) until the receiver type 1174 // is found, or until it runs out of rows. At the same time, it remembers 1175 // the location of the first empty row. (An empty row records null for its 1176 // receiver, and can be allocated for a newly-observed receiver type.) 1177 // Because there are two degrees of freedom in the state, a simple linear 1178 // search will not work; it must be a decision tree. Hence this helper 1179 // function is recursive, to generate the required tree structured code. 1180 // It's the interpreter, so we are trading off code space for speed. 1181 // See below for example code. 1182 void InterpreterMacroAssembler::record_klass_in_profile_helper( 1183 Register receiver, Register mdp, 1184 Register reg2, int start_row, 1185 Label& done, bool is_virtual_call) { 1186 if (TypeProfileWidth == 0) { 1187 if (is_virtual_call) { 1188 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1189 } 1190 #if INCLUDE_JVMCI 1191 else if (EnableJVMCI) { 1192 increment_mdp_data_at(mdp, in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset())); 1193 } 1194 #endif // INCLUDE_JVMCI 1195 } else { 1196 int non_profiled_offset = -1; 1197 if (is_virtual_call) { 1198 non_profiled_offset = in_bytes(CounterData::count_offset()); 1199 } 1200 #if INCLUDE_JVMCI 1201 else if (EnableJVMCI) { 1202 non_profiled_offset = in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset()); 1203 } 1204 #endif // INCLUDE_JVMCI 1205 1206 record_item_in_profile_helper(receiver, mdp, reg2, 0, done, TypeProfileWidth, 1207 &VirtualCallData::receiver_offset, &VirtualCallData::receiver_count_offset, non_profiled_offset); 1208 } 1209 } 1210 1211 void InterpreterMacroAssembler::record_item_in_profile_helper(Register item, Register mdp, 1212 Register reg2, int start_row, Label& done, int total_rows, 1213 OffsetFunction item_offset_fn, OffsetFunction item_count_offset_fn, 1214 int non_profiled_offset) { 1215 int last_row = total_rows - 1; 1216 assert(start_row <= last_row, "must be work left to do"); 1217 // Test this row for both the item and for null. 1218 // Take any of three different outcomes: 1219 // 1. found item => increment count and goto done 1220 // 2. found null => keep looking for case 1, maybe allocate this cell 1221 // 3. found something else => keep looking for cases 1 and 2 1222 // Case 3 is handled by a recursive call. 1223 for (int row = start_row; row <= last_row; row++) { 1224 Label next_test; 1225 bool test_for_null_also = (row == start_row); 1226 1227 // See if the item is item[n]. 1228 int item_offset = in_bytes(item_offset_fn(row)); 1229 test_mdp_data_at(mdp, item_offset, item, 1230 (test_for_null_also ? reg2 : noreg), 1231 next_test); 1232 // (Reg2 now contains the item from the CallData.) 1233 1234 // The item is item[n]. Increment count[n]. 1235 int count_offset = in_bytes(item_count_offset_fn(row)); 1236 increment_mdp_data_at(mdp, count_offset); 1237 b(done); 1238 bind(next_test); 1239 1240 if (test_for_null_also) { 1241 Label found_null; 1242 // Failed the equality check on item[n]... Test for null. 1243 if (start_row == last_row) { 1244 // The only thing left to do is handle the null case. 1245 if (non_profiled_offset >= 0) { 1246 cbz(reg2, found_null); 1247 // Item did not match any saved item and there is no empty row for it. 1248 // Increment total counter to indicate polymorphic case. 1249 increment_mdp_data_at(mdp, non_profiled_offset); 1250 b(done); 1251 bind(found_null); 1252 } else { 1253 cbnz(reg2, done); 1254 } 1255 break; 1256 } 1257 // Since null is rare, make it be the branch-taken case. 1258 cbz(reg2, found_null); 1259 1260 // Put all the "Case 3" tests here. 1261 record_item_in_profile_helper(item, mdp, reg2, start_row + 1, done, total_rows, 1262 item_offset_fn, item_count_offset_fn, non_profiled_offset); 1263 1264 // Found a null. Keep searching for a matching item, 1265 // but remember that this is an empty (unused) slot. 1266 bind(found_null); 1267 } 1268 } 1269 1270 // In the fall-through case, we found no matching item, but we 1271 // observed the item[start_row] is NULL. 1272 1273 // Fill in the item field and increment the count. 1274 int item_offset = in_bytes(item_offset_fn(start_row)); 1275 set_mdp_data_at(mdp, item_offset, item); 1276 int count_offset = in_bytes(item_count_offset_fn(start_row)); 1277 mov(reg2, DataLayout::counter_increment); 1278 set_mdp_data_at(mdp, count_offset, reg2); 1279 if (start_row > 0) { 1280 b(done); 1281 } 1282 } 1283 1284 // Example state machine code for three profile rows: 1285 // // main copy of decision tree, rooted at row[1] 1286 // if (row[0].rec == rec) { row[0].incr(); goto done; } 1287 // if (row[0].rec != NULL) { 1288 // // inner copy of decision tree, rooted at row[1] 1289 // if (row[1].rec == rec) { row[1].incr(); goto done; } 1290 // if (row[1].rec != NULL) { 1291 // // degenerate decision tree, rooted at row[2] 1292 // if (row[2].rec == rec) { row[2].incr(); goto done; } 1293 // if (row[2].rec != NULL) { count.incr(); goto done; } // overflow 1294 // row[2].init(rec); goto done; 1295 // } else { 1296 // // remember row[1] is empty 1297 // if (row[2].rec == rec) { row[2].incr(); goto done; } 1298 // row[1].init(rec); goto done; 1299 // } 1300 // } else { 1301 // // remember row[0] is empty 1302 // if (row[1].rec == rec) { row[1].incr(); goto done; } 1303 // if (row[2].rec == rec) { row[2].incr(); goto done; } 1304 // row[0].init(rec); goto done; 1305 // } 1306 // done: 1307 1308 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver, 1309 Register mdp, Register reg2, 1310 bool is_virtual_call) { 1311 assert(ProfileInterpreter, "must be profiling"); 1312 Label done; 1313 1314 record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call); 1315 1316 bind (done); 1317 } 1318 1319 void InterpreterMacroAssembler::profile_ret(Register return_bci, 1320 Register mdp) { 1321 if (ProfileInterpreter) { 1322 Label profile_continue; 1323 uint row; 1324 1325 // If no method data exists, go to profile_continue. 1326 test_method_data_pointer(mdp, profile_continue); 1327 1328 // Update the total ret count. 1329 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1330 1331 for (row = 0; row < RetData::row_limit(); row++) { 1332 Label next_test; 1333 1334 // See if return_bci is equal to bci[n]: 1335 test_mdp_data_at(mdp, 1336 in_bytes(RetData::bci_offset(row)), 1337 return_bci, noreg, 1338 next_test); 1339 1340 // return_bci is equal to bci[n]. Increment the count. 1341 increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row))); 1342 1343 // The method data pointer needs to be updated to reflect the new target. 1344 update_mdp_by_offset(mdp, 1345 in_bytes(RetData::bci_displacement_offset(row))); 1346 b(profile_continue); 1347 bind(next_test); 1348 } 1349 1350 update_mdp_for_ret(return_bci); 1351 1352 bind(profile_continue); 1353 } 1354 } 1355 1356 void InterpreterMacroAssembler::profile_null_seen(Register mdp) { 1357 if (ProfileInterpreter) { 1358 Label profile_continue; 1359 1360 // If no method data exists, go to profile_continue. 1361 test_method_data_pointer(mdp, profile_continue); 1362 1363 set_mdp_flag_at(mdp, BitData::null_seen_byte_constant()); 1364 1365 // The method data pointer needs to be updated. 1366 int mdp_delta = in_bytes(BitData::bit_data_size()); 1367 if (TypeProfileCasts) { 1368 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); 1369 } 1370 update_mdp_by_constant(mdp, mdp_delta); 1371 1372 bind(profile_continue); 1373 } 1374 } 1375 1376 void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) { 1377 if (ProfileInterpreter && TypeProfileCasts) { 1378 Label profile_continue; 1379 1380 // If no method data exists, go to profile_continue. 1381 test_method_data_pointer(mdp, profile_continue); 1382 1383 int count_offset = in_bytes(CounterData::count_offset()); 1384 // Back up the address, since we have already bumped the mdp. 1385 count_offset -= in_bytes(VirtualCallData::virtual_call_data_size()); 1386 1387 // *Decrement* the counter. We expect to see zero or small negatives. 1388 increment_mdp_data_at(mdp, count_offset, true); 1389 1390 bind (profile_continue); 1391 } 1392 } 1393 1394 void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) { 1395 if (ProfileInterpreter) { 1396 Label profile_continue; 1397 1398 // If no method data exists, go to profile_continue. 1399 test_method_data_pointer(mdp, profile_continue); 1400 1401 // The method data pointer needs to be updated. 1402 int mdp_delta = in_bytes(BitData::bit_data_size()); 1403 if (TypeProfileCasts) { 1404 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); 1405 1406 // Record the object type. 1407 record_klass_in_profile(klass, mdp, reg2, false); 1408 } 1409 update_mdp_by_constant(mdp, mdp_delta); 1410 1411 bind(profile_continue); 1412 } 1413 } 1414 1415 void InterpreterMacroAssembler::profile_switch_default(Register mdp) { 1416 if (ProfileInterpreter) { 1417 Label profile_continue; 1418 1419 // If no method data exists, go to profile_continue. 1420 test_method_data_pointer(mdp, profile_continue); 1421 1422 // Update the default case count 1423 increment_mdp_data_at(mdp, 1424 in_bytes(MultiBranchData::default_count_offset())); 1425 1426 // The method data pointer needs to be updated. 1427 update_mdp_by_offset(mdp, 1428 in_bytes(MultiBranchData:: 1429 default_displacement_offset())); 1430 1431 bind(profile_continue); 1432 } 1433 } 1434 1435 void InterpreterMacroAssembler::profile_switch_case(Register index, 1436 Register mdp, 1437 Register reg2) { 1438 if (ProfileInterpreter) { 1439 Label profile_continue; 1440 1441 // If no method data exists, go to profile_continue. 1442 test_method_data_pointer(mdp, profile_continue); 1443 1444 // Build the base (index * per_case_size_in_bytes()) + 1445 // case_array_offset_in_bytes() 1446 movw(reg2, in_bytes(MultiBranchData::per_case_size())); 1447 movw(rscratch1, in_bytes(MultiBranchData::case_array_offset())); 1448 Assembler::maddw(index, index, reg2, rscratch1); 1449 1450 // Update the case count 1451 increment_mdp_data_at(mdp, 1452 index, 1453 in_bytes(MultiBranchData::relative_count_offset())); 1454 1455 // The method data pointer needs to be updated. 1456 update_mdp_by_offset(mdp, 1457 index, 1458 in_bytes(MultiBranchData:: 1459 relative_displacement_offset())); 1460 1461 bind(profile_continue); 1462 } 1463 } 1464 1465 void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) { 1466 if (state == atos) { 1467 MacroAssembler::verify_oop(reg); 1468 } 1469 } 1470 1471 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) { ; } 1472 1473 1474 void InterpreterMacroAssembler::notify_method_entry() { 1475 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to 1476 // track stack depth. If it is possible to enter interp_only_mode we add 1477 // the code to check if the event should be sent. 1478 if (JvmtiExport::can_post_interpreter_events()) { 1479 Label L; 1480 ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset())); 1481 cbzw(r3, L); 1482 call_VM(noreg, CAST_FROM_FN_PTR(address, 1483 InterpreterRuntime::post_method_entry)); 1484 bind(L); 1485 } 1486 1487 { 1488 SkipIfEqual skip(this, &DTraceMethodProbes, false); 1489 get_method(c_rarg1); 1490 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), 1491 rthread, c_rarg1); 1492 } 1493 1494 // RedefineClasses() tracing support for obsolete method entry 1495 if (log_is_enabled(Trace, redefine, class, obsolete)) { 1496 get_method(c_rarg1); 1497 call_VM_leaf( 1498 CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry), 1499 rthread, c_rarg1); 1500 } 1501 1502 } 1503 1504 1505 void InterpreterMacroAssembler::notify_method_exit( 1506 TosState state, NotifyMethodExitMode mode) { 1507 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to 1508 // track stack depth. If it is possible to enter interp_only_mode we add 1509 // the code to check if the event should be sent. 1510 if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) { 1511 Label L; 1512 // Note: frame::interpreter_frame_result has a dependency on how the 1513 // method result is saved across the call to post_method_exit. If this 1514 // is changed then the interpreter_frame_result implementation will 1515 // need to be updated too. 1516 1517 // template interpreter will leave the result on the top of the stack. 1518 push(state); 1519 ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset())); 1520 cbz(r3, L); 1521 call_VM(noreg, 1522 CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit)); 1523 bind(L); 1524 pop(state); 1525 } 1526 1527 { 1528 SkipIfEqual skip(this, &DTraceMethodProbes, false); 1529 push(state); 1530 get_method(c_rarg1); 1531 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), 1532 rthread, c_rarg1); 1533 pop(state); 1534 } 1535 } 1536 1537 1538 // Jump if ((*counter_addr += increment) & mask) satisfies the condition. 1539 void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr, 1540 int increment, Address mask, 1541 Register scratch, Register scratch2, 1542 bool preloaded, Condition cond, 1543 Label* where) { 1544 if (!preloaded) { 1545 ldrw(scratch, counter_addr); 1546 } 1547 add(scratch, scratch, increment); 1548 strw(scratch, counter_addr); 1549 ldrw(scratch2, mask); 1550 ands(scratch, scratch, scratch2); 1551 br(cond, *where); 1552 } 1553 1554 void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point, 1555 int number_of_arguments) { 1556 // interpreter specific 1557 // 1558 // Note: No need to save/restore rbcp & rlocals pointer since these 1559 // are callee saved registers and no blocking/ GC can happen 1560 // in leaf calls. 1561 #ifdef ASSERT 1562 { 1563 Label L; 1564 ldr(rscratch1, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize)); 1565 cbz(rscratch1, L); 1566 stop("InterpreterMacroAssembler::call_VM_leaf_base:" 1567 " last_sp != NULL"); 1568 bind(L); 1569 } 1570 #endif /* ASSERT */ 1571 // super call 1572 MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments); 1573 } 1574 1575 void InterpreterMacroAssembler::call_VM_base(Register oop_result, 1576 Register java_thread, 1577 Register last_java_sp, 1578 address entry_point, 1579 int number_of_arguments, 1580 bool check_exceptions) { 1581 // interpreter specific 1582 // 1583 // Note: Could avoid restoring locals ptr (callee saved) - however doesn't 1584 // really make a difference for these runtime calls, since they are 1585 // slow anyway. Btw., bcp must be saved/restored since it may change 1586 // due to GC. 1587 // assert(java_thread == noreg , "not expecting a precomputed java thread"); 1588 save_bcp(); 1589 #ifdef ASSERT 1590 { 1591 Label L; 1592 ldr(rscratch1, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize)); 1593 cbz(rscratch1, L); 1594 stop("InterpreterMacroAssembler::call_VM_leaf_base:" 1595 " last_sp != NULL"); 1596 bind(L); 1597 } 1598 #endif /* ASSERT */ 1599 // super call 1600 MacroAssembler::call_VM_base(oop_result, noreg, last_java_sp, 1601 entry_point, number_of_arguments, 1602 check_exceptions); 1603 // interpreter specific 1604 restore_bcp(); 1605 restore_locals(); 1606 } 1607 1608 void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { 1609 Label update, next, none; 1610 1611 verify_oop(obj); 1612 1613 cbnz(obj, update); 1614 orptr(mdo_addr, TypeEntries::null_seen); 1615 b(next); 1616 1617 bind(update); 1618 load_klass(obj, obj); 1619 1620 ldr(rscratch1, mdo_addr); 1621 eor(obj, obj, rscratch1); 1622 tst(obj, TypeEntries::type_klass_mask); 1623 br(Assembler::EQ, next); // klass seen before, nothing to 1624 // do. The unknown bit may have been 1625 // set already but no need to check. 1626 1627 tbnz(obj, exact_log2(TypeEntries::type_unknown), next); 1628 // already unknown. Nothing to do anymore. 1629 1630 ldr(rscratch1, mdo_addr); 1631 cbz(rscratch1, none); 1632 cmp(rscratch1, TypeEntries::null_seen); 1633 br(Assembler::EQ, none); 1634 // There is a chance that the checks above (re-reading profiling 1635 // data from memory) fail if another thread has just set the 1636 // profiling to this obj's klass 1637 ldr(rscratch1, mdo_addr); 1638 eor(obj, obj, rscratch1); 1639 tst(obj, TypeEntries::type_klass_mask); 1640 br(Assembler::EQ, next); 1641 1642 // different than before. Cannot keep accurate profile. 1643 orptr(mdo_addr, TypeEntries::type_unknown); 1644 b(next); 1645 1646 bind(none); 1647 // first time here. Set profile type. 1648 str(obj, mdo_addr); 1649 1650 bind(next); 1651 } 1652 1653 void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { 1654 if (!ProfileInterpreter) { 1655 return; 1656 } 1657 1658 if (MethodData::profile_arguments() || MethodData::profile_return()) { 1659 Label profile_continue; 1660 1661 test_method_data_pointer(mdp, profile_continue); 1662 1663 int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); 1664 1665 ldrb(rscratch1, Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start)); 1666 cmp(rscratch1, is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); 1667 br(Assembler::NE, profile_continue); 1668 1669 if (MethodData::profile_arguments()) { 1670 Label done; 1671 int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); 1672 1673 for (int i = 0; i < TypeProfileArgsLimit; i++) { 1674 if (i > 0 || MethodData::profile_return()) { 1675 // If return value type is profiled we may have no argument to profile 1676 ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset()))); 1677 sub(tmp, tmp, i*TypeStackSlotEntries::per_arg_count()); 1678 cmp(tmp, TypeStackSlotEntries::per_arg_count()); 1679 add(rscratch1, mdp, off_to_args); 1680 br(Assembler::LT, done); 1681 } 1682 ldr(tmp, Address(callee, Method::const_offset())); 1683 load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); 1684 // stack offset o (zero based) from the start of the argument 1685 // list, for n arguments translates into offset n - o - 1 from 1686 // the end of the argument list 1687 ldr(rscratch1, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i)))); 1688 sub(tmp, tmp, rscratch1); 1689 sub(tmp, tmp, 1); 1690 Address arg_addr = argument_address(tmp); 1691 ldr(tmp, arg_addr); 1692 1693 Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))); 1694 profile_obj_type(tmp, mdo_arg_addr); 1695 1696 int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); 1697 off_to_args += to_add; 1698 } 1699 1700 if (MethodData::profile_return()) { 1701 ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset()))); 1702 sub(tmp, tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); 1703 } 1704 1705 add(rscratch1, mdp, off_to_args); 1706 bind(done); 1707 mov(mdp, rscratch1); 1708 1709 if (MethodData::profile_return()) { 1710 // We're right after the type profile for the last 1711 // argument. tmp is the number of cells left in the 1712 // CallTypeData/VirtualCallTypeData to reach its end. Non null 1713 // if there's a return to profile. 1714 assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type"); 1715 add(mdp, mdp, tmp, LSL, exact_log2(DataLayout::cell_size)); 1716 } 1717 str(mdp, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize)); 1718 } else { 1719 assert(MethodData::profile_return(), "either profile call args or call ret"); 1720 update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size())); 1721 } 1722 1723 // mdp points right after the end of the 1724 // CallTypeData/VirtualCallTypeData, right after the cells for the 1725 // return value type if there's one 1726 1727 bind(profile_continue); 1728 } 1729 } 1730 1731 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) { 1732 assert_different_registers(mdp, ret, tmp, rbcp); 1733 if (ProfileInterpreter && MethodData::profile_return()) { 1734 Label profile_continue, done; 1735 1736 test_method_data_pointer(mdp, profile_continue); 1737 1738 if (MethodData::profile_return_jsr292_only()) { 1739 assert(Method::intrinsic_id_size_in_bytes() == 2, "assuming Method::_intrinsic_id is u2"); 1740 1741 // If we don't profile all invoke bytecodes we must make sure 1742 // it's a bytecode we indeed profile. We can't go back to the 1743 // begining of the ProfileData we intend to update to check its 1744 // type because we're right after it and we don't known its 1745 // length 1746 Label do_profile; 1747 ldrb(rscratch1, Address(rbcp, 0)); 1748 cmp(rscratch1, Bytecodes::_invokedynamic); 1749 br(Assembler::EQ, do_profile); 1750 cmp(rscratch1, Bytecodes::_invokehandle); 1751 br(Assembler::EQ, do_profile); 1752 get_method(tmp); 1753 ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset_in_bytes())); 1754 cmp(rscratch1, vmIntrinsics::_compiledLambdaForm); 1755 br(Assembler::NE, profile_continue); 1756 1757 bind(do_profile); 1758 } 1759 1760 Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size())); 1761 mov(tmp, ret); 1762 profile_obj_type(tmp, mdo_ret_addr); 1763 1764 bind(profile_continue); 1765 } 1766 } 1767 1768 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) { 1769 if (ProfileInterpreter && MethodData::profile_parameters()) { 1770 Label profile_continue, done; 1771 1772 test_method_data_pointer(mdp, profile_continue); 1773 1774 // Load the offset of the area within the MDO used for 1775 // parameters. If it's negative we're not profiling any parameters 1776 ldr(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset()))); 1777 tbnz(tmp1, 63, profile_continue); // i.e. sign bit set 1778 1779 // Compute a pointer to the area for parameters from the offset 1780 // and move the pointer to the slot for the last 1781 // parameters. Collect profiling from last parameter down. 1782 // mdo start + parameters offset + array length - 1 1783 add(mdp, mdp, tmp1); 1784 ldr(tmp1, Address(mdp, ArrayData::array_len_offset())); 1785 sub(tmp1, tmp1, TypeStackSlotEntries::per_arg_count()); 1786 1787 Label loop; 1788 bind(loop); 1789 1790 int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0)); 1791 int type_base = in_bytes(ParametersTypeData::type_offset(0)); 1792 int per_arg_scale = exact_log2(DataLayout::cell_size); 1793 add(rscratch1, mdp, off_base); 1794 add(rscratch2, mdp, type_base); 1795 1796 Address arg_off(rscratch1, tmp1, Address::lsl(per_arg_scale)); 1797 Address arg_type(rscratch2, tmp1, Address::lsl(per_arg_scale)); 1798 1799 // load offset on the stack from the slot for this parameter 1800 ldr(tmp2, arg_off); 1801 neg(tmp2, tmp2); 1802 // read the parameter from the local area 1803 ldr(tmp2, Address(rlocals, tmp2, Address::lsl(Interpreter::logStackElementSize))); 1804 1805 // profile the parameter 1806 profile_obj_type(tmp2, arg_type); 1807 1808 // go to next parameter 1809 subs(tmp1, tmp1, TypeStackSlotEntries::per_arg_count()); 1810 br(Assembler::GE, loop); 1811 1812 bind(profile_continue); 1813 } 1814 }