hotspot/src/cpu/aarch64/vm/relocInfo_aarch64.cpp
changeset 29183 0cc8699f7372
child 33160 c59f1676d27e
equal deleted inserted replaced
29182:78af2a4d1ec3 29183:0cc8699f7372
       
     1 /*
       
     2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
       
     3  * Copyright (c) 2014, Red Hat Inc. 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 it
       
     7  * under the terms of the GNU General Public License version 2 only, as
       
     8  * published by the Free Software Foundation.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 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 USA
       
    21  * or visit www.oracle.com if you need additional information or have any
       
    22  * questions.
       
    23  *
       
    24  */
       
    25 
       
    26 #include "precompiled.hpp"
       
    27 #include "asm/macroAssembler.hpp"
       
    28 #include "code/relocInfo.hpp"
       
    29 #include "nativeInst_aarch64.hpp"
       
    30 #include "oops/oop.inline.hpp"
       
    31 #include "runtime/safepoint.hpp"
       
    32 
       
    33 
       
    34 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
       
    35   if (verify_only)
       
    36     return;
       
    37 
       
    38   int bytes;
       
    39 
       
    40   switch(type()) {
       
    41   case relocInfo::oop_type:
       
    42     {
       
    43       oop_Relocation *reloc = (oop_Relocation *)this;
       
    44       if (NativeInstruction::is_ldr_literal_at(addr())) {
       
    45         address constptr = (address)code()->oop_addr_at(reloc->oop_index());
       
    46         bytes = MacroAssembler::pd_patch_instruction_size(addr(), constptr);
       
    47         assert(*(address*)constptr == x, "error in oop relocation");
       
    48       } else{
       
    49         bytes = MacroAssembler::patch_oop(addr(), x);
       
    50       }
       
    51     }
       
    52     break;
       
    53   default:
       
    54     bytes = MacroAssembler::pd_patch_instruction_size(addr(), x);
       
    55     break;
       
    56   }
       
    57   ICache::invalidate_range(addr(), bytes);
       
    58 }
       
    59 
       
    60 address Relocation::pd_call_destination(address orig_addr) {
       
    61   assert(is_call(), "should be a call here");
       
    62   if (is_call()) {
       
    63     address trampoline = nativeCall_at(addr())->get_trampoline();
       
    64     if (trampoline) {
       
    65       return nativeCallTrampolineStub_at(trampoline)->destination();
       
    66     }
       
    67   }
       
    68   if (orig_addr != NULL) {
       
    69     return MacroAssembler::pd_call_destination(orig_addr);
       
    70   }
       
    71   return MacroAssembler::pd_call_destination(addr());
       
    72 }
       
    73 
       
    74 
       
    75 void Relocation::pd_set_call_destination(address x) {
       
    76   assert(is_call(), "should be a call here");
       
    77   if (NativeCall::is_call_at(addr())) {
       
    78     address trampoline = nativeCall_at(addr())->get_trampoline();
       
    79     if (trampoline) {
       
    80       nativeCall_at(addr())->set_destination_mt_safe(x, /* assert_lock */false);
       
    81       return;
       
    82     }
       
    83   }
       
    84   assert(addr() != x, "call instruction in an infinite loop");
       
    85   MacroAssembler::pd_patch_instruction(addr(), x);
       
    86   assert(pd_call_destination(addr()) == x, "fail in reloc");
       
    87 }
       
    88 
       
    89 address* Relocation::pd_address_in_code() {
       
    90   return (address*)(addr() + 8);
       
    91 }
       
    92 
       
    93 
       
    94 address Relocation::pd_get_address_from_code() {
       
    95   return MacroAssembler::pd_call_destination(addr());
       
    96 }
       
    97 
       
    98 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
       
    99   if (NativeInstruction::maybe_cpool_ref(addr())) {
       
   100     address old_addr = old_addr_for(addr(), src, dest);
       
   101     MacroAssembler::pd_patch_instruction(addr(), MacroAssembler::target_addr_for_insn(old_addr));
       
   102   }
       
   103 }
       
   104 
       
   105 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest)  {
       
   106   if (NativeInstruction::maybe_cpool_ref(addr())) {
       
   107     address old_addr = old_addr_for(addr(), src, dest);
       
   108     MacroAssembler::pd_patch_instruction(addr(), MacroAssembler::target_addr_for_insn(old_addr));
       
   109   }
       
   110 }
       
   111 
       
   112 void metadata_Relocation::pd_fix_value(address x) {
       
   113 }