< 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) {

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

1525 
1526       // If we don't profile all invoke bytecodes we must make sure
1527       // it's a bytecode we indeed profile. We can't go back to the
1528       // beginning of the ProfileData we intend to update to check its
1529       // type because we're right after it and we don't known its
1530       // length
1531       Label do_profile;
1532       ldrb(rscratch1, Address(rbcp, 0));
1533       cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
1534       br(Assembler::EQ, do_profile);
1535       cmp(rscratch1, (u1)Bytecodes::_invokehandle);
1536       br(Assembler::EQ, do_profile);
1537       get_method(tmp);
1538       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset()));
1539       subs(zr, rscratch1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1540       br(Assembler::NE, profile_continue);
1541 
1542       bind(do_profile);
1543     }
1544 
1545     Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
1546     mov(tmp, ret);
1547     profile_obj_type(tmp, mdo_ret_addr);
1548 
1549     bind(profile_continue);
1550   }
1551 }
1552 
1553 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
1554   assert_different_registers(rscratch1, rscratch2, mdp, tmp1, tmp2);
1555   if (ProfileInterpreter && MethodData::profile_parameters()) {
1556     Label profile_continue, done;
1557 
1558     test_method_data_pointer(mdp, profile_continue);
1559 
1560     // Load the offset of the area within the MDO used for
1561     // parameters. If it's negative we're not profiling any parameters
1562     ldrw(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1563     tbnz(tmp1, 31, profile_continue);  // i.e. sign bit set
1564 
1565     // 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     bind(skip);
 738     // Check above kills sender esp in rscratch2. Reload it.
 739     ldr(rscratch2, Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize));
 740   }
 741 
 742   // remove frame anchor
 743   leave();
 744 
 745   JFR_ONLY(leave_jfr_critical_section();)
 746 
 747   // restore sender esp
 748   mov(esp, rscratch2);
 749 
 750   // If we're returning to interpreted code we will shortly be
 751   // adjusting SP to allow some space for ESP.  If we're returning to
 752   // compiled code the saved sender SP was saved in sender_sp, so this
 753   // restores it.
 754   andr(sp, esp, -16);
 755 }
 756 
 757 #if INCLUDE_JFR
 758 void InterpreterMacroAssembler::enter_jfr_critical_section() {
 759   const Address sampling_critical_section(rthread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
 760   mov(rscratch1, true);
 761   strb(rscratch1, sampling_critical_section);

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

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

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

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