From 55e1ab88ad428db20554ae6a04465f20880a06ea Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 26 Jun 2024 02:03:19 +0200 Subject: [PATCH] Tests/LibWasm: Don't ignore the result of BigInt::export_data() Prior to this commit, the test runner was ignoring the result, which meant that values that fit in less than 128 bits were shifted to remove the zero words (which is obviously incorrect). --- Tests/LibWasm/test-wasm.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 1584c2db401..78c795b36c5 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -285,10 +285,13 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke) } u128 bits = 0; - (void)argument.as_bigint().big_integer().unsigned_value().export_data({ bit_cast(&bits), sizeof(bits) }); + auto bytes = argument.as_bigint().big_integer().unsigned_value().export_data({ bit_cast(&bits), sizeof(bits) }); VERIFY(!argument.as_bigint().big_integer().is_negative()); - arguments.append(Wasm::Value(bits)); + if constexpr (AK::HostIsLittleEndian) + arguments.append(Wasm::Value(bits << (128 - bytes * 8))); + else + arguments.append(Wasm::Value(bits >> (128 - bytes * 8))); break; } case Wasm::ValueType::Kind::FunctionReference: