From 9b24187545950c2dd11497971e697a19dff85a4e Mon Sep 17 00:00:00 2001 From: Milad Fa Date: Thu, 26 Mar 2026 11:46:52 +0000 Subject: [PATCH] deps: V8: cherry-pick cf1bce40a5ef Original commit message: [wasm] Fix S128Const on big endian Since http://crrev.com/c/2944437 globals are no longer little endian enforced. S128Const handling in the initializer needs to take this into account and byte reverse values which are hard coded in little endian order. This is currently causing failures on Node.js upstream: https://github.com/nodejs/node/pull/59034#issuecomment-4129144461 Change-Id: Ifcc9ade93ee51565ab19b16e9dadf0ff5752f7a6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7704213 Commit-Queue: Milad Farazmand Reviewed-by: Manos Koukoutos Cr-Commit-Position: refs/heads/main@{#106082} Refs: https://github.com/v8/v8/commit/cf1bce40a5ef4c7c1da351754f5bf526c0c96463 --- common.gypi | 2 +- deps/v8/src/wasm/constant-expression-interface.cc | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index f7c219fc8f167d..953a1448d4baa5 100644 --- a/common.gypi +++ b/common.gypi @@ -38,7 +38,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.16', + 'v8_embedder_string': '-node.17', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/wasm/constant-expression-interface.cc b/deps/v8/src/wasm/constant-expression-interface.cc index 757b4a1811916a..2d86929c011660 100644 --- a/deps/v8/src/wasm/constant-expression-interface.cc +++ b/deps/v8/src/wasm/constant-expression-interface.cc @@ -40,7 +40,17 @@ void ConstantExpressionInterface::S128Const(FullDecoder* decoder, const Simd128Immediate& imm, Value* result) { if (!generate_value()) return; +#if V8_TARGET_BIG_ENDIAN + // Globals are not little endian enforced, they use native byte order and we + // need to reverse the bytes on big endian platforms. + uint8_t value[kSimd128Size]; + for (int i = 0; i < kSimd128Size; i++) { + value[i] = imm.value[kSimd128Size - 1 - i]; + } + result->runtime_value = WasmValue(value, kWasmS128); +#else result->runtime_value = WasmValue(imm.value, kWasmS128); +#endif } void ConstantExpressionInterface::UnOp(FullDecoder* decoder, WasmOpcode opcode,