< prev index next >

src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp

Print this page

  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "asm/macroAssembler.inline.hpp"
  27 #include "compiler/compiler_globals.hpp"
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "gc/shared/barrierSetAssembler.hpp"
  30 #include "interp_masm_aarch64.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interpreterRuntime.hpp"
  33 #include "logging/log.hpp"
  34 #include "oops/arrayOop.hpp"

  35 #include "oops/markWord.hpp"
  36 #include "oops/method.hpp"
  37 #include "oops/methodData.hpp"

  38 #include "oops/resolvedFieldEntry.hpp"
  39 #include "oops/resolvedIndyEntry.hpp"
  40 #include "oops/resolvedMethodEntry.hpp"
  41 #include "prims/jvmtiExport.hpp"
  42 #include "prims/jvmtiThreadState.hpp"
  43 #include "runtime/basicLock.hpp"
  44 #include "runtime/frame.inline.hpp"
  45 #include "runtime/javaThread.hpp"
  46 #include "runtime/safepointMechanism.hpp"
  47 #include "runtime/sharedRuntime.hpp"
  48 #include "utilities/powerOfTwo.hpp"
  49 
  50 void InterpreterMacroAssembler::narrow(Register result) {
  51 
  52   // Get method->_constMethod->_result_type
  53   ldr(rscratch1, Address(rfp, frame::interpreter_frame_method_offset * wordSize));
  54   ldr(rscratch1, Address(rscratch1, Method::const_offset()));
  55   ldrb(rscratch1, Address(rscratch1, ConstMethod::result_type_offset()));
  56 
  57   Label done, notBool, notByte, notChar;

 191     ldrw(index, Address(rbcp, bcp_offset));
 192   } else if (index_size == sizeof(u1)) {
 193     load_unsigned_byte(index, Address(rbcp, bcp_offset));
 194   } else {
 195     ShouldNotReachHere();
 196   }
 197 }
 198 
 199 void InterpreterMacroAssembler::get_method_counters(Register method,
 200                                                     Register mcs, Label& skip) {
 201   Label has_counters;
 202   ldr(mcs, Address(method, Method::method_counters_offset()));
 203   cbnz(mcs, has_counters);
 204   call_VM(noreg, CAST_FROM_FN_PTR(address,
 205           InterpreterRuntime::build_method_counters), method);
 206   ldr(mcs, Address(method, Method::method_counters_offset()));
 207   cbz(mcs, skip); // No MethodCounters allocated, OutOfMemory
 208   bind(has_counters);
 209 }
 210 














































 211 // Load object from cpool->resolved_references(index)
 212 void InterpreterMacroAssembler::load_resolved_reference_at_index(
 213                                            Register result, Register index, Register tmp) {
 214   assert_different_registers(result, index);
 215 
 216   get_constant_pool(result);
 217   // load pointer for resolved_references[] objArray
 218   ldr(result, Address(result, ConstantPool::cache_offset()));
 219   ldr(result, Address(result, ConstantPoolCache::resolved_references_offset()));
 220   resolve_oop_handle(result, tmp, rscratch2);
 221   // Add in the index
 222   add(index, index, arrayOopDesc::base_offset_in_bytes(T_OBJECT) >> LogBytesPerHeapOop);
 223   load_heap_oop(result, Address(result, index, Address::uxtw(LogBytesPerHeapOop)), tmp, rscratch2);
 224 }
 225 
 226 void InterpreterMacroAssembler::load_resolved_klass_at_offset(
 227                              Register cpool, Register index, Register klass, Register temp) {
 228   add(temp, cpool, index, LSL, LogBytesPerWord);
 229   ldrh(temp, Address(temp, sizeof(ConstantPool))); // temp = resolved_klass_index
 230   ldr(klass, Address(cpool,  ConstantPool::resolved_klasses_offset())); // klass = cpool->_resolved_klasses
 231   add(klass, klass, temp, LSL, LogBytesPerWord);
 232   ldr(klass, Address(klass, Array<Klass*>::base_offset_in_bytes()));
 233 }
 234 
 235 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
 236 // subtype of super_klass.
 237 //
 238 // Args:
 239 //      r0: superklass
 240 //      Rsub_klass: subklass
 241 //
 242 // Kills:
 243 //      r2, r5
 244 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
 245                                                   Label& ok_is_subtype) {

 246   assert(Rsub_klass != r0, "r0 holds superklass");
 247   assert(Rsub_klass != r2, "r2 holds 2ndary super array length");
 248   assert(Rsub_klass != r5, "r5 holds 2ndary super array scan ptr");
 249 
 250   // Profile the not-null value's klass.
 251   profile_typecheck(r2, Rsub_klass, r5); // blows r2, reloads r5


 252 
 253   // Do the check.
 254   check_klass_subtype(Rsub_klass, r0, r2, ok_is_subtype); // blows r2
 255 }
 256 
 257 // Java Expression Stack
 258 
 259 void InterpreterMacroAssembler::pop_ptr(Register r) {
 260   ldr(r, post(esp, wordSize));
 261 }
 262 
 263 void InterpreterMacroAssembler::pop_i(Register r) {
 264   ldrw(r, post(esp, wordSize));
 265 }
 266 
 267 void InterpreterMacroAssembler::pop_l(Register r) {
 268   ldr(r, post(esp, 2 * Interpreter::stackElementSize));
 269 }
 270 
 271 void InterpreterMacroAssembler::push_ptr(Register r) {

 615   br(Assembler::AL, fast_path);
 616   bind(slow_path);
 617   push(state);
 618   set_last_Java_frame(esp, rfp, pc(), rscratch1);
 619   super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), rthread);
 620   reset_last_Java_frame(true);
 621   pop(state);
 622   bind(fast_path);
 623 
 624   // JVMTI support. Make sure the safepoint poll test is issued prior.
 625   if (notify_jvmdi) {
 626     notify_method_exit(state, NotifyJVMTI);    // preserve TOSCA
 627   } else {
 628     notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA
 629   }
 630 
 631   // remove activation
 632   // get sender esp
 633   ldr(rscratch2,
 634       Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize));

 635   if (StackReservedPages > 0) {
 636     // testing if reserved zone needs to be re-enabled
 637     Label no_reserved_zone_enabling;
 638 
 639     // check if already enabled - if so no re-enabling needed
 640     assert(sizeof(StackOverflow::StackGuardState) == 4, "unexpected size");
 641     ldrw(rscratch1, Address(rthread, JavaThread::stack_guard_state_offset()));
 642     cmpw(rscratch1, (u1)StackOverflow::stack_guard_enabled);
 643     br(Assembler::EQ, no_reserved_zone_enabling);
 644 
 645     // look for an overflow into the stack reserved zone, i.e.
 646     // interpreter_frame_sender_sp <= JavaThread::reserved_stack_activation
 647     ldr(rscratch1, Address(rthread, JavaThread::reserved_stack_activation_offset()));
 648     cmp(rscratch2, rscratch1);
 649     br(Assembler::LS, no_reserved_zone_enabling);
 650 
 651     JFR_ONLY(leave_jfr_critical_section();)
 652 
 653     call_VM_leaf(
 654       CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread);
 655     call_VM(noreg, CAST_FROM_FN_PTR(address,
 656                    InterpreterRuntime::throw_delayed_StackOverflowError));
 657     should_not_reach_here();
 658 
 659     bind(no_reserved_zone_enabling);
 660   }
 661 












































 662   // remove frame anchor
 663   leave();
 664 
 665   JFR_ONLY(leave_jfr_critical_section();)
 666 
 667   // restore sender esp
 668   mov(esp, rscratch2);
 669 
 670   // If we're returning to interpreted code we will shortly be
 671   // adjusting SP to allow some space for ESP.  If we're returning to
 672   // compiled code the saved sender SP was saved in sender_sp, so this
 673   // restores it.
 674   andr(sp, esp, -16);
 675 }
 676 
 677 #if INCLUDE_JFR
 678 void InterpreterMacroAssembler::enter_jfr_critical_section() {
 679   const Address sampling_critical_section(rthread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
 680   mov(rscratch1, true);
 681   strb(rscratch1, sampling_critical_section);

 919 }
 920 
 921 
 922 void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
 923   if (ProfileInterpreter) {
 924     Label profile_continue;
 925 
 926     // If no method data exists, go to profile_continue.
 927     test_method_data_pointer(mdp, profile_continue);
 928 
 929     // We are taking a branch.  Increment the taken count.
 930     increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
 931 
 932     // The method data pointer needs to be updated to reflect the new target.
 933     update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
 934     bind(profile_continue);
 935   }
 936 }
 937 
 938 
 939 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
 940   if (ProfileInterpreter) {
 941     Label profile_continue;
 942 
 943     // If no method data exists, go to profile_continue.
 944     test_method_data_pointer(mdp, profile_continue);
 945 
 946     // We are not taking a branch.  Increment the not taken count.
 947     increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
 948 
 949     // The method data pointer needs to be updated to correspond to
 950     // the next bytecode
 951     update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
 952     bind(profile_continue);
 953   }
 954 }
 955 
 956 
 957 void InterpreterMacroAssembler::profile_call(Register mdp) {
 958   if (ProfileInterpreter) {
 959     Label profile_continue;
 960 
 961     // If no method data exists, go to profile_continue.
 962     test_method_data_pointer(mdp, profile_continue);
 963 
 964     // We are making a call.  Increment the count.
 965     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
 966 
 967     // The method data pointer needs to be updated to reflect the new target.
 968     update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
 969     bind(profile_continue);
 970   }
 971 }

1254     // case_array_offset_in_bytes()
1255     movw(reg2, in_bytes(MultiBranchData::per_case_size()));
1256     movw(rscratch1, in_bytes(MultiBranchData::case_array_offset()));
1257     Assembler::maddw(index, index, reg2, rscratch1);
1258 
1259     // Update the case count
1260     increment_mdp_data_at(mdp,
1261                           index,
1262                           in_bytes(MultiBranchData::relative_count_offset()));
1263 
1264     // The method data pointer needs to be updated.
1265     update_mdp_by_offset(mdp,
1266                          index,
1267                          in_bytes(MultiBranchData::
1268                                   relative_displacement_offset()));
1269 
1270     bind(profile_continue);
1271   }
1272 }
1273 


















































































































1274 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1275   if (state == atos) {
1276     MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
1277   }
1278 }
1279 
1280 void InterpreterMacroAssembler::notify_method_entry() {
1281   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1282   // track stack depth.  If it is possible to enter interp_only_mode we add
1283   // the code to check if the event should be sent.
1284   if (JvmtiExport::can_post_interpreter_events()) {
1285     Label L;
1286     ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset()));
1287     cbzw(r3, L);
1288     call_VM(noreg, CAST_FROM_FN_PTR(address,
1289                                     InterpreterRuntime::post_method_entry));
1290     bind(L);
1291   }
1292 
1293   if (DTraceMethodProbes) {

1617         profile_obj_type(tmp, mdo_arg_addr);
1618 
1619         int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
1620         off_to_args += to_add;
1621       }
1622 
1623       if (MethodData::profile_return()) {
1624         ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
1625         sub(tmp, tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
1626       }
1627 
1628       add(rscratch1, mdp, off_to_args);
1629       bind(done);
1630       mov(mdp, rscratch1);
1631 
1632       if (MethodData::profile_return()) {
1633         // We're right after the type profile for the last
1634         // argument. tmp is the number of cells left in the
1635         // CallTypeData/VirtualCallTypeData to reach its end. Non null
1636         // if there's a return to profile.
1637         assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1638         add(mdp, mdp, tmp, LSL, exact_log2(DataLayout::cell_size));
1639       }
1640       str(mdp, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize));
1641     } else {
1642       assert(MethodData::profile_return(), "either profile call args or call ret");
1643       update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
1644     }
1645 
1646     // mdp points right after the end of the
1647     // CallTypeData/VirtualCallTypeData, right after the cells for the
1648     // return value type if there's one
1649 
1650     bind(profile_continue);
1651   }
1652 }
1653 
1654 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1655   assert_different_registers(mdp, ret, tmp, rbcp);
1656   if (ProfileInterpreter && MethodData::profile_return()) {
1657     Label profile_continue, done;

1663 
1664       // If we don't profile all invoke bytecodes we must make sure
1665       // it's a bytecode we indeed profile. We can't go back to the
1666       // beginning of the ProfileData we intend to update to check its
1667       // type because we're right after it and we don't known its
1668       // length
1669       Label do_profile;
1670       ldrb(rscratch1, Address(rbcp, 0));
1671       cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
1672       br(Assembler::EQ, do_profile);
1673       cmp(rscratch1, (u1)Bytecodes::_invokehandle);
1674       br(Assembler::EQ, do_profile);
1675       get_method(tmp);
1676       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset()));
1677       subs(zr, rscratch1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1678       br(Assembler::NE, profile_continue);
1679 
1680       bind(do_profile);
1681     }
1682 
1683     Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
1684     mov(tmp, ret);
1685     profile_obj_type(tmp, mdo_ret_addr);
1686 
1687     bind(profile_continue);
1688   }
1689 }
1690 
1691 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
1692   assert_different_registers(rscratch1, rscratch2, mdp, tmp1, tmp2);
1693   if (ProfileInterpreter && MethodData::profile_parameters()) {
1694     Label profile_continue, done;
1695 
1696     test_method_data_pointer(mdp, profile_continue);
1697 
1698     // Load the offset of the area within the MDO used for
1699     // parameters. If it's negative we're not profiling any parameters
1700     ldrw(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1701     tbnz(tmp1, 31, profile_continue);  // i.e. sign bit set
1702 
1703     // Compute a pointer to the area for parameters from the offset

  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "asm/macroAssembler.inline.hpp"
  27 #include "compiler/compiler_globals.hpp"
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "gc/shared/barrierSetAssembler.hpp"
  30 #include "interp_masm_aarch64.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interpreterRuntime.hpp"
  33 #include "logging/log.hpp"
  34 #include "oops/arrayOop.hpp"
  35 #include "oops/constMethodFlags.hpp"
  36 #include "oops/markWord.hpp"
  37 #include "oops/method.hpp"
  38 #include "oops/methodData.hpp"
  39 #include "oops/inlineKlass.hpp"
  40 #include "oops/resolvedFieldEntry.hpp"
  41 #include "oops/resolvedIndyEntry.hpp"
  42 #include "oops/resolvedMethodEntry.hpp"
  43 #include "prims/jvmtiExport.hpp"
  44 #include "prims/jvmtiThreadState.hpp"
  45 #include "runtime/basicLock.hpp"
  46 #include "runtime/frame.inline.hpp"
  47 #include "runtime/javaThread.hpp"
  48 #include "runtime/safepointMechanism.hpp"
  49 #include "runtime/sharedRuntime.hpp"
  50 #include "utilities/powerOfTwo.hpp"
  51 
  52 void InterpreterMacroAssembler::narrow(Register result) {
  53 
  54   // Get method->_constMethod->_result_type
  55   ldr(rscratch1, Address(rfp, frame::interpreter_frame_method_offset * wordSize));
  56   ldr(rscratch1, Address(rscratch1, Method::const_offset()));
  57   ldrb(rscratch1, Address(rscratch1, ConstMethod::result_type_offset()));
  58 
  59   Label done, notBool, notByte, notChar;

 193     ldrw(index, Address(rbcp, bcp_offset));
 194   } else if (index_size == sizeof(u1)) {
 195     load_unsigned_byte(index, Address(rbcp, bcp_offset));
 196   } else {
 197     ShouldNotReachHere();
 198   }
 199 }
 200 
 201 void InterpreterMacroAssembler::get_method_counters(Register method,
 202                                                     Register mcs, Label& skip) {
 203   Label has_counters;
 204   ldr(mcs, Address(method, Method::method_counters_offset()));
 205   cbnz(mcs, has_counters);
 206   call_VM(noreg, CAST_FROM_FN_PTR(address,
 207           InterpreterRuntime::build_method_counters), method);
 208   ldr(mcs, Address(method, Method::method_counters_offset()));
 209   cbz(mcs, skip); // No MethodCounters allocated, OutOfMemory
 210   bind(has_counters);
 211 }
 212 
 213 void InterpreterMacroAssembler::allocate_instance(Register klass, Register new_obj,
 214                                                   Register t1, Register t2,
 215                                                   bool clear_fields, Label& alloc_failed) {
 216   MacroAssembler::allocate_instance(klass, new_obj, t1, t2, clear_fields, alloc_failed);
 217   if (DTraceAllocProbes) {
 218     // Trigger dtrace event for fastpath
 219     push(atos);
 220     call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), new_obj);
 221     pop(atos);
 222   }
 223 }
 224 
 225 void InterpreterMacroAssembler::read_flat_field(Register entry, Register obj) {
 226   call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_flat_field), obj, entry);
 227   membar(Assembler::StoreStore);
 228 }
 229 
 230 void InterpreterMacroAssembler::write_flat_field(Register entry, Register field_offset,
 231                                                  Register tmp1, Register tmp2,
 232                                                  Register obj) {
 233   assert_different_registers(entry, field_offset, tmp1, tmp2, obj);
 234   Label slow_path, done;
 235 
 236   load_unsigned_byte(tmp1, Address(entry, in_bytes(ResolvedFieldEntry::flags_offset())));
 237   test_field_is_not_null_free_inline_type(tmp1, noreg /* temp */, slow_path);
 238 
 239   null_check(r0); // FIXME JDK-8341120
 240 
 241   add(obj, obj, field_offset);
 242 
 243   load_klass(tmp1, r0);
 244   payload_address(r0, r0, tmp1);
 245 
 246   Register layout_info = field_offset;
 247   load_unsigned_short(tmp1, Address(entry, in_bytes(ResolvedFieldEntry::field_index_offset())));
 248   ldr(tmp2, Address(entry, in_bytes(ResolvedFieldEntry::field_holder_offset())));
 249   inline_layout_info(tmp2, tmp1, layout_info);
 250 
 251   flat_field_copy(IN_HEAP, r0, obj, layout_info);
 252   b(done);
 253 
 254   bind(slow_path);
 255   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::write_flat_field), obj, r0, entry);
 256   bind(done);
 257 }
 258 
 259 // Load object from cpool->resolved_references(index)
 260 void InterpreterMacroAssembler::load_resolved_reference_at_index(
 261                                            Register result, Register index, Register tmp) {
 262   assert_different_registers(result, index);
 263 
 264   get_constant_pool(result);
 265   // load pointer for resolved_references[] objArray
 266   ldr(result, Address(result, ConstantPool::cache_offset()));
 267   ldr(result, Address(result, ConstantPoolCache::resolved_references_offset()));
 268   resolve_oop_handle(result, tmp, rscratch2);
 269   // Add in the index
 270   add(index, index, arrayOopDesc::base_offset_in_bytes(T_OBJECT) >> LogBytesPerHeapOop);
 271   load_heap_oop(result, Address(result, index, Address::uxtw(LogBytesPerHeapOop)), tmp, rscratch2);
 272 }
 273 
 274 void InterpreterMacroAssembler::load_resolved_klass_at_offset(
 275                              Register cpool, Register index, Register klass, Register temp) {
 276   add(temp, cpool, index, LSL, LogBytesPerWord);
 277   ldrh(temp, Address(temp, sizeof(ConstantPool))); // temp = resolved_klass_index
 278   ldr(klass, Address(cpool,  ConstantPool::resolved_klasses_offset())); // klass = cpool->_resolved_klasses
 279   add(klass, klass, temp, LSL, LogBytesPerWord);
 280   ldr(klass, Address(klass, Array<Klass*>::base_offset_in_bytes()));
 281 }
 282 
 283 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
 284 // subtype of super_klass.
 285 //
 286 // Args:
 287 //      r0: superklass
 288 //      Rsub_klass: subklass
 289 //
 290 // Kills:
 291 //      r2, r5
 292 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
 293                                                   Label& ok_is_subtype,
 294                                                   bool profile) {
 295   assert(Rsub_klass != r0, "r0 holds superklass");
 296   assert(Rsub_klass != r2, "r2 holds 2ndary super array length");
 297   assert(Rsub_klass != r5, "r5 holds 2ndary super array scan ptr");
 298 
 299   // Profile the not-null value's klass.
 300   if (profile) {
 301     profile_typecheck(r2, Rsub_klass, r5); // blows r2, reloads r5
 302   }
 303 
 304   // Do the check.
 305   check_klass_subtype(Rsub_klass, r0, r2, ok_is_subtype); // blows r2
 306 }
 307 
 308 // Java Expression Stack
 309 
 310 void InterpreterMacroAssembler::pop_ptr(Register r) {
 311   ldr(r, post(esp, wordSize));
 312 }
 313 
 314 void InterpreterMacroAssembler::pop_i(Register r) {
 315   ldrw(r, post(esp, wordSize));
 316 }
 317 
 318 void InterpreterMacroAssembler::pop_l(Register r) {
 319   ldr(r, post(esp, 2 * Interpreter::stackElementSize));
 320 }
 321 
 322 void InterpreterMacroAssembler::push_ptr(Register r) {

 666   br(Assembler::AL, fast_path);
 667   bind(slow_path);
 668   push(state);
 669   set_last_Java_frame(esp, rfp, pc(), rscratch1);
 670   super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), rthread);
 671   reset_last_Java_frame(true);
 672   pop(state);
 673   bind(fast_path);
 674 
 675   // JVMTI support. Make sure the safepoint poll test is issued prior.
 676   if (notify_jvmdi) {
 677     notify_method_exit(state, NotifyJVMTI);    // preserve TOSCA
 678   } else {
 679     notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA
 680   }
 681 
 682   // remove activation
 683   // get sender esp
 684   ldr(rscratch2,
 685       Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize));
 686 
 687   if (StackReservedPages > 0) {
 688     // testing if reserved zone needs to be re-enabled
 689     Label no_reserved_zone_enabling;
 690 
 691     // check if already enabled - if so no re-enabling needed
 692     assert(sizeof(StackOverflow::StackGuardState) == 4, "unexpected size");
 693     ldrw(rscratch1, Address(rthread, JavaThread::stack_guard_state_offset()));
 694     cmpw(rscratch1, (u1)StackOverflow::stack_guard_enabled);
 695     br(Assembler::EQ, no_reserved_zone_enabling);
 696 
 697     // look for an overflow into the stack reserved zone, i.e.
 698     // interpreter_frame_sender_sp <= JavaThread::reserved_stack_activation
 699     ldr(rscratch1, Address(rthread, JavaThread::reserved_stack_activation_offset()));
 700     cmp(rscratch2, rscratch1);
 701     br(Assembler::LS, no_reserved_zone_enabling);
 702 
 703     JFR_ONLY(leave_jfr_critical_section();)
 704 
 705     call_VM_leaf(
 706       CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread);
 707     call_VM(noreg, CAST_FROM_FN_PTR(address,
 708                    InterpreterRuntime::throw_delayed_StackOverflowError));
 709     should_not_reach_here();
 710 
 711     bind(no_reserved_zone_enabling);
 712   }
 713 
 714   if (state == atos && InlineTypeReturnedAsFields) {
 715     Label skip;
 716     Label not_null;
 717     cbnz(r0, not_null);
 718     // Returned value is null, zero all return registers because they may belong to oop fields
 719     mov(j_rarg1, zr);
 720     mov(j_rarg2, zr);
 721     mov(j_rarg3, zr);
 722     mov(j_rarg4, zr);
 723     mov(j_rarg5, zr);
 724     mov(j_rarg6, zr);
 725     mov(j_rarg7, zr);
 726     b(skip);
 727     bind(not_null);
 728 
 729     // Check if we are returning an non-null inline type and load its fields into registers
 730     test_oop_is_not_inline_type(r0, rscratch2, skip, /* can_be_null= */ false);
 731 
 732     // Load fields from a buffered value with an inline class specific handler
 733     load_klass(rscratch1 /*dst*/, r0 /*src*/);
 734     ldr(rscratch1, Address(rscratch1, InlineKlass::adr_members_offset()));
 735     ldr(rscratch1, Address(rscratch1, InlineKlass::unpack_handler_offset()));
 736     // Unpack handler can be null if inline type is not scalarizable in returns
 737     cbz(rscratch1, skip);
 738 
 739     blr(rscratch1);
 740 #ifdef ASSERT
 741     // TODO 8284443 Enable
 742     if (StressCallingConvention && false) {
 743       Label skip_stress;
 744       ldr(rscratch1, Address(rfp, frame::interpreter_frame_method_offset * wordSize));
 745       ldrw(rscratch1, Address(rscratch1, Method::flags_offset()));
 746       tstw(rscratch1, MethodFlags::has_scalarized_return_flag());
 747       br(Assembler::EQ, skip_stress);
 748       load_klass(r0, r0);
 749       orr(r0, r0, 1);
 750       bind(skip_stress);
 751     }
 752 #endif
 753     bind(skip);
 754     // Check above kills sender esp in rscratch2. Reload it.
 755     ldr(rscratch2, Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize));
 756   }
 757 
 758   // remove frame anchor
 759   leave();
 760 
 761   JFR_ONLY(leave_jfr_critical_section();)
 762 
 763   // restore sender esp
 764   mov(esp, rscratch2);
 765 
 766   // If we're returning to interpreted code we will shortly be
 767   // adjusting SP to allow some space for ESP.  If we're returning to
 768   // compiled code the saved sender SP was saved in sender_sp, so this
 769   // restores it.
 770   andr(sp, esp, -16);
 771 }
 772 
 773 #if INCLUDE_JFR
 774 void InterpreterMacroAssembler::enter_jfr_critical_section() {
 775   const Address sampling_critical_section(rthread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
 776   mov(rscratch1, true);
 777   strb(rscratch1, sampling_critical_section);

1015 }
1016 
1017 
1018 void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
1019   if (ProfileInterpreter) {
1020     Label profile_continue;
1021 
1022     // If no method data exists, go to profile_continue.
1023     test_method_data_pointer(mdp, profile_continue);
1024 
1025     // We are taking a branch.  Increment the taken count.
1026     increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
1027 
1028     // The method data pointer needs to be updated to reflect the new target.
1029     update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
1030     bind(profile_continue);
1031   }
1032 }
1033 
1034 
1035 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp, bool acmp) {
1036   if (ProfileInterpreter) {
1037     Label profile_continue;
1038 
1039     // If no method data exists, go to profile_continue.
1040     test_method_data_pointer(mdp, profile_continue);
1041 
1042     // We are not taking a branch.  Increment the not taken count.
1043     increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
1044 
1045     // The method data pointer needs to be updated to correspond to
1046     // the next bytecode
1047     update_mdp_by_constant(mdp, acmp ? in_bytes(ACmpData::acmp_data_size()) : in_bytes(BranchData::branch_data_size()));
1048     bind(profile_continue);
1049   }
1050 }
1051 
1052 
1053 void InterpreterMacroAssembler::profile_call(Register mdp) {
1054   if (ProfileInterpreter) {
1055     Label profile_continue;
1056 
1057     // If no method data exists, go to profile_continue.
1058     test_method_data_pointer(mdp, profile_continue);
1059 
1060     // We are making a call.  Increment the count.
1061     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1062 
1063     // The method data pointer needs to be updated to reflect the new target.
1064     update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1065     bind(profile_continue);
1066   }
1067 }

1350     // case_array_offset_in_bytes()
1351     movw(reg2, in_bytes(MultiBranchData::per_case_size()));
1352     movw(rscratch1, in_bytes(MultiBranchData::case_array_offset()));
1353     Assembler::maddw(index, index, reg2, rscratch1);
1354 
1355     // Update the case count
1356     increment_mdp_data_at(mdp,
1357                           index,
1358                           in_bytes(MultiBranchData::relative_count_offset()));
1359 
1360     // The method data pointer needs to be updated.
1361     update_mdp_by_offset(mdp,
1362                          index,
1363                          in_bytes(MultiBranchData::
1364                                   relative_displacement_offset()));
1365 
1366     bind(profile_continue);
1367   }
1368 }
1369 
1370 template <class ArrayData> void InterpreterMacroAssembler::profile_array_type(Register mdp,
1371                                                                               Register array,
1372                                                                               Register tmp) {
1373   if (ProfileInterpreter) {
1374     Label profile_continue;
1375 
1376     // If no method data exists, go to profile_continue.
1377     test_method_data_pointer(mdp, profile_continue);
1378 
1379     mov(tmp, array);
1380     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayData::array_offset())));
1381 
1382     Label not_flat;
1383     test_non_flat_array_oop(array, tmp, not_flat);
1384 
1385     set_mdp_flag_at(mdp, ArrayData::flat_array_byte_constant());
1386 
1387     bind(not_flat);
1388 
1389     Label not_null_free;
1390     test_non_null_free_array_oop(array, tmp, not_null_free);
1391 
1392     set_mdp_flag_at(mdp, ArrayData::null_free_array_byte_constant());
1393 
1394     bind(not_null_free);
1395 
1396     bind(profile_continue);
1397   }
1398 }
1399 
1400 template void InterpreterMacroAssembler::profile_array_type<ArrayLoadData>(Register mdp,
1401                                                                            Register array,
1402                                                                            Register tmp);
1403 template void InterpreterMacroAssembler::profile_array_type<ArrayStoreData>(Register mdp,
1404                                                                             Register array,
1405                                                                             Register tmp);
1406 
1407 void InterpreterMacroAssembler::profile_multiple_element_types(Register mdp, Register element, Register tmp, const Register tmp2) {
1408   if (ProfileInterpreter) {
1409     Label profile_continue;
1410 
1411     // If no method data exists, go to profile_continue.
1412     test_method_data_pointer(mdp, profile_continue);
1413 
1414     Label done, update;
1415     cbnz(element, update);
1416     set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
1417     b(done);
1418 
1419     bind(update);
1420     load_klass(tmp, element);
1421 
1422     // Record the object type.
1423     record_klass_in_profile(tmp, mdp, tmp2);
1424 
1425     bind(done);
1426 
1427     // The method data pointer needs to be updated.
1428     update_mdp_by_constant(mdp, in_bytes(ArrayStoreData::array_store_data_size()));
1429 
1430     bind(profile_continue);
1431   }
1432 }
1433 
1434 
1435 void InterpreterMacroAssembler::profile_element_type(Register mdp,
1436                                                      Register element,
1437                                                      Register tmp) {
1438   if (ProfileInterpreter) {
1439     Label profile_continue;
1440 
1441     // If no method data exists, go to profile_continue.
1442     test_method_data_pointer(mdp, profile_continue);
1443 
1444     mov(tmp, element);
1445     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayLoadData::element_offset())));
1446 
1447     // The method data pointer needs to be updated.
1448     update_mdp_by_constant(mdp, in_bytes(ArrayLoadData::array_load_data_size()));
1449 
1450     bind(profile_continue);
1451   }
1452 }
1453 
1454 void InterpreterMacroAssembler::profile_acmp(Register mdp,
1455                                              Register left,
1456                                              Register right,
1457                                              Register tmp) {
1458   if (ProfileInterpreter) {
1459     Label profile_continue;
1460 
1461     // If no method data exists, go to profile_continue.
1462     test_method_data_pointer(mdp, profile_continue);
1463 
1464     mov(tmp, left);
1465     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::left_offset())));
1466 
1467     Label left_not_inline_type;
1468     test_oop_is_not_inline_type(left, tmp, left_not_inline_type);
1469     set_mdp_flag_at(mdp, ACmpData::left_inline_type_byte_constant());
1470     bind(left_not_inline_type);
1471 
1472     mov(tmp, right);
1473     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::right_offset())));
1474 
1475     Label right_not_inline_type;
1476     test_oop_is_not_inline_type(right, tmp, right_not_inline_type);
1477     set_mdp_flag_at(mdp, ACmpData::right_inline_type_byte_constant());
1478     bind(right_not_inline_type);
1479 
1480     bind(profile_continue);
1481   }
1482 }
1483 
1484 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1485   if (state == atos) {
1486     MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
1487   }
1488 }
1489 
1490 void InterpreterMacroAssembler::notify_method_entry() {
1491   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1492   // track stack depth.  If it is possible to enter interp_only_mode we add
1493   // the code to check if the event should be sent.
1494   if (JvmtiExport::can_post_interpreter_events()) {
1495     Label L;
1496     ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset()));
1497     cbzw(r3, L);
1498     call_VM(noreg, CAST_FROM_FN_PTR(address,
1499                                     InterpreterRuntime::post_method_entry));
1500     bind(L);
1501   }
1502 
1503   if (DTraceMethodProbes) {

1827         profile_obj_type(tmp, mdo_arg_addr);
1828 
1829         int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
1830         off_to_args += to_add;
1831       }
1832 
1833       if (MethodData::profile_return()) {
1834         ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
1835         sub(tmp, tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
1836       }
1837 
1838       add(rscratch1, mdp, off_to_args);
1839       bind(done);
1840       mov(mdp, rscratch1);
1841 
1842       if (MethodData::profile_return()) {
1843         // We're right after the type profile for the last
1844         // argument. tmp is the number of cells left in the
1845         // CallTypeData/VirtualCallTypeData to reach its end. Non null
1846         // if there's a return to profile.
1847         assert(SingleTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1848         add(mdp, mdp, tmp, LSL, exact_log2(DataLayout::cell_size));
1849       }
1850       str(mdp, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize));
1851     } else {
1852       assert(MethodData::profile_return(), "either profile call args or call ret");
1853       update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
1854     }
1855 
1856     // mdp points right after the end of the
1857     // CallTypeData/VirtualCallTypeData, right after the cells for the
1858     // return value type if there's one
1859 
1860     bind(profile_continue);
1861   }
1862 }
1863 
1864 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1865   assert_different_registers(mdp, ret, tmp, rbcp);
1866   if (ProfileInterpreter && MethodData::profile_return()) {
1867     Label profile_continue, done;

1873 
1874       // If we don't profile all invoke bytecodes we must make sure
1875       // it's a bytecode we indeed profile. We can't go back to the
1876       // beginning of the ProfileData we intend to update to check its
1877       // type because we're right after it and we don't known its
1878       // length
1879       Label do_profile;
1880       ldrb(rscratch1, Address(rbcp, 0));
1881       cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
1882       br(Assembler::EQ, do_profile);
1883       cmp(rscratch1, (u1)Bytecodes::_invokehandle);
1884       br(Assembler::EQ, do_profile);
1885       get_method(tmp);
1886       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset()));
1887       subs(zr, rscratch1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1888       br(Assembler::NE, profile_continue);
1889 
1890       bind(do_profile);
1891     }
1892 
1893     Address mdo_ret_addr(mdp, -in_bytes(SingleTypeEntry::size()));
1894     mov(tmp, ret);
1895     profile_obj_type(tmp, mdo_ret_addr);
1896 
1897     bind(profile_continue);
1898   }
1899 }
1900 
1901 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
1902   assert_different_registers(rscratch1, rscratch2, mdp, tmp1, tmp2);
1903   if (ProfileInterpreter && MethodData::profile_parameters()) {
1904     Label profile_continue, done;
1905 
1906     test_method_data_pointer(mdp, profile_continue);
1907 
1908     // Load the offset of the area within the MDO used for
1909     // parameters. If it's negative we're not profiling any parameters
1910     ldrw(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1911     tbnz(tmp1, 31, profile_continue);  // i.e. sign bit set
1912 
1913     // Compute a pointer to the area for parameters from the offset
< prev index next >