1 /* 2 * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2021, 2022, 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 * 24 */ 25 26 #include "precompiled.hpp" 27 #include "opto/c2_MacroAssembler.hpp" 28 #include "opto/c2_CodeStubs.hpp" 29 #include "runtime/sharedRuntime.hpp" 30 31 #define __ masm. 32 33 int C2SafepointPollStub::max_size() const { 34 return 56; 35 } 36 37 void C2SafepointPollStub::emit(C2_MacroAssembler& masm) { 38 assert(SharedRuntime::polling_page_return_handler_blob() != NULL, 39 "polling page return stub not created yet"); 40 address stub = SharedRuntime::polling_page_return_handler_blob()->entry_point(); 41 42 __ bind(entry()); 43 // Using pc relative address computation. 44 { 45 Label next_pc; 46 __ bl(next_pc); 47 __ bind(next_pc); 48 } 49 int current_offset = __ offset(); 50 // Code size should not depend on offset: see _stub_size computation in output.cpp 51 __ load_const32(R12, _safepoint_offset - current_offset); 52 __ mflr(R0); 53 __ add(R12, R12, R0); 54 __ std(R12, in_bytes(JavaThread::saved_exception_pc_offset()), R16_thread); 55 56 __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); 57 __ mtctr(R0); 58 __ bctr(); 59 } 60 #undef __