< prev index next >

src/hotspot/cpu/x86/relocInfo_x86.cpp

Print this page




   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/macroAssembler.hpp"
  27 #include "code/relocInfo.hpp"
  28 #include "nativeInst_x86.hpp"

  29 #include "oops/klass.inline.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/safepoint.hpp"
  32 #include "runtime/safepointMechanism.hpp"
  33 
  34 
  35 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
  36 #ifdef AMD64
  37   x += o;
  38   typedef Assembler::WhichOperand WhichOperand;
  39   WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm, call32, narrow oop
  40   assert(which == Assembler::disp32_operand ||
  41          which == Assembler::narrow_oop_operand ||
  42          which == Assembler::imm_operand, "format unpacks ok");
  43   if (which == Assembler::imm_operand) {
  44     if (verify_only) {
  45       guarantee(*pd_address_in_code() == x, "instructions must match");
  46     } else {
  47       *pd_address_in_code() = x;
  48     }
  49   } else if (which == Assembler::narrow_oop_operand) {
  50     address disp = Assembler::locate_operand(addr(), which);
  51     // both compressed oops and compressed classes look the same
  52     if (Universe::heap()->is_in_reserved((oop)x)) {
  53     if (verify_only) {
  54       guarantee(*(uint32_t*) disp == oopDesc::encode_heap_oop((oop)x), "instructions must match");
  55     } else {
  56       *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
  57     }
  58   } else {
  59       if (verify_only) {
  60         guarantee(*(uint32_t*) disp == Klass::encode_klass((Klass*)x), "instructions must match");
  61       } else {
  62         *(int32_t*) disp = Klass::encode_klass((Klass*)x);
  63       }
  64     }
  65   } else {
  66     // Note:  Use runtime_call_type relocations for call32_operand.
  67     address ip = addr();
  68     address disp = Assembler::locate_operand(ip, which);
  69     address next_ip = Assembler::locate_next_instruction(ip);
  70     if (verify_only) {
  71       guarantee(*(int32_t*) disp == (x - next_ip), "instructions must match");
  72     } else {
  73       *(int32_t*) disp = x - next_ip;
  74     }
  75   }
  76 #else




   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/macroAssembler.hpp"
  27 #include "code/relocInfo.hpp"
  28 #include "nativeInst_x86.hpp"
  29 #include "oops/compressedOops.inline.hpp"
  30 #include "oops/klass.inline.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/safepoint.hpp"
  33 #include "runtime/safepointMechanism.hpp"
  34 
  35 
  36 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
  37 #ifdef AMD64
  38   x += o;
  39   typedef Assembler::WhichOperand WhichOperand;
  40   WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm, call32, narrow oop
  41   assert(which == Assembler::disp32_operand ||
  42          which == Assembler::narrow_oop_operand ||
  43          which == Assembler::imm_operand, "format unpacks ok");
  44   if (which == Assembler::imm_operand) {
  45     if (verify_only) {
  46       guarantee(*pd_address_in_code() == x, "instructions must match");
  47     } else {
  48       *pd_address_in_code() = x;
  49     }
  50   } else if (which == Assembler::narrow_oop_operand) {
  51     address disp = Assembler::locate_operand(addr(), which);
  52     // both compressed oops and compressed classes look the same
  53     if (Universe::heap()->is_in_reserved((oop)x)) {
  54     if (verify_only) {
  55       guarantee(*(uint32_t*) disp == CompressedOops::encode((oop)x), "instructions must match");
  56     } else {
  57       *(int32_t*) disp = CompressedOops::encode((oop)x);
  58     }
  59   } else {
  60       if (verify_only) {
  61         guarantee(*(uint32_t*) disp == Klass::encode_klass((Klass*)x), "instructions must match");
  62       } else {
  63         *(int32_t*) disp = Klass::encode_klass((Klass*)x);
  64       }
  65     }
  66   } else {
  67     // Note:  Use runtime_call_type relocations for call32_operand.
  68     address ip = addr();
  69     address disp = Assembler::locate_operand(ip, which);
  70     address next_ip = Assembler::locate_next_instruction(ip);
  71     if (verify_only) {
  72       guarantee(*(int32_t*) disp == (x - next_ip), "instructions must match");
  73     } else {
  74       *(int32_t*) disp = x - next_ip;
  75     }
  76   }
  77 #else


< prev index next >