Commit 14bed9bd authored by Kanghua Yu's avatar Kanghua Yu Committed by Commit Bot

[turbofan][x64] Optimize moving constant to stack for GapResolver

Before:
    movl r10,0x1
    REX.W movq [rbp-0x40],r10

After:
    REX.W movq [rbp-0x40],0x1

Change-Id: Iebc77e14a947fd89f7ed4702cea703c15dcb6718
Reviewed-on: https://chromium-review.googlesource.com/1092159Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53598}
parent bbea1672
......@@ -3260,6 +3260,23 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
break;
}
};
// Helper function to write the given constant to the stack.
auto MoveConstantToSlot = [&](Operand dst, Constant src) {
if (!RelocInfo::IsWasmPtrReference(src.rmode())) {
switch (src.type()) {
case Constant::kInt32:
__ movq(dst, Immediate(src.ToInt32()));
return;
case Constant::kInt64:
__ Set(dst, src.ToInt64());
return;
default:
break;
}
}
MoveConstantToRegister(kScratchRegister, src);
__ movq(dst, kScratchRegister);
};
// Dispatch on the source and destination operand kinds.
switch (MoveType::InferMove(source, destination)) {
case MoveType::kRegisterToRegister:
......@@ -3347,8 +3364,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
Constant src = g.ToConstant(source);
Operand dst = g.ToOperand(destination);
if (destination->IsStackSlot()) {
MoveConstantToRegister(kScratchRegister, src);
__ movq(dst, kScratchRegister);
MoveConstantToSlot(dst, src);
} else {
DCHECK(destination->IsFPStackSlot());
if (src.type() == Constant::kFloat32) {
......
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