1 /*
   2  * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compiler_globals.hpp"
  27 #include "interp_masm_x86.hpp"
  28 #include "interpreter/interpreter.hpp"
  29 #include "interpreter/interpreterRuntime.hpp"
  30 #include "logging/log.hpp"
  31 #include "oops/arrayOop.hpp"
  32 #include "oops/markWord.hpp"
  33 #include "oops/methodData.hpp"
  34 #include "oops/method.hpp"
  35 #include "oops/inlineKlass.hpp"
  36 #include "prims/jvmtiExport.hpp"
  37 #include "prims/jvmtiThreadState.hpp"
  38 #include "runtime/basicLock.hpp"
  39 #include "runtime/frame.inline.hpp"
  40 #include "runtime/safepointMechanism.hpp"
  41 #include "runtime/sharedRuntime.hpp"
  42 #include "runtime/thread.inline.hpp"
  43 #include "utilities/powerOfTwo.hpp"
  44 
  45 // Implementation of InterpreterMacroAssembler
  46 
  47 void InterpreterMacroAssembler::jump_to_entry(address entry) {
  48   assert(entry, "Entry must have been generated by now");
  49   jump(RuntimeAddress(entry));
  50 }
  51 
  52 void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) {
  53   Label update, next, none;
  54 
  55   interp_verify_oop(obj, atos);
  56 
  57   testptr(obj, obj);
  58   jccb(Assembler::notZero, update);
  59   orptr(mdo_addr, TypeEntries::null_seen);
  60   jmpb(next);
  61 
  62   bind(update);
  63   Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
  64   load_klass(obj, obj, tmp_load_klass);
  65 
  66   xorptr(obj, mdo_addr);
  67   testptr(obj, TypeEntries::type_klass_mask);
  68   jccb(Assembler::zero, next); // klass seen before, nothing to
  69                                // do. The unknown bit may have been
  70                                // set already but no need to check.
  71 
  72   testptr(obj, TypeEntries::type_unknown);
  73   jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
  74 
  75   cmpptr(mdo_addr, 0);
  76   jccb(Assembler::equal, none);
  77   cmpptr(mdo_addr, TypeEntries::null_seen);
  78   jccb(Assembler::equal, none);
  79   // There is a chance that the checks above (re-reading profiling
  80   // data from memory) fail if another thread has just set the
  81   // profiling to this obj's klass
  82   xorptr(obj, mdo_addr);
  83   testptr(obj, TypeEntries::type_klass_mask);
  84   jccb(Assembler::zero, next);
  85 
  86   // different than before. Cannot keep accurate profile.
  87   orptr(mdo_addr, TypeEntries::type_unknown);
  88   jmpb(next);
  89 
  90   bind(none);
  91   // first time here. Set profile type.
  92   movptr(mdo_addr, obj);
  93 
  94   bind(next);
  95 }
  96 
  97 void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) {
  98   if (!ProfileInterpreter) {
  99     return;
 100   }
 101 
 102   if (MethodData::profile_arguments() || MethodData::profile_return()) {
 103     Label profile_continue;
 104 
 105     test_method_data_pointer(mdp, profile_continue);
 106 
 107     int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
 108 
 109     cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag);
 110     jcc(Assembler::notEqual, profile_continue);
 111 
 112     if (MethodData::profile_arguments()) {
 113       Label done;
 114       int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset());
 115       addptr(mdp, off_to_args);
 116 
 117       for (int i = 0; i < TypeProfileArgsLimit; i++) {
 118         if (i > 0 || MethodData::profile_return()) {
 119           // If return value type is profiled we may have no argument to profile
 120           movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args));
 121           subl(tmp, i*TypeStackSlotEntries::per_arg_count());
 122           cmpl(tmp, TypeStackSlotEntries::per_arg_count());
 123           jcc(Assembler::less, done);
 124         }
 125         movptr(tmp, Address(callee, Method::const_offset()));
 126         load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset()));
 127         // stack offset o (zero based) from the start of the argument
 128         // list, for n arguments translates into offset n - o - 1 from
 129         // the end of the argument list
 130         subptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args));
 131         subl(tmp, 1);
 132         Address arg_addr = argument_address(tmp);
 133         movptr(tmp, arg_addr);
 134 
 135         Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args);
 136         profile_obj_type(tmp, mdo_arg_addr);
 137 
 138         int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
 139         addptr(mdp, to_add);
 140         off_to_args += to_add;
 141       }
 142 
 143       if (MethodData::profile_return()) {
 144         movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args));
 145         subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
 146       }
 147 
 148       bind(done);
 149 
 150       if (MethodData::profile_return()) {
 151         // We're right after the type profile for the last
 152         // argument. tmp is the number of cells left in the
 153         // CallTypeData/VirtualCallTypeData to reach its end. Non null
 154         // if there's a return to profile.
 155         assert(SingleTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
 156         shll(tmp, log2i_exact((int)DataLayout::cell_size));
 157         addptr(mdp, tmp);
 158       }
 159       movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp);
 160     } else {
 161       assert(MethodData::profile_return(), "either profile call args or call ret");
 162       update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
 163     }
 164 
 165     // mdp points right after the end of the
 166     // CallTypeData/VirtualCallTypeData, right after the cells for the
 167     // return value type if there's one
 168 
 169     bind(profile_continue);
 170   }
 171 }
 172 
 173 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
 174   assert_different_registers(mdp, ret, tmp, _bcp_register);
 175   if (ProfileInterpreter && MethodData::profile_return()) {
 176     Label profile_continue;
 177 
 178     test_method_data_pointer(mdp, profile_continue);
 179 
 180     if (MethodData::profile_return_jsr292_only()) {
 181       assert(Method::intrinsic_id_size_in_bytes() == 2, "assuming Method::_intrinsic_id is u2");
 182 
 183       // If we don't profile all invoke bytecodes we must make sure
 184       // it's a bytecode we indeed profile. We can't go back to the
 185       // begining of the ProfileData we intend to update to check its
 186       // type because we're right after it and we don't known its
 187       // length
 188       Label do_profile;
 189       cmpb(Address(_bcp_register, 0), Bytecodes::_invokedynamic);
 190       jcc(Assembler::equal, do_profile);
 191       cmpb(Address(_bcp_register, 0), Bytecodes::_invokehandle);
 192       jcc(Assembler::equal, do_profile);
 193       get_method(tmp);
 194       cmpw(Address(tmp, Method::intrinsic_id_offset_in_bytes()), static_cast<int>(vmIntrinsics::_compiledLambdaForm));
 195       jcc(Assembler::notEqual, profile_continue);
 196 
 197       bind(do_profile);
 198     }
 199 
 200     Address mdo_ret_addr(mdp, -in_bytes(SingleTypeEntry::size()));
 201     mov(tmp, ret);
 202     profile_obj_type(tmp, mdo_ret_addr);
 203 
 204     bind(profile_continue);
 205   }
 206 }
 207 
 208 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
 209   if (ProfileInterpreter && MethodData::profile_parameters()) {
 210     Label profile_continue;
 211 
 212     test_method_data_pointer(mdp, profile_continue);
 213 
 214     // Load the offset of the area within the MDO used for
 215     // parameters. If it's negative we're not profiling any parameters
 216     movl(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
 217     testl(tmp1, tmp1);
 218     jcc(Assembler::negative, profile_continue);
 219 
 220     // Compute a pointer to the area for parameters from the offset
 221     // and move the pointer to the slot for the last
 222     // parameters. Collect profiling from last parameter down.
 223     // mdo start + parameters offset + array length - 1
 224     addptr(mdp, tmp1);
 225     movptr(tmp1, Address(mdp, ArrayData::array_len_offset()));
 226     decrement(tmp1, TypeStackSlotEntries::per_arg_count());
 227 
 228     Label loop;
 229     bind(loop);
 230 
 231     int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0));
 232     int type_base = in_bytes(ParametersTypeData::type_offset(0));
 233     Address::ScaleFactor per_arg_scale = Address::times(DataLayout::cell_size);
 234     Address arg_off(mdp, tmp1, per_arg_scale, off_base);
 235     Address arg_type(mdp, tmp1, per_arg_scale, type_base);
 236 
 237     // load offset on the stack from the slot for this parameter
 238     movptr(tmp2, arg_off);
 239     negptr(tmp2);
 240     // read the parameter from the local area
 241     movptr(tmp2, Address(_locals_register, tmp2, Interpreter::stackElementScale()));
 242 
 243     // profile the parameter
 244     profile_obj_type(tmp2, arg_type);
 245 
 246     // go to next parameter
 247     decrement(tmp1, TypeStackSlotEntries::per_arg_count());
 248     jcc(Assembler::positive, loop);
 249 
 250     bind(profile_continue);
 251   }
 252 }
 253 
 254 void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point,
 255                                                   int number_of_arguments) {
 256   // interpreter specific
 257   //
 258   // Note: No need to save/restore bcp & locals registers
 259   //       since these are callee saved registers and no blocking/
 260   //       GC can happen in leaf calls.
 261   // Further Note: DO NOT save/restore bcp/locals. If a caller has
 262   // already saved them so that it can use rsi/rdi as temporaries
 263   // then a save/restore here will DESTROY the copy the caller
 264   // saved! There used to be a save_bcp() that only happened in
 265   // the ASSERT path (no restore_bcp). Which caused bizarre failures
 266   // when jvm built with ASSERTs.
 267 #ifdef ASSERT
 268   {
 269     Label L;
 270     cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
 271     jcc(Assembler::equal, L);
 272     stop("InterpreterMacroAssembler::call_VM_leaf_base:"
 273          " last_sp != NULL");
 274     bind(L);
 275   }
 276 #endif
 277   // super call
 278   MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments);
 279   // interpreter specific
 280   // LP64: Used to ASSERT that r13/r14 were equal to frame's bcp/locals
 281   // but since they may not have been saved (and we don't want to
 282   // save them here (see note above) the assert is invalid.
 283 }
 284 
 285 void InterpreterMacroAssembler::call_VM_base(Register oop_result,
 286                                              Register java_thread,
 287                                              Register last_java_sp,
 288                                              address  entry_point,
 289                                              int      number_of_arguments,
 290                                              bool     check_exceptions) {
 291   // interpreter specific
 292   //
 293   // Note: Could avoid restoring locals ptr (callee saved) - however doesn't
 294   //       really make a difference for these runtime calls, since they are
 295   //       slow anyway. Btw., bcp must be saved/restored since it may change
 296   //       due to GC.
 297   NOT_LP64(assert(java_thread == noreg , "not expecting a precomputed java thread");)
 298   save_bcp();
 299 #ifdef ASSERT
 300   {
 301     Label L;
 302     cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
 303     jcc(Assembler::equal, L);
 304     stop("InterpreterMacroAssembler::call_VM_base:"
 305          " last_sp != NULL");
 306     bind(L);
 307   }
 308 #endif /* ASSERT */
 309   // super call
 310   MacroAssembler::call_VM_base(oop_result, noreg, last_java_sp,
 311                                entry_point, number_of_arguments,
 312                                check_exceptions);
 313   // interpreter specific
 314   restore_bcp();
 315   restore_locals();
 316 }
 317 
 318 void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) {
 319   if (JvmtiExport::can_pop_frame()) {
 320     Label L;
 321     // Initiate popframe handling only if it is not already being
 322     // processed.  If the flag has the popframe_processing bit set, it
 323     // means that this code is called *during* popframe handling - we
 324     // don't want to reenter.
 325     // This method is only called just after the call into the vm in
 326     // call_VM_base, so the arg registers are available.
 327     Register pop_cond = NOT_LP64(java_thread) // Not clear if any other register is available on 32 bit
 328                         LP64_ONLY(c_rarg0);
 329     movl(pop_cond, Address(java_thread, JavaThread::popframe_condition_offset()));
 330     testl(pop_cond, JavaThread::popframe_pending_bit);
 331     jcc(Assembler::zero, L);
 332     testl(pop_cond, JavaThread::popframe_processing_bit);
 333     jcc(Assembler::notZero, L);
 334     // Call Interpreter::remove_activation_preserving_args_entry() to get the
 335     // address of the same-named entrypoint in the generated interpreter code.
 336     call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
 337     jmp(rax);
 338     bind(L);
 339     NOT_LP64(get_thread(java_thread);)
 340   }
 341 }
 342 
 343 void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
 344   Register thread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
 345   NOT_LP64(get_thread(thread);)
 346   movptr(rcx, Address(thread, JavaThread::jvmti_thread_state_offset()));
 347   const Address tos_addr(rcx, JvmtiThreadState::earlyret_tos_offset());
 348   const Address oop_addr(rcx, JvmtiThreadState::earlyret_oop_offset());
 349   const Address val_addr(rcx, JvmtiThreadState::earlyret_value_offset());
 350 #ifdef _LP64
 351   switch (state) {
 352     case atos: movptr(rax, oop_addr);
 353                movptr(oop_addr, (int32_t)NULL_WORD);
 354                interp_verify_oop(rax, state);         break;
 355     case ltos: movptr(rax, val_addr);                 break;
 356     case btos:                                   // fall through
 357     case ztos:                                   // fall through
 358     case ctos:                                   // fall through
 359     case stos:                                   // fall through
 360     case itos: movl(rax, val_addr);                 break;
 361     case ftos: load_float(val_addr);                break;
 362     case dtos: load_double(val_addr);               break;
 363     case vtos: /* nothing to do */                  break;
 364     default  : ShouldNotReachHere();
 365   }
 366   // Clean up tos value in the thread object
 367   movl(tos_addr,  (int) ilgl);
 368   movl(val_addr,  (int32_t) NULL_WORD);
 369 #else
 370   const Address val_addr1(rcx, JvmtiThreadState::earlyret_value_offset()
 371                              + in_ByteSize(wordSize));
 372   switch (state) {
 373     case atos: movptr(rax, oop_addr);
 374                movptr(oop_addr, NULL_WORD);
 375                interp_verify_oop(rax, state);         break;
 376     case ltos:
 377                movl(rdx, val_addr1);               // fall through
 378     case btos:                                     // fall through
 379     case ztos:                                     // fall through
 380     case ctos:                                     // fall through
 381     case stos:                                     // fall through
 382     case itos: movl(rax, val_addr);                   break;
 383     case ftos: load_float(val_addr);                  break;
 384     case dtos: load_double(val_addr);                 break;
 385     case vtos: /* nothing to do */                    break;
 386     default  : ShouldNotReachHere();
 387   }
 388 #endif // _LP64
 389   // Clean up tos value in the thread object
 390   movl(tos_addr,  (int32_t) ilgl);
 391   movptr(val_addr,  NULL_WORD);
 392   NOT_LP64(movptr(val_addr1, NULL_WORD);)
 393 }
 394 
 395 
 396 void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) {
 397   if (JvmtiExport::can_force_early_return()) {
 398     Label L;
 399     Register tmp = LP64_ONLY(c_rarg0) NOT_LP64(java_thread);
 400     Register rthread = LP64_ONLY(r15_thread) NOT_LP64(java_thread);
 401 
 402     movptr(tmp, Address(rthread, JavaThread::jvmti_thread_state_offset()));
 403     testptr(tmp, tmp);
 404     jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == NULL) exit;
 405 
 406     // Initiate earlyret handling only if it is not already being processed.
 407     // If the flag has the earlyret_processing bit set, it means that this code
 408     // is called *during* earlyret handling - we don't want to reenter.
 409     movl(tmp, Address(tmp, JvmtiThreadState::earlyret_state_offset()));
 410     cmpl(tmp, JvmtiThreadState::earlyret_pending);
 411     jcc(Assembler::notEqual, L);
 412 
 413     // Call Interpreter::remove_activation_early_entry() to get the address of the
 414     // same-named entrypoint in the generated interpreter code.
 415     NOT_LP64(get_thread(java_thread);)
 416     movptr(tmp, Address(rthread, JavaThread::jvmti_thread_state_offset()));
 417 #ifdef _LP64
 418     movl(tmp, Address(tmp, JvmtiThreadState::earlyret_tos_offset()));
 419     call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), tmp);
 420 #else
 421     pushl(Address(tmp, JvmtiThreadState::earlyret_tos_offset()));
 422     call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), 1);
 423 #endif // _LP64
 424     jmp(rax);
 425     bind(L);
 426     NOT_LP64(get_thread(java_thread);)
 427   }
 428 }
 429 
 430 void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) {
 431   assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode");
 432   load_unsigned_short(reg, Address(_bcp_register, bcp_offset));
 433   bswapl(reg);
 434   shrl(reg, 16);
 435 }
 436 
 437 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
 438                                                        int bcp_offset,
 439                                                        size_t index_size) {
 440   assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
 441   if (index_size == sizeof(u2)) {
 442     load_unsigned_short(index, Address(_bcp_register, bcp_offset));
 443   } else if (index_size == sizeof(u4)) {
 444     movl(index, Address(_bcp_register, bcp_offset));
 445     // Check if the secondary index definition is still ~x, otherwise
 446     // we have to change the following assembler code to calculate the
 447     // plain index.
 448     assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
 449     notl(index);  // convert to plain index
 450   } else if (index_size == sizeof(u1)) {
 451     load_unsigned_byte(index, Address(_bcp_register, bcp_offset));
 452   } else {
 453     ShouldNotReachHere();
 454   }
 455 }
 456 
 457 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache,
 458                                                            Register index,
 459                                                            int bcp_offset,
 460                                                            size_t index_size) {
 461   assert_different_registers(cache, index);
 462   get_cache_index_at_bcp(index, bcp_offset, index_size);
 463   movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));
 464   assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below");
 465   // convert from field index to ConstantPoolCacheEntry index
 466   assert(exact_log2(in_words(ConstantPoolCacheEntry::size())) == 2, "else change next line");
 467   shll(index, 2);
 468 }
 469 
 470 void InterpreterMacroAssembler::get_cache_and_index_and_bytecode_at_bcp(Register cache,
 471                                                                         Register index,
 472                                                                         Register bytecode,
 473                                                                         int byte_no,
 474                                                                         int bcp_offset,
 475                                                                         size_t index_size) {
 476   get_cache_and_index_at_bcp(cache, index, bcp_offset, index_size);
 477   // We use a 32-bit load here since the layout of 64-bit words on
 478   // little-endian machines allow us that.
 479   movl(bytecode, Address(cache, index, Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()));
 480   const int shift_count = (1 + byte_no) * BitsPerByte;
 481   assert((byte_no == TemplateTable::f1_byte && shift_count == ConstantPoolCacheEntry::bytecode_1_shift) ||
 482          (byte_no == TemplateTable::f2_byte && shift_count == ConstantPoolCacheEntry::bytecode_2_shift),
 483          "correct shift count");
 484   shrl(bytecode, shift_count);
 485   assert(ConstantPoolCacheEntry::bytecode_1_mask == ConstantPoolCacheEntry::bytecode_2_mask, "common mask");
 486   andl(bytecode, ConstantPoolCacheEntry::bytecode_1_mask);
 487 }
 488 
 489 void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache,
 490                                                                Register tmp,
 491                                                                int bcp_offset,
 492                                                                size_t index_size) {
 493   assert_different_registers(cache, tmp);
 494 
 495   get_cache_index_at_bcp(tmp, bcp_offset, index_size);
 496   assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below");
 497   // convert from field index to ConstantPoolCacheEntry index
 498   // and from word offset to byte offset
 499   assert(exact_log2(in_bytes(ConstantPoolCacheEntry::size_in_bytes())) == 2 + LogBytesPerWord, "else change next line");
 500   shll(tmp, 2 + LogBytesPerWord);
 501   movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));
 502   // skip past the header
 503   addptr(cache, in_bytes(ConstantPoolCache::base_offset()));
 504   addptr(cache, tmp);  // construct pointer to cache entry
 505 }
 506 
 507 // Load object from cpool->resolved_references(index)
 508 void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result,
 509                                                                  Register index,
 510                                                                  Register tmp) {
 511   assert_different_registers(result, index);
 512 
 513   get_constant_pool(result);
 514   // load pointer for resolved_references[] objArray
 515   movptr(result, Address(result, ConstantPool::cache_offset_in_bytes()));
 516   movptr(result, Address(result, ConstantPoolCache::resolved_references_offset_in_bytes()));
 517   resolve_oop_handle(result, tmp);
 518   load_heap_oop(result, Address(result, index,
 519                                 UseCompressedOops ? Address::times_4 : Address::times_ptr,
 520                                 arrayOopDesc::base_offset_in_bytes(T_OBJECT)), tmp);
 521 }
 522 
 523 // load cpool->resolved_klass_at(index)
 524 void InterpreterMacroAssembler::load_resolved_klass_at_index(Register klass,
 525                                                              Register cpool,
 526                                                              Register index) {
 527   assert_different_registers(cpool, index);
 528 
 529   movw(index, Address(cpool, index, Address::times_ptr, sizeof(ConstantPool)));
 530   Register resolved_klasses = cpool;
 531   movptr(resolved_klasses, Address(cpool, ConstantPool::resolved_klasses_offset_in_bytes()));
 532   movptr(klass, Address(resolved_klasses, index, Address::times_ptr, Array<Klass*>::base_offset_in_bytes()));
 533 }
 534 
 535 void InterpreterMacroAssembler::load_resolved_method_at_index(int byte_no,
 536                                                               Register method,
 537                                                               Register cache,
 538                                                               Register index) {
 539   assert_different_registers(cache, index);
 540 
 541   const int method_offset = in_bytes(
 542     ConstantPoolCache::base_offset() +
 543       ((byte_no == TemplateTable::f2_byte)
 544        ? ConstantPoolCacheEntry::f2_offset()
 545        : ConstantPoolCacheEntry::f1_offset()));
 546 
 547   movptr(method, Address(cache, index, Address::times_ptr, method_offset)); // get f1 Method*
 548 }
 549 
 550 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
 551 // subtype of super_klass.
 552 //
 553 // Args:
 554 //      rax: superklass
 555 //      Rsub_klass: subklass
 556 //
 557 // Kills:
 558 //      rcx, rdi
 559 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
 560                                                   Label& ok_is_subtype,
 561                                                   bool profile) {
 562   assert(Rsub_klass != rax, "rax holds superklass");
 563   LP64_ONLY(assert(Rsub_klass != r14, "r14 holds locals");)
 564   LP64_ONLY(assert(Rsub_klass != r13, "r13 holds bcp");)
 565   assert(Rsub_klass != rcx, "rcx holds 2ndary super array length");
 566   assert(Rsub_klass != rdi, "rdi holds 2ndary super array scan ptr");
 567 
 568   // Profile the not-null value's klass.
 569   if (profile) {
 570     profile_typecheck(rcx, Rsub_klass, rdi); // blows rcx, reloads rdi
 571   }
 572 
 573   // Do the check.
 574   check_klass_subtype(Rsub_klass, rax, rcx, ok_is_subtype); // blows rcx
 575 
 576   // Profile the failure of the check.
 577   if (profile) {
 578     profile_typecheck_failed(rcx); // blows rcx
 579   }
 580 }
 581 
 582 
 583 #ifndef _LP64
 584 void InterpreterMacroAssembler::f2ieee() {
 585   if (IEEEPrecision) {
 586     fstp_s(Address(rsp, 0));
 587     fld_s(Address(rsp, 0));
 588   }
 589 }
 590 
 591 
 592 void InterpreterMacroAssembler::d2ieee() {
 593   if (IEEEPrecision) {
 594     fstp_d(Address(rsp, 0));
 595     fld_d(Address(rsp, 0));
 596   }
 597 }
 598 #endif // _LP64
 599 
 600 // Java Expression Stack
 601 
 602 void InterpreterMacroAssembler::pop_ptr(Register r) {
 603   pop(r);
 604 }
 605 
 606 void InterpreterMacroAssembler::push_ptr(Register r) {
 607   push(r);
 608 }
 609 
 610 void InterpreterMacroAssembler::push_i(Register r) {
 611   push(r);
 612 }
 613 
 614 void InterpreterMacroAssembler::push_i_or_ptr(Register r) {
 615   push(r);
 616 }
 617 
 618 void InterpreterMacroAssembler::push_f(XMMRegister r) {
 619   subptr(rsp, wordSize);
 620   movflt(Address(rsp, 0), r);
 621 }
 622 
 623 void InterpreterMacroAssembler::pop_f(XMMRegister r) {
 624   movflt(r, Address(rsp, 0));
 625   addptr(rsp, wordSize);
 626 }
 627 
 628 void InterpreterMacroAssembler::push_d(XMMRegister r) {
 629   subptr(rsp, 2 * wordSize);
 630   movdbl(Address(rsp, 0), r);
 631 }
 632 
 633 void InterpreterMacroAssembler::pop_d(XMMRegister r) {
 634   movdbl(r, Address(rsp, 0));
 635   addptr(rsp, 2 * Interpreter::stackElementSize);
 636 }
 637 
 638 #ifdef _LP64
 639 void InterpreterMacroAssembler::pop_i(Register r) {
 640   // XXX can't use pop currently, upper half non clean
 641   movl(r, Address(rsp, 0));
 642   addptr(rsp, wordSize);
 643 }
 644 
 645 void InterpreterMacroAssembler::pop_l(Register r) {
 646   movq(r, Address(rsp, 0));
 647   addptr(rsp, 2 * Interpreter::stackElementSize);
 648 }
 649 
 650 void InterpreterMacroAssembler::push_l(Register r) {
 651   subptr(rsp, 2 * wordSize);
 652   movptr(Address(rsp, Interpreter::expr_offset_in_bytes(0)), r         );
 653   movptr(Address(rsp, Interpreter::expr_offset_in_bytes(1)), NULL_WORD );
 654 }
 655 
 656 void InterpreterMacroAssembler::pop(TosState state) {
 657   switch (state) {
 658   case atos: pop_ptr();                 break;
 659   case btos:
 660   case ztos:
 661   case ctos:
 662   case stos:
 663   case itos: pop_i();                   break;
 664   case ltos: pop_l();                   break;
 665   case ftos: pop_f(xmm0);               break;
 666   case dtos: pop_d(xmm0);               break;
 667   case vtos: /* nothing to do */        break;
 668   default:   ShouldNotReachHere();
 669   }
 670   interp_verify_oop(rax, state);
 671 }
 672 
 673 void InterpreterMacroAssembler::push(TosState state) {
 674   interp_verify_oop(rax, state);
 675   switch (state) {
 676   case atos: push_ptr();                break;
 677   case btos:
 678   case ztos:
 679   case ctos:
 680   case stos:
 681   case itos: push_i();                  break;
 682   case ltos: push_l();                  break;
 683   case ftos: push_f(xmm0);              break;
 684   case dtos: push_d(xmm0);              break;
 685   case vtos: /* nothing to do */        break;
 686   default  : ShouldNotReachHere();
 687   }
 688 }
 689 #else
 690 void InterpreterMacroAssembler::pop_i(Register r) {
 691   pop(r);
 692 }
 693 
 694 void InterpreterMacroAssembler::pop_l(Register lo, Register hi) {
 695   pop(lo);
 696   pop(hi);
 697 }
 698 
 699 void InterpreterMacroAssembler::pop_f() {
 700   fld_s(Address(rsp, 0));
 701   addptr(rsp, 1 * wordSize);
 702 }
 703 
 704 void InterpreterMacroAssembler::pop_d() {
 705   fld_d(Address(rsp, 0));
 706   addptr(rsp, 2 * wordSize);
 707 }
 708 
 709 
 710 void InterpreterMacroAssembler::pop(TosState state) {
 711   switch (state) {
 712     case atos: pop_ptr(rax);                                 break;
 713     case btos:                                               // fall through
 714     case ztos:                                               // fall through
 715     case ctos:                                               // fall through
 716     case stos:                                               // fall through
 717     case itos: pop_i(rax);                                   break;
 718     case ltos: pop_l(rax, rdx);                              break;
 719     case ftos:
 720       if (UseSSE >= 1) {
 721         pop_f(xmm0);
 722       } else {
 723         pop_f();
 724       }
 725       break;
 726     case dtos:
 727       if (UseSSE >= 2) {
 728         pop_d(xmm0);
 729       } else {
 730         pop_d();
 731       }
 732       break;
 733     case vtos: /* nothing to do */                           break;
 734     default  : ShouldNotReachHere();
 735   }
 736   interp_verify_oop(rax, state);
 737 }
 738 
 739 
 740 void InterpreterMacroAssembler::push_l(Register lo, Register hi) {
 741   push(hi);
 742   push(lo);
 743 }
 744 
 745 void InterpreterMacroAssembler::push_f() {
 746   // Do not schedule for no AGI! Never write beyond rsp!
 747   subptr(rsp, 1 * wordSize);
 748   fstp_s(Address(rsp, 0));
 749 }
 750 
 751 void InterpreterMacroAssembler::push_d() {
 752   // Do not schedule for no AGI! Never write beyond rsp!
 753   subptr(rsp, 2 * wordSize);
 754   fstp_d(Address(rsp, 0));
 755 }
 756 
 757 
 758 void InterpreterMacroAssembler::push(TosState state) {
 759   interp_verify_oop(rax, state);
 760   switch (state) {
 761     case atos: push_ptr(rax); break;
 762     case btos:                                               // fall through
 763     case ztos:                                               // fall through
 764     case ctos:                                               // fall through
 765     case stos:                                               // fall through
 766     case itos: push_i(rax);                                    break;
 767     case ltos: push_l(rax, rdx);                               break;
 768     case ftos:
 769       if (UseSSE >= 1) {
 770         push_f(xmm0);
 771       } else {
 772         push_f();
 773       }
 774       break;
 775     case dtos:
 776       if (UseSSE >= 2) {
 777         push_d(xmm0);
 778       } else {
 779         push_d();
 780       }
 781       break;
 782     case vtos: /* nothing to do */                             break;
 783     default  : ShouldNotReachHere();
 784   }
 785 }
 786 #endif // _LP64
 787 
 788 
 789 // Helpers for swap and dup
 790 void InterpreterMacroAssembler::load_ptr(int n, Register val) {
 791   movptr(val, Address(rsp, Interpreter::expr_offset_in_bytes(n)));
 792 }
 793 
 794 void InterpreterMacroAssembler::store_ptr(int n, Register val) {
 795   movptr(Address(rsp, Interpreter::expr_offset_in_bytes(n)), val);
 796 }
 797 
 798 
 799 void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() {
 800   // set sender sp
 801   lea(_bcp_register, Address(rsp, wordSize));
 802   // record last_sp
 803   movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), _bcp_register);
 804 }
 805 
 806 
 807 // Jump to from_interpreted entry of a call unless single stepping is possible
 808 // in this thread in which case we must call the i2i entry
 809 void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) {
 810   prepare_to_jump_from_interpreted();
 811 
 812   if (JvmtiExport::can_post_interpreter_events()) {
 813     Label run_compiled_code;
 814     // JVMTI events, such as single-stepping, are implemented partly by avoiding running
 815     // compiled code in threads for which the event is enabled.  Check here for
 816     // interp_only_mode if these events CAN be enabled.
 817     // interp_only is an int, on little endian it is sufficient to test the byte only
 818     // Is a cmpl faster?
 819     LP64_ONLY(temp = r15_thread;)
 820     NOT_LP64(get_thread(temp);)
 821     cmpb(Address(temp, JavaThread::interp_only_mode_offset()), 0);
 822     jccb(Assembler::zero, run_compiled_code);
 823     jmp(Address(method, Method::interpreter_entry_offset()));
 824     bind(run_compiled_code);
 825   }
 826 
 827   jmp(Address(method, Method::from_interpreted_offset()));
 828 }
 829 
 830 // The following two routines provide a hook so that an implementation
 831 // can schedule the dispatch in two parts.  x86 does not do this.
 832 void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) {
 833   // Nothing x86 specific to be done here
 834 }
 835 
 836 void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) {
 837   dispatch_next(state, step);
 838 }
 839 
 840 void InterpreterMacroAssembler::dispatch_base(TosState state,
 841                                               address* table,
 842                                               bool verifyoop,
 843                                               bool generate_poll) {
 844   verify_FPU(1, state);
 845   if (VerifyActivationFrameSize) {
 846     Label L;
 847     mov(rcx, rbp);
 848     subptr(rcx, rsp);
 849     int32_t min_frame_size =
 850       (frame::link_offset - frame::interpreter_frame_initial_sp_offset) *
 851       wordSize;
 852     cmpptr(rcx, (int32_t)min_frame_size);
 853     jcc(Assembler::greaterEqual, L);
 854     stop("broken stack frame");
 855     bind(L);
 856   }
 857   if (verifyoop) {
 858     interp_verify_oop(rax, state);
 859   }
 860 
 861   address* const safepoint_table = Interpreter::safept_table(state);
 862 #ifdef _LP64
 863   Label no_safepoint, dispatch;
 864   if (table != safepoint_table && generate_poll) {
 865     NOT_PRODUCT(block_comment("Thread-local Safepoint poll"));
 866     testb(Address(r15_thread, JavaThread::polling_word_offset()), SafepointMechanism::poll_bit());
 867 
 868     jccb(Assembler::zero, no_safepoint);
 869     lea(rscratch1, ExternalAddress((address)safepoint_table));
 870     jmpb(dispatch);
 871   }
 872 
 873   bind(no_safepoint);
 874   lea(rscratch1, ExternalAddress((address)table));
 875   bind(dispatch);
 876   jmp(Address(rscratch1, rbx, Address::times_8));
 877 
 878 #else
 879   Address index(noreg, rbx, Address::times_ptr);
 880   if (table != safepoint_table && generate_poll) {
 881     NOT_PRODUCT(block_comment("Thread-local Safepoint poll"));
 882     Label no_safepoint;
 883     const Register thread = rcx;
 884     get_thread(thread);
 885     testb(Address(thread, JavaThread::polling_word_offset()), SafepointMechanism::poll_bit());
 886 
 887     jccb(Assembler::zero, no_safepoint);
 888     ArrayAddress dispatch_addr(ExternalAddress((address)safepoint_table), index);
 889     jump(dispatch_addr);
 890     bind(no_safepoint);
 891   }
 892 
 893   {
 894     ArrayAddress dispatch_addr(ExternalAddress((address)table), index);
 895     jump(dispatch_addr);
 896   }
 897 #endif // _LP64
 898 }
 899 
 900 void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) {
 901   dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
 902 }
 903 
 904 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
 905   dispatch_base(state, Interpreter::normal_table(state));
 906 }
 907 
 908 void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) {
 909   dispatch_base(state, Interpreter::normal_table(state), false);
 910 }
 911 
 912 
 913 void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) {
 914   // load next bytecode (load before advancing _bcp_register to prevent AGI)
 915   load_unsigned_byte(rbx, Address(_bcp_register, step));
 916   // advance _bcp_register
 917   increment(_bcp_register, step);
 918   dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
 919 }
 920 
 921 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
 922   // load current bytecode
 923   load_unsigned_byte(rbx, Address(_bcp_register, 0));
 924   dispatch_base(state, table);
 925 }
 926 
 927 void InterpreterMacroAssembler::narrow(Register result) {
 928 
 929   // Get method->_constMethod->_result_type
 930   movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
 931   movptr(rcx, Address(rcx, Method::const_offset()));
 932   load_unsigned_byte(rcx, Address(rcx, ConstMethod::result_type_offset()));
 933 
 934   Label done, notBool, notByte, notChar;
 935 
 936   // common case first
 937   cmpl(rcx, T_INT);
 938   jcc(Assembler::equal, done);
 939 
 940   // mask integer result to narrower return type.
 941   cmpl(rcx, T_BOOLEAN);
 942   jcc(Assembler::notEqual, notBool);
 943   andl(result, 0x1);
 944   jmp(done);
 945 
 946   bind(notBool);
 947   cmpl(rcx, T_BYTE);
 948   jcc(Assembler::notEqual, notByte);
 949   LP64_ONLY(movsbl(result, result);)
 950   NOT_LP64(shll(result, 24);)      // truncate upper 24 bits
 951   NOT_LP64(sarl(result, 24);)      // and sign-extend byte
 952   jmp(done);
 953 
 954   bind(notByte);
 955   cmpl(rcx, T_CHAR);
 956   jcc(Assembler::notEqual, notChar);
 957   LP64_ONLY(movzwl(result, result);)
 958   NOT_LP64(andl(result, 0xFFFF);)  // truncate upper 16 bits
 959   jmp(done);
 960 
 961   bind(notChar);
 962   // cmpl(rcx, T_SHORT);  // all that's left
 963   // jcc(Assembler::notEqual, done);
 964   LP64_ONLY(movswl(result, result);)
 965   NOT_LP64(shll(result, 16);)      // truncate upper 16 bits
 966   NOT_LP64(sarl(result, 16);)      // and sign-extend short
 967 
 968   // Nothing to do for T_INT
 969   bind(done);
 970 }
 971 
 972 // remove activation
 973 //
 974 // Apply stack watermark barrier.
 975 // Unlock the receiver if this is a synchronized method.
 976 // Unlock any Java monitors from syncronized blocks.
 977 // Remove the activation from the stack.
 978 //
 979 // If there are locked Java monitors
 980 //    If throw_monitor_exception
 981 //       throws IllegalMonitorStateException
 982 //    Else if install_monitor_exception
 983 //       installs IllegalMonitorStateException
 984 //    Else
 985 //       no error processing
 986 void InterpreterMacroAssembler::remove_activation(
 987         TosState state,
 988         Register ret_addr,
 989         bool throw_monitor_exception,
 990         bool install_monitor_exception,
 991         bool notify_jvmdi) {
 992   // Note: Registers rdx xmm0 may be in use for the
 993   // result check if synchronized method
 994   Label unlocked, unlock, no_unlock;
 995 
 996   const Register rthread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
 997   const Register robj    = LP64_ONLY(c_rarg1) NOT_LP64(rdx);
 998   const Register rmon    = LP64_ONLY(c_rarg1) NOT_LP64(rcx);
 999                               // monitor pointers need different register
1000                               // because rdx may have the result in it
1001   NOT_LP64(get_thread(rthread);)
1002 
1003   // The below poll is for the stack watermark barrier. It allows fixing up frames lazily,
1004   // that would normally not be safe to use. Such bad returns into unsafe territory of
1005   // the stack, will call InterpreterRuntime::at_unwind.
1006   Label slow_path;
1007   Label fast_path;
1008   safepoint_poll(slow_path, rthread, true /* at_return */, false /* in_nmethod */);
1009   jmp(fast_path);
1010   bind(slow_path);
1011   push(state);
1012   set_last_Java_frame(rthread, noreg, rbp, (address)pc());
1013   super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), rthread);
1014   NOT_LP64(get_thread(rthread);) // call_VM clobbered it, restore
1015   reset_last_Java_frame(rthread, true);
1016   pop(state);
1017   bind(fast_path);
1018 
1019   // get the value of _do_not_unlock_if_synchronized into rdx
1020   const Address do_not_unlock_if_synchronized(rthread,
1021     in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
1022   movbool(rbx, do_not_unlock_if_synchronized);
1023   movbool(do_not_unlock_if_synchronized, false); // reset the flag
1024 
1025   // get method access flags
1026   movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
1027   movl(rcx, Address(rcx, Method::access_flags_offset()));
1028   testl(rcx, JVM_ACC_SYNCHRONIZED);
1029   jcc(Assembler::zero, unlocked);
1030 
1031   // Don't unlock anything if the _do_not_unlock_if_synchronized flag
1032   // is set.
1033   testbool(rbx);
1034   jcc(Assembler::notZero, no_unlock);
1035 
1036   // unlock monitor
1037   push(state); // save result
1038 
1039   // BasicObjectLock will be first in list, since this is a
1040   // synchronized method. However, need to check that the object has
1041   // not been unlocked by an explicit monitorexit bytecode.
1042   const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset *
1043                         wordSize - (int) sizeof(BasicObjectLock));
1044   // We use c_rarg1/rdx so that if we go slow path it will be the correct
1045   // register for unlock_object to pass to VM directly
1046   lea(robj, monitor); // address of first monitor
1047 
1048   movptr(rax, Address(robj, BasicObjectLock::obj_offset_in_bytes()));
1049   testptr(rax, rax);
1050   jcc(Assembler::notZero, unlock);
1051 
1052   pop(state);
1053   if (throw_monitor_exception) {
1054     // Entry already unlocked, need to throw exception
1055     NOT_LP64(empty_FPU_stack();)  // remove possible return value from FPU-stack, otherwise stack could overflow
1056     call_VM(noreg, CAST_FROM_FN_PTR(address,
1057                    InterpreterRuntime::throw_illegal_monitor_state_exception));
1058     should_not_reach_here();
1059   } else {
1060     // Monitor already unlocked during a stack unroll. If requested,
1061     // install an illegal_monitor_state_exception.  Continue with
1062     // stack unrolling.
1063     if (install_monitor_exception) {
1064       NOT_LP64(empty_FPU_stack();)
1065       call_VM(noreg, CAST_FROM_FN_PTR(address,
1066                      InterpreterRuntime::new_illegal_monitor_state_exception));
1067     }
1068     jmp(unlocked);
1069   }
1070 
1071   bind(unlock);
1072   unlock_object(robj);
1073   pop(state);
1074 
1075   // Check that for block-structured locking (i.e., that all locked
1076   // objects has been unlocked)
1077   bind(unlocked);
1078 
1079   // rax, rdx: Might contain return value
1080 
1081   // Check that all monitors are unlocked
1082   {
1083     Label loop, exception, entry, restart;
1084     const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
1085     const Address monitor_block_top(
1086         rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
1087     const Address monitor_block_bot(
1088         rbp, frame::interpreter_frame_initial_sp_offset * wordSize);
1089 
1090     bind(restart);
1091     // We use c_rarg1 so that if we go slow path it will be the correct
1092     // register for unlock_object to pass to VM directly
1093     movptr(rmon, monitor_block_top); // points to current entry, starting
1094                                   // with top-most entry
1095     lea(rbx, monitor_block_bot);  // points to word before bottom of
1096                                   // monitor block
1097     jmp(entry);
1098 
1099     // Entry already locked, need to throw exception
1100     bind(exception);
1101 
1102     if (throw_monitor_exception) {
1103       // Throw exception
1104       NOT_LP64(empty_FPU_stack();)
1105       MacroAssembler::call_VM(noreg,
1106                               CAST_FROM_FN_PTR(address, InterpreterRuntime::
1107                                    throw_illegal_monitor_state_exception));
1108       should_not_reach_here();
1109     } else {
1110       // Stack unrolling. Unlock object and install illegal_monitor_exception.
1111       // Unlock does not block, so don't have to worry about the frame.
1112       // We don't have to preserve c_rarg1 since we are going to throw an exception.
1113 
1114       push(state);
1115       mov(robj, rmon);   // nop if robj and rmon are the same
1116       unlock_object(robj);
1117       pop(state);
1118 
1119       if (install_monitor_exception) {
1120         NOT_LP64(empty_FPU_stack();)
1121         call_VM(noreg, CAST_FROM_FN_PTR(address,
1122                                         InterpreterRuntime::
1123                                         new_illegal_monitor_state_exception));
1124       }
1125 
1126       jmp(restart);
1127     }
1128 
1129     bind(loop);
1130     // check if current entry is used
1131     cmpptr(Address(rmon, BasicObjectLock::obj_offset_in_bytes()), (int32_t) NULL);
1132     jcc(Assembler::notEqual, exception);
1133 
1134     addptr(rmon, entry_size); // otherwise advance to next entry
1135     bind(entry);
1136     cmpptr(rmon, rbx); // check if bottom reached
1137     jcc(Assembler::notEqual, loop); // if not at bottom then check this entry
1138   }
1139 
1140   bind(no_unlock);
1141 
1142   // jvmti support
1143   if (notify_jvmdi) {
1144     notify_method_exit(state, NotifyJVMTI);    // preserve TOSCA
1145   } else {
1146     notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA
1147   }
1148 
1149   if (StackReservedPages > 0) {
1150     movptr(rbx,
1151                Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize));
1152     // testing if reserved zone needs to be re-enabled
1153     Register rthread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
1154     Label no_reserved_zone_enabling;
1155 
1156     NOT_LP64(get_thread(rthread);)
1157 
1158     cmpl(Address(rthread, JavaThread::stack_guard_state_offset()), StackOverflow::stack_guard_enabled);
1159     jcc(Assembler::equal, no_reserved_zone_enabling);
1160 
1161     cmpptr(rbx, Address(rthread, JavaThread::reserved_stack_activation_offset()));
1162     jcc(Assembler::lessEqual, no_reserved_zone_enabling);
1163 
1164     call_VM_leaf(
1165       CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread);
1166     call_VM(noreg, CAST_FROM_FN_PTR(address,
1167                    InterpreterRuntime::throw_delayed_StackOverflowError));
1168     should_not_reach_here();
1169 
1170     bind(no_reserved_zone_enabling);
1171   }
1172 
1173   // remove activation
1174   // get sender sp
1175   movptr(rbx,
1176          Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize));
1177 
1178   if (state == atos && InlineTypeReturnedAsFields) {
1179     Label skip;
1180     // Test if the return type is an inline type
1181     movptr(rdi, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
1182     movptr(rdi, Address(rdi, Method::const_offset()));
1183     load_unsigned_byte(rdi, Address(rdi, ConstMethod::result_type_offset()));
1184     cmpl(rdi, T_INLINE_TYPE);
1185     jcc(Assembler::notEqual, skip);
1186 
1187     // We are returning an inline type, load its fields into registers
1188 #ifndef _LP64
1189     super_call_VM_leaf(StubRoutines::load_inline_type_fields_in_regs());
1190 #else
1191     // Load fields from a buffered value with an inline class specific handler
1192     Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
1193     load_klass(rdi, rax, tmp_load_klass);
1194     movptr(rdi, Address(rdi, InstanceKlass::adr_inlineklass_fixed_block_offset()));
1195     movptr(rdi, Address(rdi, InlineKlass::unpack_handler_offset()));
1196 
1197     testptr(rdi, rdi);
1198     jcc(Assembler::equal, skip);
1199 
1200     call(rdi);
1201 #endif
1202     // call above kills the value in rbx. Reload it.
1203     movptr(rbx, Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize));
1204     bind(skip);
1205   }
1206   leave();                           // remove frame anchor
1207   pop(ret_addr);                     // get return address
1208   mov(rsp, rbx);                     // set sp to sender sp
1209 }
1210 
1211 void InterpreterMacroAssembler::get_method_counters(Register method,
1212                                                     Register mcs, Label& skip) {
1213   Label has_counters;
1214   movptr(mcs, Address(method, Method::method_counters_offset()));
1215   testptr(mcs, mcs);
1216   jcc(Assembler::notZero, has_counters);
1217   call_VM(noreg, CAST_FROM_FN_PTR(address,
1218           InterpreterRuntime::build_method_counters), method);
1219   movptr(mcs, Address(method,Method::method_counters_offset()));
1220   testptr(mcs, mcs);
1221   jcc(Assembler::zero, skip); // No MethodCounters allocated, OutOfMemory
1222   bind(has_counters);
1223 }
1224 
1225 void InterpreterMacroAssembler::allocate_instance(Register klass, Register new_obj,
1226                                                   Register t1, Register t2,
1227                                                   bool clear_fields, Label& alloc_failed) {
1228   MacroAssembler::allocate_instance(klass, new_obj, t1, t2, clear_fields, alloc_failed);
1229   {
1230     SkipIfEqual skip_if(this, &DTraceAllocProbes, 0);
1231     // Trigger dtrace event for fastpath
1232     push(atos);
1233     call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), new_obj);
1234     pop(atos);
1235   }
1236 }
1237 
1238 
1239 void InterpreterMacroAssembler::read_inlined_field(Register holder_klass,
1240                                                      Register field_index, Register field_offset,
1241                                                      Register obj) {
1242   Label alloc_failed, empty_value, done;
1243   const Register src = field_offset;
1244   const Register alloc_temp = LP64_ONLY(rscratch1) NOT_LP64(rsi);
1245   const Register dst_temp   = LP64_ONLY(rscratch2) NOT_LP64(rdi);
1246   assert_different_registers(obj, holder_klass, field_index, field_offset, dst_temp);
1247 
1248   // Grap the inline field klass
1249   push(holder_klass);
1250   const Register field_klass = holder_klass;
1251   get_inline_type_field_klass(holder_klass, field_index, field_klass);
1252 
1253   //check for empty value klass
1254   test_klass_is_empty_inline_type(field_klass, dst_temp, empty_value);
1255 
1256   // allocate buffer
1257   push(obj); // save holder
1258   allocate_instance(field_klass, obj, alloc_temp, dst_temp, false, alloc_failed);
1259 
1260   // Have an oop instance buffer, copy into it
1261   data_for_oop(obj, dst_temp, field_klass);
1262   pop(alloc_temp);             // restore holder
1263   lea(src, Address(alloc_temp, field_offset));
1264   // call_VM_leaf, clobbers a few regs, save restore new obj
1265   push(obj);
1266   access_value_copy(IS_DEST_UNINITIALIZED, src, dst_temp, field_klass);
1267   pop(obj);
1268   pop(holder_klass);
1269   jmp(done);
1270 
1271   bind(empty_value);
1272   get_empty_inline_type_oop(field_klass, dst_temp, obj);
1273   pop(holder_klass);
1274   jmp(done);
1275 
1276   bind(alloc_failed);
1277   pop(obj);
1278   pop(holder_klass);
1279   call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_inlined_field),
1280           obj, field_index, holder_klass);
1281 
1282   bind(done);
1283 }
1284 
1285 void InterpreterMacroAssembler::read_flattened_element(Register array, Register index,
1286                                                        Register t1, Register t2,
1287                                                        Register obj) {
1288   assert_different_registers(array, index, t1, t2);
1289   Label alloc_failed, empty_value, done;
1290   const Register array_klass = t2;
1291   const Register elem_klass = t1;
1292   const Register alloc_temp = LP64_ONLY(rscratch1) NOT_LP64(rsi);
1293   const Register dst_temp   = LP64_ONLY(rscratch2) NOT_LP64(rdi);
1294 
1295   // load in array->klass()->element_klass()
1296   Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
1297   load_klass(array_klass, array, tmp_load_klass);
1298   movptr(elem_klass, Address(array_klass, ArrayKlass::element_klass_offset()));
1299 
1300   //check for empty value klass
1301   test_klass_is_empty_inline_type(elem_klass, dst_temp, empty_value);
1302 
1303   // calc source into "array_klass" and free up some regs
1304   const Register src = array_klass;
1305   push(index); // preserve index reg in case alloc_failed
1306   data_for_value_array_index(array, array_klass, index, src);
1307 
1308   allocate_instance(elem_klass, obj, alloc_temp, dst_temp, false, alloc_failed);
1309   // Have an oop instance buffer, copy into it
1310   store_ptr(0, obj); // preserve obj (overwrite index, no longer needed)
1311   data_for_oop(obj, dst_temp, elem_klass);
1312   access_value_copy(IS_DEST_UNINITIALIZED, src, dst_temp, elem_klass);
1313   pop(obj);
1314   jmp(done);
1315 
1316   bind(empty_value);
1317   get_empty_inline_type_oop(elem_klass, dst_temp, obj);
1318   jmp(done);
1319 
1320   bind(alloc_failed);
1321   pop(index);
1322   if (array == c_rarg2) {
1323     mov(elem_klass, array);
1324     array = elem_klass;
1325   }
1326   call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::value_array_load), array, index);
1327 
1328   bind(done);
1329 }
1330 
1331 
1332 // Lock object
1333 //
1334 // Args:
1335 //      rdx, c_rarg1: BasicObjectLock to be used for locking
1336 //
1337 // Kills:
1338 //      rax, rbx
1339 void InterpreterMacroAssembler::lock_object(Register lock_reg) {
1340   assert(lock_reg == LP64_ONLY(c_rarg1) NOT_LP64(rdx),
1341          "The argument is only for looks. It must be c_rarg1");
1342 
1343   if (UseHeavyMonitors) {
1344     call_VM(noreg,
1345             CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
1346             lock_reg);
1347   } else {
1348     Label done;
1349 
1350     const Register swap_reg = rax; // Must use rax for cmpxchg instruction
1351     const Register tmp_reg = rbx;
1352     const Register obj_reg = LP64_ONLY(c_rarg3) NOT_LP64(rcx); // Will contain the oop
1353     const Register rklass_decode_tmp = LP64_ONLY(rscratch1) NOT_LP64(noreg);
1354 
1355     const int obj_offset = BasicObjectLock::obj_offset_in_bytes();
1356     const int lock_offset = BasicObjectLock::lock_offset_in_bytes ();
1357     const int mark_offset = lock_offset +
1358                             BasicLock::displaced_header_offset_in_bytes();
1359 
1360     Label slow_case;
1361 
1362     // Load object pointer into obj_reg
1363     movptr(obj_reg, Address(lock_reg, obj_offset));
1364 
1365     if (DiagnoseSyncOnValueBasedClasses != 0) {
1366       load_klass(tmp_reg, obj_reg, rklass_decode_tmp);
1367       movl(tmp_reg, Address(tmp_reg, Klass::access_flags_offset()));
1368       testl(tmp_reg, JVM_ACC_IS_VALUE_BASED_CLASS);
1369       jcc(Assembler::notZero, slow_case);
1370     }
1371 
1372     // Load immediate 1 into swap_reg %rax
1373     movl(swap_reg, (int32_t)1);
1374 
1375     // Load (object->mark() | 1) into swap_reg %rax
1376     orptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1377     if (EnableValhalla) {
1378       // Mask inline_type bit such that we go to the slow path if object is an inline type
1379       andptr(swap_reg, ~((int) markWord::inline_type_bit_in_place));
1380     }
1381 
1382     // Save (object->mark() | 1) into BasicLock's displaced header
1383     movptr(Address(lock_reg, mark_offset), swap_reg);
1384 
1385     assert(lock_offset == 0,
1386            "displaced header must be first word in BasicObjectLock");
1387 
1388     lock();
1389     cmpxchgptr(lock_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1390     jcc(Assembler::zero, done);
1391 
1392     const int zero_bits = LP64_ONLY(7) NOT_LP64(3);
1393 
1394     // Fast check for recursive lock.
1395     //
1396     // Can apply the optimization only if this is a stack lock
1397     // allocated in this thread. For efficiency, we can focus on
1398     // recently allocated stack locks (instead of reading the stack
1399     // base and checking whether 'mark' points inside the current
1400     // thread stack):
1401     //  1) (mark & zero_bits) == 0, and
1402     //  2) rsp <= mark < mark + os::pagesize()
1403     //
1404     // Warning: rsp + os::pagesize can overflow the stack base. We must
1405     // neither apply the optimization for an inflated lock allocated
1406     // just above the thread stack (this is why condition 1 matters)
1407     // nor apply the optimization if the stack lock is inside the stack
1408     // of another thread. The latter is avoided even in case of overflow
1409     // because we have guard pages at the end of all stacks. Hence, if
1410     // we go over the stack base and hit the stack of another thread,
1411     // this should not be in a writeable area that could contain a
1412     // stack lock allocated by that thread. As a consequence, a stack
1413     // lock less than page size away from rsp is guaranteed to be
1414     // owned by the current thread.
1415     //
1416     // These 3 tests can be done by evaluating the following
1417     // expression: ((mark - rsp) & (zero_bits - os::vm_page_size())),
1418     // assuming both stack pointer and pagesize have their
1419     // least significant bits clear.
1420     // NOTE: the mark is in swap_reg %rax as the result of cmpxchg
1421     subptr(swap_reg, rsp);
1422     andptr(swap_reg, zero_bits - os::vm_page_size());
1423 
1424     // Save the test result, for recursive case, the result is zero
1425     movptr(Address(lock_reg, mark_offset), swap_reg);
1426     jcc(Assembler::zero, done);
1427 
1428     bind(slow_case);
1429 
1430     // Call the runtime routine for slow case
1431     call_VM(noreg,
1432             CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
1433             lock_reg);
1434 
1435     bind(done);
1436   }
1437 }
1438 
1439 
1440 // Unlocks an object. Used in monitorexit bytecode and
1441 // remove_activation.  Throws an IllegalMonitorException if object is
1442 // not locked by current thread.
1443 //
1444 // Args:
1445 //      rdx, c_rarg1: BasicObjectLock for lock
1446 //
1447 // Kills:
1448 //      rax
1449 //      c_rarg0, c_rarg1, c_rarg2, c_rarg3, ... (param regs)
1450 //      rscratch1 (scratch reg)
1451 // rax, rbx, rcx, rdx
1452 void InterpreterMacroAssembler::unlock_object(Register lock_reg) {
1453   assert(lock_reg == LP64_ONLY(c_rarg1) NOT_LP64(rdx),
1454          "The argument is only for looks. It must be c_rarg1");
1455 
1456   if (UseHeavyMonitors) {
1457     call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);
1458   } else {
1459     Label done;
1460 
1461     const Register swap_reg   = rax;  // Must use rax for cmpxchg instruction
1462     const Register header_reg = LP64_ONLY(c_rarg2) NOT_LP64(rbx);  // Will contain the old oopMark
1463     const Register obj_reg    = LP64_ONLY(c_rarg3) NOT_LP64(rcx);  // Will contain the oop
1464 
1465     save_bcp(); // Save in case of exception
1466 
1467     // Convert from BasicObjectLock structure to object and BasicLock
1468     // structure Store the BasicLock address into %rax
1469     lea(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset_in_bytes()));
1470 
1471     // Load oop into obj_reg(%c_rarg3)
1472     movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()));
1473 
1474     // Free entry
1475     movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD);
1476 
1477     // Load the old header from BasicLock structure
1478     movptr(header_reg, Address(swap_reg,
1479                                BasicLock::displaced_header_offset_in_bytes()));
1480 
1481     // Test for recursion
1482     testptr(header_reg, header_reg);
1483 
1484     // zero for recursive case
1485     jcc(Assembler::zero, done);
1486 
1487     // Atomic swap back the old header
1488     lock();
1489     cmpxchgptr(header_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1490 
1491     // zero for simple unlock of a stack-lock case
1492     jcc(Assembler::zero, done);
1493 
1494 
1495     // Call the runtime routine for slow case.
1496     movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), obj_reg); // restore obj
1497     call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);
1498 
1499     bind(done);
1500 
1501     restore_bcp();
1502   }
1503 }
1504 
1505 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp,
1506                                                          Label& zero_continue) {
1507   assert(ProfileInterpreter, "must be profiling interpreter");
1508   movptr(mdp, Address(rbp, frame::interpreter_frame_mdp_offset * wordSize));
1509   testptr(mdp, mdp);
1510   jcc(Assembler::zero, zero_continue);
1511 }
1512 
1513 
1514 // Set the method data pointer for the current bcp.
1515 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
1516   assert(ProfileInterpreter, "must be profiling interpreter");
1517   Label set_mdp;
1518   push(rax);
1519   push(rbx);
1520 
1521   get_method(rbx);
1522   // Test MDO to avoid the call if it is NULL.
1523   movptr(rax, Address(rbx, in_bytes(Method::method_data_offset())));
1524   testptr(rax, rax);
1525   jcc(Assembler::zero, set_mdp);
1526   // rbx: method
1527   // _bcp_register: bcp
1528   call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, _bcp_register);
1529   // rax: mdi
1530   // mdo is guaranteed to be non-zero here, we checked for it before the call.
1531   movptr(rbx, Address(rbx, in_bytes(Method::method_data_offset())));
1532   addptr(rbx, in_bytes(MethodData::data_offset()));
1533   addptr(rax, rbx);
1534   bind(set_mdp);
1535   movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), rax);
1536   pop(rbx);
1537   pop(rax);
1538 }
1539 
1540 void InterpreterMacroAssembler::verify_method_data_pointer() {
1541   assert(ProfileInterpreter, "must be profiling interpreter");
1542 #ifdef ASSERT
1543   Label verify_continue;
1544   push(rax);
1545   push(rbx);
1546   Register arg3_reg = LP64_ONLY(c_rarg3) NOT_LP64(rcx);
1547   Register arg2_reg = LP64_ONLY(c_rarg2) NOT_LP64(rdx);
1548   push(arg3_reg);
1549   push(arg2_reg);
1550   test_method_data_pointer(arg3_reg, verify_continue); // If mdp is zero, continue
1551   get_method(rbx);
1552 
1553   // If the mdp is valid, it will point to a DataLayout header which is
1554   // consistent with the bcp.  The converse is highly probable also.
1555   load_unsigned_short(arg2_reg,
1556                       Address(arg3_reg, in_bytes(DataLayout::bci_offset())));
1557   addptr(arg2_reg, Address(rbx, Method::const_offset()));
1558   lea(arg2_reg, Address(arg2_reg, ConstMethod::codes_offset()));
1559   cmpptr(arg2_reg, _bcp_register);
1560   jcc(Assembler::equal, verify_continue);
1561   // rbx: method
1562   // _bcp_register: bcp
1563   // c_rarg3: mdp
1564   call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp),
1565                rbx, _bcp_register, arg3_reg);
1566   bind(verify_continue);
1567   pop(arg2_reg);
1568   pop(arg3_reg);
1569   pop(rbx);
1570   pop(rax);
1571 #endif // ASSERT
1572 }
1573 
1574 
1575 void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in,
1576                                                 int constant,
1577                                                 Register value) {
1578   assert(ProfileInterpreter, "must be profiling interpreter");
1579   Address data(mdp_in, constant);
1580   movptr(data, value);
1581 }
1582 
1583 
1584 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
1585                                                       int constant,
1586                                                       bool decrement) {
1587   // Counter address
1588   Address data(mdp_in, constant);
1589 
1590   increment_mdp_data_at(data, decrement);
1591 }
1592 
1593 void InterpreterMacroAssembler::increment_mdp_data_at(Address data,
1594                                                       bool decrement) {
1595   assert(ProfileInterpreter, "must be profiling interpreter");
1596   // %%% this does 64bit counters at best it is wasting space
1597   // at worst it is a rare bug when counters overflow
1598 
1599   if (decrement) {
1600     // Decrement the register.  Set condition codes.
1601     addptr(data, (int32_t) -DataLayout::counter_increment);
1602     // If the decrement causes the counter to overflow, stay negative
1603     Label L;
1604     jcc(Assembler::negative, L);
1605     addptr(data, (int32_t) DataLayout::counter_increment);
1606     bind(L);
1607   } else {
1608     assert(DataLayout::counter_increment == 1,
1609            "flow-free idiom only works with 1");
1610     // Increment the register.  Set carry flag.
1611     addptr(data, DataLayout::counter_increment);
1612     // If the increment causes the counter to overflow, pull back by 1.
1613     sbbptr(data, (int32_t)0);
1614   }
1615 }
1616 
1617 
1618 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
1619                                                       Register reg,
1620                                                       int constant,
1621                                                       bool decrement) {
1622   Address data(mdp_in, reg, Address::times_1, constant);
1623 
1624   increment_mdp_data_at(data, decrement);
1625 }
1626 
1627 void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in,
1628                                                 int flag_byte_constant) {
1629   assert(ProfileInterpreter, "must be profiling interpreter");
1630   int header_offset = in_bytes(DataLayout::flags_offset());
1631   int header_bits = flag_byte_constant;
1632   // Set the flag
1633   orb(Address(mdp_in, header_offset), header_bits);
1634 }
1635 
1636 
1637 
1638 void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in,
1639                                                  int offset,
1640                                                  Register value,
1641                                                  Register test_value_out,
1642                                                  Label& not_equal_continue) {
1643   assert(ProfileInterpreter, "must be profiling interpreter");
1644   if (test_value_out == noreg) {
1645     cmpptr(value, Address(mdp_in, offset));
1646   } else {
1647     // Put the test value into a register, so caller can use it:
1648     movptr(test_value_out, Address(mdp_in, offset));
1649     cmpptr(test_value_out, value);
1650   }
1651   jcc(Assembler::notEqual, not_equal_continue);
1652 }
1653 
1654 
1655 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in,
1656                                                      int offset_of_disp) {
1657   assert(ProfileInterpreter, "must be profiling interpreter");
1658   Address disp_address(mdp_in, offset_of_disp);
1659   addptr(mdp_in, disp_address);
1660   movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in);
1661 }
1662 
1663 
1664 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in,
1665                                                      Register reg,
1666                                                      int offset_of_disp) {
1667   assert(ProfileInterpreter, "must be profiling interpreter");
1668   Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp);
1669   addptr(mdp_in, disp_address);
1670   movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in);
1671 }
1672 
1673 
1674 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in,
1675                                                        int constant) {
1676   assert(ProfileInterpreter, "must be profiling interpreter");
1677   addptr(mdp_in, constant);
1678   movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in);
1679 }
1680 
1681 
1682 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
1683   assert(ProfileInterpreter, "must be profiling interpreter");
1684   push(return_bci); // save/restore across call_VM
1685   call_VM(noreg,
1686           CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret),
1687           return_bci);
1688   pop(return_bci);
1689 }
1690 
1691 
1692 void InterpreterMacroAssembler::profile_taken_branch(Register mdp,
1693                                                      Register bumped_count) {
1694   if (ProfileInterpreter) {
1695     Label profile_continue;
1696 
1697     // If no method data exists, go to profile_continue.
1698     // Otherwise, assign to mdp
1699     test_method_data_pointer(mdp, profile_continue);
1700 
1701     // We are taking a branch.  Increment the taken count.
1702     // We inline increment_mdp_data_at to return bumped_count in a register
1703     //increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
1704     Address data(mdp, in_bytes(JumpData::taken_offset()));
1705     movptr(bumped_count, data);
1706     assert(DataLayout::counter_increment == 1,
1707             "flow-free idiom only works with 1");
1708     addptr(bumped_count, DataLayout::counter_increment);
1709     sbbptr(bumped_count, 0);
1710     movptr(data, bumped_count); // Store back out
1711 
1712     // The method data pointer needs to be updated to reflect the new target.
1713     update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
1714     bind(profile_continue);
1715   }
1716 }
1717 
1718 
1719 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp, bool acmp) {
1720   if (ProfileInterpreter) {
1721     Label profile_continue;
1722 
1723     // If no method data exists, go to profile_continue.
1724     test_method_data_pointer(mdp, profile_continue);
1725 
1726     // We are taking a branch.  Increment the not taken count.
1727     increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
1728 
1729     // The method data pointer needs to be updated to correspond to
1730     // the next bytecode
1731     update_mdp_by_constant(mdp, acmp ? in_bytes(ACmpData::acmp_data_size()): in_bytes(BranchData::branch_data_size()));
1732     bind(profile_continue);
1733   }
1734 }
1735 
1736 void InterpreterMacroAssembler::profile_call(Register mdp) {
1737   if (ProfileInterpreter) {
1738     Label profile_continue;
1739 
1740     // If no method data exists, go to profile_continue.
1741     test_method_data_pointer(mdp, profile_continue);
1742 
1743     // We are making a call.  Increment the count.
1744     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1745 
1746     // The method data pointer needs to be updated to reflect the new target.
1747     update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1748     bind(profile_continue);
1749   }
1750 }
1751 
1752 
1753 void InterpreterMacroAssembler::profile_final_call(Register mdp) {
1754   if (ProfileInterpreter) {
1755     Label profile_continue;
1756 
1757     // If no method data exists, go to profile_continue.
1758     test_method_data_pointer(mdp, profile_continue);
1759 
1760     // We are making a call.  Increment the count.
1761     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1762 
1763     // The method data pointer needs to be updated to reflect the new target.
1764     update_mdp_by_constant(mdp,
1765                            in_bytes(VirtualCallData::
1766                                     virtual_call_data_size()));
1767     bind(profile_continue);
1768   }
1769 }
1770 
1771 
1772 void InterpreterMacroAssembler::profile_virtual_call(Register receiver,
1773                                                      Register mdp,
1774                                                      Register reg2,
1775                                                      bool receiver_can_be_null) {
1776   if (ProfileInterpreter) {
1777     Label profile_continue;
1778 
1779     // If no method data exists, go to profile_continue.
1780     test_method_data_pointer(mdp, profile_continue);
1781 
1782     Label skip_receiver_profile;
1783     if (receiver_can_be_null) {
1784       Label not_null;
1785       testptr(receiver, receiver);
1786       jccb(Assembler::notZero, not_null);
1787       // We are making a call.  Increment the count for null receiver.
1788       increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1789       jmp(skip_receiver_profile);
1790       bind(not_null);
1791     }
1792 
1793     // Record the receiver type.
1794     record_klass_in_profile(receiver, mdp, reg2, true);
1795     bind(skip_receiver_profile);
1796 
1797     // The method data pointer needs to be updated to reflect the new target.
1798     update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));
1799     bind(profile_continue);
1800   }
1801 }
1802 
1803 // This routine creates a state machine for updating the multi-row
1804 // type profile at a virtual call site (or other type-sensitive bytecode).
1805 // The machine visits each row (of receiver/count) until the receiver type
1806 // is found, or until it runs out of rows.  At the same time, it remembers
1807 // the location of the first empty row.  (An empty row records null for its
1808 // receiver, and can be allocated for a newly-observed receiver type.)
1809 // Because there are two degrees of freedom in the state, a simple linear
1810 // search will not work; it must be a decision tree.  Hence this helper
1811 // function is recursive, to generate the required tree structured code.
1812 // It's the interpreter, so we are trading off code space for speed.
1813 // See below for example code.
1814 void InterpreterMacroAssembler::record_klass_in_profile_helper(
1815                                         Register receiver, Register mdp,
1816                                         Register reg2, int start_row,
1817                                         Label& done, bool is_virtual_call) {
1818   if (TypeProfileWidth == 0) {
1819     if (is_virtual_call) {
1820       increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1821     }
1822 #if INCLUDE_JVMCI
1823     else if (EnableJVMCI) {
1824       increment_mdp_data_at(mdp, in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset()));
1825     }
1826 #endif // INCLUDE_JVMCI
1827   } else {
1828     int non_profiled_offset = -1;
1829     if (is_virtual_call) {
1830       non_profiled_offset = in_bytes(CounterData::count_offset());
1831     }
1832 #if INCLUDE_JVMCI
1833     else if (EnableJVMCI) {
1834       non_profiled_offset = in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset());
1835     }
1836 #endif // INCLUDE_JVMCI
1837 
1838     record_item_in_profile_helper(receiver, mdp, reg2, 0, done, TypeProfileWidth,
1839         &VirtualCallData::receiver_offset, &VirtualCallData::receiver_count_offset, non_profiled_offset);
1840   }
1841 }
1842 
1843 void InterpreterMacroAssembler::record_item_in_profile_helper(Register item, Register mdp,
1844                                         Register reg2, int start_row, Label& done, int total_rows,
1845                                         OffsetFunction item_offset_fn, OffsetFunction item_count_offset_fn,
1846                                         int non_profiled_offset) {
1847   int last_row = total_rows - 1;
1848   assert(start_row <= last_row, "must be work left to do");
1849   // Test this row for both the item and for null.
1850   // Take any of three different outcomes:
1851   //   1. found item => increment count and goto done
1852   //   2. found null => keep looking for case 1, maybe allocate this cell
1853   //   3. found something else => keep looking for cases 1 and 2
1854   // Case 3 is handled by a recursive call.
1855   for (int row = start_row; row <= last_row; row++) {
1856     Label next_test;
1857     bool test_for_null_also = (row == start_row);
1858 
1859     // See if the item is item[n].
1860     int item_offset = in_bytes(item_offset_fn(row));
1861     test_mdp_data_at(mdp, item_offset, item,
1862                      (test_for_null_also ? reg2 : noreg),
1863                      next_test);
1864     // (Reg2 now contains the item from the CallData.)
1865 
1866     // The item is item[n].  Increment count[n].
1867     int count_offset = in_bytes(item_count_offset_fn(row));
1868     increment_mdp_data_at(mdp, count_offset);
1869     jmp(done);
1870     bind(next_test);
1871 
1872     if (test_for_null_also) {
1873       // Failed the equality check on item[n]...  Test for null.
1874       testptr(reg2, reg2);
1875       if (start_row == last_row) {
1876         // The only thing left to do is handle the null case.
1877         if (non_profiled_offset >= 0) {
1878           Label found_null;
1879           jccb(Assembler::zero, found_null);
1880           // Item did not match any saved item and there is no empty row for it.
1881           // Increment total counter to indicate polymorphic case.
1882           increment_mdp_data_at(mdp, non_profiled_offset);
1883           jmp(done);
1884           bind(found_null);
1885         } else {
1886           jcc(Assembler::notZero, done);
1887         }
1888         break;
1889       }
1890       Label found_null;
1891       // Since null is rare, make it be the branch-taken case.
1892       jcc(Assembler::zero, found_null);
1893 
1894       // Put all the "Case 3" tests here.
1895       record_item_in_profile_helper(item, mdp, reg2, start_row + 1, done, total_rows,
1896         item_offset_fn, item_count_offset_fn, non_profiled_offset);
1897 
1898       // Found a null.  Keep searching for a matching item,
1899       // but remember that this is an empty (unused) slot.
1900       bind(found_null);
1901     }
1902   }
1903 
1904   // In the fall-through case, we found no matching item, but we
1905   // observed the item[start_row] is NULL.
1906 
1907   // Fill in the item field and increment the count.
1908   int item_offset = in_bytes(item_offset_fn(start_row));
1909   set_mdp_data_at(mdp, item_offset, item);
1910   int count_offset = in_bytes(item_count_offset_fn(start_row));
1911   movl(reg2, DataLayout::counter_increment);
1912   set_mdp_data_at(mdp, count_offset, reg2);
1913   if (start_row > 0) {
1914     jmp(done);
1915   }
1916 }
1917 
1918 // Example state machine code for three profile rows:
1919 //   // main copy of decision tree, rooted at row[1]
1920 //   if (row[0].rec == rec) { row[0].incr(); goto done; }
1921 //   if (row[0].rec != NULL) {
1922 //     // inner copy of decision tree, rooted at row[1]
1923 //     if (row[1].rec == rec) { row[1].incr(); goto done; }
1924 //     if (row[1].rec != NULL) {
1925 //       // degenerate decision tree, rooted at row[2]
1926 //       if (row[2].rec == rec) { row[2].incr(); goto done; }
1927 //       if (row[2].rec != NULL) { count.incr(); goto done; } // overflow
1928 //       row[2].init(rec); goto done;
1929 //     } else {
1930 //       // remember row[1] is empty
1931 //       if (row[2].rec == rec) { row[2].incr(); goto done; }
1932 //       row[1].init(rec); goto done;
1933 //     }
1934 //   } else {
1935 //     // remember row[0] is empty
1936 //     if (row[1].rec == rec) { row[1].incr(); goto done; }
1937 //     if (row[2].rec == rec) { row[2].incr(); goto done; }
1938 //     row[0].init(rec); goto done;
1939 //   }
1940 //   done:
1941 
1942 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
1943                                                         Register mdp, Register reg2,
1944                                                         bool is_virtual_call) {
1945   assert(ProfileInterpreter, "must be profiling");
1946   Label done;
1947 
1948   record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call);
1949 
1950   bind (done);
1951 }
1952 
1953 void InterpreterMacroAssembler::profile_ret(Register return_bci,
1954                                             Register mdp) {
1955   if (ProfileInterpreter) {
1956     Label profile_continue;
1957     uint row;
1958 
1959     // If no method data exists, go to profile_continue.
1960     test_method_data_pointer(mdp, profile_continue);
1961 
1962     // Update the total ret count.
1963     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1964 
1965     for (row = 0; row < RetData::row_limit(); row++) {
1966       Label next_test;
1967 
1968       // See if return_bci is equal to bci[n]:
1969       test_mdp_data_at(mdp,
1970                        in_bytes(RetData::bci_offset(row)),
1971                        return_bci, noreg,
1972                        next_test);
1973 
1974       // return_bci is equal to bci[n].  Increment the count.
1975       increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row)));
1976 
1977       // The method data pointer needs to be updated to reflect the new target.
1978       update_mdp_by_offset(mdp,
1979                            in_bytes(RetData::bci_displacement_offset(row)));
1980       jmp(profile_continue);
1981       bind(next_test);
1982     }
1983 
1984     update_mdp_for_ret(return_bci);
1985 
1986     bind(profile_continue);
1987   }
1988 }
1989 
1990 
1991 void InterpreterMacroAssembler::profile_null_seen(Register mdp) {
1992   if (ProfileInterpreter) {
1993     Label profile_continue;
1994 
1995     // If no method data exists, go to profile_continue.
1996     test_method_data_pointer(mdp, profile_continue);
1997 
1998     set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
1999 
2000     // The method data pointer needs to be updated.
2001     int mdp_delta = in_bytes(BitData::bit_data_size());
2002     if (TypeProfileCasts) {
2003       mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
2004     }
2005     update_mdp_by_constant(mdp, mdp_delta);
2006 
2007     bind(profile_continue);
2008   }
2009 }
2010 
2011 
2012 void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) {
2013   if (ProfileInterpreter && TypeProfileCasts) {
2014     Label profile_continue;
2015 
2016     // If no method data exists, go to profile_continue.
2017     test_method_data_pointer(mdp, profile_continue);
2018 
2019     int count_offset = in_bytes(CounterData::count_offset());
2020     // Back up the address, since we have already bumped the mdp.
2021     count_offset -= in_bytes(VirtualCallData::virtual_call_data_size());
2022 
2023     // *Decrement* the counter.  We expect to see zero or small negatives.
2024     increment_mdp_data_at(mdp, count_offset, true);
2025 
2026     bind (profile_continue);
2027   }
2028 }
2029 
2030 
2031 void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) {
2032   if (ProfileInterpreter) {
2033     Label profile_continue;
2034 
2035     // If no method data exists, go to profile_continue.
2036     test_method_data_pointer(mdp, profile_continue);
2037 
2038     // The method data pointer needs to be updated.
2039     int mdp_delta = in_bytes(BitData::bit_data_size());
2040     if (TypeProfileCasts) {
2041       mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
2042 
2043       // Record the object type.
2044       record_klass_in_profile(klass, mdp, reg2, false);
2045       NOT_LP64(assert(reg2 == rdi, "we know how to fix this blown reg");)
2046       NOT_LP64(restore_locals();)         // Restore EDI
2047     }
2048     update_mdp_by_constant(mdp, mdp_delta);
2049 
2050     bind(profile_continue);
2051   }
2052 }
2053 
2054 
2055 void InterpreterMacroAssembler::profile_switch_default(Register mdp) {
2056   if (ProfileInterpreter) {
2057     Label profile_continue;
2058 
2059     // If no method data exists, go to profile_continue.
2060     test_method_data_pointer(mdp, profile_continue);
2061 
2062     // Update the default case count
2063     increment_mdp_data_at(mdp,
2064                           in_bytes(MultiBranchData::default_count_offset()));
2065 
2066     // The method data pointer needs to be updated.
2067     update_mdp_by_offset(mdp,
2068                          in_bytes(MultiBranchData::
2069                                   default_displacement_offset()));
2070 
2071     bind(profile_continue);
2072   }
2073 }
2074 
2075 
2076 void InterpreterMacroAssembler::profile_switch_case(Register index,
2077                                                     Register mdp,
2078                                                     Register reg2) {
2079   if (ProfileInterpreter) {
2080     Label profile_continue;
2081 
2082     // If no method data exists, go to profile_continue.
2083     test_method_data_pointer(mdp, profile_continue);
2084 
2085     // Build the base (index * per_case_size_in_bytes()) +
2086     // case_array_offset_in_bytes()
2087     movl(reg2, in_bytes(MultiBranchData::per_case_size()));
2088     imulptr(index, reg2); // XXX l ?
2089     addptr(index, in_bytes(MultiBranchData::case_array_offset())); // XXX l ?
2090 
2091     // Update the case count
2092     increment_mdp_data_at(mdp,
2093                           index,
2094                           in_bytes(MultiBranchData::relative_count_offset()));
2095 
2096     // The method data pointer needs to be updated.
2097     update_mdp_by_offset(mdp,
2098                          index,
2099                          in_bytes(MultiBranchData::
2100                                   relative_displacement_offset()));
2101 
2102     bind(profile_continue);
2103   }
2104 }
2105 
2106 void InterpreterMacroAssembler::profile_array(Register mdp,
2107                                               Register array,
2108                                               Register tmp) {
2109   if (ProfileInterpreter) {
2110     Label profile_continue;
2111 
2112     // If no method data exists, go to profile_continue.
2113     test_method_data_pointer(mdp, profile_continue);
2114 
2115     mov(tmp, array);
2116     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayLoadStoreData::array_offset())));
2117 
2118     Label not_flat;
2119     test_non_flattened_array_oop(array, tmp, not_flat);
2120 
2121     set_mdp_flag_at(mdp, ArrayLoadStoreData::flat_array_byte_constant());
2122 
2123     bind(not_flat);
2124 
2125     Label not_null_free;
2126     test_non_null_free_array_oop(array, tmp, not_null_free);
2127 
2128     set_mdp_flag_at(mdp, ArrayLoadStoreData::null_free_array_byte_constant());
2129 
2130     bind(not_null_free);
2131 
2132     bind(profile_continue);
2133   }
2134 }
2135 
2136 void InterpreterMacroAssembler::profile_element(Register mdp,
2137                                                 Register element,
2138                                                 Register tmp) {
2139   if (ProfileInterpreter) {
2140     Label profile_continue;
2141 
2142     // If no method data exists, go to profile_continue.
2143     test_method_data_pointer(mdp, profile_continue);
2144 
2145     mov(tmp, element);
2146     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayLoadStoreData::element_offset())));
2147 
2148     // The method data pointer needs to be updated.
2149     update_mdp_by_constant(mdp, in_bytes(ArrayLoadStoreData::array_load_store_data_size()));
2150 
2151     bind(profile_continue);
2152   }
2153 }
2154 
2155 void InterpreterMacroAssembler::profile_acmp(Register mdp,
2156                                              Register left,
2157                                              Register right,
2158                                              Register tmp) {
2159   if (ProfileInterpreter) {
2160     Label profile_continue;
2161 
2162     // If no method data exists, go to profile_continue.
2163     test_method_data_pointer(mdp, profile_continue);
2164 
2165     mov(tmp, left);
2166     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::left_offset())));
2167 
2168     Label left_not_inline_type;
2169     test_oop_is_not_inline_type(left, tmp, left_not_inline_type);
2170     set_mdp_flag_at(mdp, ACmpData::left_inline_type_byte_constant());
2171     bind(left_not_inline_type);
2172 
2173     mov(tmp, right);
2174     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::right_offset())));
2175 
2176     Label right_not_inline_type;
2177     test_oop_is_not_inline_type(right, tmp, right_not_inline_type);
2178     set_mdp_flag_at(mdp, ACmpData::right_inline_type_byte_constant());
2179     bind(right_not_inline_type);
2180 
2181     bind(profile_continue);
2182   }
2183 }
2184 
2185 
2186 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
2187   if (state == atos) {
2188     MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
2189   }
2190 }
2191 
2192 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
2193 #ifndef _LP64
2194   if ((state == ftos && UseSSE < 1) ||
2195       (state == dtos && UseSSE < 2)) {
2196     MacroAssembler::verify_FPU(stack_depth);
2197   }
2198 #endif
2199 }
2200 
2201 // Jump if ((*counter_addr += increment) & mask) satisfies the condition.
2202 void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,
2203                                                         int increment, Address mask,
2204                                                         Register scratch, bool preloaded,
2205                                                         Condition cond, Label* where) {
2206   if (!preloaded) {
2207     movl(scratch, counter_addr);
2208   }
2209   incrementl(scratch, increment);
2210   movl(counter_addr, scratch);
2211   andl(scratch, mask);
2212   if (where != NULL) {
2213     jcc(cond, *where);
2214   }
2215 }
2216 
2217 void InterpreterMacroAssembler::notify_method_entry() {
2218   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
2219   // track stack depth.  If it is possible to enter interp_only_mode we add
2220   // the code to check if the event should be sent.
2221   Register rthread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
2222   Register rarg = LP64_ONLY(c_rarg1) NOT_LP64(rbx);
2223   if (JvmtiExport::can_post_interpreter_events()) {
2224     Label L;
2225     NOT_LP64(get_thread(rthread);)
2226     movl(rdx, Address(rthread, JavaThread::interp_only_mode_offset()));
2227     testl(rdx, rdx);
2228     jcc(Assembler::zero, L);
2229     call_VM(noreg, CAST_FROM_FN_PTR(address,
2230                                     InterpreterRuntime::post_method_entry));
2231     bind(L);
2232   }
2233 
2234   {
2235     SkipIfEqual skip(this, &DTraceMethodProbes, false);
2236     NOT_LP64(get_thread(rthread);)
2237     get_method(rarg);
2238     call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
2239                  rthread, rarg);
2240   }
2241 
2242   // RedefineClasses() tracing support for obsolete method entry
2243   if (log_is_enabled(Trace, redefine, class, obsolete)) {
2244     NOT_LP64(get_thread(rthread);)
2245     get_method(rarg);
2246     call_VM_leaf(
2247       CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
2248       rthread, rarg);
2249   }
2250 }
2251 
2252 
2253 void InterpreterMacroAssembler::notify_method_exit(
2254     TosState state, NotifyMethodExitMode mode) {
2255   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
2256   // track stack depth.  If it is possible to enter interp_only_mode we add
2257   // the code to check if the event should be sent.
2258   Register rthread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
2259   Register rarg = LP64_ONLY(c_rarg1) NOT_LP64(rbx);
2260   if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) {
2261     Label L;
2262     // Note: frame::interpreter_frame_result has a dependency on how the
2263     // method result is saved across the call to post_method_exit. If this
2264     // is changed then the interpreter_frame_result implementation will
2265     // need to be updated too.
2266 
2267     // template interpreter will leave the result on the top of the stack.
2268     push(state);
2269     NOT_LP64(get_thread(rthread);)
2270     movl(rdx, Address(rthread, JavaThread::interp_only_mode_offset()));
2271     testl(rdx, rdx);
2272     jcc(Assembler::zero, L);
2273     call_VM(noreg,
2274             CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit));
2275     bind(L);
2276     pop(state);
2277   }
2278 
2279   {
2280     SkipIfEqual skip(this, &DTraceMethodProbes, false);
2281     push(state);
2282     NOT_LP64(get_thread(rthread);)
2283     get_method(rarg);
2284     call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
2285                  rthread, rarg);
2286     pop(state);
2287   }
2288 }