src/cpu/x86/vm/relocInfo_x86.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7028374 Sdiff src/cpu/x86/vm

src/cpu/x86/vm/relocInfo_x86.cpp

Print this page




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/assembler.inline.hpp"
  27 #include "assembler_x86.inline.hpp"
  28 #include "code/relocInfo.hpp"
  29 #include "nativeInst_x86.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) {
  35 #ifdef AMD64
  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     *pd_address_in_code() = x;

  44   } else if (which == Assembler::narrow_oop_operand) {
  45     address disp = Assembler::locate_operand(addr(), which);



  46     *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);

  47   } else {
  48     // Note:  Use runtime_call_type relocations for call32_operand.
  49     address ip = addr();
  50     address disp = Assembler::locate_operand(ip, which);
  51     address next_ip = Assembler::locate_next_instruction(ip);



  52     *(int32_t*) disp = x - next_ip;
  53   }

  54 #else



  55   *pd_address_in_code() = x + o;

  56 #endif // AMD64
  57 }
  58 
  59 
  60 address Relocation::pd_call_destination(address orig_addr) {
  61   intptr_t adj = 0;
  62   if (orig_addr != NULL) {
  63     // We just moved this call instruction from orig_addr to addr().
  64     // This means its target will appear to have grown by addr() - orig_addr.
  65     adj = -( addr() - orig_addr );
  66   }
  67   NativeInstruction* ni = nativeInstruction_at(addr());
  68   if (ni->is_call()) {
  69     return nativeCall_at(addr())->destination() + adj;
  70   } else if (ni->is_jump()) {
  71     return nativeJump_at(addr())->jump_destination() + adj;
  72   } else if (ni->is_cond_jump()) {
  73     return nativeGeneralJump_at(addr())->jump_destination() + adj;
  74   } else if (ni->is_mov_literal64()) {
  75     return (address) ((NativeMovConstReg*)ni)->data();




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/assembler.inline.hpp"
  27 #include "assembler_x86.inline.hpp"
  28 #include "code/relocInfo.hpp"
  29 #include "nativeInst_x86.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 #ifdef AMD64
  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(*pd_address_in_code() == x, "instructions must match");
  45     } else {
  46       *pd_address_in_code() = x;
  47     }
  48   } else if (which == Assembler::narrow_oop_operand) {
  49     address disp = Assembler::locate_operand(addr(), which);
  50     if (verify_only) {
  51       assert(*(int32_t*) disp == oopDesc::encode_heap_oop((oop)x), "instructions must match");
  52     } else {
  53       *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
  54     }
  55   } else {
  56     // Note:  Use runtime_call_type relocations for call32_operand.
  57     address ip = addr();
  58     address disp = Assembler::locate_operand(ip, which);
  59     address next_ip = Assembler::locate_next_instruction(ip);
  60     if (verify_only) {
  61       assert(*(int32_t*) disp == (x - next_ip), "instructions must match");
  62     } else {
  63       *(int32_t*) disp = x - next_ip;
  64     }
  65   }
  66 #else
  67   if (verify_only) {
  68     assert(*pd_address_in_code() == (x + o), "instructions must match");
  69   } else {
  70     *pd_address_in_code() = x + o;
  71   }
  72 #endif // AMD64
  73 }
  74 
  75 
  76 address Relocation::pd_call_destination(address orig_addr) {
  77   intptr_t adj = 0;
  78   if (orig_addr != NULL) {
  79     // We just moved this call instruction from orig_addr to addr().
  80     // This means its target will appear to have grown by addr() - orig_addr.
  81     adj = -( addr() - orig_addr );
  82   }
  83   NativeInstruction* ni = nativeInstruction_at(addr());
  84   if (ni->is_call()) {
  85     return nativeCall_at(addr())->destination() + adj;
  86   } else if (ni->is_jump()) {
  87     return nativeJump_at(addr())->jump_destination() + adj;
  88   } else if (ni->is_cond_jump()) {
  89     return nativeGeneralJump_at(addr())->jump_destination() + adj;
  90   } else if (ni->is_mov_literal64()) {
  91     return (address) ((NativeMovConstReg*)ni)->data();


src/cpu/x86/vm/relocInfo_x86.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File