1 /* |
1 /* |
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * Copyright (c) 2012, 2018 SAP SE. All rights reserved. |
3 * Copyright (c) 2012, 2019 SAP SE. All rights reserved. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * |
5 * |
6 * This code is free software; you can redistribute it and/or modify it |
6 * This code is free software; you can redistribute it and/or modify it |
7 * under the terms of the GNU General Public License version 2 only, as |
7 * under the terms of the GNU General Public License version 2 only, as |
8 * published by the Free Software Foundation. |
8 * published by the Free Software Foundation. |
32 #include "gc/shared/gcLocker.hpp" |
32 #include "gc/shared/gcLocker.hpp" |
33 #include "interpreter/interpreter.hpp" |
33 #include "interpreter/interpreter.hpp" |
34 #include "interpreter/interp_masm.hpp" |
34 #include "interpreter/interp_masm.hpp" |
35 #include "memory/resourceArea.hpp" |
35 #include "memory/resourceArea.hpp" |
36 #include "oops/compiledICHolder.hpp" |
36 #include "oops/compiledICHolder.hpp" |
|
37 #include "oops/klass.inline.hpp" |
37 #include "runtime/safepointMechanism.hpp" |
38 #include "runtime/safepointMechanism.hpp" |
38 #include "runtime/sharedRuntime.hpp" |
39 #include "runtime/sharedRuntime.hpp" |
39 #include "runtime/vframeArray.hpp" |
40 #include "runtime/vframeArray.hpp" |
40 #include "utilities/align.hpp" |
41 #include "utilities/align.hpp" |
41 #include "vmreg_ppc.inline.hpp" |
42 #include "vmreg_ppc.inline.hpp" |
1140 } else { |
1141 } else { |
1141 r = r_1->as_Register(); |
1142 r = r_1->as_Register(); |
1142 } |
1143 } |
1143 if (!r_2->is_valid()) { |
1144 if (!r_2->is_valid()) { |
1144 // Not sure we need to do this but it shouldn't hurt. |
1145 // Not sure we need to do this but it shouldn't hurt. |
1145 if (sig_bt[i] == T_OBJECT || sig_bt[i] == T_ADDRESS || sig_bt[i] == T_ARRAY) { |
1146 if (is_reference_type(sig_bt[i]) || sig_bt[i] == T_ADDRESS) { |
1146 __ ld(r, ld_offset, ld_ptr); |
1147 __ ld(r, ld_offset, ld_ptr); |
1147 ld_offset-=wordSize; |
1148 ld_offset-=wordSize; |
1148 } else { |
1149 } else { |
1149 __ lwz(r, ld_offset, ld_ptr); |
1150 __ lwz(r, ld_offset, ld_ptr); |
1150 ld_offset-=wordSize; |
1151 ld_offset-=wordSize; |
1272 // Branch to ic_miss_stub. |
1273 // Branch to ic_miss_stub. |
1273 __ b64_patchable((address)SharedRuntime::get_ic_miss_stub(), relocInfo::runtime_call_type); |
1274 __ b64_patchable((address)SharedRuntime::get_ic_miss_stub(), relocInfo::runtime_call_type); |
1274 |
1275 |
1275 // entry: c2i |
1276 // entry: c2i |
1276 |
1277 |
1277 c2i_entry = gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, call_interpreter, ientry); |
1278 c2i_entry = __ pc(); |
1278 |
1279 |
1279 return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
1280 // Class initialization barrier for static methods |
|
1281 address c2i_no_clinit_check_entry = NULL; |
|
1282 if (VM_Version::supports_fast_class_init_checks()) { |
|
1283 Label L_skip_barrier; |
|
1284 |
|
1285 { // Bypass the barrier for non-static methods |
|
1286 __ lwz(R0, in_bytes(Method::access_flags_offset()), R19_method); |
|
1287 __ andi_(R0, R0, JVM_ACC_STATIC); |
|
1288 __ beq(CCR0, L_skip_barrier); // non-static |
|
1289 } |
|
1290 |
|
1291 Register klass = R11_scratch1; |
|
1292 __ load_method_holder(klass, R19_method); |
|
1293 __ clinit_barrier(klass, R16_thread, &L_skip_barrier /*L_fast_path*/); |
|
1294 |
|
1295 __ load_const_optimized(klass, SharedRuntime::get_handle_wrong_method_stub(), R0); |
|
1296 __ mtctr(klass); |
|
1297 __ bctr(); |
|
1298 |
|
1299 __ bind(L_skip_barrier); |
|
1300 c2i_no_clinit_check_entry = __ pc(); |
|
1301 } |
|
1302 |
|
1303 gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, call_interpreter, ientry); |
|
1304 |
|
1305 return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry); |
1280 } |
1306 } |
1281 |
1307 |
1282 #ifdef COMPILER2 |
1308 #ifdef COMPILER2 |
1283 // An oop arg. Must pass a handle not the oop itself. |
1309 // An oop arg. Must pass a handle not the oop itself. |
1284 static void object_move(MacroAssembler* masm, |
1310 static void object_move(MacroAssembler* masm, |
1712 const BasicType* sig_bt, |
1738 const BasicType* sig_bt, |
1713 const VMRegPair* regs) { |
1739 const VMRegPair* regs) { |
1714 Register temp_reg = R19_method; // not part of any compiled calling seq |
1740 Register temp_reg = R19_method; // not part of any compiled calling seq |
1715 if (VerifyOops) { |
1741 if (VerifyOops) { |
1716 for (int i = 0; i < method->size_of_parameters(); i++) { |
1742 for (int i = 0; i < method->size_of_parameters(); i++) { |
1717 if (sig_bt[i] == T_OBJECT || |
1743 if (is_reference_type(sig_bt[i])) { |
1718 sig_bt[i] == T_ARRAY) { |
|
1719 VMReg r = regs[i].first(); |
1744 VMReg r = regs[i].first(); |
1720 assert(r->is_valid(), "bad oop arg"); |
1745 assert(r->is_valid(), "bad oop arg"); |
1721 if (r->is_stack()) { |
1746 if (r->is_stack()) { |
1722 __ ld(temp_reg, reg2offset(r), R1_SP); |
1747 __ ld(temp_reg, reg2offset(r), R1_SP); |
1723 __ verify_oop(temp_reg); |
1748 __ verify_oop(temp_reg); |
1822 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, |
1847 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, |
1823 const methodHandle& method, |
1848 const methodHandle& method, |
1824 int compile_id, |
1849 int compile_id, |
1825 BasicType *in_sig_bt, |
1850 BasicType *in_sig_bt, |
1826 VMRegPair *in_regs, |
1851 VMRegPair *in_regs, |
1827 BasicType ret_type) { |
1852 BasicType ret_type, |
|
1853 address critical_entry) { |
1828 #ifdef COMPILER2 |
1854 #ifdef COMPILER2 |
1829 if (method->is_method_handle_intrinsic()) { |
1855 if (method->is_method_handle_intrinsic()) { |
1830 vmIntrinsics::ID iid = method->intrinsic_id(); |
1856 vmIntrinsics::ID iid = method->intrinsic_id(); |
1831 intptr_t start = (intptr_t)__ pc(); |
1857 intptr_t start = (intptr_t)__ pc(); |
1832 int vep_offset = ((intptr_t)__ pc()) - start; |
1858 int vep_offset = ((intptr_t)__ pc()) - start; |
1847 in_ByteSize(-1), |
1873 in_ByteSize(-1), |
1848 (OopMapSet*)NULL); |
1874 (OopMapSet*)NULL); |
1849 } |
1875 } |
1850 |
1876 |
1851 bool is_critical_native = true; |
1877 bool is_critical_native = true; |
1852 address native_func = method->critical_native_function(); |
1878 address native_func = critical_entry; |
1853 if (native_func == NULL) { |
1879 if (native_func == NULL) { |
1854 native_func = method->native_function(); |
1880 native_func = method->native_function(); |
1855 is_critical_native = false; |
1881 is_critical_native = false; |
1856 } |
1882 } |
1857 assert(native_func != NULL, "must have function"); |
1883 assert(native_func != NULL, "must have function"); |
2102 if (UseRTMLocking) { |
2128 if (UseRTMLocking) { |
2103 // Abort RTM transaction before calling JNI |
2129 // Abort RTM transaction before calling JNI |
2104 // because critical section can be large and |
2130 // because critical section can be large and |
2105 // abort anyway. Also nmethod can be deoptimized. |
2131 // abort anyway. Also nmethod can be deoptimized. |
2106 __ tabort_(); |
2132 __ tabort_(); |
|
2133 } |
|
2134 |
|
2135 if (VM_Version::supports_fast_class_init_checks() && method->needs_clinit_barrier()) { |
|
2136 Label L_skip_barrier; |
|
2137 Register klass = r_temp_1; |
|
2138 // Notify OOP recorder (don't need the relocation) |
|
2139 AddressLiteral md = __ constant_metadata_address(method->method_holder()); |
|
2140 __ load_const_optimized(klass, md.value(), R0); |
|
2141 __ clinit_barrier(klass, R16_thread, &L_skip_barrier /*L_fast_path*/); |
|
2142 |
|
2143 __ load_const_optimized(klass, SharedRuntime::get_handle_wrong_method_stub(), R0); |
|
2144 __ mtctr(klass); |
|
2145 __ bctr(); |
|
2146 |
|
2147 __ bind(L_skip_barrier); |
2107 } |
2148 } |
2108 |
2149 |
2109 __ save_LR_CR(r_temp_1); |
2150 __ save_LR_CR(r_temp_1); |
2110 __ generate_stack_overflow_check(frame_size_in_bytes); // Check before creating frame. |
2151 __ generate_stack_overflow_check(frame_size_in_bytes); // Check before creating frame. |
2111 __ mr(r_callers_sp, R1_SP); // Remember frame pointer. |
2152 __ mr(r_callers_sp, R1_SP); // Remember frame pointer. |
2559 __ reset_last_Java_frame(); |
2600 __ reset_last_Java_frame(); |
2560 |
2601 |
2561 // Unbox oop result, e.g. JNIHandles::resolve value. |
2602 // Unbox oop result, e.g. JNIHandles::resolve value. |
2562 // -------------------------------------------------------------------------- |
2603 // -------------------------------------------------------------------------- |
2563 |
2604 |
2564 if (ret_type == T_OBJECT || ret_type == T_ARRAY) { |
2605 if (is_reference_type(ret_type)) { |
2565 __ resolve_jobject(R3_RET, r_temp_1, r_temp_2, /* needs_frame */ false); |
2606 __ resolve_jobject(R3_RET, r_temp_1, r_temp_2, /* needs_frame */ false); |
2566 } |
2607 } |
2567 |
2608 |
2568 if (CheckJNICalls) { |
2609 if (CheckJNICalls) { |
2569 // clear_pending_jni_exception_check |
2610 // clear_pending_jni_exception_check |
2677 |
2718 |
2678 __ ld(pc_reg, 0, pcs_reg); |
2719 __ ld(pc_reg, 0, pcs_reg); |
2679 __ ld(frame_size_reg, 0, frame_sizes_reg); |
2720 __ ld(frame_size_reg, 0, frame_sizes_reg); |
2680 __ std(pc_reg, _abi(lr), R1_SP); |
2721 __ std(pc_reg, _abi(lr), R1_SP); |
2681 __ push_frame(frame_size_reg, R0/*tmp*/); |
2722 __ push_frame(frame_size_reg, R0/*tmp*/); |
2682 #ifdef ASSERT |
|
2683 __ load_const_optimized(pc_reg, 0x5afe); |
|
2684 __ std(pc_reg, _ijava_state_neg(ijava_reserved), R1_SP); |
|
2685 #endif |
|
2686 __ std(R1_SP, _ijava_state_neg(sender_sp), R1_SP); |
2723 __ std(R1_SP, _ijava_state_neg(sender_sp), R1_SP); |
2687 __ addi(number_of_frames_reg, number_of_frames_reg, -1); |
2724 __ addi(number_of_frames_reg, number_of_frames_reg, -1); |
2688 __ addi(frame_sizes_reg, frame_sizes_reg, wordSize); |
2725 __ addi(frame_sizes_reg, frame_sizes_reg, wordSize); |
2689 __ addi(pcs_reg, pcs_reg, wordSize); |
2726 __ addi(pcs_reg, pcs_reg, wordSize); |
2690 } |
2727 } |
2753 // In the case where we have resized a c2i frame above, the optional |
2790 // In the case where we have resized a c2i frame above, the optional |
2754 // alignment below the locals has size 32 (why?). |
2791 // alignment below the locals has size 32 (why?). |
2755 __ std(R12_scratch2, _abi(lr), R1_SP); |
2792 __ std(R12_scratch2, _abi(lr), R1_SP); |
2756 |
2793 |
2757 // Initialize initial_caller_sp. |
2794 // Initialize initial_caller_sp. |
2758 #ifdef ASSERT |
|
2759 __ load_const_optimized(pc_reg, 0x5afe); |
|
2760 __ std(pc_reg, _ijava_state_neg(ijava_reserved), R1_SP); |
|
2761 #endif |
|
2762 __ std(frame_size_reg, _ijava_state_neg(sender_sp), R1_SP); |
2795 __ std(frame_size_reg, _ijava_state_neg(sender_sp), R1_SP); |
2763 |
2796 |
2764 #ifdef ASSERT |
2797 #ifdef ASSERT |
2765 // Make sure that there is at least one entry in the array. |
2798 // Make sure that there is at least one entry in the array. |
2766 __ cmpdi(CCR0, number_of_frames_reg, 0); |
2799 __ cmpdi(CCR0, number_of_frames_reg, 0); |