Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.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"3233// Release the CompiledICHolder* associated with this call site is there is one.34void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {35// This call site might have become stale so inspect it carefully.36NativeCall* call = nativeCall_at(call_site->addr());37if (is_icholder_entry(call->destination())) {38NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());39InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());40}41}4243bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {44// This call site might have become stale so inspect it carefully.45NativeCall* call = nativeCall_at(call_site->addr());46return is_icholder_entry(call->destination());47}4849// ----------------------------------------------------------------------------5051#define __ _masm.52address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) {53// Stub is fixed up when the corresponding call is converted from54// calling compiled code to calling interpreted code.55// movq rmethod, 056// jmp -4 # to self5758// address mark = cbuf.insts_mark(); // Get mark within main instrs section.5960// Note that the code buffer's insts_mark is always relative to insts.61// That's why we must use the macroassembler to generate a stub.62MacroAssembler _masm(&cbuf);6364address base = __ start_a_stub(to_interp_stub_size());65int offset = __ offset();66if (base == NULL) {67return NULL; // CodeBuffer::expand failed68}69// static stub relocation stores the instruction address of the call70__ relocate(static_stub_Relocation::spec(mark));71// static stub relocation also tags the Method* in the code-stream.72__ mov_metadata(rmethod, (Metadata*)NULL);73__ movptr(rscratch1, 0);74__ br(rscratch1);7576assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big");77__ end_a_stub();78return base;79}80#undef __8182int CompiledStaticCall::to_interp_stub_size() {83return 7 * NativeInstruction::instruction_size;84}8586// Relocation entries for call stub, compiled java to interpreter.87int CompiledStaticCall::reloc_to_interp_stub() {88return 4; // 3 in emit_to_interp_stub + 1 in emit_call89}9091void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) {92address stub = find_stub();93guarantee(stub != NULL, "stub not found");9495if (TraceICs) {96ResourceMark rm;97tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",98p2i(instruction_address()),99callee->name_and_sig_as_C_string());100}101102// Creation also verifies the object.103NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);104#ifndef PRODUCT105NativeGeneralJump* jump = nativeGeneralJump_at(method_holder->next_instruction_address());106107assert(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());114NativeGeneralJump::insert_unconditional(method_holder->next_instruction_address(), 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");144// Creation also verifies the object.145NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);146NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());147148// Verify state.149assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");150}151152#endif // !PRODUCT153154155