From 2f4b0e31bdd0bfddb403e1cf8951b8cee1126b69 Mon Sep 17 00:00:00 2001 From: "haitao.feng@intel.com" Date: Wed, 24 Jul 2013 13:50:45 +0000 Subject: [PATCH] Add the emitp function for X64 assembler R=danno@chromium.org Review URL: https://codereview.chromium.org/19752004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15861 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/assembler-x64-inl.h | 10 ++++++++++ src/x64/assembler-x64.cc | 8 ++++---- src/x64/assembler-x64.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h index b9af527eea..ae9aeee812 100644 --- a/src/x64/assembler-x64-inl.h +++ b/src/x64/assembler-x64-inl.h @@ -51,6 +51,16 @@ void Assembler::emitl(uint32_t x) { } +void Assembler::emitp(void* x, RelocInfo::Mode rmode) { + uintptr_t value = reinterpret_cast(x); + Memory::uintptr_at(pc_) = value; + if (!RelocInfo::IsNone(rmode)) { + RecordRelocInfo(rmode, value); + } + pc_ += sizeof(uintptr_t); +} + + void Assembler::emitq(uint64_t x, RelocInfo::Mode rmode) { Memory::uint64_at(pc_) = x; if (!RelocInfo::IsNone(rmode)) { diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index aaab839121..f5939c3b7e 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -1377,7 +1377,7 @@ void Assembler::load_rax(void* value, RelocInfo::Mode mode) { EnsureSpace ensure_space(this); emit(0x48); // REX.W emit(0xA1); - emitq(reinterpret_cast(value), mode); + emitp(value, mode); } @@ -1529,7 +1529,7 @@ void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { EnsureSpace ensure_space(this); emit_rex_64(dst); emit(0xB8 | dst.low_bits()); - emitq(reinterpret_cast(value), rmode); + emitp(value, rmode); } @@ -1606,7 +1606,7 @@ void Assembler::movq(Register dst, Handle value, RelocInfo::Mode mode) { ASSERT(!HEAP->InNewSpace(*value)); emit_rex_64(dst); emit(0xB8 | dst.low_bits()); - emitq(reinterpret_cast(value.location()), mode); + emitp(value.location(), mode); } } @@ -1998,7 +1998,7 @@ void Assembler::store_rax(void* dst, RelocInfo::Mode mode) { EnsureSpace ensure_space(this); emit(0x48); // REX.W emit(0xA3); - emitq(reinterpret_cast(dst), mode); + emitp(dst, mode); } diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h index aec50c9110..07afc129dc 100644 --- a/src/x64/assembler-x64.h +++ b/src/x64/assembler-x64.h @@ -1444,6 +1444,7 @@ class Assembler : public AssemblerBase { void emit(byte x) { *pc_++ = x; } inline void emitl(uint32_t x); + inline void emitp(void* x, RelocInfo::Mode rmode); inline void emitq(uint64_t x, RelocInfo::Mode rmode); inline void emitw(uint16_t x); inline void emit_code_target(Handle target,