Commit 2a78f298 authored by ahaas's avatar ahaas Committed by Commit bot

[x64] Do not compact constants with attached reloc info.

Reloc info often means that the constant will be patched later, and for
this patching we have to make sure that there is enough space in the
code for the new value.

R=bmeurer@chromium.org, titzer@chromium.org, gdeepti@chromium.org
BUG=chromium:684407
TEST=cctest/test-assembler-x64/Regression684407

Review-Url: https://codereview.chromium.org/2655213003
Cr-Commit-Position: refs/heads/master@{#42719}
parent 78c0be52
......@@ -606,12 +606,9 @@ void Assembler::immediate_arithmetic_op(byte subcode,
int size) {
EnsureSpace ensure_space(this);
emit_rex(dst, size);
if (is_int8(src.value_)) {
if (is_int8(src.value_) && RelocInfo::IsNone(src.rmode_)) {
emit(0x83);
emit_operand(subcode, dst);
if (!RelocInfo::IsNone(src.rmode_)) {
RecordRelocInfo(src.rmode_);
}
emit(src.value_);
} else {
emit(0x81);
......
......@@ -173,6 +173,22 @@ TEST(AssemblerX64CmpbOperation) {
CHECK_EQ(0, result);
}
TEST(Regression684407) {
CcTest::InitializeVM();
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
Assembler::kMinimalBufferSize, &actual_size, true));
CHECK(buffer);
Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
Address before = assm.pc();
__ cmpl(Operand(arg1, 0),
Immediate(0, RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
Address after = assm.pc();
size_t instruction_size = static_cast<size_t>(after - before);
// Check that the immediate is not encoded as uint8.
CHECK_LT(sizeof(uint32_t), instruction_size);
}
TEST(AssemblerX64ImulOperation) {
CcTest::InitializeVM();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment