src/cpu/mips/vm/relocInfo_mips.cpp

Thu, 24 May 2018 19:49:50 +0800

author
aoqi
date
Thu, 24 May 2018 19:49:50 +0800
changeset 8865
ffcdff41a92f
parent 8862
fd13a567f179
child 9251
1ccc5a3b3671
permissions
-rw-r--r--

some C1 fix
Contributed-by: chenhaoxuan, zhaixiang, aoqi

     1 /*
     2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2015, 2016, Loongson Technology. 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  */
    26 #include "precompiled.hpp"
    27 #include "asm/macroAssembler.hpp"
    28 #include "code/relocInfo.hpp"
    29 #include "nativeInst_mips.hpp"
    30 #include "oops/oop.inline.hpp"
    31 #include "runtime/safepoint.hpp"
    34 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
    35 #ifdef _LP64
    36   x += o;
    37   typedef Assembler::WhichOperand WhichOperand;
    38   WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm, call32, narrow oop
    39   assert(which == Assembler::disp32_operand ||
    40          which == Assembler::narrow_oop_operand ||
    41          which == Assembler::imm_operand, "format unpacks ok");
    42   if (which == Assembler::imm_operand) {
    43     if (verify_only) {
    44       assert(nativeMovConstReg_at(addr())->data() == (long)x, "instructions must match");
    45     } else {
    46       nativeMovConstReg_at(addr())->set_data((intptr_t)(x));
    47     }
    48   } else if (which == Assembler::narrow_oop_operand) {
    49     // both compressed oops and compressed classes look the same
    50     if (Universe::heap()->is_in_reserved((oop)x)) {
    51       if (verify_only) {
    52         assert(nativeMovConstReg_at(addr())->data() == (long)oopDesc::encode_heap_oop((oop)x), "instructions must match");
    53       } else {
    54         nativeMovConstReg_at(addr())->set_data((intptr_t)(oopDesc::encode_heap_oop((oop)x)));
    55       }
    56     } else {
    57       if (verify_only) {
    58         assert(nativeMovConstReg_at(addr())->data() == (long)Klass::encode_klass((Klass*)x), "instructions must match");
    59       } else {
    60         nativeMovConstReg_at(addr())->set_data((intptr_t)(Klass::encode_klass((Klass*)x)));
    61       }
    62     }
    63   } else {
    64     // Note:  Use runtime_call_type relocations for call32_operand.
    65     assert(0, "call32_operand not supported in MIPS64");
    66   }
    67 #else
    68   if (verify_only) {
    69     assert(*pd_address_in_code() == (x + o), "instructions must match");
    70   } else {
    71     *pd_address_in_code() = x + o;
    72   }
    73 #endif // AMD64
    74 }
    77 //NOTICE HERE, this relocate is not need for MIPS, since MIPS USE abosolutly target,
    78 //Maybe We should FORGET CALL RELOCATION
    79 address Relocation::pd_call_destination(address orig_addr) {
    80   intptr_t adj = 0;
    81   NativeInstruction* ni = nativeInstruction_at(addr());
    82   if (ni->is_call()) {
    83     return nativeCall_at(addr())->destination() + adj;
    84   } else if (ni->is_jump()) {
    85     return nativeGeneralJump_at(addr())->jump_destination() + adj;
    86   } else if (ni->is_cond_jump()) {
    87     return nativeCondJump_at(addr())->jump_destination() +adj;
    88   } else {
    89     tty->print_cr("\nError!\ncall destination: 0x%lx", addr());
    90     Disassembler::decode(addr() - 10 * 4, addr() + 10 * 4, tty);
    91     ShouldNotReachHere();
    92     return NULL;
    93   }
    94 }
    97 void Relocation::pd_set_call_destination(address x) {
    98   NativeInstruction* ni = nativeInstruction_at(addr());
    99   if (ni->is_call()) {
   100     nativeCall_at(addr())->set_destination(x);
   101   } else if (ni->is_jump())
   102     nativeGeneralJump_at(addr())->set_jump_destination(x);
   103   else if (ni->is_cond_jump())
   104     nativeCondJump_at(addr())->set_jump_destination(x);
   105   else
   106     { ShouldNotReachHere(); }
   108     // Unresolved jumps are recognized by a destination of -1
   109     // However 64bit can't actually produce such an address
   110     // and encodes a jump to self but jump_destination will
   111     // return a -1 as the signal. We must not relocate this
   112     // jmp or the ic code will not see it as unresolved.
   113 }
   116 address* Relocation::pd_address_in_code() {
   117 //  ShouldNotReachHere();
   118   return (address*)addr();
   119 }
   122 address Relocation::pd_get_address_from_code() {
   123   NativeMovConstReg* ni = nativeMovConstReg_at(addr());
   124   return (address)ni->data();
   125 }
   129 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
   130   //Unimplemented();
   131   //tty->print_cr("%s not finished yet!!!", __func__);
   132 }
   134 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
   135   //Unimplemented();
   136   //tty->print_cr("%s not finished yet!!!", __func__);
   137 }
   139 void internal_pc_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
   140   address target =0;
   141   NativeMovConstReg* ni = nativeMovConstReg_at(addr());
   142   target = new_addr_for((address)ni->data(), src, dest);
   143   ni->set_data((intptr_t)target);
   144 }
   146 void metadata_Relocation::pd_fix_value(address x) {
   147 }

mercurial