mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 21:12:08 +02:00
LibWeb: Manually convert the js bigint to a wasm i64 value
SignedBigInteger::export() generates sign-magnitude, but the native i64 type uses 2's comp, make this work by exporting it as unsigned and tweaking the sign later.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
03629a2b3c
commit
7b88857c5a
Notes:
sideshowbarker
2024-07-18 08:29:41 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/7b88857c5ac Pull-request: https://github.com/SerenityOS/serenity/pull/8939 Reviewed-by: https://github.com/IdanHo
@@ -374,10 +374,11 @@ Optional<Wasm::Value> to_webassembly_value(JS::Value value, const Wasm::ValueTyp
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto value = bigint->big_integer().divided_by(two_64).remainder;
|
||||
VERIFY(value.trimmed_length() <= 2);
|
||||
BigEndian<i64> integer { 0 };
|
||||
value.export_data({ &integer, 2 });
|
||||
return Wasm::Value { static_cast<i64>(integer) };
|
||||
VERIFY(value.unsigned_value().trimmed_length() <= 2);
|
||||
i64 integer = static_cast<i64>(value.unsigned_value().to_u64());
|
||||
if (value.is_negative())
|
||||
integer = -integer;
|
||||
return Wasm::Value { integer };
|
||||
}
|
||||
case Wasm::ValueType::I32: {
|
||||
auto _i32 = value.to_i32(global_object);
|
||||
|
||||
Reference in New Issue
Block a user