|
@@ -0,0 +1,69 @@
|
|
|
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
+From: Clemens Backes <[email protected]>
|
|
|
+Date: Thu, 15 Dec 2022 11:58:50 +0100
|
|
|
+Subject: Merged: [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.
|
|
|
+
|
|
|
+Also include the related fix https://crrev.com/c/4096985.
|
|
|
+
|
|
|
[email protected]
|
|
|
+
|
|
|
+(cherry picked from commit 2ee52447c878721c89a55a780eb689ecba6817d3)
|
|
|
+(cherry picked from commit a38209949fcbf045231c316e2d790b8b70ccb7ef)
|
|
|
+
|
|
|
+Bug: chromium:1395604
|
|
|
+Change-Id: I54a2182ada6fadbfcf5565f0dc8d4f477ecff393
|
|
|
+Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4110897
|
|
|
+Reviewed-by: Maya Lekova <[email protected]>
|
|
|
+Commit-Queue: Clemens Backes <[email protected]>
|
|
|
+Cr-Commit-Position: refs/branch-heads/10.8@{#46}
|
|
|
+Cr-Branched-From: f1bc03fd6b4c201abd9f0fd9d51fb989150f97b9-refs/heads/10.8.168@{#1}
|
|
|
+Cr-Branched-From: 237de893e1c0a0628a57d0f5797483d3add7f005-refs/heads/main@{#83672}
|
|
|
+
|
|
|
+diff --git a/src/compiler/backend/x64/code-generator-x64.cc b/src/compiler/backend/x64/code-generator-x64.cc
|
|
|
+index 3a882f8c7938820b787d0a59c1208ea9517dde15..87ac836d59a1901a5513cb14dc0c0d2e25922be3 100644
|
|
|
+--- a/src/compiler/backend/x64/code-generator-x64.cc
|
|
|
++++ b/src/compiler/backend/x64/code-generator-x64.cc
|
|
|
+@@ -5215,7 +5215,22 @@ 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();
|
|
|
++ const bool is_32_bit = mr == MachineRepresentation::kWord32 ||
|
|
|
++ mr == MachineRepresentation::kCompressed ||
|
|
|
++ mr == MachineRepresentation::kCompressedPointer;
|
|
|
++ // TODO(13581): Fix this for other code kinds (see
|
|
|
++ // https://crbug.com/1356461).
|
|
|
++ if (code_kind() == CodeKind::WASM_FUNCTION && is_32_bit) {
|
|
|
++ // 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);
|
|
|
+diff --git a/src/wasm/graph-builder-interface.cc b/src/wasm/graph-builder-interface.cc
|
|
|
+index 31a06d5a138ac610b10f5eea6b338d44eac3373a..ca8394e5055889c81b57892c4efed53cc6bfa3bc 100644
|
|
|
+--- a/src/wasm/graph-builder-interface.cc
|
|
|
++++ b/src/wasm/graph-builder-interface.cc
|
|
|
+@@ -2060,7 +2060,7 @@ class WasmGraphBuildingInterface {
|
|
|
+ if (exception_value != nullptr) {
|
|
|
+ // TODO(manoskouk): Can we assign a wasm type to the exception value?
|
|
|
+ *exception_value = builder_->LoopExitValue(
|
|
|
+- *exception_value, MachineRepresentation::kWord32);
|
|
|
++ *exception_value, MachineRepresentation::kTaggedPointer);
|
|
|
+ }
|
|
|
+ if (wrap_exit_values) {
|
|
|
+ WrapLocalsAtLoopExit(decoder, control);
|