15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 */
26
27 #include "asm/macroAssembler.inline.hpp"
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/barrierSetAssembler.hpp"
30 #include "interp_masm_riscv.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 // Get method->_constMethod->_result_type
52 ld(t0, Address(fp, frame::interpreter_frame_method_offset * wordSize));
53 ld(t0, Address(t0, Method::const_offset()));
54 lbu(t0, Address(t0, ConstMethod::result_type_offset()));
55
56 Label done, notBool, notByte, notChar;
57
222
223 void InterpreterMacroAssembler::load_resolved_klass_at_offset(
224 Register cpool, Register index, Register klass, Register temp) {
225 shadd(temp, index, cpool, temp, LogBytesPerWord);
226 lhu(temp, Address(temp, sizeof(ConstantPool))); // temp = resolved_klass_index
227 ld(klass, Address(cpool, ConstantPool::resolved_klasses_offset())); // klass = cpool->_resolved_klasses
228 shadd(klass, temp, klass, temp, LogBytesPerWord);
229 ld(klass, Address(klass, Array<Klass*>::base_offset_in_bytes()));
230 }
231
232 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
233 // subtype of super_klass.
234 //
235 // Args:
236 // x10: superklass
237 // Rsub_klass: subklass
238 //
239 // Kills:
240 // x12
241 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
242 Label& ok_is_subtype) {
243 assert(Rsub_klass != x10, "x10 holds superklass");
244 assert(Rsub_klass != x12, "x12 holds 2ndary super array length");
245
246 // Profile the not-null value's klass.
247 profile_typecheck(x12, Rsub_klass); // blows x12
248
249 // Do the check.
250 check_klass_subtype(Rsub_klass, x10, x12, ok_is_subtype); // blows x12
251 }
252
253 // Java Expression Stack
254
255 void InterpreterMacroAssembler::pop_ptr(Register r) {
256 ld(r, Address(esp, 0));
257 addi(esp, esp, wordSize);
258 }
259
260 void InterpreterMacroAssembler::pop_i(Register r) {
261 lw(r, Address(esp, 0)); // lw do signed extended
262 addi(esp, esp, wordSize);
263 }
264
265 void InterpreterMacroAssembler::pop_l(Register r) {
266 ld(r, Address(esp, 0));
267 addi(esp, esp, 2 * Interpreter::stackElementSize);
970 ld(return_bci, Address(sp, wordSize));
971 addi(sp, sp, 2 * wordSize);
972 }
973
974 void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
975 if (ProfileInterpreter) {
976 Label profile_continue;
977
978 // If no method data exists, go to profile_continue.
979 test_method_data_pointer(mdp, profile_continue);
980
981 // We are taking a branch. Increment the taken count.
982 increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
983
984 // The method data pointer needs to be updated to reflect the new target.
985 update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
986 bind(profile_continue);
987 }
988 }
989
990 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
991 if (ProfileInterpreter) {
992 Label profile_continue;
993
994 // If no method data exists, go to profile_continue.
995 test_method_data_pointer(mdp, profile_continue);
996
997 // We are not taking a branch. Increment the not taken count.
998 increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
999
1000 // The method data pointer needs to be updated to correspond to
1001 // the next bytecode
1002 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
1003 bind(profile_continue);
1004 }
1005 }
1006
1007 void InterpreterMacroAssembler::profile_call(Register mdp) {
1008 if (ProfileInterpreter) {
1009 Label profile_continue;
1010
1011 // If no method data exists, go to profile_continue.
1012 test_method_data_pointer(mdp, profile_continue);
1013
1014 // We are making a call. Increment the count.
1015 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1016
1017 // The method data pointer needs to be updated to reflect the new target.
1018 update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1019 bind(profile_continue);
1020 }
1021 }
1022
1169 mv(reg2, in_bytes(MultiBranchData::per_case_size()));
1170 mv(t0, in_bytes(MultiBranchData::case_array_offset()));
1171 Assembler::mul(index, index, reg2);
1172 Assembler::add(index, index, t0);
1173
1174 // Update the case count
1175 increment_mdp_data_at(mdp,
1176 index,
1177 in_bytes(MultiBranchData::relative_count_offset()));
1178
1179 // The method data pointer need to be updated.
1180 update_mdp_by_offset(mdp,
1181 index,
1182 in_bytes(MultiBranchData::
1183 relative_displacement_offset()));
1184
1185 bind(profile_continue);
1186 }
1187 }
1188
1189 void InterpreterMacroAssembler::notify_method_entry() {
1190 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1191 // track stack depth. If it is possible to enter interp_only_mode we add
1192 // the code to check if the event should be sent.
1193 if (JvmtiExport::can_post_interpreter_events()) {
1194 Label L;
1195 lwu(x13, Address(xthread, JavaThread::interp_only_mode_offset()));
1196 beqz(x13, L);
1197 call_VM(noreg, CAST_FROM_FN_PTR(address,
1198 InterpreterRuntime::post_method_entry));
1199 bind(L);
1200 }
1201
1202 if (DTraceMethodProbes) {
1203 get_method(c_rarg1);
1204 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
1205 xthread, c_rarg1);
1206 }
1207
1208 // RedefineClasses() tracing support for obsolete method entry
1583 blt(index, t1, loop);
1584 bind(loopEnd);
1585
1586 if (MethodData::profile_return()) {
1587 ld(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
1588 sub(tmp, tmp, TypeProfileArgsLimit * TypeStackSlotEntries::per_arg_count());
1589 }
1590
1591 add(t0, mdp, off_to_args);
1592 bind(done);
1593 mv(mdp, t0);
1594
1595 // unspill the clobbered registers
1596 pop_reg(pushed_registers, sp);
1597
1598 if (MethodData::profile_return()) {
1599 // We're right after the type profile for the last
1600 // argument. tmp is the number of cells left in the
1601 // CallTypeData/VirtualCallTypeData to reach its end. Non null
1602 // if there's a return to profile.
1603 assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1604 shadd(mdp, tmp, mdp, tmp, exact_log2(DataLayout::cell_size));
1605 }
1606 sd(mdp, Address(fp, frame::interpreter_frame_mdp_offset * wordSize));
1607 } else {
1608 assert(MethodData::profile_return(), "either profile call args or call ret");
1609 update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
1610 }
1611
1612 // mdp points right after the end of the
1613 // CallTypeData/VirtualCallTypeData, right after the cells for the
1614 // return value type if there's one
1615
1616 bind(profile_continue);
1617 }
1618 }
1619
1620 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1621 assert_different_registers(mdp, ret, tmp, xbcp, t0, t1);
1622 if (ProfileInterpreter && MethodData::profile_return()) {
1623 Label profile_continue, done;
1628 assert(Method::intrinsic_id_size_in_bytes() == 2, "assuming Method::_intrinsic_id is u2");
1629
1630 // If we don't profile all invoke bytecodes we must make sure
1631 // it's a bytecode we indeed profile. We can't go back to the
1632 // beginning of the ProfileData we intend to update to check its
1633 // type because we're right after it and we don't known its
1634 // length
1635 Label do_profile;
1636 lbu(t0, Address(xbcp, 0));
1637 mv(tmp, (u1)Bytecodes::_invokedynamic);
1638 beq(t0, tmp, do_profile);
1639 mv(tmp, (u1)Bytecodes::_invokehandle);
1640 beq(t0, tmp, do_profile);
1641 get_method(tmp);
1642 lhu(t0, Address(tmp, Method::intrinsic_id_offset()));
1643 mv(t1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1644 bne(t0, t1, profile_continue);
1645 bind(do_profile);
1646 }
1647
1648 Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
1649 mv(tmp, ret);
1650 profile_obj_type(tmp, mdo_ret_addr, t1);
1651
1652 bind(profile_continue);
1653 }
1654 }
1655
1656 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2, Register tmp3) {
1657 assert_different_registers(t0, t1, mdp, tmp1, tmp2, tmp3);
1658 if (ProfileInterpreter && MethodData::profile_parameters()) {
1659 Label profile_continue, done;
1660
1661 test_method_data_pointer(mdp, profile_continue);
1662
1663 // Load the offset of the area within the MDO used for
1664 // parameters. If it's negative we're not profiling any parameters
1665 lwu(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1666 srli(tmp2, tmp1, 31);
1667 bnez(tmp2, profile_continue); // i.e. sign bit set
1668
1730 // Get address of field entries array
1731 ld(cache, Address(xcpool, ConstantPoolCache::field_entries_offset()));
1732 addi(cache, cache, Array<ResolvedIndyEntry>::base_offset_in_bytes());
1733 add(cache, cache, index);
1734 // Prevents stale data from being read after the bytecode is patched to the fast bytecode
1735 membar(MacroAssembler::LoadLoad);
1736 }
1737
1738 void InterpreterMacroAssembler::get_method_counters(Register method,
1739 Register mcs, Label& skip) {
1740 Label has_counters;
1741 ld(mcs, Address(method, Method::method_counters_offset()));
1742 bnez(mcs, has_counters);
1743 call_VM(noreg, CAST_FROM_FN_PTR(address,
1744 InterpreterRuntime::build_method_counters), method);
1745 ld(mcs, Address(method, Method::method_counters_offset()));
1746 beqz(mcs, skip); // No MethodCounters allocated, OutOfMemory
1747 bind(has_counters);
1748 }
1749
1750 void InterpreterMacroAssembler::load_method_entry(Register cache, Register index, int bcp_offset) {
1751 // Get index out of bytecode pointer
1752 get_cache_index_at_bcp(index, cache, bcp_offset, sizeof(u2));
1753 mv(cache, sizeof(ResolvedMethodEntry));
1754 mul(index, index, cache); // Scale the index to be the entry index * sizeof(ResolvedMethodEntry)
1755
1756 // Get address of field entries array
1757 ld(cache, Address(xcpool, ConstantPoolCache::method_entries_offset()));
1758 addi(cache, cache, Array<ResolvedMethodEntry>::base_offset_in_bytes());
1759 add(cache, cache, index);
1760 }
1761
1762 #ifdef ASSERT
1763 void InterpreterMacroAssembler::verify_field_offset(Register reg) {
1764 // Verify the field offset is not in the header, implicitly checks for 0
1765 Label L;
1766 mv(t0, oopDesc::base_offset_in_bytes());
1767 bge(reg, t0, L);
1768 stop("bad field offset");
1769 bind(L);
|
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 */
26
27 #include "asm/macroAssembler.inline.hpp"
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/barrierSetAssembler.hpp"
30 #include "interp_masm_riscv.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 // Get method->_constMethod->_result_type
54 ld(t0, Address(fp, frame::interpreter_frame_method_offset * wordSize));
55 ld(t0, Address(t0, Method::const_offset()));
56 lbu(t0, Address(t0, ConstMethod::result_type_offset()));
57
58 Label done, notBool, notByte, notChar;
59
224
225 void InterpreterMacroAssembler::load_resolved_klass_at_offset(
226 Register cpool, Register index, Register klass, Register temp) {
227 shadd(temp, index, cpool, temp, LogBytesPerWord);
228 lhu(temp, Address(temp, sizeof(ConstantPool))); // temp = resolved_klass_index
229 ld(klass, Address(cpool, ConstantPool::resolved_klasses_offset())); // klass = cpool->_resolved_klasses
230 shadd(klass, temp, klass, temp, LogBytesPerWord);
231 ld(klass, Address(klass, Array<Klass*>::base_offset_in_bytes()));
232 }
233
234 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
235 // subtype of super_klass.
236 //
237 // Args:
238 // x10: superklass
239 // Rsub_klass: subklass
240 //
241 // Kills:
242 // x12
243 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
244 Label& ok_is_subtype,
245 bool profile) {
246 assert(Rsub_klass != x10, "x10 holds superklass");
247 assert(Rsub_klass != x12, "x12 holds 2ndary super array length");
248
249 // Profile the not-null value's klass.
250 if (profile) {
251 profile_typecheck(x12, Rsub_klass); // blows x12
252 }
253
254 // Do the check.
255 check_klass_subtype(Rsub_klass, x10, x12, ok_is_subtype); // blows x12
256 }
257
258 // Java Expression Stack
259
260 void InterpreterMacroAssembler::pop_ptr(Register r) {
261 ld(r, Address(esp, 0));
262 addi(esp, esp, wordSize);
263 }
264
265 void InterpreterMacroAssembler::pop_i(Register r) {
266 lw(r, Address(esp, 0)); // lw do signed extended
267 addi(esp, esp, wordSize);
268 }
269
270 void InterpreterMacroAssembler::pop_l(Register r) {
271 ld(r, Address(esp, 0));
272 addi(esp, esp, 2 * Interpreter::stackElementSize);
975 ld(return_bci, Address(sp, wordSize));
976 addi(sp, sp, 2 * wordSize);
977 }
978
979 void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
980 if (ProfileInterpreter) {
981 Label profile_continue;
982
983 // If no method data exists, go to profile_continue.
984 test_method_data_pointer(mdp, profile_continue);
985
986 // We are taking a branch. Increment the taken count.
987 increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
988
989 // The method data pointer needs to be updated to reflect the new target.
990 update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
991 bind(profile_continue);
992 }
993 }
994
995 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp, bool acmp) {
996 if (ProfileInterpreter) {
997 Label profile_continue;
998
999 // If no method data exists, go to profile_continue.
1000 test_method_data_pointer(mdp, profile_continue);
1001
1002 // We are not taking a branch. Increment the not taken count.
1003 increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
1004
1005 // The method data pointer needs to be updated to correspond to
1006 // the next bytecode
1007 update_mdp_by_constant(mdp, acmp ? in_bytes(ACmpData::acmp_data_size()) : in_bytes(BranchData::branch_data_size()));
1008 bind(profile_continue);
1009 }
1010 }
1011
1012 void InterpreterMacroAssembler::profile_call(Register mdp) {
1013 if (ProfileInterpreter) {
1014 Label profile_continue;
1015
1016 // If no method data exists, go to profile_continue.
1017 test_method_data_pointer(mdp, profile_continue);
1018
1019 // We are making a call. Increment the count.
1020 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
1021
1022 // The method data pointer needs to be updated to reflect the new target.
1023 update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
1024 bind(profile_continue);
1025 }
1026 }
1027
1174 mv(reg2, in_bytes(MultiBranchData::per_case_size()));
1175 mv(t0, in_bytes(MultiBranchData::case_array_offset()));
1176 Assembler::mul(index, index, reg2);
1177 Assembler::add(index, index, t0);
1178
1179 // Update the case count
1180 increment_mdp_data_at(mdp,
1181 index,
1182 in_bytes(MultiBranchData::relative_count_offset()));
1183
1184 // The method data pointer need to be updated.
1185 update_mdp_by_offset(mdp,
1186 index,
1187 in_bytes(MultiBranchData::
1188 relative_displacement_offset()));
1189
1190 bind(profile_continue);
1191 }
1192 }
1193
1194 template <class ArrayData> void InterpreterMacroAssembler::profile_array_type(Register mdp,
1195 Register array,
1196 Register tmp) {
1197 if (ProfileInterpreter) {
1198 Label profile_continue;
1199
1200 // If no method data exists, go to profile_continue.
1201 test_method_data_pointer(mdp, profile_continue);
1202
1203 mv(tmp, array);
1204 profile_obj_type(tmp, Address(mdp, in_bytes(ArrayData::array_offset())), t1);
1205
1206 Label not_flat;
1207 test_non_flat_array_oop(array, tmp, not_flat);
1208
1209 set_mdp_flag_at(mdp, ArrayData::flat_array_byte_constant());
1210
1211 bind(not_flat);
1212
1213 Label not_null_free;
1214 test_non_null_free_array_oop(array, tmp, not_null_free);
1215
1216 set_mdp_flag_at(mdp, ArrayData::null_free_array_byte_constant());
1217
1218 bind(not_null_free);
1219
1220 bind(profile_continue);
1221 }
1222 }
1223
1224 template void InterpreterMacroAssembler::profile_array_type<ArrayLoadData>(Register mdp,
1225 Register array,
1226 Register tmp);
1227 template void InterpreterMacroAssembler::profile_array_type<ArrayStoreData>(Register mdp,
1228 Register array,
1229 Register tmp);
1230
1231 void InterpreterMacroAssembler::profile_multiple_element_types(Register mdp, Register element, Register tmp, const Register tmp2) {
1232 if (ProfileInterpreter) {
1233 Label profile_continue;
1234
1235 // If no method data exists, go to profile_continue.
1236 test_method_data_pointer(mdp, profile_continue);
1237
1238 Label done, update;
1239 bnez(element, update);
1240 set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
1241 j(done);
1242
1243 bind(update);
1244 load_klass(tmp, element);
1245
1246 // Record the object type.
1247 profile_receiver_type(tmp, mdp, 0);
1248
1249 bind(done);
1250
1251 // The method data pointer needs to be updated.
1252 update_mdp_by_constant(mdp, in_bytes(ArrayStoreData::array_store_data_size()));
1253
1254 bind(profile_continue);
1255 }
1256 }
1257
1258 void InterpreterMacroAssembler::profile_element_type(Register mdp,
1259 Register element,
1260 Register tmp) {
1261 if (ProfileInterpreter) {
1262 Label profile_continue;
1263
1264 // If no method data exists, go to profile_continue.
1265 test_method_data_pointer(mdp, profile_continue);
1266
1267 mv(tmp, element);
1268 profile_obj_type(tmp, Address(mdp, in_bytes(ArrayLoadData::element_offset())), t1);
1269
1270 // The method data pointer needs to be updated.
1271 update_mdp_by_constant(mdp, in_bytes(ArrayLoadData::array_load_data_size()));
1272
1273 bind(profile_continue);
1274 }
1275 }
1276
1277 void InterpreterMacroAssembler::profile_acmp(Register mdp,
1278 Register left,
1279 Register right,
1280 Register tmp) {
1281 if (ProfileInterpreter) {
1282 Label profile_continue;
1283
1284 // If no method data exists, go to profile_continue.
1285 test_method_data_pointer(mdp, profile_continue);
1286
1287 mv(tmp, left);
1288 profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::left_offset())), t1);
1289
1290 Label left_not_inline_type;
1291 test_oop_is_not_inline_type(left, tmp, left_not_inline_type);
1292 set_mdp_flag_at(mdp, ACmpData::left_inline_type_byte_constant());
1293 bind(left_not_inline_type);
1294
1295 mv(tmp, right);
1296 profile_obj_type(tmp, Address(mdp, in_bytes(ACmpData::right_offset())), t1);
1297
1298 Label right_not_inline_type;
1299 test_oop_is_not_inline_type(right, tmp, right_not_inline_type);
1300 set_mdp_flag_at(mdp, ACmpData::right_inline_type_byte_constant());
1301 bind(right_not_inline_type);
1302
1303 bind(profile_continue);
1304 }
1305 }
1306
1307
1308 void InterpreterMacroAssembler::notify_method_entry() {
1309 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
1310 // track stack depth. If it is possible to enter interp_only_mode we add
1311 // the code to check if the event should be sent.
1312 if (JvmtiExport::can_post_interpreter_events()) {
1313 Label L;
1314 lwu(x13, Address(xthread, JavaThread::interp_only_mode_offset()));
1315 beqz(x13, L);
1316 call_VM(noreg, CAST_FROM_FN_PTR(address,
1317 InterpreterRuntime::post_method_entry));
1318 bind(L);
1319 }
1320
1321 if (DTraceMethodProbes) {
1322 get_method(c_rarg1);
1323 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
1324 xthread, c_rarg1);
1325 }
1326
1327 // RedefineClasses() tracing support for obsolete method entry
1702 blt(index, t1, loop);
1703 bind(loopEnd);
1704
1705 if (MethodData::profile_return()) {
1706 ld(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
1707 sub(tmp, tmp, TypeProfileArgsLimit * TypeStackSlotEntries::per_arg_count());
1708 }
1709
1710 add(t0, mdp, off_to_args);
1711 bind(done);
1712 mv(mdp, t0);
1713
1714 // unspill the clobbered registers
1715 pop_reg(pushed_registers, sp);
1716
1717 if (MethodData::profile_return()) {
1718 // We're right after the type profile for the last
1719 // argument. tmp is the number of cells left in the
1720 // CallTypeData/VirtualCallTypeData to reach its end. Non null
1721 // if there's a return to profile.
1722 assert(SingleTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
1723 shadd(mdp, tmp, mdp, tmp, exact_log2(DataLayout::cell_size));
1724 }
1725 sd(mdp, Address(fp, frame::interpreter_frame_mdp_offset * wordSize));
1726 } else {
1727 assert(MethodData::profile_return(), "either profile call args or call ret");
1728 update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
1729 }
1730
1731 // mdp points right after the end of the
1732 // CallTypeData/VirtualCallTypeData, right after the cells for the
1733 // return value type if there's one
1734
1735 bind(profile_continue);
1736 }
1737 }
1738
1739 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
1740 assert_different_registers(mdp, ret, tmp, xbcp, t0, t1);
1741 if (ProfileInterpreter && MethodData::profile_return()) {
1742 Label profile_continue, done;
1747 assert(Method::intrinsic_id_size_in_bytes() == 2, "assuming Method::_intrinsic_id is u2");
1748
1749 // If we don't profile all invoke bytecodes we must make sure
1750 // it's a bytecode we indeed profile. We can't go back to the
1751 // beginning of the ProfileData we intend to update to check its
1752 // type because we're right after it and we don't known its
1753 // length
1754 Label do_profile;
1755 lbu(t0, Address(xbcp, 0));
1756 mv(tmp, (u1)Bytecodes::_invokedynamic);
1757 beq(t0, tmp, do_profile);
1758 mv(tmp, (u1)Bytecodes::_invokehandle);
1759 beq(t0, tmp, do_profile);
1760 get_method(tmp);
1761 lhu(t0, Address(tmp, Method::intrinsic_id_offset()));
1762 mv(t1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1763 bne(t0, t1, profile_continue);
1764 bind(do_profile);
1765 }
1766
1767 Address mdo_ret_addr(mdp, -in_bytes(SingleTypeEntry::size()));
1768 mv(tmp, ret);
1769 profile_obj_type(tmp, mdo_ret_addr, t1);
1770
1771 bind(profile_continue);
1772 }
1773 }
1774
1775 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2, Register tmp3) {
1776 assert_different_registers(t0, t1, mdp, tmp1, tmp2, tmp3);
1777 if (ProfileInterpreter && MethodData::profile_parameters()) {
1778 Label profile_continue, done;
1779
1780 test_method_data_pointer(mdp, profile_continue);
1781
1782 // Load the offset of the area within the MDO used for
1783 // parameters. If it's negative we're not profiling any parameters
1784 lwu(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
1785 srli(tmp2, tmp1, 31);
1786 bnez(tmp2, profile_continue); // i.e. sign bit set
1787
1849 // Get address of field entries array
1850 ld(cache, Address(xcpool, ConstantPoolCache::field_entries_offset()));
1851 addi(cache, cache, Array<ResolvedIndyEntry>::base_offset_in_bytes());
1852 add(cache, cache, index);
1853 // Prevents stale data from being read after the bytecode is patched to the fast bytecode
1854 membar(MacroAssembler::LoadLoad);
1855 }
1856
1857 void InterpreterMacroAssembler::get_method_counters(Register method,
1858 Register mcs, Label& skip) {
1859 Label has_counters;
1860 ld(mcs, Address(method, Method::method_counters_offset()));
1861 bnez(mcs, has_counters);
1862 call_VM(noreg, CAST_FROM_FN_PTR(address,
1863 InterpreterRuntime::build_method_counters), method);
1864 ld(mcs, Address(method, Method::method_counters_offset()));
1865 beqz(mcs, skip); // No MethodCounters allocated, OutOfMemory
1866 bind(has_counters);
1867 }
1868
1869 void InterpreterMacroAssembler::read_flat_field(Register entry, Register obj) {
1870 call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_flat_field), obj, entry);
1871 membar(MacroAssembler::StoreStore);
1872 }
1873
1874 void InterpreterMacroAssembler::write_flat_field(Register entry, Register field_offset,
1875 Register tmp1, Register tmp2,
1876 Register obj) {
1877 assert_different_registers(entry, field_offset, tmp1, tmp2, obj);
1878 Label slow_path, done;
1879
1880 load_unsigned_byte(tmp1, Address(entry, in_bytes(ResolvedFieldEntry::flags_offset())));
1881 test_field_is_not_null_free_inline_type(tmp1, tmp2, slow_path);
1882
1883 null_check(x10); // FIXME JDK-8341120
1884
1885 add(obj, obj, field_offset);
1886
1887 load_klass(tmp1, x10);
1888 payload_address(x10, x10, tmp1);
1889
1890 Register layout_info = field_offset;
1891 load_unsigned_short(tmp1, Address(entry, in_bytes(ResolvedFieldEntry::field_index_offset())));
1892 ld(tmp2, Address(entry, in_bytes(ResolvedFieldEntry::field_holder_offset())));
1893 inline_layout_info(tmp2, tmp1, layout_info);
1894
1895 flat_field_copy(IN_HEAP, x10, obj, layout_info);
1896 j(done);
1897
1898 bind(slow_path);
1899 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::write_flat_field), obj, x10, entry);
1900 bind(done);
1901 }
1902
1903 void InterpreterMacroAssembler::load_method_entry(Register cache, Register index, int bcp_offset) {
1904 // Get index out of bytecode pointer
1905 get_cache_index_at_bcp(index, cache, bcp_offset, sizeof(u2));
1906 mv(cache, sizeof(ResolvedMethodEntry));
1907 mul(index, index, cache); // Scale the index to be the entry index * sizeof(ResolvedMethodEntry)
1908
1909 // Get address of field entries array
1910 ld(cache, Address(xcpool, ConstantPoolCache::method_entries_offset()));
1911 addi(cache, cache, Array<ResolvedMethodEntry>::base_offset_in_bytes());
1912 add(cache, cache, index);
1913 }
1914
1915 #ifdef ASSERT
1916 void InterpreterMacroAssembler::verify_field_offset(Register reg) {
1917 // Verify the field offset is not in the header, implicitly checks for 0
1918 Label L;
1919 mv(t0, oopDesc::base_offset_in_bytes());
1920 bge(reg, t0, L);
1921 stop("bad field offset");
1922 bind(L);
|