hotspot/src/cpu/x86/vm/relocInfo_x86.cpp
author twisti
Wed, 17 Mar 2010 10:22:41 +0100
changeset 5052 c6c9ff8ad36a
parent 1066 717c3345024f
child 5547 f4b087cbb361
permissions -rw-r--r--
6934966: JSR 292 add C1 logic for saved SP over MethodHandle calls Summary: The logic for x86 C1 to save the SP over MH calls is pretty straight forward but SPARC handles that differently. Reviewed-by: never, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 590
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_relocInfo_x86.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
void Relocation::pd_set_data_value(address x, intptr_t o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  x += o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  typedef Assembler::WhichOperand WhichOperand;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    33
  WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm, call32, narrow oop
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  assert(which == Assembler::disp32_operand ||
590
2954744d7bba 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 1
diff changeset
    35
         which == Assembler::narrow_oop_operand ||
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    36
         which == Assembler::imm_operand, "format unpacks ok");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    37
  if (which == Assembler::imm_operand) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    *pd_address_in_code() = x;
590
2954744d7bba 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 1
diff changeset
    39
  } else if (which == Assembler::narrow_oop_operand) {
2954744d7bba 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 1
diff changeset
    40
    address disp = Assembler::locate_operand(addr(), which);
2954744d7bba 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 1
diff changeset
    41
    *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    // Note:  Use runtime_call_type relocations for call32_operand.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    address ip = addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    address disp = Assembler::locate_operand(ip, which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    address next_ip = Assembler::locate_next_instruction(ip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    *(int32_t*) disp = x - next_ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  *pd_address_in_code() = x + o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
address Relocation::pd_call_destination(address orig_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  intptr_t adj = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  if (orig_addr != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    // We just moved this call instruction from orig_addr to addr().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    // This means its target will appear to have grown by addr() - orig_addr.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    adj = -( addr() - orig_addr );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  NativeInstruction* ni = nativeInstruction_at(addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  if (ni->is_call()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    return nativeCall_at(addr())->destination() + adj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  } else if (ni->is_jump()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    return nativeJump_at(addr())->jump_destination() + adj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  } else if (ni->is_cond_jump()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    return nativeGeneralJump_at(addr())->jump_destination() + adj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  } else if (ni->is_mov_literal64()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    return (address) ((NativeMovConstReg*)ni)->data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
void Relocation::pd_set_call_destination(address x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  NativeInstruction* ni = nativeInstruction_at(addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  if (ni->is_call()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    nativeCall_at(addr())->set_destination(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  } else if (ni->is_jump()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    NativeJump* nj = nativeJump_at(addr());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    84
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    85
    // Unresolved jumps are recognized by a destination of -1
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    86
    // However 64bit can't actually produce such an address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    87
    // and encodes a jump to self but jump_destination will
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    88
    // return a -1 as the signal. We must not relocate this
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    89
    // jmp or the ic code will not see it as unresolved.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    90
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    if (nj->jump_destination() == (address) -1) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
    92
      x = addr(); // jump to self
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    nj->set_jump_destination(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  } else if (ni->is_cond_jump()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    // %%%% kludge this, for now, until we get a jump_destination method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    address old_dest = nativeGeneralJump_at(addr())->jump_destination();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    address disp = Assembler::locate_operand(addr(), Assembler::call32_operand);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    *(jint*)disp += (x - old_dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  } else if (ni->is_mov_literal64()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    ((NativeMovConstReg*)ni)->set_data((intptr_t)x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
address* Relocation::pd_address_in_code() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // All embedded Intel addresses are stored in 32-bit words.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // Since the addr points at the start of the instruction,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // we must parse the instruction a bit to find the embedded word.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  assert(is_data(), "must be a DataRelocation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  typedef Assembler::WhichOperand WhichOperand;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   114
  WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  assert(which == Assembler::disp32_operand ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
         which == Assembler::call32_operand ||
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   118
         which == Assembler::imm_operand, "format unpacks ok");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   119
  if (which != Assembler::imm_operand) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    // The "address" in the code is a displacement can't return it as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    // and address* since it is really a jint*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
#else
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   126
  assert(which == Assembler::disp32_operand || which == Assembler::imm_operand, "format unpacks ok");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  return (address*) Assembler::locate_operand(addr(), which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
address Relocation::pd_get_address_from_code() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // All embedded Intel addresses are stored in 32-bit words.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // Since the addr points at the start of the instruction,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // we must parse the instruction a bit to find the embedded word.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  assert(is_data(), "must be a DataRelocation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  typedef Assembler::WhichOperand WhichOperand;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   139
  WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  assert(which == Assembler::disp32_operand ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
         which == Assembler::call32_operand ||
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   142
         which == Assembler::imm_operand, "format unpacks ok");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   143
  if (which != Assembler::imm_operand) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    address ip = addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    address disp = Assembler::locate_operand(ip, which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    address next_ip = Assembler::locate_next_instruction(ip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    address a = next_ip + *(int32_t*) disp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    return a;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  return *pd_address_in_code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
int Relocation::pd_breakpoint_size() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // minimum breakpoint size, in short words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  return NativeIllegalInstruction::instruction_size / sizeof(short);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
void Relocation::pd_swap_in_breakpoint(address x, short* instrs, int instrlen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  Untested("pd_swap_in_breakpoint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  if (instrs != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    assert(instrlen * sizeof(short) == NativeIllegalInstruction::instruction_size, "enough instrlen in reloc. data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    for (int i = 0; i < instrlen; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
      instrs[i] = ((short*)x)[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  NativeIllegalInstruction::insert(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
void Relocation::pd_swap_out_breakpoint(address x, short* instrs, int instrlen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  Untested("pd_swap_out_breakpoint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  assert(NativeIllegalInstruction::instruction_size == sizeof(short), "right address unit for update");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  NativeInstruction* ni = nativeInstruction_at(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  *(short*)ni->addr_at(0) = instrs[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
}
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   177
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   178
void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   179
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   180
  typedef Assembler::WhichOperand WhichOperand;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   181
  WhichOperand which = (WhichOperand) format();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   182
  // This format is imm but it is really disp32
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   183
  which = Assembler::disp32_operand;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   184
  address orig_addr = old_addr_for(addr(), src, dest);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   185
  NativeInstruction* oni = nativeInstruction_at(orig_addr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   186
  int32_t* orig_disp = (int32_t*) Assembler::locate_operand(orig_addr, which);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   187
  // This poll_addr is incorrect by the size of the instruction it is irrelevant
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   188
  intptr_t poll_addr = (intptr_t)oni + *orig_disp;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   189
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   190
  NativeInstruction* ni = nativeInstruction_at(addr());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   191
  intptr_t new_disp = poll_addr - (intptr_t) ni;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   192
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   193
  int32_t* disp = (int32_t*) Assembler::locate_operand(addr(), which);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   194
  * disp = (int32_t)new_disp;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   195
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   196
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   197
}
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   198
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   199
void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   200
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   201
  typedef Assembler::WhichOperand WhichOperand;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   202
  WhichOperand which = (WhichOperand) format();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   203
  // This format is imm but it is really disp32
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   204
  which = Assembler::disp32_operand;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   205
  address orig_addr = old_addr_for(addr(), src, dest);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   206
  NativeInstruction* oni = nativeInstruction_at(orig_addr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   207
  int32_t* orig_disp = (int32_t*) Assembler::locate_operand(orig_addr, which);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   208
  // This poll_addr is incorrect by the size of the instruction it is irrelevant
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   209
  intptr_t poll_addr = (intptr_t)oni + *orig_disp;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   210
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   211
  NativeInstruction* ni = nativeInstruction_at(addr());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   212
  intptr_t new_disp = poll_addr - (intptr_t) ni;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   213
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   214
  int32_t* disp = (int32_t*) Assembler::locate_operand(addr(), which);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   215
  * disp = (int32_t)new_disp;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   216
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   217
}