relocInfo_aarch64.cpp revision 9111:a41fe5ffa839
1155192Srwatson/* 2155192Srwatson * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 3155406Srwatson * Copyright (c) 2014, Red Hat Inc. All rights reserved. 4155192Srwatson * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5155192Srwatson * 6155192Srwatson * This code is free software; you can redistribute it and/or modify it 7155192Srwatson * under the terms of the GNU General Public License version 2 only, as 8155192Srwatson * published by the Free Software Foundation. 9155192Srwatson * 10155192Srwatson * This code is distributed in the hope that it will be useful, but WITHOUT 11155192Srwatson * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12155192Srwatson * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13155192Srwatson * version 2 for more details (a copy is included in the LICENSE file that 14155192Srwatson * accompanied this code). 15155192Srwatson * 16155192Srwatson * You should have received a copy of the GNU General Public License version 17155192Srwatson * 2 along with this work; if not, write to the Free Software Foundation, 18155192Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19155192Srwatson * 20155192Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21155192Srwatson * or visit www.oracle.com if you need additional information or have any 22155192Srwatson * questions. 23155192Srwatson * 24155192Srwatson */ 25155192Srwatson 26155192Srwatson#include "precompiled.hpp" 27155192Srwatson#include "asm/macroAssembler.hpp" 28155192Srwatson#include "code/relocInfo.hpp" 29155192Srwatson#include "nativeInst_aarch64.hpp" 30155192Srwatson#include "oops/oop.inline.hpp" 31155192Srwatson#include "runtime/safepoint.hpp" 32155192Srwatson 33155192Srwatson 34155192Srwatsonvoid Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) { 35155192Srwatson if (verify_only) 36155192Srwatson return; 37155192Srwatson 38155192Srwatson int bytes; 39155192Srwatson 40155192Srwatson switch(type()) { 41155192Srwatson case relocInfo::oop_type: 42155192Srwatson { 43155192Srwatson oop_Relocation *reloc = (oop_Relocation *)this; 44155192Srwatson if (NativeInstruction::is_ldr_literal_at(addr())) { 45155192Srwatson address constptr = (address)code()->oop_addr_at(reloc->oop_index()); 46155192Srwatson bytes = MacroAssembler::pd_patch_instruction_size(addr(), constptr); 47155192Srwatson assert(*(address*)constptr == x, "error in oop relocation"); 48155192Srwatson } else{ 49155192Srwatson bytes = MacroAssembler::patch_oop(addr(), x); 50155192Srwatson } 51155192Srwatson } 52155192Srwatson break; 53155192Srwatson default: 54155192Srwatson bytes = MacroAssembler::pd_patch_instruction_size(addr(), x); 55155192Srwatson break; 56155192Srwatson } 57155192Srwatson ICache::invalidate_range(addr(), bytes); 58155192Srwatson} 59155192Srwatson 60155406Srwatsonaddress Relocation::pd_call_destination(address orig_addr) { 61156291Srwatson assert(is_call(), "should be a call here"); 62155406Srwatson if (is_call()) { 63155406Srwatson address trampoline = nativeCall_at(addr())->get_trampoline(); 64155192Srwatson if (trampoline) { 65155192Srwatson return nativeCallTrampolineStub_at(trampoline)->destination(); 66155192Srwatson } 67155192Srwatson } 68155192Srwatson if (orig_addr != NULL) { 69155192Srwatson return MacroAssembler::pd_call_destination(orig_addr); 70155406Srwatson } 71155406Srwatson return MacroAssembler::pd_call_destination(addr()); 72156888Srwatson} 73155192Srwatson 74155192Srwatson 75155192Srwatsonvoid Relocation::pd_set_call_destination(address x) { 76155192Srwatson assert(is_call(), "should be a call here"); 77155192Srwatson if (NativeCall::is_call_at(addr())) { 78155192Srwatson address trampoline = nativeCall_at(addr())->get_trampoline(); 79156889Srwatson if (trampoline) { 80155192Srwatson nativeCall_at(addr())->set_destination_mt_safe(x, /* assert_lock */false); 81155192Srwatson return; 82156889Srwatson } 83155192Srwatson } 84155192Srwatson assert(addr() != x, "call instruction in an infinite loop"); 85156889Srwatson MacroAssembler::pd_patch_instruction(addr(), x); 86156889Srwatson assert(pd_call_destination(addr()) == x, "fail in reloc"); 87155192Srwatson} 88155192Srwatson 89155192Srwatsonaddress* Relocation::pd_address_in_code() { 90155192Srwatson return (address*)(addr() + 8); 91155192Srwatson} 92155192Srwatson 93156889Srwatson 94156889Srwatsonaddress Relocation::pd_get_address_from_code() { 95155192Srwatson return MacroAssembler::pd_call_destination(addr()); 96155192Srwatson} 97155192Srwatson 98155192Srwatsonvoid poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { 99156889Srwatson if (NativeInstruction::maybe_cpool_ref(addr())) { 100155192Srwatson address old_addr = old_addr_for(addr(), src, dest); 101155192Srwatson MacroAssembler::pd_patch_instruction(addr(), MacroAssembler::target_addr_for_insn(old_addr)); 102156889Srwatson } 103155192Srwatson} 104156889Srwatson 105155192Srwatsonvoid metadata_Relocation::pd_fix_value(address x) { 106155192Srwatson} 107155192Srwatson