< 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
 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 
 249   // Profile the not-null value's klass.
 250   profile_typecheck(r2, Rsub_klass); // blows r2
 251 

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

 641     cmpw(rscratch1, (u1)StackOverflow::stack_guard_enabled);
 642     br(Assembler::EQ, no_reserved_zone_enabling);
 643 
 644     // look for an overflow into the stack reserved zone, i.e.
 645     // interpreter_frame_sender_sp <= JavaThread::reserved_stack_activation
 646     ldr(rscratch1, Address(rthread, JavaThread::reserved_stack_activation_offset()));
 647     cmp(rscratch2, rscratch1);
 648     br(Assembler::LS, no_reserved_zone_enabling);
 649 
 650     JFR_ONLY(leave_jfr_critical_section();)
 651 
 652     call_VM_leaf(
 653       CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread);
 654     call_VM(noreg, CAST_FROM_FN_PTR(address,
 655                    InterpreterRuntime::throw_delayed_StackOverflowError));
 656     should_not_reach_here();
 657 
 658     bind(no_reserved_zone_enabling);
 659   }
 660 































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

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

1116     // case_array_offset_in_bytes()
1117     movw(reg2, in_bytes(MultiBranchData::per_case_size()));
1118     movw(rscratch1, in_bytes(MultiBranchData::case_array_offset()));
1119     Assembler::maddw(index, index, reg2, rscratch1);
1120 
1121     // Update the case count
1122     increment_mdp_data_at(mdp,
1123                           index,
1124                           in_bytes(MultiBranchData::relative_count_offset()));
1125 
1126     // The method data pointer needs to be updated.
1127     update_mdp_by_offset(mdp,
1128                          index,
1129                          in_bytes(MultiBranchData::
1130                                   relative_displacement_offset()));
1131 
1132     bind(profile_continue);
1133   }
1134 }
1135 


















































































































1136 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1137   if (state == atos) {
1138     MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
1139   }
1140 }
1141 
1142 void InterpreterMacroAssembler::notify_method_entry() {
1143   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1144   // track stack depth.  If it is possible to enter interp_only_mode we add
1145   // the code to check if the event should be sent.
1146   if (JvmtiExport::can_post_interpreter_events()) {
1147     Label L;
1148     ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset()));
1149     cbzw(r3, L);
1150     call_VM(noreg, CAST_FROM_FN_PTR(address,
1151                                     InterpreterRuntime::post_method_entry));
1152     bind(L);
1153   }
1154 
1155   if (DTraceMethodProbes) {

1486         profile_obj_type(tmp, mdo_arg_addr);
1487 
1488         int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
1489         off_to_args += to_add;
1490       }
1491 
1492       if (MethodData::profile_return()) {
1493         ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
1494         sub(tmp, tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
1495       }
1496 
1497       add(rscratch1, mdp, off_to_args);
1498       bind(done);
1499       mov(mdp, rscratch1);
1500 
1501       if (MethodData::profile_return()) {
1502         // We're right after the type profile for the last
1503         // argument. tmp is the number of cells left in the
1504         // CallTypeData/VirtualCallTypeData to reach its end. Non null
1505         // if there's a return to profile.
1506         assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1507         add(mdp, mdp, tmp, LSL, exact_log2(DataLayout::cell_size));
1508       }
1509       str(mdp, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize));
1510     } else {
1511       assert(MethodData::profile_return(), "either profile call args or call ret");
1512       update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
1513     }
1514 
1515     // mdp points right after the end of the
1516     // CallTypeData/VirtualCallTypeData, right after the cells for the
1517     // return value type if there's one
1518 
1519     bind(profile_continue);
1520   }
1521 }
1522 
1523 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1524   assert_different_registers(mdp, ret, tmp, rbcp);
1525   if (ProfileInterpreter && MethodData::profile_return()) {
1526     Label profile_continue, done;

1532 
1533       // If we don't profile all invoke bytecodes we must make sure
1534       // it's a bytecode we indeed profile. We can't go back to the
1535       // beginning of the ProfileData we intend to update to check its
1536       // type because we're right after it and we don't known its
1537       // length
1538       Label do_profile;
1539       ldrb(rscratch1, Address(rbcp, 0));
1540       cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
1541       br(Assembler::EQ, do_profile);
1542       cmp(rscratch1, (u1)Bytecodes::_invokehandle);
1543       br(Assembler::EQ, do_profile);
1544       get_method(tmp);
1545       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset()));
1546       subs(zr, rscratch1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1547       br(Assembler::NE, profile_continue);
1548 
1549       bind(do_profile);
1550     }
1551 
1552     Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
1553     mov(tmp, ret);
1554     profile_obj_type(tmp, mdo_ret_addr);
1555 
1556     bind(profile_continue);
1557   }
1558 }
1559 
1560 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
1561   assert_different_registers(rscratch1, rscratch2, mdp, tmp1, tmp2);
1562   if (ProfileInterpreter && MethodData::profile_parameters()) {
1563     Label profile_continue, done;
1564 
1565     test_method_data_pointer(mdp, profile_continue);
1566 
1567     // Load the offset of the area within the MDO used for
1568     // parameters. If it's negative we're not profiling any parameters
1569     ldrw(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1570     tbnz(tmp1, 31, profile_continue);  // i.e. sign bit set
1571 
1572     // 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::read_flat_field(Register entry, Register obj) {
 214   call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_flat_field), obj, entry);
 215 }
 216 
 217 void InterpreterMacroAssembler::write_flat_field(Register entry, Register field_offset,
 218                                                  Register tmp1, Register tmp2,
 219                                                  Register obj) {
 220   assert_different_registers(entry, field_offset, tmp1, tmp2, obj);
 221   Label slow_path, done;
 222 
 223   load_unsigned_byte(tmp1, Address(entry, in_bytes(ResolvedFieldEntry::flags_offset())));
 224   test_field_is_not_null_free_inline_type(tmp1, noreg /* temp */, slow_path);
 225 
 226   null_check(r0); // FIXME JDK-8341120
 227 
 228   add(obj, obj, field_offset);
 229 
 230   load_klass(tmp1, r0);
 231   payload_address(r0, r0, tmp1);
 232 
 233   Register layout_info = field_offset;
 234   load_unsigned_short(tmp1, Address(entry, in_bytes(ResolvedFieldEntry::field_index_offset())));
 235   ldr(tmp2, Address(entry, in_bytes(ResolvedFieldEntry::field_holder_offset())));
 236   inline_layout_info(tmp2, tmp1, layout_info);
 237 
 238   flat_field_copy(IN_HEAP, r0, obj, layout_info);
 239   b(done);
 240 
 241   bind(slow_path);
 242   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::write_flat_field), obj, r0, entry);
 243   bind(done);
 244 }
 245 
 246 // Load object from cpool->resolved_references(index)
 247 void InterpreterMacroAssembler::load_resolved_reference_at_index(
 248                                            Register result, Register index, Register tmp) {
 249   assert_different_registers(result, index);
 250 
 251   get_constant_pool(result);
 252   // load pointer for resolved_references[] objArray
 253   ldr(result, Address(result, ConstantPool::cache_offset()));
 254   ldr(result, Address(result, ConstantPoolCache::resolved_references_offset()));
 255   resolve_oop_handle(result, tmp, rscratch2);
 256   // Add in the index
 257   add(index, index, arrayOopDesc::base_offset_in_bytes(T_OBJECT) >> LogBytesPerHeapOop);
 258   load_heap_oop(result, Address(result, index, Address::uxtw(LogBytesPerHeapOop)), tmp, rscratch2);
 259 }
 260 
 261 void InterpreterMacroAssembler::load_resolved_klass_at_offset(
 262                              Register cpool, Register index, Register klass, Register temp) {
 263   add(temp, cpool, index, LSL, LogBytesPerWord);
 264   ldrh(temp, Address(temp, sizeof(ConstantPool))); // temp = resolved_klass_index
 265   ldr(klass, Address(cpool,  ConstantPool::resolved_klasses_offset())); // klass = cpool->_resolved_klasses
 266   add(klass, klass, temp, LSL, LogBytesPerWord);
 267   ldr(klass, Address(klass, Array<Klass*>::base_offset_in_bytes()));
 268 }
 269 
 270 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
 271 // subtype of super_klass.
 272 //
 273 // Args:
 274 //      r0: superklass
 275 //      Rsub_klass: subklass
 276 //
 277 // Kills:
 278 //      r2
 279 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
 280                                                   Label& ok_is_subtype,
 281                                                   bool profile) {
 282   assert(Rsub_klass != r0, "r0 holds superklass");
 283   assert(Rsub_klass != r2, "r2 holds 2ndary super array length");
 284 
 285   // Profile the not-null value's klass.
 286   if (profile) {
 287     profile_typecheck(r2, Rsub_klass); // blows r2
 288   }
 289   // Do the check.
 290   check_klass_subtype(Rsub_klass, r0, r2, ok_is_subtype); // blows r2
 291 }
 292 
 293 // Java Expression Stack
 294 
 295 void InterpreterMacroAssembler::pop_ptr(Register r) {
 296   ldr(r, post(esp, wordSize));
 297 }
 298 
 299 void InterpreterMacroAssembler::pop_i(Register r) {
 300   ldrw(r, post(esp, wordSize));
 301 }
 302 
 303 void InterpreterMacroAssembler::pop_l(Register r) {
 304   ldr(r, post(esp, 2 * Interpreter::stackElementSize));
 305 }
 306 
 307 void InterpreterMacroAssembler::push_ptr(Register r) {
 308   str(r, pre(esp, -wordSize));

 678     cmpw(rscratch1, (u1)StackOverflow::stack_guard_enabled);
 679     br(Assembler::EQ, no_reserved_zone_enabling);
 680 
 681     // look for an overflow into the stack reserved zone, i.e.
 682     // interpreter_frame_sender_sp <= JavaThread::reserved_stack_activation
 683     ldr(rscratch1, Address(rthread, JavaThread::reserved_stack_activation_offset()));
 684     cmp(rscratch2, rscratch1);
 685     br(Assembler::LS, no_reserved_zone_enabling);
 686 
 687     JFR_ONLY(leave_jfr_critical_section();)
 688 
 689     call_VM_leaf(
 690       CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread);
 691     call_VM(noreg, CAST_FROM_FN_PTR(address,
 692                    InterpreterRuntime::throw_delayed_StackOverflowError));
 693     should_not_reach_here();
 694 
 695     bind(no_reserved_zone_enabling);
 696   }
 697 
 698   if (state == atos && InlineTypeReturnedAsFields) {
 699     Label skip;
 700     Label not_null;
 701     cbnz(r0, not_null);
 702     // Returned value is null, zero all return registers because they may belong to oop fields
 703     mov(j_rarg1, zr);
 704     mov(j_rarg2, zr);
 705     mov(j_rarg3, zr);
 706     mov(j_rarg4, zr);
 707     mov(j_rarg5, zr);
 708     mov(j_rarg6, zr);
 709     mov(j_rarg7, zr);
 710     b(skip);
 711     bind(not_null);
 712 
 713     // Check if we are returning a non-null inline type and load its fields into registers
 714     test_oop_is_not_inline_type(r0, rscratch2, skip, /* can_be_null= */ false);
 715 
 716     // Load fields from a buffered value with an inline class specific handler
 717     load_klass(rscratch1 /*dst*/, r0 /*src*/);
 718     ldr(rscratch1, Address(rscratch1, InlineKlass::adr_members_offset()));
 719     ldr(rscratch1, Address(rscratch1, InlineKlass::unpack_handler_offset()));
 720     // Unpack handler can be null if inline type is not scalarizable in returns
 721     cbz(rscratch1, skip);
 722 
 723     blr(rscratch1);
 724     bind(skip);
 725     // Check above kills sender esp in rscratch2. Reload it.
 726     ldr(rscratch2, Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize));
 727   }
 728 
 729   // remove frame anchor
 730   leave();
 731 
 732   JFR_ONLY(leave_jfr_critical_section();)
 733 
 734   // restore sender esp
 735   mov(esp, rscratch2);
 736 
 737   // If we're returning to interpreted code we will shortly be
 738   // adjusting SP to allow some space for ESP.  If we're returning to
 739   // compiled code the saved sender SP was saved in sender_sp, so this
 740   // restores it.
 741   andr(sp, esp, -16);
 742 }
 743 
 744 #if INCLUDE_JFR
 745 void InterpreterMacroAssembler::enter_jfr_critical_section() {
 746   const Address sampling_critical_section(rthread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
 747   mov(rscratch1, true);
 748   strb(rscratch1, sampling_critical_section);

 986 }
 987 
 988 
 989 void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
 990   if (ProfileInterpreter) {
 991     Label profile_continue;
 992 
 993     // If no method data exists, go to profile_continue.
 994     test_method_data_pointer(mdp, profile_continue);
 995 
 996     // We are taking a branch.  Increment the taken count.
 997     increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
 998 
 999     // The method data pointer needs to be updated to reflect the new target.
1000     update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
1001     bind(profile_continue);
1002   }
1003 }
1004 
1005 
1006 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp, bool acmp) {
1007   if (ProfileInterpreter) {
1008     Label profile_continue;
1009 
1010     // If no method data exists, go to profile_continue.
1011     test_method_data_pointer(mdp, profile_continue);
1012 
1013     // We are not taking a branch.  Increment the not taken count.
1014     increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
1015 
1016     // The method data pointer needs to be updated to correspond to
1017     // the next bytecode
1018     update_mdp_by_constant(mdp, acmp ? in_bytes(ACmpData::acmp_data_size()) : in_bytes(BranchData::branch_data_size()));
1019     bind(profile_continue);
1020   }
1021 }
1022 
1023 
1024 void InterpreterMacroAssembler::profile_call(Register mdp) {
1025   if (ProfileInterpreter) {
1026     Label profile_continue;
1027 
1028     // If no method data exists, go to profile_continue.
1029     test_method_data_pointer(mdp, profile_continue);
1030 
1031     // We are making a call.  Increment the count.
1032     increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1033 
1034     // The method data pointer needs to be updated to reflect the new target.
1035     update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1036     bind(profile_continue);
1037   }
1038 }

1184     // case_array_offset_in_bytes()
1185     movw(reg2, in_bytes(MultiBranchData::per_case_size()));
1186     movw(rscratch1, in_bytes(MultiBranchData::case_array_offset()));
1187     Assembler::maddw(index, index, reg2, rscratch1);
1188 
1189     // Update the case count
1190     increment_mdp_data_at(mdp,
1191                           index,
1192                           in_bytes(MultiBranchData::relative_count_offset()));
1193 
1194     // The method data pointer needs to be updated.
1195     update_mdp_by_offset(mdp,
1196                          index,
1197                          in_bytes(MultiBranchData::
1198                                   relative_displacement_offset()));
1199 
1200     bind(profile_continue);
1201   }
1202 }
1203 
1204 template <class ArrayData> void InterpreterMacroAssembler::profile_array_type(Register mdp,
1205                                                                               Register array,
1206                                                                               Register tmp) {
1207   if (ProfileInterpreter) {
1208     Label profile_continue;
1209 
1210     // If no method data exists, go to profile_continue.
1211     test_method_data_pointer(mdp, profile_continue);
1212 
1213     mov(tmp, array);
1214     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayData::array_offset())));
1215 
1216     Label not_flat;
1217     test_non_flat_array_oop(array, tmp, not_flat);
1218 
1219     set_mdp_flag_at(mdp, ArrayData::flat_array_byte_constant());
1220 
1221     bind(not_flat);
1222 
1223     Label not_null_free;
1224     test_non_null_free_array_oop(array, tmp, not_null_free);
1225 
1226     set_mdp_flag_at(mdp, ArrayData::null_free_array_byte_constant());
1227 
1228     bind(not_null_free);
1229 
1230     bind(profile_continue);
1231   }
1232 }
1233 
1234 template void InterpreterMacroAssembler::profile_array_type<ArrayLoadData>(Register mdp,
1235                                                                            Register array,
1236                                                                            Register tmp);
1237 template void InterpreterMacroAssembler::profile_array_type<ArrayStoreData>(Register mdp,
1238                                                                             Register array,
1239                                                                             Register tmp);
1240 
1241 void InterpreterMacroAssembler::profile_multiple_element_types(Register mdp, Register element, Register tmp, const Register tmp2) {
1242   if (ProfileInterpreter) {
1243     Label profile_continue;
1244 
1245     // If no method data exists, go to profile_continue.
1246     test_method_data_pointer(mdp, profile_continue);
1247 
1248     Label done, update;
1249     cbnz(element, update);
1250     set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
1251     b(done);
1252 
1253     bind(update);
1254     load_klass(tmp, element);
1255 
1256     // Record the object type.
1257     profile_receiver_type(tmp, mdp, 0);
1258 
1259     bind(done);
1260 
1261     // The method data pointer needs to be updated.
1262     update_mdp_by_constant(mdp, in_bytes(ArrayStoreData::array_store_data_size()));
1263 
1264     bind(profile_continue);
1265   }
1266 }
1267 
1268 
1269 void InterpreterMacroAssembler::profile_element_type(Register mdp,
1270                                                      Register element,
1271                                                      Register tmp) {
1272   if (ProfileInterpreter) {
1273     Label profile_continue;
1274 
1275     // If no method data exists, go to profile_continue.
1276     test_method_data_pointer(mdp, profile_continue);
1277 
1278     mov(tmp, element);
1279     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayLoadData::element_offset())));
1280 
1281     // The method data pointer needs to be updated.
1282     update_mdp_by_constant(mdp, in_bytes(ArrayLoadData::array_load_data_size()));
1283 
1284     bind(profile_continue);
1285   }
1286 }
1287 
1288 void InterpreterMacroAssembler::profile_acmp(Register mdp,
1289                                              Register left,
1290                                              Register right,
1291                                              Register tmp) {
1292   if (ProfileInterpreter) {
1293     Label profile_continue;
1294 
1295     // If no method data exists, go to profile_continue.
1296     test_method_data_pointer(mdp, profile_continue);
1297 
1298     mov(tmp, left);
1299     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::left_offset())));
1300 
1301     Label left_not_inline_type;
1302     test_oop_is_not_inline_type(left, tmp, left_not_inline_type);
1303     set_mdp_flag_at(mdp, ACmpData::left_inline_type_byte_constant());
1304     bind(left_not_inline_type);
1305 
1306     mov(tmp, right);
1307     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::right_offset())));
1308 
1309     Label right_not_inline_type;
1310     test_oop_is_not_inline_type(right, tmp, right_not_inline_type);
1311     set_mdp_flag_at(mdp, ACmpData::right_inline_type_byte_constant());
1312     bind(right_not_inline_type);
1313 
1314     bind(profile_continue);
1315   }
1316 }
1317 
1318 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1319   if (state == atos) {
1320     MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
1321   }
1322 }
1323 
1324 void InterpreterMacroAssembler::notify_method_entry() {
1325   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1326   // track stack depth.  If it is possible to enter interp_only_mode we add
1327   // the code to check if the event should be sent.
1328   if (JvmtiExport::can_post_interpreter_events()) {
1329     Label L;
1330     ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset()));
1331     cbzw(r3, L);
1332     call_VM(noreg, CAST_FROM_FN_PTR(address,
1333                                     InterpreterRuntime::post_method_entry));
1334     bind(L);
1335   }
1336 
1337   if (DTraceMethodProbes) {

1668         profile_obj_type(tmp, mdo_arg_addr);
1669 
1670         int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
1671         off_to_args += to_add;
1672       }
1673 
1674       if (MethodData::profile_return()) {
1675         ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
1676         sub(tmp, tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
1677       }
1678 
1679       add(rscratch1, mdp, off_to_args);
1680       bind(done);
1681       mov(mdp, rscratch1);
1682 
1683       if (MethodData::profile_return()) {
1684         // We're right after the type profile for the last
1685         // argument. tmp is the number of cells left in the
1686         // CallTypeData/VirtualCallTypeData to reach its end. Non null
1687         // if there's a return to profile.
1688         assert(SingleTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1689         add(mdp, mdp, tmp, LSL, exact_log2(DataLayout::cell_size));
1690       }
1691       str(mdp, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize));
1692     } else {
1693       assert(MethodData::profile_return(), "either profile call args or call ret");
1694       update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
1695     }
1696 
1697     // mdp points right after the end of the
1698     // CallTypeData/VirtualCallTypeData, right after the cells for the
1699     // return value type if there's one
1700 
1701     bind(profile_continue);
1702   }
1703 }
1704 
1705 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1706   assert_different_registers(mdp, ret, tmp, rbcp);
1707   if (ProfileInterpreter && MethodData::profile_return()) {
1708     Label profile_continue, done;

1714 
1715       // If we don't profile all invoke bytecodes we must make sure
1716       // it's a bytecode we indeed profile. We can't go back to the
1717       // beginning of the ProfileData we intend to update to check its
1718       // type because we're right after it and we don't known its
1719       // length
1720       Label do_profile;
1721       ldrb(rscratch1, Address(rbcp, 0));
1722       cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
1723       br(Assembler::EQ, do_profile);
1724       cmp(rscratch1, (u1)Bytecodes::_invokehandle);
1725       br(Assembler::EQ, do_profile);
1726       get_method(tmp);
1727       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset()));
1728       subs(zr, rscratch1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1729       br(Assembler::NE, profile_continue);
1730 
1731       bind(do_profile);
1732     }
1733 
1734     Address mdo_ret_addr(mdp, -in_bytes(SingleTypeEntry::size()));
1735     mov(tmp, ret);
1736     profile_obj_type(tmp, mdo_ret_addr);
1737 
1738     bind(profile_continue);
1739   }
1740 }
1741 
1742 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
1743   assert_different_registers(rscratch1, rscratch2, mdp, tmp1, tmp2);
1744   if (ProfileInterpreter && MethodData::profile_parameters()) {
1745     Label profile_continue, done;
1746 
1747     test_method_data_pointer(mdp, profile_continue);
1748 
1749     // Load the offset of the area within the MDO used for
1750     // parameters. If it's negative we're not profiling any parameters
1751     ldrw(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1752     tbnz(tmp1, 31, profile_continue);  // i.e. sign bit set
1753 
1754     // Compute a pointer to the area for parameters from the offset
< prev index next >