Path: blob/master/src/hotspot/cpu/aarch64/icBuffer_aarch64.cpp
40930 views
/*1* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2014, Red Hat Inc. 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.hpp"27#include "asm/macroAssembler.inline.hpp"28#include "code/icBuffer.hpp"29#include "gc/shared/collectedHeap.inline.hpp"30#include "interpreter/bytecodes.hpp"31#include "memory/resourceArea.hpp"32#include "nativeInst_aarch64.hpp"33#include "oops/oop.inline.hpp"3435int InlineCacheBuffer::ic_stub_code_size() {36return (MacroAssembler::far_branches() ? 6 : 4) * NativeInstruction::instruction_size;37}3839#define __ masm->4041void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point) {42ResourceMark rm;43CodeBuffer code(code_begin, ic_stub_code_size());44MacroAssembler* masm = new MacroAssembler(&code);45// note: even though the code contains an embedded value, we do not need reloc info46// because47// (1) the value is old (i.e., doesn't matter for scavenges)48// (2) these ICStubs are removed *before* a GC happens, so the roots disappear49// assert(cached_value == NULL || cached_oop->is_perm(), "must be perm oop");5051address start = __ pc();52Label l;53__ ldr(rscratch2, l);54__ far_jump(ExternalAddress(entry_point));55__ align(wordSize);56__ bind(l);57__ emit_int64((int64_t)cached_value);58// Only need to invalidate the 1st two instructions - not the whole ic stub59ICache::invalidate_range(code_begin, InlineCacheBuffer::ic_stub_code_size());60assert(__ pc() - start == ic_stub_code_size(), "must be");61}6263address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) {64NativeMovConstReg* move = nativeMovConstReg_at(code_begin); // creation also verifies the object65NativeJump* jump = nativeJump_at(code_begin + 4);66return jump->jump_destination();67}686970void* InlineCacheBuffer::ic_buffer_cached_value(address code_begin) {71// The word containing the cached value is at the end of this IC buffer72uintptr_t *p = (uintptr_t *)(code_begin + ic_stub_code_size() - wordSize);73void* o = (void*)*p;74return o;75}767778