mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibJS: Crudely implement growable SharedArrayBuffers
We treat any mention of [[ArrayBufferByteLengthData]] and related atomic operations as FIXMEs to be fixed at a later date. We also add the HostGrowSharedArrayBuffer abstract operation, which will be overridden by LibWeb to grow shared WebAssembly memories.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
ee141dd9f7
commit
d44b239621
Notes:
github-actions[bot]
2026-01-04 06:49:02 +00:00
Author: https://github.com/CountBleck Commit: https://github.com/LadybirdBrowser/ladybird/commit/d44b2396217 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7306 Reviewed-by: https://github.com/alimpfard
@@ -49,8 +49,11 @@ ThrowCompletionOr<GC::Ref<Object>> SharedArrayBufferConstructor::construct(Funct
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
||||
auto length = vm.argument(0);
|
||||
auto options = vm.argument(1);
|
||||
|
||||
// 2. Let byteLength be ? ToIndex(length).
|
||||
auto byte_length_or_error = vm.argument(0).to_index(vm);
|
||||
auto byte_length_or_error = length.to_index(vm);
|
||||
|
||||
if (byte_length_or_error.is_error()) {
|
||||
auto error = byte_length_or_error.release_error();
|
||||
@@ -61,8 +64,11 @@ ThrowCompletionOr<GC::Ref<Object>> SharedArrayBufferConstructor::construct(Funct
|
||||
return error;
|
||||
}
|
||||
|
||||
// 3. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength).
|
||||
return *TRY(allocate_shared_array_buffer(vm, new_target, byte_length_or_error.release_value()));
|
||||
// 3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options).
|
||||
auto requested_max_byte_length = TRY(get_array_buffer_max_byte_length_option(vm, options));
|
||||
|
||||
// 4. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength, requestedMaxByteLength).
|
||||
return *TRY(allocate_shared_array_buffer(vm, new_target, byte_length_or_error.release_value(), requested_max_byte_length));
|
||||
}
|
||||
|
||||
// 25.2.4.2 get SharedArrayBuffer [ @@species ], https://tc39.es/ecma262/#sec-sharedarraybuffer-@@species
|
||||
|
||||
Reference in New Issue
Block a user