Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp
32285 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "asm/macroAssembler.inline.hpp"26#include "code/compiledIC.hpp"27#include "code/icBuffer.hpp"28#include "code/nmethod.hpp"29#include "memory/resourceArea.hpp"30#include "runtime/mutexLocker.hpp"31#include "runtime/safepoint.hpp"32#ifdef COMPILER233#include "opto/matcher.hpp"34#endif3536// Release the CompiledICHolder* associated with this call site is there is one.37void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {38// This call site might have become stale so inspect it carefully.39NativeCall* call = nativeCall_at(call_site->addr());40if (is_icholder_entry(call->destination())) {41NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());42InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());43}44}4546bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {47// This call site might have become stale so inspect it carefully.48NativeCall* call = nativeCall_at(call_site->addr());49return is_icholder_entry(call->destination());50}5152// ----------------------------------------------------------------------------5354#define __ _masm.55address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {56#ifdef COMPILER257// Stub is fixed up when the corresponding call is converted from calling58// compiled code to calling interpreted code.59// set (empty), G560// jmp -16162address mark = cbuf.insts_mark(); // Get mark within main instrs section.6364MacroAssembler _masm(&cbuf);6566address base = __ start_a_stub(to_interp_stub_size());67if (base == NULL) {68return NULL; // CodeBuffer::expand failed.69}7071// Static stub relocation stores the instruction address of the call.72__ relocate(static_stub_Relocation::spec(mark));7374__ set_metadata(NULL, as_Register(Matcher::inline_cache_reg_encode()));7576__ set_inst_mark();77AddressLiteral addrlit(-1);78__ JUMP(addrlit, G3, 0);7980__ delayed()->nop();8182// Update current stubs pointer and restore code_end.83__ end_a_stub();84return base;85#else86ShouldNotReachHere();87#endif88}89#undef __9091int CompiledStaticCall::to_interp_stub_size() {92// This doesn't need to be accurate but it must be larger or equal to93// the real size of the stub.94return (NativeMovConstReg::instruction_size + // sethi/setlo;95NativeJump::instruction_size + // sethi; jmp; nop96(TraceJumps ? 20 * BytesPerInstWord : 0) );97}9899// Relocation entries for call stub, compiled java to interpreter.100int CompiledStaticCall::reloc_to_interp_stub() {101return 10; // 4 in emit_java_to_interp + 1 in Java_Static_Call102}103104void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) {105address stub = find_stub();106guarantee(stub != NULL, "stub not found");107108if (TraceICs) {109ResourceMark rm;110tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",111instruction_address(),112callee->name_and_sig_as_C_string());113}114115// Creation also verifies the object.116NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);117NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());118119assert(method_holder->data() == 0 || method_holder->data() == (intptr_t)callee(),120"a) MT-unsafe modification of inline cache");121assert(jump->jump_destination() == (address)-1 || jump->jump_destination() == entry,122"b) MT-unsafe modification of inline cache");123124// Update stub.125method_holder->set_data((intptr_t)callee());126jump->set_jump_destination(entry);127128// Update jump to call.129set_destination_mt_safe(stub);130}131132void CompiledStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {133assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call");134// Reset stub.135address stub = static_stub->addr();136assert(stub != NULL, "stub not found");137// Creation also verifies the object.138NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);139NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());140method_holder->set_data(0);141jump->set_jump_destination((address)-1);142}143144//-----------------------------------------------------------------------------145// Non-product mode code146#ifndef PRODUCT147148void CompiledStaticCall::verify() {149// Verify call.150NativeCall::verify();151if (os::is_MP()) {152verify_alignment();153}154155// Verify stub.156address stub = find_stub();157assert(stub != NULL, "no stub found for static call");158// Creation also verifies the object.159NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);160NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());161162// Verify state.163assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");164}165166#endif // !PRODUCT167168169