mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-20 08:18:55 +00:00
LibWeb: Don't create a copy SharedArrayBuffer for shared Wasm memories
For whatever reason, the implementation of "create a fixed length memory buffer" was borked for shared Wasm memories, in that a new SharedArrayBuffer was created, with the contents of the Wasm memory copied into it. This is incorrect, since the SharedArrayBuffer should be a view into the Wasm memory's span, not a copy of it. This helps pass a WPT subtest in wasm/jsapi/memory/grow.any.html.
This commit is contained in:
parent
aadd563592
commit
0bda014c96
Notes:
github-actions[bot]
2025-08-23 06:28:07 +00:00
Author: https://github.com/CountBleck
Commit: 0bda014c96
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5889
Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 5 additions and 6 deletions
|
@ -135,13 +135,12 @@ WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> Memory::create_a_fixed_length_memo
|
|||
// 3. If share is shared,
|
||||
if (shared == Shared::Yes) {
|
||||
// 1. Let block be a Shared Data Block which is identified with the underlying memory of memaddr.
|
||||
auto bytes = memory->data();
|
||||
|
||||
// 2. Let buffer be a new SharedArrayBuffer with the internal slots [[ArrayBufferData]] and [[ArrayBufferByteLength]].
|
||||
array_buffer = TRY(JS::allocate_shared_array_buffer(vm, realm.intrinsics().shared_array_buffer_constructor(), bytes.size()));
|
||||
bytes.span().copy_to(array_buffer->buffer().span());
|
||||
// 3. FIXME: Set buffer.[[ArrayBufferData]] to block.
|
||||
// 4. FIXME: Set buffer.[[ArrayBufferByteLength]] to the length of block.
|
||||
// 3. Set buffer.[[ArrayBufferData]] to block.
|
||||
array_buffer = JS::ArrayBuffer::create(realm, &memory->data(), JS::DataBlock::Shared::Yes);
|
||||
|
||||
// 4. Set buffer.[[ArrayBufferByteLength]] to the length of block.
|
||||
VERIFY(array_buffer->byte_length() == memory->size());
|
||||
|
||||
// 5. Perform ! SetIntegrityLevel(buffer, "frozen").
|
||||
MUST(array_buffer->set_integrity_level(JS::Object::IntegrityLevel::Frozen));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue