< 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 }

1127     // case_array_offset_in_bytes()
1128     movw(reg2, in_bytes(MultiBranchData::per_case_size()));
1129     movw(rscratch1, in_bytes(MultiBranchData::case_array_offset()));
1130     Assembler::maddw(index, index, reg2, rscratch1);
1131 
1132     // Update the case count
1133     increment_mdp_data_at(mdp,
1134                           index,
1135                           in_bytes(MultiBranchData::relative_count_offset()));
1136 
1137     // The method data pointer needs to be updated.
1138     update_mdp_by_offset(mdp,
1139                          index,
1140                          in_bytes(MultiBranchData::
1141                                   relative_displacement_offset()));
1142 
1143     bind(profile_continue);
1144   }
1145 }
1146 


















































































































1147 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1148   if (state == atos) {
1149     MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
1150   }
1151 }
1152 
1153 void InterpreterMacroAssembler::notify_method_entry() {
1154   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1155   // track stack depth.  If it is possible to enter interp_only_mode we add
1156   // the code to check if the event should be sent.
1157   if (JvmtiExport::can_post_interpreter_events()) {
1158     Label L;
1159     ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset()));
1160     cbzw(r3, L);
1161     call_VM(noreg, CAST_FROM_FN_PTR(address,
1162                                     InterpreterRuntime::post_method_entry));
1163     bind(L);
1164   }
1165 
1166   if (DTraceMethodProbes) {

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

1536 
1537       // If we don't profile all invoke bytecodes we must make sure
1538       // it's a bytecode we indeed profile. We can't go back to the
1539       // beginning of the ProfileData we intend to update to check its
1540       // type because we're right after it and we don't known its
1541       // length
1542       Label do_profile;
1543       ldrb(rscratch1, Address(rbcp, 0));
1544       cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
1545       br(Assembler::EQ, do_profile);
1546       cmp(rscratch1, (u1)Bytecodes::_invokehandle);
1547       br(Assembler::EQ, do_profile);
1548       get_method(tmp);
1549       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset()));
1550       subs(zr, rscratch1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1551       br(Assembler::NE, profile_continue);
1552 
1553       bind(do_profile);
1554     }
1555 
1556     Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
1557     mov(tmp, ret);
1558     profile_obj_type(tmp, mdo_ret_addr);
1559 
1560     bind(profile_continue);
1561   }
1562 }
1563 
1564 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
1565   assert_different_registers(rscratch1, rscratch2, mdp, tmp1, tmp2);
1566   if (ProfileInterpreter && MethodData::profile_parameters()) {
1567     Label profile_continue, done;
1568 
1569     test_method_data_pointer(mdp, profile_continue);
1570 
1571     // Load the offset of the area within the MDO used for
1572     // parameters. If it's negative we're not profiling any parameters
1573     ldrw(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1574     tbnz(tmp1, 31, profile_continue);  // i.e. sign bit set
1575 
1576     // 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
 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 
 298   // Profile the not-null value's klass.
 299   if (profile) {
 300     profile_typecheck(r2, Rsub_klass); // blows r2
 301   }
 302   // Do the check.
 303   check_klass_subtype(Rsub_klass, r0, r2, ok_is_subtype); // blows r2
 304 }
 305 
 306 // Java Expression Stack
 307 
 308 void InterpreterMacroAssembler::pop_ptr(Register r) {
 309   ldr(r, post(esp, wordSize));
 310 }
 311 
 312 void InterpreterMacroAssembler::pop_i(Register r) {
 313   ldrw(r, post(esp, wordSize));
 314 }
 315 
 316 void InterpreterMacroAssembler::pop_l(Register r) {
 317   ldr(r, post(esp, 2 * Interpreter::stackElementSize));
 318 }
 319 
 320 void InterpreterMacroAssembler::push_ptr(Register r) {
 321   str(r, pre(esp, -wordSize));

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

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

1221     // case_array_offset_in_bytes()
1222     movw(reg2, in_bytes(MultiBranchData::per_case_size()));
1223     movw(rscratch1, in_bytes(MultiBranchData::case_array_offset()));
1224     Assembler::maddw(index, index, reg2, rscratch1);
1225 
1226     // Update the case count
1227     increment_mdp_data_at(mdp,
1228                           index,
1229                           in_bytes(MultiBranchData::relative_count_offset()));
1230 
1231     // The method data pointer needs to be updated.
1232     update_mdp_by_offset(mdp,
1233                          index,
1234                          in_bytes(MultiBranchData::
1235                                   relative_displacement_offset()));
1236 
1237     bind(profile_continue);
1238   }
1239 }
1240 
1241 template <class ArrayData> void InterpreterMacroAssembler::profile_array_type(Register mdp,
1242                                                                               Register array,
1243                                                                               Register tmp) {
1244   if (ProfileInterpreter) {
1245     Label profile_continue;
1246 
1247     // If no method data exists, go to profile_continue.
1248     test_method_data_pointer(mdp, profile_continue);
1249 
1250     mov(tmp, array);
1251     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayData::array_offset())));
1252 
1253     Label not_flat;
1254     test_non_flat_array_oop(array, tmp, not_flat);
1255 
1256     set_mdp_flag_at(mdp, ArrayData::flat_array_byte_constant());
1257 
1258     bind(not_flat);
1259 
1260     Label not_null_free;
1261     test_non_null_free_array_oop(array, tmp, not_null_free);
1262 
1263     set_mdp_flag_at(mdp, ArrayData::null_free_array_byte_constant());
1264 
1265     bind(not_null_free);
1266 
1267     bind(profile_continue);
1268   }
1269 }
1270 
1271 template void InterpreterMacroAssembler::profile_array_type<ArrayLoadData>(Register mdp,
1272                                                                            Register array,
1273                                                                            Register tmp);
1274 template void InterpreterMacroAssembler::profile_array_type<ArrayStoreData>(Register mdp,
1275                                                                             Register array,
1276                                                                             Register tmp);
1277 
1278 void InterpreterMacroAssembler::profile_multiple_element_types(Register mdp, Register element, Register tmp, const Register tmp2) {
1279   if (ProfileInterpreter) {
1280     Label profile_continue;
1281 
1282     // If no method data exists, go to profile_continue.
1283     test_method_data_pointer(mdp, profile_continue);
1284 
1285     Label done, update;
1286     cbnz(element, update);
1287     set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
1288     b(done);
1289 
1290     bind(update);
1291     load_klass(tmp, element);
1292 
1293     // Record the object type.
1294     profile_receiver_type(tmp, mdp, 0);
1295 
1296     bind(done);
1297 
1298     // The method data pointer needs to be updated.
1299     update_mdp_by_constant(mdp, in_bytes(ArrayStoreData::array_store_data_size()));
1300 
1301     bind(profile_continue);
1302   }
1303 }
1304 
1305 
1306 void InterpreterMacroAssembler::profile_element_type(Register mdp,
1307                                                      Register element,
1308                                                      Register tmp) {
1309   if (ProfileInterpreter) {
1310     Label profile_continue;
1311 
1312     // If no method data exists, go to profile_continue.
1313     test_method_data_pointer(mdp, profile_continue);
1314 
1315     mov(tmp, element);
1316     profile_obj_type(tmp, Address(mdp, in_bytes(ArrayLoadData::element_offset())));
1317 
1318     // The method data pointer needs to be updated.
1319     update_mdp_by_constant(mdp, in_bytes(ArrayLoadData::array_load_data_size()));
1320 
1321     bind(profile_continue);
1322   }
1323 }
1324 
1325 void InterpreterMacroAssembler::profile_acmp(Register mdp,
1326                                              Register left,
1327                                              Register right,
1328                                              Register tmp) {
1329   if (ProfileInterpreter) {
1330     Label profile_continue;
1331 
1332     // If no method data exists, go to profile_continue.
1333     test_method_data_pointer(mdp, profile_continue);
1334 
1335     mov(tmp, left);
1336     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::left_offset())));
1337 
1338     Label left_not_inline_type;
1339     test_oop_is_not_inline_type(left, tmp, left_not_inline_type);
1340     set_mdp_flag_at(mdp, ACmpData::left_inline_type_byte_constant());
1341     bind(left_not_inline_type);
1342 
1343     mov(tmp, right);
1344     profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::right_offset())));
1345 
1346     Label right_not_inline_type;
1347     test_oop_is_not_inline_type(right, tmp, right_not_inline_type);
1348     set_mdp_flag_at(mdp, ACmpData::right_inline_type_byte_constant());
1349     bind(right_not_inline_type);
1350 
1351     bind(profile_continue);
1352   }
1353 }
1354 
1355 void InterpreterMacroAssembler::_interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1356   if (state == atos) {
1357     MacroAssembler::_verify_oop_checked(reg, "broken oop", file, line);
1358   }
1359 }
1360 
1361 void InterpreterMacroAssembler::notify_method_entry() {
1362   // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1363   // track stack depth.  If it is possible to enter interp_only_mode we add
1364   // the code to check if the event should be sent.
1365   if (JvmtiExport::can_post_interpreter_events()) {
1366     Label L;
1367     ldrw(r3, Address(rthread, JavaThread::interp_only_mode_offset()));
1368     cbzw(r3, L);
1369     call_VM(noreg, CAST_FROM_FN_PTR(address,
1370                                     InterpreterRuntime::post_method_entry));
1371     bind(L);
1372   }
1373 
1374   if (DTraceMethodProbes) {

1698         profile_obj_type(tmp, mdo_arg_addr);
1699 
1700         int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
1701         off_to_args += to_add;
1702       }
1703 
1704       if (MethodData::profile_return()) {
1705         ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
1706         sub(tmp, tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
1707       }
1708 
1709       add(rscratch1, mdp, off_to_args);
1710       bind(done);
1711       mov(mdp, rscratch1);
1712 
1713       if (MethodData::profile_return()) {
1714         // We're right after the type profile for the last
1715         // argument. tmp is the number of cells left in the
1716         // CallTypeData/VirtualCallTypeData to reach its end. Non null
1717         // if there's a return to profile.
1718         assert(SingleTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1719         add(mdp, mdp, tmp, LSL, exact_log2(DataLayout::cell_size));
1720       }
1721       str(mdp, Address(rfp, frame::interpreter_frame_mdp_offset * wordSize));
1722     } else {
1723       assert(MethodData::profile_return(), "either profile call args or call ret");
1724       update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
1725     }
1726 
1727     // mdp points right after the end of the
1728     // CallTypeData/VirtualCallTypeData, right after the cells for the
1729     // return value type if there's one
1730 
1731     bind(profile_continue);
1732   }
1733 }
1734 
1735 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1736   assert_different_registers(mdp, ret, tmp, rbcp);
1737   if (ProfileInterpreter && MethodData::profile_return()) {
1738     Label profile_continue, done;

1744 
1745       // If we don't profile all invoke bytecodes we must make sure
1746       // it's a bytecode we indeed profile. We can't go back to the
1747       // beginning of the ProfileData we intend to update to check its
1748       // type because we're right after it and we don't known its
1749       // length
1750       Label do_profile;
1751       ldrb(rscratch1, Address(rbcp, 0));
1752       cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
1753       br(Assembler::EQ, do_profile);
1754       cmp(rscratch1, (u1)Bytecodes::_invokehandle);
1755       br(Assembler::EQ, do_profile);
1756       get_method(tmp);
1757       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset()));
1758       subs(zr, rscratch1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1759       br(Assembler::NE, profile_continue);
1760 
1761       bind(do_profile);
1762     }
1763 
1764     Address mdo_ret_addr(mdp, -in_bytes(SingleTypeEntry::size()));
1765     mov(tmp, ret);
1766     profile_obj_type(tmp, mdo_ret_addr);
1767 
1768     bind(profile_continue);
1769   }
1770 }
1771 
1772 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
1773   assert_different_registers(rscratch1, rscratch2, mdp, tmp1, tmp2);
1774   if (ProfileInterpreter && MethodData::profile_parameters()) {
1775     Label profile_continue, done;
1776 
1777     test_method_data_pointer(mdp, profile_continue);
1778 
1779     // Load the offset of the area within the MDO used for
1780     // parameters. If it's negative we're not profiling any parameters
1781     ldrw(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1782     tbnz(tmp1, 31, profile_continue);  // i.e. sign bit set
1783 
1784     // Compute a pointer to the area for parameters from the offset
< prev index next >