Path: blob/master/src/hotspot/cpu/s390/compiledIC_s390.cpp
40930 views
/*1* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2016, 2019 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "asm/macroAssembler.inline.hpp"27#include "code/compiledIC.hpp"28#include "code/icBuffer.hpp"29#include "code/nmethod.hpp"30#include "memory/resourceArea.hpp"31#include "runtime/mutexLocker.hpp"32#include "runtime/safepoint.hpp"33#ifdef COMPILER234#include "opto/matcher.hpp"35#endif3637// ----------------------------------------------------------------------------3839#undef __40#define __ _masm.4142address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark/* = NULL*/) {43#ifdef COMPILER244// Stub is fixed up when the corresponding call is converted from calling45// compiled code to calling interpreted code.46if (mark == NULL) {47// Get the mark within main instrs section which is set to the address of the call.48mark = cbuf.insts_mark();49}50assert(mark != NULL, "mark must not be NULL");5152// Note that the code buffer's insts_mark is always relative to insts.53// That's why we must use the macroassembler to generate a stub.54MacroAssembler _masm(&cbuf);5556address stub = __ start_a_stub(CompiledStaticCall::to_interp_stub_size());57if (stub == NULL) {58return NULL; // CodeBuffer::expand failed.59}60__ relocate(static_stub_Relocation::spec(mark));6162AddressLiteral meta = __ allocate_metadata_address(NULL);63bool success = __ load_const_from_toc(as_Register(Matcher::inline_cache_reg_encode()), meta);6465__ set_inst_mark();66AddressLiteral a((address)-1);67success = success && __ load_const_from_toc(Z_R1, a);68if (!success) {69return NULL; // CodeCache is full.70}7172__ z_br(Z_R1);73__ end_a_stub(); // Update current stubs pointer and restore insts_end.74return stub;75#else76ShouldNotReachHere();77return NULL;78#endif79}8081#undef __8283int CompiledStaticCall::to_interp_stub_size() {84return 2 * MacroAssembler::load_const_from_toc_size() +852; // branch86}8788// Relocation entries for call stub, compiled java to interpreter.89int CompiledStaticCall::reloc_to_interp_stub() {90return 5; // 4 in emit_java_to_interp + 1 in Java_Static_Call91}9293void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, address entry) {94address stub = find_stub();95guarantee(stub != NULL, "stub not found");9697if (TraceICs) {98ResourceMark rm;99tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",100p2i(instruction_address()),101callee->name_and_sig_as_C_string());102}103104// Creation also verifies the object.105NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub());106NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());107verify_mt_safe(callee, entry, method_holder, jump);108109// Update stub.110method_holder->set_data((intptr_t)callee(), relocInfo::metadata_type);111jump->set_jump_destination(entry);112113// Update jump to call.114set_destination_mt_safe(stub);115}116117void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {118// Reset stub.119address stub = static_stub->addr();120assert(stub != NULL, "stub not found");121assert(CompiledICLocker::is_safe(stub), "mt unsafe call");122// Creation also verifies the object.123NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub());124NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());125method_holder->set_data(0, relocInfo::metadata_type);126jump->set_jump_destination((address)-1);127}128129//-----------------------------------------------------------------------------130131#ifndef PRODUCT132133void CompiledDirectStaticCall::verify() {134// Verify call.135_call->verify();136_call->verify_alignment();137138// Verify stub.139address stub = find_stub();140assert(stub != NULL, "no stub found for static call");141// Creation also verifies the object.142NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub());143NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());144145// Verify state.146assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");147}148149#endif // !PRODUCT150151152