|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
34 | 34 | #include "oops/compiledICHolder.hpp"
|
35 | 35 | #include "oops/klass.inline.hpp"
|
36 | 36 | #include "runtime/sharedRuntime.hpp"
|
| 37 | +#include "runtime/safepointMechanism.hpp" |
37 | 38 | #include "runtime/vframeArray.hpp"
|
38 | 39 | #include "utilities/align.hpp"
|
39 | 40 | #include "vmreg_arm.inline.hpp"
|
@@ -1219,20 +1220,18 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
|
1219 | 1220 | }
|
1220 | 1221 |
|
1221 | 1222 | // Do a safepoint check while thread is in transition state
|
1222 |
| - InlinedAddress safepoint_state(SafepointSynchronize::address_of_state()); |
1223 | 1223 | Label call_safepoint_runtime, return_to_java;
|
1224 | 1224 | __ mov(Rtemp, _thread_in_native_trans);
|
1225 |
| - __ ldr_literal(R2, safepoint_state); |
1226 | 1225 | __ str_32(Rtemp, Address(Rthread, JavaThread::thread_state_offset()));
|
1227 | 1226 |
|
1228 | 1227 | // make sure the store is observed before reading the SafepointSynchronize state and further mem refs
|
1229 | 1228 | __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad | MacroAssembler::StoreStore), Rtemp);
|
1230 | 1229 |
|
1231 |
| - __ ldr_s32(R2, Address(R2)); |
| 1230 | + __ safepoint_poll(R2, call_safepoint_runtime); |
1232 | 1231 | __ ldr_u32(R3, Address(Rthread, JavaThread::suspend_flags_offset()));
|
1233 |
| - __ cmp(R2, SafepointSynchronize::_not_synchronized); |
1234 |
| - __ cond_cmp(R3, 0, eq); |
| 1232 | + __ cmp(R3, 0); |
1235 | 1233 | __ b(call_safepoint_runtime, ne);
|
| 1234 | + |
1236 | 1235 | __ bind(return_to_java);
|
1237 | 1236 |
|
1238 | 1237 | // Perform thread state transition and reguard stack yellow pages if needed
|
@@ -1303,8 +1302,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
|
1303 | 1302 | pop_result_registers(masm, ret_type);
|
1304 | 1303 | __ b(return_to_java);
|
1305 | 1304 |
|
1306 |
| - __ bind_literal(safepoint_state); |
1307 |
| - |
1308 | 1305 | // Reguard stack pages. Save native results around a call to C runtime.
|
1309 | 1306 | __ bind(reguard);
|
1310 | 1307 | push_result_registers(masm, ret_type);
|
@@ -1806,15 +1803,29 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
|
1806 | 1803 | oop_maps->add_gc_map(pc_offset, map);
|
1807 | 1804 | __ reset_last_Java_frame(Rtemp); // Rtemp free since scratched by far call
|
1808 | 1805 |
|
1809 |
| - // Check for pending exception |
1810 |
| - __ ldr(Rtemp, Address(Rthread, Thread::pending_exception_offset())); |
1811 |
| - __ cmp(Rtemp, 0); |
1812 |
| - |
1813 | 1806 | if (!cause_return) {
|
| 1807 | + if (SafepointMechanism::uses_thread_local_poll()) { |
| 1808 | + // If our stashed return pc was modified by the runtime we avoid touching it |
| 1809 | + __ ldr(R3_tmp, Address(Rthread, JavaThread::saved_exception_pc_offset())); |
| 1810 | + __ ldr(R2_tmp, Address(SP, RegisterSaver::LR_offset * wordSize)); |
| 1811 | + __ cmp(R2_tmp, R3_tmp); |
| 1812 | + // Adjust return pc forward to step over the safepoint poll instruction |
| 1813 | + __ add(R2_tmp, R2_tmp, 4, eq); |
| 1814 | + __ str(R2_tmp, Address(SP, RegisterSaver::LR_offset * wordSize), eq); |
| 1815 | + } |
| 1816 | + |
| 1817 | + // Check for pending exception |
| 1818 | + __ ldr(Rtemp, Address(Rthread, Thread::pending_exception_offset())); |
| 1819 | + __ cmp(Rtemp, 0); |
| 1820 | + |
1814 | 1821 | RegisterSaver::restore_live_registers(masm, false);
|
1815 | 1822 | __ pop(PC, eq);
|
1816 | 1823 | __ pop(Rexception_pc);
|
1817 | 1824 | } else {
|
| 1825 | + // Check for pending exception |
| 1826 | + __ ldr(Rtemp, Address(Rthread, Thread::pending_exception_offset())); |
| 1827 | + __ cmp(Rtemp, 0); |
| 1828 | + |
1818 | 1829 | RegisterSaver::restore_live_registers(masm);
|
1819 | 1830 | __ bx(LR, eq);
|
1820 | 1831 | __ mov(Rexception_pc, LR);
|
|
0 commit comments