Skip to content

Commit a382099

Browse files
backesV8 LUCI CQ
authored andcommitted
[wasm][turbofan] Load 32-bit values more efficiently
When loading a 32-bit value from the stack, just load 32 bit and zero-extend them into the target register, instead of loading the full 64 bits. As there are things to fix (see https://crbug.com/1356461), we only enable this optimization for Wasm for now. [email protected] Bug: chromium:1395604, chromium:1356461, v8:13581 Change-Id: Ibdd2d80704973362906aec9b38faa762d3b43f3f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4097424 Reviewed-by: Jakob Kummerow <[email protected]> Reviewed-by: Maya Lekova <[email protected]> Commit-Queue: Clemens Backes <[email protected]> Cr-Commit-Position: refs/heads/main@{#84796}
1 parent 50961e7 commit a382099

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/compiler/backend/x64/code-generator-x64.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5335,7 +5335,22 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
53355335
case MoveType::kStackToRegister: {
53365336
Operand src = g.ToOperand(source);
53375337
if (source->IsStackSlot()) {
5338-
__ movq(g.ToRegister(destination), src);
5338+
MachineRepresentation mr =
5339+
LocationOperand::cast(source)->representation();
5340+
const bool is_32_bit = mr == MachineRepresentation::kWord32 ||
5341+
mr == MachineRepresentation::kCompressed ||
5342+
mr == MachineRepresentation::kCompressedPointer;
5343+
// TODO(13581): Fix this for other code kinds (see
5344+
// https://crbug.com/1356461).
5345+
if (code_kind() == CodeKind::WASM_FUNCTION && is_32_bit) {
5346+
// When we need only 32 bits, move only 32 bits. Benefits:
5347+
// - Save a byte here and there (depending on the destination
5348+
// register; "movl eax, ..." is smaller than "movq rax, ...").
5349+
// - Safeguard against accidental decompression of compressed slots.
5350+
__ movl(g.ToRegister(destination), src);
5351+
} else {
5352+
__ movq(g.ToRegister(destination), src);
5353+
}
53395354
} else {
53405355
DCHECK(source->IsFPStackSlot());
53415356
XMMRegister dst = g.ToDoubleRegister(destination);

0 commit comments

Comments
 (0)