src/cpu/x86/vm/relocInfo_x86.cpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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 "incls/_precompiled.incl"
  26 # include "incls/_relocInfo_x86.cpp.incl"





  27 
  28 
  29 void Relocation::pd_set_data_value(address x, intptr_t o) {
  30 #ifdef AMD64
  31   x += o;
  32   typedef Assembler::WhichOperand WhichOperand;
  33   WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm, call32, narrow oop
  34   assert(which == Assembler::disp32_operand ||
  35          which == Assembler::narrow_oop_operand ||
  36          which == Assembler::imm_operand, "format unpacks ok");
  37   if (which == Assembler::imm_operand) {
  38     *pd_address_in_code() = x;
  39   } else if (which == Assembler::narrow_oop_operand) {
  40     address disp = Assembler::locate_operand(addr(), which);
  41     *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
  42   } else {
  43     // Note:  Use runtime_call_type relocations for call32_operand.
  44     address ip = addr();
  45     address disp = Assembler::locate_operand(ip, which);
  46     address next_ip = Assembler::locate_next_instruction(ip);


   1 /*
   2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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);