Wed, 27 Apr 2016 01:25:04 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "asm/assembler.hpp" |
aoqi@0 | 27 | #include "code/relocInfo.hpp" |
aoqi@0 | 28 | #include "nativeInst_sparc.hpp" |
aoqi@0 | 29 | #include "oops/oop.inline.hpp" |
aoqi@0 | 30 | #include "runtime/safepoint.hpp" |
aoqi@0 | 31 | |
aoqi@0 | 32 | void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) { |
aoqi@0 | 33 | NativeInstruction* ip = nativeInstruction_at(addr()); |
aoqi@0 | 34 | jint inst = ip->long_at(0); |
aoqi@0 | 35 | assert(inst != NativeInstruction::illegal_instruction(), "no breakpoint"); |
aoqi@0 | 36 | switch (Assembler::inv_op(inst)) { |
aoqi@0 | 37 | |
aoqi@0 | 38 | case Assembler::ldst_op: |
aoqi@0 | 39 | #ifdef ASSERT |
aoqi@0 | 40 | switch (Assembler::inv_op3(inst)) { |
aoqi@0 | 41 | case Assembler::lduw_op3: |
aoqi@0 | 42 | case Assembler::ldub_op3: |
aoqi@0 | 43 | case Assembler::lduh_op3: |
aoqi@0 | 44 | case Assembler::ldd_op3: |
aoqi@0 | 45 | case Assembler::ldsw_op3: |
aoqi@0 | 46 | case Assembler::ldsb_op3: |
aoqi@0 | 47 | case Assembler::ldsh_op3: |
aoqi@0 | 48 | case Assembler::ldx_op3: |
aoqi@0 | 49 | case Assembler::ldf_op3: |
aoqi@0 | 50 | case Assembler::lddf_op3: |
aoqi@0 | 51 | case Assembler::stw_op3: |
aoqi@0 | 52 | case Assembler::stb_op3: |
aoqi@0 | 53 | case Assembler::sth_op3: |
aoqi@0 | 54 | case Assembler::std_op3: |
aoqi@0 | 55 | case Assembler::stx_op3: |
aoqi@0 | 56 | case Assembler::stf_op3: |
aoqi@0 | 57 | case Assembler::stdf_op3: |
aoqi@0 | 58 | case Assembler::casa_op3: |
aoqi@0 | 59 | case Assembler::casxa_op3: |
aoqi@0 | 60 | break; |
aoqi@0 | 61 | default: |
aoqi@0 | 62 | ShouldNotReachHere(); |
aoqi@0 | 63 | } |
aoqi@0 | 64 | goto do_non_sethi; |
aoqi@0 | 65 | #endif |
aoqi@0 | 66 | |
aoqi@0 | 67 | case Assembler::arith_op: |
aoqi@0 | 68 | #ifdef ASSERT |
aoqi@0 | 69 | switch (Assembler::inv_op3(inst)) { |
aoqi@0 | 70 | case Assembler::or_op3: |
aoqi@0 | 71 | case Assembler::add_op3: |
aoqi@0 | 72 | case Assembler::jmpl_op3: |
aoqi@0 | 73 | break; |
aoqi@0 | 74 | default: |
aoqi@0 | 75 | ShouldNotReachHere(); |
aoqi@0 | 76 | } |
aoqi@0 | 77 | do_non_sethi:; |
aoqi@0 | 78 | #endif |
aoqi@0 | 79 | { |
aoqi@0 | 80 | guarantee(Assembler::inv_immed(inst), "must have a simm13 field"); |
aoqi@0 | 81 | int simm13 = Assembler::low10((intptr_t)x) + o; |
aoqi@0 | 82 | guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13"); |
aoqi@0 | 83 | inst &= ~Assembler::simm( -1, 13); |
aoqi@0 | 84 | inst |= Assembler::simm(simm13, 13); |
aoqi@0 | 85 | if (verify_only) { |
aoqi@0 | 86 | assert(ip->long_at(0) == inst, "instructions must match"); |
aoqi@0 | 87 | } else { |
aoqi@0 | 88 | ip->set_long_at(0, inst); |
aoqi@0 | 89 | } |
aoqi@0 | 90 | } |
aoqi@0 | 91 | break; |
aoqi@0 | 92 | |
aoqi@0 | 93 | case Assembler::branch_op: |
aoqi@0 | 94 | { |
aoqi@0 | 95 | #ifdef _LP64 |
aoqi@0 | 96 | jint inst2; |
aoqi@0 | 97 | guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi"); |
aoqi@0 | 98 | if (format() != 0) { |
aoqi@0 | 99 | assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type, "only narrow oops or klasses case"); |
aoqi@0 | 100 | jint np = type() == relocInfo::oop_type ? oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x); |
aoqi@0 | 101 | inst &= ~Assembler::hi22(-1); |
aoqi@0 | 102 | inst |= Assembler::hi22((intptr_t)np); |
aoqi@0 | 103 | if (verify_only) { |
aoqi@0 | 104 | assert(ip->long_at(0) == inst, "instructions must match"); |
aoqi@0 | 105 | } else { |
aoqi@0 | 106 | ip->set_long_at(0, inst); |
aoqi@0 | 107 | } |
aoqi@0 | 108 | inst2 = ip->long_at( NativeInstruction::nop_instruction_size ); |
aoqi@0 | 109 | guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op"); |
aoqi@0 | 110 | if (verify_only) { |
aoqi@0 | 111 | assert(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np), |
aoqi@0 | 112 | "instructions must match"); |
aoqi@0 | 113 | } else { |
aoqi@0 | 114 | ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np)); |
aoqi@0 | 115 | } |
aoqi@0 | 116 | break; |
aoqi@0 | 117 | } |
aoqi@0 | 118 | if (verify_only) { |
aoqi@0 | 119 | ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x ); |
aoqi@0 | 120 | } else { |
aoqi@0 | 121 | ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x ); |
aoqi@0 | 122 | } |
aoqi@0 | 123 | #else |
aoqi@0 | 124 | guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi"); |
aoqi@0 | 125 | inst &= ~Assembler::hi22( -1); |
aoqi@0 | 126 | inst |= Assembler::hi22((intptr_t)x); |
aoqi@0 | 127 | // (ignore offset; it doesn't play into the sethi) |
aoqi@0 | 128 | if (verify_only) { |
aoqi@0 | 129 | assert(ip->long_at(0) == inst, "instructions must match"); |
aoqi@0 | 130 | } else { |
aoqi@0 | 131 | ip->set_long_at(0, inst); |
aoqi@0 | 132 | } |
aoqi@0 | 133 | #endif |
aoqi@0 | 134 | } |
aoqi@0 | 135 | break; |
aoqi@0 | 136 | |
aoqi@0 | 137 | default: |
aoqi@0 | 138 | guarantee(false, "instruction must perform arithmetic or memory access"); |
aoqi@0 | 139 | } |
aoqi@0 | 140 | } |
aoqi@0 | 141 | |
aoqi@0 | 142 | |
aoqi@0 | 143 | address Relocation::pd_call_destination(address orig_addr) { |
aoqi@0 | 144 | intptr_t adj = 0; |
aoqi@0 | 145 | if (orig_addr != NULL) { |
aoqi@0 | 146 | // We just moved this call instruction from orig_addr to addr(). |
aoqi@0 | 147 | // This means its target will appear to have grown by addr() - orig_addr. |
aoqi@0 | 148 | adj = -( addr() - orig_addr ); |
aoqi@0 | 149 | } |
aoqi@0 | 150 | if (NativeCall::is_call_at(addr())) { |
aoqi@0 | 151 | NativeCall* call = nativeCall_at(addr()); |
aoqi@0 | 152 | return call->destination() + adj; |
aoqi@0 | 153 | } |
aoqi@0 | 154 | if (NativeFarCall::is_call_at(addr())) { |
aoqi@0 | 155 | NativeFarCall* call = nativeFarCall_at(addr()); |
aoqi@0 | 156 | return call->destination() + adj; |
aoqi@0 | 157 | } |
aoqi@0 | 158 | // Special case: Patchable branch local to the code cache. |
aoqi@0 | 159 | // This will break badly if the code cache grows larger than a few Mb. |
aoqi@0 | 160 | NativeGeneralJump* br = nativeGeneralJump_at(addr()); |
aoqi@0 | 161 | return br->jump_destination() + adj; |
aoqi@0 | 162 | } |
aoqi@0 | 163 | |
aoqi@0 | 164 | |
aoqi@0 | 165 | void Relocation::pd_set_call_destination(address x) { |
aoqi@0 | 166 | if (NativeCall::is_call_at(addr())) { |
aoqi@0 | 167 | NativeCall* call = nativeCall_at(addr()); |
aoqi@0 | 168 | call->set_destination(x); |
aoqi@0 | 169 | return; |
aoqi@0 | 170 | } |
aoqi@0 | 171 | if (NativeFarCall::is_call_at(addr())) { |
aoqi@0 | 172 | NativeFarCall* call = nativeFarCall_at(addr()); |
aoqi@0 | 173 | call->set_destination(x); |
aoqi@0 | 174 | return; |
aoqi@0 | 175 | } |
aoqi@0 | 176 | // Special case: Patchable branch local to the code cache. |
aoqi@0 | 177 | // This will break badly if the code cache grows larger than a few Mb. |
aoqi@0 | 178 | NativeGeneralJump* br = nativeGeneralJump_at(addr()); |
aoqi@0 | 179 | br->set_jump_destination(x); |
aoqi@0 | 180 | } |
aoqi@0 | 181 | |
aoqi@0 | 182 | |
aoqi@0 | 183 | address* Relocation::pd_address_in_code() { |
aoqi@0 | 184 | // SPARC never embeds addresses in code, at present. |
aoqi@0 | 185 | //assert(type() == relocInfo::oop_type, "only oops are inlined at present"); |
aoqi@0 | 186 | return (address*)addr(); |
aoqi@0 | 187 | } |
aoqi@0 | 188 | |
aoqi@0 | 189 | |
aoqi@0 | 190 | address Relocation::pd_get_address_from_code() { |
aoqi@0 | 191 | // SPARC never embeds addresses in code, at present. |
aoqi@0 | 192 | //assert(type() == relocInfo::oop_type, "only oops are inlined at present"); |
aoqi@0 | 193 | return *(address*)addr(); |
aoqi@0 | 194 | } |
aoqi@0 | 195 | |
aoqi@0 | 196 | void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { |
aoqi@0 | 197 | } |
aoqi@0 | 198 | |
aoqi@0 | 199 | void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { |
aoqi@0 | 200 | } |
aoqi@0 | 201 | |
aoqi@0 | 202 | void metadata_Relocation::pd_fix_value(address x) { |
aoqi@0 | 203 | } |