diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index 910d7600a9..4585fa70ce 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -1305,9 +1305,19 @@ void Assembler::leal(Register dst, const Operand& src) { void Assembler::load_rax(void* value, RelocInfo::Mode mode) { EnsureSpace ensure_space(this); - emit(0x48); // REX.W - emit(0xA1); - emitp(value, mode); + if (kPointerSize == kInt64Size) { + emit(0x48); // REX.W + emit(0xA1); + emitp(value, mode); + } else { + ASSERT(kPointerSize == kInt32Size); + emit(0xA1); + emitp(value, mode); + // In 64-bit mode, need to zero extend the operand to 8 bytes. + // See 2.2.1.4 in Intel64 and IA32 Architectures Software + // Developer's Manual Volume 2. + emitl(0); + } } @@ -1888,9 +1898,19 @@ void Assembler::xchgl(Register dst, Register src) { void Assembler::store_rax(void* dst, RelocInfo::Mode mode) { EnsureSpace ensure_space(this); - emit(0x48); // REX.W - emit(0xA3); - emitp(dst, mode); + if (kPointerSize == kInt64Size) { + emit(0x48); // REX.W + emit(0xA3); + emitp(dst, mode); + } else { + ASSERT(kPointerSize == kInt32Size); + emit(0xA3); + emitp(dst, mode); + // In 64-bit mode, need to zero extend the operand to 8 bytes. + // See 2.2.1.4 in Intel64 and IA32 Architectures Software + // Developer's Manual Volume 2. + emitl(0); + } }