1 /*
2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1223 __ mov(R0, Rthread, ne);
1224 __ call(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans), relocInfo::none, ne);
1225 #if R9_IS_SCRATCHED
1226 __ restore_method();
1227 #endif
1228 #endif // AARCH64
1229 }
1230
1231 // Perform Native->Java thread transition
1232 __ mov(Rtemp, _thread_in_Java);
1233 __ str_32(Rtemp, Address(Rthread, JavaThread::thread_state_offset()));
1234
1235 // Zero handles and last_java_sp
1236 __ reset_last_Java_frame(Rtemp);
1237 __ ldr(R3, Address(Rthread, JavaThread::active_handles_offset()));
1238 __ str_32(__ zero_register(Rtemp), Address(R3, JNIHandleBlock::top_offset_in_bytes()));
1239 if (CheckJNICalls) {
1240 __ str(__ zero_register(Rtemp), Address(Rthread, JavaThread::pending_jni_exception_check_fn_offset()));
1241 }
1242
1243 // Unbox if the result is non-zero object
1244 #ifdef AARCH64
1245 {
1246 Label L, Lnull;
1247 __ mov_slow(Rtemp, AbstractInterpreter::result_handler(T_OBJECT));
1248 __ cmp(Rresult_handler, Rtemp);
1249 __ b(L, ne);
1250 __ cbz(Rsaved_result, Lnull);
1251 __ ldr(Rsaved_result, Address(Rsaved_result));
1252 __ bind(Lnull);
1253 // Store oop on the stack for GC
1254 __ str(Rsaved_result, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize));
1255 __ bind(L);
1256 }
1257 #else
1258 __ tst(Rsaved_result_lo, Rresult_handler);
1259 __ ldr(Rsaved_result_lo, Address(Rsaved_result_lo), ne);
1260
1261 // Store oop on the stack for GC
1262 __ cmp(Rresult_handler, 0);
1263 __ str(Rsaved_result_lo, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize), ne);
1264 #endif // AARCH64
1265
1266 #ifdef AARCH64
1267 // Restore SP (drop native parameters area), to keep SP in sync with extended_sp in frame
1268 __ restore_sp_after_call(Rtemp);
1269 __ check_stack_top();
1270 #endif // AARCH64
1271
1272 // reguard stack if StackOverflow exception happened while in native.
1273 {
1274 __ ldr_u32(Rtemp, Address(Rthread, JavaThread::stack_guard_state_offset()));
1275 __ cmp_32(Rtemp, JavaThread::stack_guard_yellow_reserved_disabled);
1276 #ifdef AARCH64
1277 Label L;
1278 __ b(L, ne);
1279 __ call(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages), relocInfo::none);
1280 __ bind(L);
1281 #else
1282 __ call(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages), relocInfo::none, eq);
1283 #if R9_IS_SCRATCHED
1284 __ restore_method();
|
1 /*
2 * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1223 __ mov(R0, Rthread, ne);
1224 __ call(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans), relocInfo::none, ne);
1225 #if R9_IS_SCRATCHED
1226 __ restore_method();
1227 #endif
1228 #endif // AARCH64
1229 }
1230
1231 // Perform Native->Java thread transition
1232 __ mov(Rtemp, _thread_in_Java);
1233 __ str_32(Rtemp, Address(Rthread, JavaThread::thread_state_offset()));
1234
1235 // Zero handles and last_java_sp
1236 __ reset_last_Java_frame(Rtemp);
1237 __ ldr(R3, Address(Rthread, JavaThread::active_handles_offset()));
1238 __ str_32(__ zero_register(Rtemp), Address(R3, JNIHandleBlock::top_offset_in_bytes()));
1239 if (CheckJNICalls) {
1240 __ str(__ zero_register(Rtemp), Address(Rthread, JavaThread::pending_jni_exception_check_fn_offset()));
1241 }
1242
1243 // Unbox oop result, e.g. JNIHandles::resolve result if it's an oop.
1244 {
1245 Label Lnot_oop;
1246 #ifdef AARCH64
1247 __ mov_slow(Rtemp, AbstractInterpreter::result_handler(T_OBJECT));
1248 __ cmp(Rresult_handler, Rtemp);
1249 __ b(Lnot_oop, ne);
1250 #else // !AARCH64
1251 // For ARM32, Rresult_handler is -1 for oop result, 0 otherwise.
1252 __ cbz(Rresult_handler, Lnot_oop);
1253 #endif // !AARCH64
1254 Register value = AARCH64_ONLY(Rsaved_result) NOT_AARCH64(Rsaved_result_lo);
1255 __ resolve_jobject(value, // value
1256 Rtemp, // tmp1
1257 R1_tmp); // tmp2
1258 // Store resolved result in frame for GC visibility.
1259 __ str(value, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize));
1260 __ bind(Lnot_oop);
1261 }
1262
1263 #ifdef AARCH64
1264 // Restore SP (drop native parameters area), to keep SP in sync with extended_sp in frame
1265 __ restore_sp_after_call(Rtemp);
1266 __ check_stack_top();
1267 #endif // AARCH64
1268
1269 // reguard stack if StackOverflow exception happened while in native.
1270 {
1271 __ ldr_u32(Rtemp, Address(Rthread, JavaThread::stack_guard_state_offset()));
1272 __ cmp_32(Rtemp, JavaThread::stack_guard_yellow_reserved_disabled);
1273 #ifdef AARCH64
1274 Label L;
1275 __ b(L, ne);
1276 __ call(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages), relocInfo::none);
1277 __ bind(L);
1278 #else
1279 __ call(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages), relocInfo::none, eq);
1280 #if R9_IS_SCRATCHED
1281 __ restore_method();
|