[assembler] Add dcheck to mov[sz]x_b to ensure source is byte register

Drive-by: Fix bug where 8x16ExtractLane could extract garbage value.

Change-Id: I7eaa758c0c649e4e79e64039d1db6e19092d1293
Bug: v8:6666
Reviewed-on: https://chromium-review.googlesource.com/c/1271056
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56493}
This commit is contained in:
Sigurd Schneider 2018-10-09 16:30:44 +02:00 committed by Commit Bot
parent 69876bccb5
commit 4192bd4c82
2 changed files with 8 additions and 1 deletions

View File

@ -237,7 +237,12 @@ void VisitRRISimd(InstructionSelector* selector, Node* node,
InstructionOperand operand0 = g.UseRegister(node->InputAt(0)); InstructionOperand operand0 = g.UseRegister(node->InputAt(0));
InstructionOperand operand1 = InstructionOperand operand1 =
g.UseImmediate(OpParameter<int32_t>(node->op())); g.UseImmediate(OpParameter<int32_t>(node->op()));
selector->Emit(opcode, g.DefineAsRegister(node), operand0, operand1); // 8x16 uses movsx_b on dest to extract a byte, which only works
// if dest is a byte register.
InstructionOperand dest = opcode == kIA32I8x16ExtractLane
? g.DefineAsFixed(node, eax)
: g.DefineAsRegister(node);
selector->Emit(opcode, dest, operand0, operand1);
} }
void VisitRRISimd(InstructionSelector* selector, Node* node, void VisitRRISimd(InstructionSelector* selector, Node* node,

View File

@ -687,6 +687,7 @@ void Assembler::mov(Operand dst, Register src) {
} }
void Assembler::movsx_b(Register dst, Operand src) { void Assembler::movsx_b(Register dst, Operand src) {
DCHECK_IMPLIES(src.is_reg_only(), src.reg().is_byte_register());
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
EMIT(0x0F); EMIT(0x0F);
EMIT(0xBE); EMIT(0xBE);
@ -701,6 +702,7 @@ void Assembler::movsx_w(Register dst, Operand src) {
} }
void Assembler::movzx_b(Register dst, Operand src) { void Assembler::movzx_b(Register dst, Operand src) {
DCHECK_IMPLIES(src.is_reg_only(), src.reg().is_byte_register());
EnsureSpace ensure_space(this); EnsureSpace ensure_space(this);
EMIT(0x0F); EMIT(0x0F);
EMIT(0xB6); EMIT(0xB6);