1 /* 2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2016, 2017 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 * 1678 1679 // The method register is junk from after the thread_in_native transition 1680 // until here. Also can't call_VM until the bcp has been 1681 // restored. Need bcp for throwing exception below so get it now. 1682 __ get_method(Rmethod); 1683 1684 // Restore Z_bcp to have legal interpreter frame, 1685 // i.e., bci == 0 <=> Z_bcp == code_base(). 1686 __ z_lg(Z_bcp, Address(Rmethod, Method::const_offset())); // get constMethod 1687 __ add2reg(Z_bcp, in_bytes(ConstMethod::codes_offset())); // get codebase 1688 1689 if (CheckJNICalls) { 1690 // clear_pending_jni_exception_check 1691 __ clear_mem(Address(Z_thread, JavaThread::pending_jni_exception_check_fn_offset()), sizeof(oop)); 1692 } 1693 1694 // Check if the native method returns an oop, and if so, move it 1695 // from the jni handle to z_ijava_state.oop_temp. This is 1696 // necessary, because we reset the jni handle block below. 1697 // NOTE: frame::interpreter_frame_result() depends on this, too. 1698 { NearLabel no_oop_result; 1699 __ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT)); 1700 __ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_result); 1701 __ resolve_jobject(Rlresult, /* tmp1 */ Rmethod, /* tmp2 */ Z_R1); 1702 __ z_stg(Rlresult, oop_tmp_offset, Z_fp); 1703 __ bind(no_oop_result); 1704 } 1705 1706 // Reset handle block. 1707 __ z_lg(Z_R1/*active_handles*/, thread_(active_handles)); 1708 __ clear_mem(Address(Z_R1, JNIHandleBlock::top_offset_in_bytes()), 4); 1709 1710 // Bandle exceptions (exception handling will handle unlocking!). 1711 { 1712 Label L; 1713 __ load_and_test_long(Z_R0/*pending_exception*/, thread_(pending_exception)); 1714 __ z_bre(L); 1715 __ MacroAssembler::call_VM(noreg, 1716 CAST_FROM_FN_PTR(address, 1717 InterpreterRuntime::throw_pending_exception)); 1718 __ should_not_reach_here(); 1719 __ bind(L); 1720 } 1721 1722 if (synchronized) { | 1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2016 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 * 1678 1679 // The method register is junk from after the thread_in_native transition 1680 // until here. Also can't call_VM until the bcp has been 1681 // restored. Need bcp for throwing exception below so get it now. 1682 __ get_method(Rmethod); 1683 1684 // Restore Z_bcp to have legal interpreter frame, 1685 // i.e., bci == 0 <=> Z_bcp == code_base(). 1686 __ z_lg(Z_bcp, Address(Rmethod, Method::const_offset())); // get constMethod 1687 __ add2reg(Z_bcp, in_bytes(ConstMethod::codes_offset())); // get codebase 1688 1689 if (CheckJNICalls) { 1690 // clear_pending_jni_exception_check 1691 __ clear_mem(Address(Z_thread, JavaThread::pending_jni_exception_check_fn_offset()), sizeof(oop)); 1692 } 1693 1694 // Check if the native method returns an oop, and if so, move it 1695 // from the jni handle to z_ijava_state.oop_temp. This is 1696 // necessary, because we reset the jni handle block below. 1697 // NOTE: frame::interpreter_frame_result() depends on this, too. 1698 { NearLabel no_oop_result, store_oop_result; 1699 __ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT)); 1700 __ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_result); 1701 __ compareU64_and_branch(Rlresult, (intptr_t)0L, Assembler::bcondEqual, store_oop_result); 1702 __ z_lg(Rlresult, 0, Rlresult); // unbox 1703 __ bind(store_oop_result); 1704 __ z_stg(Rlresult, oop_tmp_offset, Z_fp); 1705 __ verify_oop(Rlresult); 1706 __ bind(no_oop_result); 1707 } 1708 1709 // Reset handle block. 1710 __ z_lg(Z_R1/*active_handles*/, thread_(active_handles)); 1711 __ clear_mem(Address(Z_R1, JNIHandleBlock::top_offset_in_bytes()), 4); 1712 1713 // Bandle exceptions (exception handling will handle unlocking!). 1714 { 1715 Label L; 1716 __ load_and_test_long(Z_R0/*pending_exception*/, thread_(pending_exception)); 1717 __ z_bre(L); 1718 __ MacroAssembler::call_VM(noreg, 1719 CAST_FROM_FN_PTR(address, 1720 InterpreterRuntime::throw_pending_exception)); 1721 __ should_not_reach_here(); 1722 __ bind(L); 1723 } 1724 1725 if (synchronized) { |