Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/aarch32/vm/compiledIC_aarch32.cpp
32285 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2014, Red Hat Inc. All rights reserved.3* Copyright (c) 2015, Linaro 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 it7* under the terms of the GNU General Public License version 2 only, as8* published by the Free Software Foundation.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*24*/2526#include "precompiled.hpp"27#include "asm/macroAssembler.inline.hpp"28#include "code/compiledIC.hpp"29#include "code/icBuffer.hpp"30#include "code/nmethod.hpp"31#include "memory/resourceArea.hpp"32#include "runtime/mutexLocker.hpp"33#include "runtime/safepoint.hpp"3435// Release the CompiledICHolder* associated with this call site is there is one.36void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {37// This call site might have become stale so inspect it carefully.38NativeCall* call = nativeCall_at(call_site->addr());39if (is_icholder_entry(call->destination())) {40NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());41InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());42}43}4445bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {46// This call site might have become stale so inspect it carefully.47NativeCall* call = nativeCall_at(call_site->addr());48return is_icholder_entry(call->destination());49}5051// ----------------------------------------------------------------------------5253#define __ _masm.54address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {55// Stub is fixed up when the corresponding call is converted from56// calling compiled code to calling interpreted code.57// mov rmethod, 058// jmp -4 # to self5960address mark = cbuf.insts_mark(); // Get mark within main instrs section.6162// Note that the code buffer's insts_mark is always relative to insts.63// That's why we must use the macroassembler to generate a stub.64MacroAssembler _masm(&cbuf);6566address base = __ start_a_stub(to_interp_stub_size()*2);6768int offset = __ offset();69if (base == NULL) return NULL; // CodeBuffer::expand failed70// static stub relocation stores the instruction address of the call71__ relocate(static_stub_Relocation::spec(mark));72// static stub relocation also tags the Method* in the code-stream.73__ mov_metadata(rmethod, (Metadata*)NULL);74__ movptr(rscratch1, 0);75__ b(rscratch1);7677assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big");78__ end_a_stub();79return base;80}81#undef __8283int CompiledStaticCall::to_interp_stub_size() {84return 7 * NativeInstruction::arm_insn_sz;85}8687// Relocation entries for call stub, compiled java to interpreter.88int CompiledStaticCall::reloc_to_interp_stub() {89return 4; // 3 in emit_to_interp_stub + 1 in emit_call90}9192void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) {93address stub = find_stub();94guarantee(stub != NULL, "stub not found");9596if (TraceICs) {97ResourceMark rm;98tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",99p2i(instruction_address()),100callee->name_and_sig_as_C_string());101}102103// Creation also verifies the object.104NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);105NativeJump* jump = NativeJump::from(method_holder->next_instruction_address());106#ifndef PRODUCT107assert(method_holder->data() == 0 || method_holder->data() == (intptr_t)callee(),108"a) MT-unsafe modification of inline cache");109assert(method_holder->data() == 0 || jump->jump_destination() == entry,110"b) MT-unsafe modification of inline cache");111#endif112// Update stub.113method_holder->set_data((intptr_t)callee());114jump->set_jump_destination(entry);115ICache::invalidate_range(stub, to_interp_stub_size());116// Update jump to call.117set_destination_mt_safe(stub);118}119120void CompiledStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {121assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call");122// Reset stub.123address stub = static_stub->addr();124assert(stub != NULL, "stub not found");125// Creation also verifies the object.126NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);127method_holder->set_data(0);128}129130//-----------------------------------------------------------------------------131// Non-product mode code132#ifndef PRODUCT133134void CompiledStaticCall::verify() {135// Verify call.136NativeCall::verify();137if (os::is_MP()) {138verify_alignment();139}140141// Verify stub.142address stub = find_stub();143assert(stub != NULL, "no stub found for static call");144145// Verify state.146assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");147}148149#endif // !PRODUCT150151152