LibWeb: Implement resizable ArrayBuffers for Wasm memories

This commit adds the toResizableBuffer() and toFixedLengthBuffer()
methods to WebAssembly.Memory. This includes the necessary hook to
HostResizeArrayBuffer. Some modifications to function signatures in
LibWeb/WebAssembly/Memory.h were also made (changing the return type
from WebIDL::ExceptionOr to JS::ThrowCompletionOr) to allow the use of
some code in the aforementioned hook.

Note: the hook for HostGrowSharedArrayBuffer isn't implemented, since
LibJS doesn't seem to have complete support for growable
SharedArrayBuffers; the relevant methods/getters don't even exist on
the prototype, let alone HostGrowSharedArrayBuffer!

This should help pass the WebAssembly.Memory WPT tests included in
Interop 2025, except those pertaining to growable SharedArrayBuffers.
This commit is contained in:
CountBleck 2025-08-17 14:14:24 -07:00 committed by Ali Mohammad Pur
commit d0d5bffb2d
Notes: github-actions[bot] 2025-08-23 06:27:40 +00:00
6 changed files with 246 additions and 6 deletions

View file

@ -107,6 +107,7 @@ JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM&, JS::Value value
Wasm::Value default_webassembly_value(JS::VM&, Wasm::ValueType type);
JS::Value to_js_value(JS::VM&, Wasm::Value& wasm_value, Wasm::ValueType type);
JS::ThrowCompletionOr<void> host_ensure_can_compile_wasm_bytes(JS::VM&);
JS::ThrowCompletionOr<JS::HandledByHost> host_resize_array_buffer(JS::VM&, JS::ArrayBuffer&, size_t);
extern HashMap<GC::Ptr<JS::Object>, WebAssemblyCache> s_caches;