1 /*
 2  * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
 3  * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. 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  *
24  */
25 
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.hpp"
28 #include "opto/compile.hpp"
29 #include "opto/node.hpp"
30 #include "opto/output.hpp"
31 #include "runtime/sharedRuntime.hpp"
32 
33 #define __ masm.
34 void C2SafepointPollStubTable::emit_stub_impl(MacroAssembler& masm, C2SafepointPollStub* entry) const {
35   assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
36          "polling page return stub not created yet");
37   address stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
38 
39   RuntimeAddress callback_addr(stub);
40 
41   __ bind(entry->_stub_label);
42   InternalAddress safepoint_pc(masm.pc() - masm.offset() + entry->_safepoint_offset);
43   masm.code_section()->relocate(masm.pc(), safepoint_pc.rspec());
44   __ la(t0, safepoint_pc.target());
45   __ sd(t0, Address(xthread, JavaThread::saved_exception_pc_offset()));
46   __ far_jump(callback_addr);
47 }
48 #undef __