Commit adb5e163 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by V8 LUCI CQ

[turbofan][x64] When spilling 32bit values, reload only 32 bits

When we spill a register that we know contains only 32 interesting bits
and then reload it from the spill slot, it's enough to reload its lower
half. This may save a few bytes, and guards against accidental changes
to the upper half (e.g. via pointer decompression).

Bug: v8:13216
Change-Id: I1d950d6e33d8ae94cf385af4f3e1db028bf333c5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3854506Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82704}
parent 2bbc99a0
......@@ -5231,7 +5231,19 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case MoveType::kStackToRegister: {
Operand src = g.ToOperand(source);
if (source->IsStackSlot()) {
__ movq(g.ToRegister(destination), src);
MachineRepresentation mr =
LocationOperand::cast(source)->representation();
if (mr == MachineRepresentation::kWord32 ||
mr == MachineRepresentation::kCompressed ||
mr == MachineRepresentation::kCompressedPointer) {
// When we need only 32 bits, move only 32 bits. Benefits:
// - Save a byte here and there (depending on the destination
// register; "movl eax, ..." is smaller than "movq rax, ...").
// - Safeguard against accidental decompression of compressed slots.
__ movl(g.ToRegister(destination), src);
} else {
__ movq(g.ToRegister(destination), src);
}
} else {
DCHECK(source->IsFPStackSlot());
XMMRegister dst = g.ToDoubleRegister(destination);
......
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