mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Support creation of shared memory in WebAssembly API
Add support for shared memory creation in WebAssembly memory API. This API is needed for WPT tests that use shared array buffers. Import related WPT tests.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
6ec06a01a2
commit
b03138cbff
Notes:
github-actions[bot]
2024-12-08 21:11:34 +00:00
Author: https://github.com/zetslief Commit: https://github.com/LadybirdBrowser/ladybird/commit/b03138cbffd Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2828 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/alimpfard ✅
@@ -27,6 +27,7 @@
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/RegExpObject.h>
|
||||
#include <LibJS/Runtime/Set.h>
|
||||
#include <LibJS/Runtime/SharedArrayBufferConstructor.h>
|
||||
#include <LibJS/Runtime/StringObject.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
@@ -803,7 +804,7 @@ public:
|
||||
if (bytes_or_error.is_error())
|
||||
return WebIDL::DataCloneError::create(*realm, "out of memory"_string);
|
||||
auto bytes = bytes_or_error.release_value();
|
||||
JS::ArrayBuffer* buffer = TRY(JS::allocate_shared_array_buffer(m_vm, realm->intrinsics().array_buffer_constructor(), bytes.size()));
|
||||
JS::ArrayBuffer* buffer = TRY(JS::allocate_shared_array_buffer(m_vm, realm->intrinsics().shared_array_buffer_constructor(), bytes.size()));
|
||||
bytes.span().copy_to(buffer->buffer().span());
|
||||
value = buffer;
|
||||
break;
|
||||
@@ -820,7 +821,7 @@ public:
|
||||
return WebIDL::DataCloneError::create(*realm, "out of memory"_string);
|
||||
size_t max_byte_length = deserialize_primitive_type<size_t>(m_serialized, m_position);
|
||||
auto bytes = bytes_or_error.release_value();
|
||||
JS::ArrayBuffer* buffer = TRY(JS::allocate_shared_array_buffer(m_vm, realm->intrinsics().array_buffer_constructor(), bytes.size()));
|
||||
JS::ArrayBuffer* buffer = TRY(JS::allocate_shared_array_buffer(m_vm, realm->intrinsics().shared_array_buffer_constructor(), bytes.size()));
|
||||
bytes.span().copy_to(buffer->buffer().span());
|
||||
buffer->set_max_byte_length(max_byte_length);
|
||||
value = buffer;
|
||||
|
||||
Reference in New Issue
Block a user