1 /*
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 2018 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
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 *
866 // The java_calling_convention describes stack locations as ideal slots on
867 // a frame with no abi restrictions. Since we must observe abi restrictions
868 // (like the placement of the register window) the slots must be biased by
869 // the following value.
870 //----------------------------------------------------------------------
871 static int reg2slot(VMReg r) {
872 return r->reg2stack() + SharedRuntime::out_preserve_stack_slots();
873 }
874
875 static int reg2offset(VMReg r) {
876 return reg2slot(r) * VMRegImpl::stack_slot_size;
877 }
878
879 static void verify_oop_args(MacroAssembler *masm,
880 int total_args_passed,
881 const BasicType *sig_bt,
882 const VMRegPair *regs) {
883 if (!VerifyOops) { return; }
884
885 for (int i = 0; i < total_args_passed; i++) {
886 if (sig_bt[i] == T_OBJECT || sig_bt[i] == T_ARRAY) {
887 VMReg r = regs[i].first();
888 assert(r->is_valid(), "bad oop arg");
889
890 if (r->is_stack()) {
891 __ z_lg(Z_R0_scratch,
892 Address(Z_SP, r->reg2stack() * VMRegImpl::stack_slot_size + wordSize));
893 __ verify_oop(Z_R0_scratch);
894 } else {
895 __ verify_oop(r->as_Register());
896 }
897 }
898 }
899 }
900
901 static void gen_special_dispatch(MacroAssembler *masm,
902 int total_args_passed,
903 vmIntrinsics::ID special_dispatch,
904 const BasicType *sig_bt,
905 const VMRegPair *regs) {
906 verify_oop_args(masm, total_args_passed, sig_bt, regs);
2301 // exception in pending_exception and not in a register. Kind of clumsy,
2302 // since all folks who branch to forward_exception must have tested
2303 // pending_exception first and hence have it in a register already.
2304 __ z_stg(R_exc, Address(Z_thread, Thread::pending_exception_offset()));
2305 restore_native_result(masm, ret_type, workspace_slot_offset);
2306 __ z_bru(done);
2307 __ z_illtrap(0x66);
2308
2309 __ bind(done);
2310 }
2311
2312
2313 //--------------------------------------------------------------------
2314 // Clear "last Java frame" SP and PC.
2315 //--------------------------------------------------------------------
2316 __ verify_thread(); // Z_thread must be correct.
2317
2318 __ reset_last_Java_frame();
2319
2320 // Unpack oop result, e.g. JNIHandles::resolve result.
2321 if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
2322 __ resolve_jobject(Z_RET, /* tmp1 */ Z_R13, /* tmp2 */ Z_R7);
2323 }
2324
2325 if (CheckJNICalls) {
2326 // clear_pending_jni_exception_check
2327 __ clear_mem(Address(Z_thread, JavaThread::pending_jni_exception_check_fn_offset()), sizeof(oop));
2328 }
2329
2330 // Reset handle block.
2331 if (!is_critical_native) {
2332 __ z_lg(Z_R1_scratch, Address(Z_thread, JavaThread::active_handles_offset()));
2333 __ clear_mem(Address(Z_R1_scratch, JNIHandleBlock::top_offset_in_bytes()), 4);
2334
2335 // Check for pending exceptions.
2336 __ load_and_test_long(Z_R0, Address(Z_thread, Thread::pending_exception_offset()));
2337 __ z_brne(handle_pending_exception);
2338 }
2339
2340
2341 //////////////////////////////////////////////////////////////////////
2604 ld_offset -= 2 * wordSize;
2605 }
2606 } else {
2607 if (r_1->is_stack()) {
2608 // Must do a memory to memory move.
2609 int st_off = (r_1->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;
2610
2611 if (!r_2->is_valid()) {
2612 __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2613 } else {
2614 // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2615 // data is passed in only 1 slot.
2616 if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2617 ld_offset -= wordSize;
2618 }
2619 __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2620 }
2621 } else {
2622 if (!r_2->is_valid()) {
2623 // Not sure we need to do this but it shouldn't hurt.
2624 if (sig_bt[i] == T_OBJECT || sig_bt[i] == T_ADDRESS || sig_bt[i] == T_ARRAY) {
2625 __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2626 } else {
2627 __ z_l(r_1->as_Register(), ld_offset, ld_ptr);
2628 }
2629 } else {
2630 // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2631 // data is passed in only 1 slot.
2632 if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2633 ld_offset -= wordSize;
2634 }
2635 __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2636 }
2637 }
2638 ld_offset -= wordSize;
2639 }
2640 }
2641
2642 // Jump to the compiled code just as if compiled code was doing it.
2643 // load target address from method oop:
2644 __ z_lg(Z_R1_scratch, Address(Z_method, Method::from_compiled_offset()));
|
1 /*
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 2019, SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
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 *
866 // The java_calling_convention describes stack locations as ideal slots on
867 // a frame with no abi restrictions. Since we must observe abi restrictions
868 // (like the placement of the register window) the slots must be biased by
869 // the following value.
870 //----------------------------------------------------------------------
871 static int reg2slot(VMReg r) {
872 return r->reg2stack() + SharedRuntime::out_preserve_stack_slots();
873 }
874
875 static int reg2offset(VMReg r) {
876 return reg2slot(r) * VMRegImpl::stack_slot_size;
877 }
878
879 static void verify_oop_args(MacroAssembler *masm,
880 int total_args_passed,
881 const BasicType *sig_bt,
882 const VMRegPair *regs) {
883 if (!VerifyOops) { return; }
884
885 for (int i = 0; i < total_args_passed; i++) {
886 if (is_reference_type(sig_bt[i])) {
887 VMReg r = regs[i].first();
888 assert(r->is_valid(), "bad oop arg");
889
890 if (r->is_stack()) {
891 __ z_lg(Z_R0_scratch,
892 Address(Z_SP, r->reg2stack() * VMRegImpl::stack_slot_size + wordSize));
893 __ verify_oop(Z_R0_scratch);
894 } else {
895 __ verify_oop(r->as_Register());
896 }
897 }
898 }
899 }
900
901 static void gen_special_dispatch(MacroAssembler *masm,
902 int total_args_passed,
903 vmIntrinsics::ID special_dispatch,
904 const BasicType *sig_bt,
905 const VMRegPair *regs) {
906 verify_oop_args(masm, total_args_passed, sig_bt, regs);
2301 // exception in pending_exception and not in a register. Kind of clumsy,
2302 // since all folks who branch to forward_exception must have tested
2303 // pending_exception first and hence have it in a register already.
2304 __ z_stg(R_exc, Address(Z_thread, Thread::pending_exception_offset()));
2305 restore_native_result(masm, ret_type, workspace_slot_offset);
2306 __ z_bru(done);
2307 __ z_illtrap(0x66);
2308
2309 __ bind(done);
2310 }
2311
2312
2313 //--------------------------------------------------------------------
2314 // Clear "last Java frame" SP and PC.
2315 //--------------------------------------------------------------------
2316 __ verify_thread(); // Z_thread must be correct.
2317
2318 __ reset_last_Java_frame();
2319
2320 // Unpack oop result, e.g. JNIHandles::resolve result.
2321 if (is_reference_type(ret_type)) {
2322 __ resolve_jobject(Z_RET, /* tmp1 */ Z_R13, /* tmp2 */ Z_R7);
2323 }
2324
2325 if (CheckJNICalls) {
2326 // clear_pending_jni_exception_check
2327 __ clear_mem(Address(Z_thread, JavaThread::pending_jni_exception_check_fn_offset()), sizeof(oop));
2328 }
2329
2330 // Reset handle block.
2331 if (!is_critical_native) {
2332 __ z_lg(Z_R1_scratch, Address(Z_thread, JavaThread::active_handles_offset()));
2333 __ clear_mem(Address(Z_R1_scratch, JNIHandleBlock::top_offset_in_bytes()), 4);
2334
2335 // Check for pending exceptions.
2336 __ load_and_test_long(Z_R0, Address(Z_thread, Thread::pending_exception_offset()));
2337 __ z_brne(handle_pending_exception);
2338 }
2339
2340
2341 //////////////////////////////////////////////////////////////////////
2604 ld_offset -= 2 * wordSize;
2605 }
2606 } else {
2607 if (r_1->is_stack()) {
2608 // Must do a memory to memory move.
2609 int st_off = (r_1->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;
2610
2611 if (!r_2->is_valid()) {
2612 __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2613 } else {
2614 // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2615 // data is passed in only 1 slot.
2616 if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2617 ld_offset -= wordSize;
2618 }
2619 __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*));
2620 }
2621 } else {
2622 if (!r_2->is_valid()) {
2623 // Not sure we need to do this but it shouldn't hurt.
2624 if (is_reference_type(sig_bt[i]) || sig_bt[i] == T_ADDRESS) {
2625 __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2626 } else {
2627 __ z_l(r_1->as_Register(), ld_offset, ld_ptr);
2628 }
2629 } else {
2630 // In 64bit, longs are given 2 64-bit slots in the interpreter, but the
2631 // data is passed in only 1 slot.
2632 if (sig_bt[i] == T_LONG || sig_bt[i] == T_DOUBLE) {
2633 ld_offset -= wordSize;
2634 }
2635 __ z_lg(r_1->as_Register(), ld_offset, ld_ptr);
2636 }
2637 }
2638 ld_offset -= wordSize;
2639 }
2640 }
2641
2642 // Jump to the compiled code just as if compiled code was doing it.
2643 // load target address from method oop:
2644 __ z_lg(Z_R1_scratch, Address(Z_method, Method::from_compiled_offset()));
|