diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index b090e49a93..fc2c6ed46e 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -174,10 +174,10 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea { auto& vm = realm.vm(); - auto prototype = heap().allocate<@prototype_class@>(realm, realm); + auto prototype = heap().allocate<@prototype_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); m_prototypes.set("@interface_name@"sv, prototype); - auto constructor = heap().allocate<@constructor_class@>(realm, realm); + auto constructor = heap().allocate<@constructor_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); m_constructors.set("@interface_name@"sv, constructor); prototype->define_direct_property(vm.names.constructor, constructor.ptr(), JS::Attribute::Writable | JS::Attribute::Configurable); @@ -188,7 +188,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea gen.set("legacy_interface_name", legacy_constructor->name); gen.set("legacy_constructor_class", legacy_constructor->constructor_class); gen.append(R"~~~( - auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm); + auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); m_constructors.set("@legacy_interface_name@"sv, legacy_constructor); legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"sv), JS::Attribute::Configurable);)~~~"); diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 80832141aa..e203c6486f 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -51,7 +51,7 @@ public: static JS::ThrowCompletionOr create(JS::Realm& realm, Wasm::Module module, HashMap const& imports) { auto& vm = realm.vm(); - auto instance = realm.heap().allocate(realm, *realm.intrinsics().object_prototype()); + auto instance = MUST_OR_THROW_OOM(realm.heap().allocate(realm, *realm.intrinsics().object_prototype())); instance->m_module = move(module); Wasm::Linker linker(*instance->m_module); linker.link(imports); diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index bc426b2a12..16c0ba407c 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -27,7 +27,7 @@ Workbook::Workbook(NonnullRefPtrVector&& sheets, GUI::Window& parent_wind , m_main_execution_context(m_vm->heap()) , m_parent_window(parent_window) { - m_workbook_object = m_vm->heap().allocate(m_interpreter->realm(), m_interpreter->realm(), *this); + m_workbook_object = m_vm->heap().allocate(m_interpreter->realm(), m_interpreter->realm(), *this).release_allocated_value_but_fixme_should_propagate_errors(); m_interpreter->realm().global_object().define_direct_property("workbook", workbook_object(), JS::default_attributes); m_main_execution_context.current_node = nullptr; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp index e655200342..d0911ba6d5 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp @@ -28,8 +28,8 @@ ThrowCompletionOr $262Object::initialize(Realm& realm) { MUST_OR_THROW_OOM(Base::initialize(realm)); - m_agent = vm().heap().allocate(realm, realm); - m_is_htmldda = vm().heap().allocate(realm, realm); + m_agent = MUST_OR_THROW_OOM(vm().heap().allocate(realm, realm)); + m_is_htmldda = MUST_OR_THROW_OOM(vm().heap().allocate(realm, realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr); diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp index 2175b0c6dd..6ea4172847 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp @@ -18,7 +18,7 @@ ThrowCompletionOr GlobalObject::initialize(Realm& realm) { MUST_OR_THROW_OOM(Base::initialize(realm)); - m_$262 = vm().heap().allocate<$262Object>(realm, realm); + m_$262 = MUST_OR_THROW_OOM(vm().heap().allocate<$262Object>(realm, realm)); // https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions u8 attr = Attribute::Writable | Attribute::Configurable; diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index 18cc94473a..3e1c20fefe 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -41,15 +41,12 @@ public: } template - NonnullGCPtr allocate(Realm& realm, Args&&... args) + ThrowCompletionOr> allocate(Realm& realm, Args&&... args) { auto* memory = allocate_cell(sizeof(T)); new (memory) T(forward(args)...); auto* cell = static_cast(memory); - - // FIXME: Propagate this error. - (void)memory->initialize(realm); - + MUST_OR_THROW_OOM(memory->initialize(realm)); return *cell; } diff --git a/Userland/Libraries/LibJS/Module.cpp b/Userland/Libraries/LibJS/Module.cpp index 38ad302488..714a8d15e8 100644 --- a/Userland/Libraries/LibJS/Module.cpp +++ b/Userland/Libraries/LibJS/Module.cpp @@ -114,7 +114,7 @@ Object* Module::module_namespace_create(VM& vm, Vector unam // 6. Let sortedExports be a List whose elements are the elements of exports ordered as if an Array of the same values had been sorted using %Array.prototype.sort% using undefined as comparefn. // 7. Set M.[[Exports]] to sortedExports. // 8. Create own properties of M corresponding to the definitions in 28.3. - auto module_namespace = vm.heap().allocate(realm, realm, this, move(unambiguous_names)); + auto module_namespace = vm.heap().allocate(realm, realm, this, move(unambiguous_names)).release_allocated_value_but_fixme_should_propagate_errors(); // 9. Set module.[[Namespace]] to M. m_namespace = make_handle(module_namespace); diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index bad2a4cf74..5005043989 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -1104,7 +1104,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector< // 7. Set obj.[[Set]] as specified in 10.4.4.4. // 8. Set obj.[[Delete]] as specified in 10.4.4.5. // 9. Set obj.[[Prototype]] to %Object.prototype%. - auto object = vm.heap().allocate(realm, realm, environment); + auto object = vm.heap().allocate(realm, realm, environment).release_allocated_value_but_fixme_should_propagate_errors(); // 14. Let index be 0. // 15. Repeat, while index < len, diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h index a72915e651..105108c753 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h @@ -146,7 +146,7 @@ ThrowCompletionOr> ordinary_create_from_constructor(VM& vm, Func { auto& realm = *vm.current_realm(); auto* prototype = TRY(get_prototype_from_constructor(vm, constructor, intrinsic_default_prototype)); - return realm.heap().allocate(realm, forward(args)..., *prototype); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, forward(args)..., *prototype)); } // 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists diff --git a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp index 7780e464cf..1f3a225b80 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr AggregateError::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().aggregate_error_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().aggregate_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } AggregateError::AggregateError(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index 4bf4922556..02ea98bc4b 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -32,7 +32,7 @@ ThrowCompletionOr> Array::create(Realm& realm, u64 length, O // 3. Let A be MakeBasicObject(« [[Prototype]], [[Extensible]] »). // 4. Set A.[[Prototype]] to proto. // 5. Set A.[[DefineOwnProperty]] as specified in 10.4.2.1. - auto array = realm.heap().allocate(realm, *prototype); + auto array = MUST_OR_THROW_OOM(realm.heap().allocate(realm, *prototype)); // 6. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }). MUST(array->internal_define_own_property(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = false })); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp index 809e1ea3a9..e86be838a3 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp @@ -17,17 +17,17 @@ ThrowCompletionOr> ArrayBuffer::create(Realm& realm, s if (buffer.is_error()) return realm.vm().throw_completion(ErrorType::NotEnoughMemoryToAllocate, byte_length); - return realm.heap().allocate(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype()); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype())); } NonnullGCPtr ArrayBuffer::create(Realm& realm, ByteBuffer buffer) { - return realm.heap().allocate(realm, move(buffer), *realm.intrinsics().array_buffer_prototype()); + return realm.heap().allocate(realm, move(buffer), *realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } NonnullGCPtr ArrayBuffer::create(Realm& realm, ByteBuffer* buffer) { - return realm.heap().allocate(realm, buffer, *realm.intrinsics().array_buffer_prototype()); + return realm.heap().allocate(realm, buffer, *realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp index 4b23b3c3c9..483f25f3d7 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind) { - return realm.heap().allocate(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype()); + return realm.heap().allocate(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp index 7b3d4e53b3..ad1c97f981 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr AsyncFromSyncIterator::create(Realm& realm, Iterator sync_iterator_record) { - return realm.heap().allocate(realm, realm, sync_iterator_record); + return realm.heap().allocate(realm, realm, sync_iterator_record).release_allocated_value_but_fixme_should_propagate_errors(); } AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record) diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp index e3afe6ec5c..acae27a191 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp @@ -15,7 +15,7 @@ namespace JS { ThrowCompletionOr AsyncFunctionDriverWrapper::create(Realm& realm, GeneratorObject* generator_object) { - auto wrapper = realm.heap().allocate(realm, realm, generator_object); + auto wrapper = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, generator_object)); return wrapper->react_to_async_task_completion(realm.vm(), js_undefined(), true); } diff --git a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp index 25ffe5b4fd..182d2002f1 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr BigIntObject::create(Realm& realm, BigInt& bigint) { - return realm.heap().allocate(realm, bigint, *realm.intrinsics().bigint_prototype()); + return realm.heap().allocate(realm, bigint, *realm.intrinsics().bigint_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } BigIntObject::BigIntObject(BigInt& bigint, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp index 95121a47f6..964cc3926f 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr BooleanObject::create(Realm& realm, bool value) { - return realm.heap().allocate(realm, value, *realm.intrinsics().boolean_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().boolean_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } BooleanObject::BooleanObject(bool value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index 82e34d745f..6c0bc8d7cb 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -26,7 +26,7 @@ ThrowCompletionOr> BoundFunction::create(Realm& real // 7. Set obj.[[BoundTargetFunction]] to targetFunction. // 8. Set obj.[[BoundThis]] to boundThis. // 9. Set obj.[[BoundArguments]] to boundArgs. - auto object = realm.heap().allocate(realm, realm, target_function, bound_this, move(bound_arguments), prototype); + auto object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, target_function, bound_this, move(bound_arguments), prototype)); // 10. Return obj. return object; diff --git a/Userland/Libraries/LibJS/Runtime/DataView.cpp b/Userland/Libraries/LibJS/Runtime/DataView.cpp index 8abf686c46..eb3131b03f 100644 --- a/Userland/Libraries/LibJS/Runtime/DataView.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataView.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset) { - return realm.heap().allocate(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype()); + return realm.heap().allocate(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index 873671a633..2c42a60fa4 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -25,7 +25,7 @@ Crypto::SignedBigInteger const ns_per_day_bigint { static_cast(ns_per_day) NonnullGCPtr Date::create(Realm& realm, double date_value) { - return realm.heap().allocate(realm, date_value, *realm.intrinsics().date_prototype()); + return realm.heap().allocate(realm, date_value, *realm.intrinsics().date_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } Date::Date(double date_value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index af27f64cd4..abb2790ab6 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -45,12 +45,12 @@ NonnullGCPtr ECMAScriptFunctionObject::create(Realm& r prototype = realm.intrinsics().async_generator_function_prototype(); break; } - return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); + return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)).release_allocated_value_but_fixme_should_propagate_errors(); } NonnullGCPtr ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name) { - return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); + return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)).release_allocated_value_but_fixme_should_propagate_errors(); } ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector formal_parameters, i32 function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name) @@ -114,7 +114,7 @@ ThrowCompletionOr ECMAScriptFunctionObject::initialize(Realm& realm) Object* prototype = nullptr; switch (m_kind) { case FunctionKind::Normal: - prototype = vm.heap().allocate(realm, *realm.intrinsics().new_ordinary_function_prototype_object_shape()); + prototype = MUST_OR_THROW_OOM(vm.heap().allocate(realm, *realm.intrinsics().new_ordinary_function_prototype_object_shape())); MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true })); break; case FunctionKind::Generator: diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp index 69551c1130..6d11909d54 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.cpp +++ b/Userland/Libraries/LibJS/Runtime/Error.cpp @@ -16,7 +16,7 @@ namespace JS { NonnullGCPtr Error::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().error_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().error_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } NonnullGCPtr Error::create(Realm& realm, DeprecatedString const& message) @@ -98,24 +98,24 @@ DeprecatedString Error::stack_string() const return stack_string_builder.to_deprecated_string(); } -#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - NonnullGCPtr ClassName::create(Realm& realm) \ - { \ - return realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype()); \ - } \ - \ - NonnullGCPtr ClassName::create(Realm& realm, DeprecatedString const& message) \ - { \ - auto& vm = realm.vm(); \ - auto error = ClassName::create(realm); \ - u8 attr = Attribute::Writable | Attribute::Configurable; \ - error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \ - return error; \ - } \ - \ - ClassName::ClassName(Object& prototype) \ - : Error(prototype) \ - { \ +#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ + NonnullGCPtr ClassName::create(Realm& realm) \ + { \ + return realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \ + } \ + \ + NonnullGCPtr ClassName::create(Realm& realm, DeprecatedString const& message) \ + { \ + auto& vm = realm.vm(); \ + auto error = ClassName::create(realm); \ + u8 attr = Attribute::Writable | Attribute::Configurable; \ + error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \ + return error; \ + } \ + \ + ClassName::ClassName(Object& prototype) \ + : Error(prototype) \ + { \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 8cba0588c4..ce2a6c4b80 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -28,7 +28,7 @@ ThrowCompletionOr> GeneratorObject::create(Realm& generating_function_prototype = TRY(generating_function->get(vm.names.prototype)); } auto* generating_function_prototype_object = TRY(generating_function_prototype.to_object(vm)); - auto object = realm.heap().allocate(realm, realm, *generating_function_prototype_object, move(execution_context)); + auto object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *generating_function_prototype_object, move(execution_context))); object->m_generating_function = generating_function; object->m_frame = move(frame); object->m_previous_value = initial_value; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index 2e711f43bf..1282b39208 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp @@ -13,7 +13,7 @@ namespace JS::Intl { NonnullGCPtr CollatorCompareFunction::create(Realm& realm, Collator& collator) { - return realm.heap().allocate(realm, realm, collator); + return realm.heap().allocate(realm, realm, collator).release_allocated_value_but_fixme_should_propagate_errors(); } CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp index 85e2c35262..ed51ac926b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp @@ -16,7 +16,7 @@ namespace JS::Intl { // 11.5.5 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions NonnullGCPtr DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format) { - return realm.heap().allocate(realm, date_time_format, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, date_time_format, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp index 278e91a582..b177efc065 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -16,7 +16,7 @@ namespace JS::Intl { ThrowCompletionOr> Locale::create(Realm& realm, ::Locale::LocaleID locale_id) { - auto locale = realm.heap().allocate(realm, *realm.intrinsics().intl_locale_prototype()); + auto locale = MUST_OR_THROW_OOM(realm.heap().allocate(realm, *realm.intrinsics().intl_locale_prototype())); locale->set_locale(TRY_OR_THROW_OOM(realm.vm(), locale_id.to_string())); for (auto& extension : locale_id.extensions) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index bd3e1fef56..7caf51606e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -14,7 +14,7 @@ namespace JS::Intl { // 1.5.2 Number Format Functions, https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-number-format-functions NonnullGCPtr NumberFormatFunction::create(Realm& realm, NumberFormat& number_format) { - return realm.heap().allocate(realm, number_format, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, number_format, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp index 1fb4f32d73..8e23fcc6d3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp @@ -19,7 +19,7 @@ NonnullGCPtr SegmentIterator::create(Realm& realm, Segmenter& s // 4. Set iterator.[[IteratedString]] to string. // 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0. // 6. Return iterator. - return realm.heap().allocate(realm, realm, segmenter, move(string), segments); + return realm.heap().allocate(realm, realm, segmenter, move(string), segments).release_allocated_value_but_fixme_should_propagate_errors(); } // 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp index 585b3b7229..7f892a3257 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp @@ -18,7 +18,7 @@ NonnullGCPtr Segments::create(Realm& realm, Segmenter& segmenter, Utf1 // 3. Set segments.[[SegmentsSegmenter]] to segmenter. // 4. Set segments.[[SegmentsString]] to string. // 5. Return segments. - return realm.heap().allocate(realm, realm, segmenter, move(string)); + return realm.heap().allocate(realm, realm, segmenter, move(string)).release_allocated_value_but_fixme_should_propagate_errors(); } // 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp index feac0524d4..8e3c456749 100644 --- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -189,26 +189,26 @@ void Intrinsics::initialize_intrinsics(Realm& realm) #define __JS_ENUMERATE(ClassName, snake_name) \ VERIFY(!m_##snake_name##_prototype); \ - m_##snake_name##_prototype = heap().allocate(realm, realm); + m_##snake_name##_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); JS_ENUMERATE_ITERATOR_PROTOTYPES #undef __JS_ENUMERATE // These must be initialized separately as they have no companion constructor - m_async_from_sync_iterator_prototype = heap().allocate(realm, realm); - m_async_generator_prototype = heap().allocate(realm, realm); - m_generator_prototype = heap().allocate(realm, realm); - m_intl_segments_prototype = heap().allocate(realm, realm); + m_async_from_sync_iterator_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_async_generator_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_generator_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_intl_segments_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); // These must be initialized before allocating... // - AggregateErrorPrototype, which uses ErrorPrototype as its prototype // - AggregateErrorConstructor, which uses ErrorConstructor as its prototype // - AsyncFunctionConstructor, which uses FunctionConstructor as its prototype - m_error_prototype = heap().allocate(realm, realm); - m_error_constructor = heap().allocate(realm, realm); - m_function_constructor = heap().allocate(realm, realm); + m_error_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_error_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_function_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype - m_proxy_constructor = heap().allocate(realm, realm); + m_proxy_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); // Global object functions m_eval_function = NativeFunction::create(realm, GlobalObject::eval, 1, vm.names.eval, &realm); @@ -223,7 +223,7 @@ void Intrinsics::initialize_intrinsics(Realm& realm) m_escape_function = NativeFunction::create(realm, GlobalObject::escape, 1, vm.names.escape, &realm); m_unescape_function = NativeFunction::create(realm, GlobalObject::unescape, 1, vm.names.unescape, &realm); - m_object_constructor = heap().allocate(realm, realm); + m_object_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); // 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror% m_throw_type_error_function = NativeFunction::create( @@ -266,52 +266,52 @@ constexpr inline bool IsTypedArrayConstructor = false; JS_ENUMERATE_TYPED_ARRAYS #undef __JS_ENUMERATE -#define __JS_ENUMERATE_INNER(ClassName, snake_name, PrototypeName, ConstructorName, Namespace, snake_namespace) \ - void Intrinsics::initialize_##snake_namespace##snake_name() \ - { \ - auto& vm = this->vm(); \ - \ - VERIFY(!m_##snake_namespace##snake_name##_prototype); \ - VERIFY(!m_##snake_namespace##snake_name##_constructor); \ - if constexpr (IsTypedArrayConstructor) { \ - m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, *typed_array_prototype()); \ - m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm, *typed_array_constructor()); \ - } else { \ - m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, m_realm); \ - m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm); \ - } \ - \ - /* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \ - if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Symbol, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else \ - initialize_constructor(vm, vm.names.ClassName, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - } \ - \ - Namespace::ConstructorName* Intrinsics::snake_namespace##snake_name##_constructor() \ - { \ - if (!m_##snake_namespace##snake_name##_constructor) \ - initialize_##snake_namespace##snake_name(); \ - return m_##snake_namespace##snake_name##_constructor; \ - } \ - \ - Object* Intrinsics::snake_namespace##snake_name##_prototype() \ - { \ - if (!m_##snake_namespace##snake_name##_prototype) \ - initialize_##snake_namespace##snake_name(); \ - return m_##snake_namespace##snake_name##_prototype; \ +#define __JS_ENUMERATE_INNER(ClassName, snake_name, PrototypeName, ConstructorName, Namespace, snake_namespace) \ + void Intrinsics::initialize_##snake_namespace##snake_name() \ + { \ + auto& vm = this->vm(); \ + \ + VERIFY(!m_##snake_namespace##snake_name##_prototype); \ + VERIFY(!m_##snake_namespace##snake_name##_constructor); \ + if constexpr (IsTypedArrayConstructor) { \ + m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, *typed_array_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \ + m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm, *typed_array_constructor()).release_allocated_value_but_fixme_should_propagate_errors(); \ + } else { \ + m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \ + m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \ + } \ + \ + /* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \ + if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Symbol, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else \ + initialize_constructor(vm, vm.names.ClassName, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + } \ + \ + Namespace::ConstructorName* Intrinsics::snake_namespace##snake_name##_constructor() \ + { \ + if (!m_##snake_namespace##snake_name##_constructor) \ + initialize_##snake_namespace##snake_name(); \ + return m_##snake_namespace##snake_name##_constructor; \ + } \ + \ + Object* Intrinsics::snake_namespace##snake_name##_prototype() \ + { \ + if (!m_##snake_namespace##snake_name##_prototype) \ + initialize_##snake_namespace##snake_name(); \ + return m_##snake_namespace##snake_name##_prototype; \ } #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ @@ -331,12 +331,12 @@ JS_ENUMERATE_TEMPORAL_OBJECTS #undef __JS_ENUMERATE_INNER -#define __JS_ENUMERATE(ClassName, snake_name) \ - ClassName* Intrinsics::snake_name##_object() \ - { \ - if (!m_##snake_name##_object) \ - m_##snake_name##_object = heap().allocate(m_realm, m_realm); \ - return m_##snake_name##_object; \ +#define __JS_ENUMERATE(ClassName, snake_name) \ + ClassName* Intrinsics::snake_name##_object() \ + { \ + if (!m_##snake_name##_object) \ + m_##snake_name##_object = heap().allocate(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \ + return m_##snake_name##_object; \ } JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS #undef __JS_ENUMERATE diff --git a/Userland/Libraries/LibJS/Runtime/Map.cpp b/Userland/Libraries/LibJS/Runtime/Map.cpp index bc29064bf6..e685db97fa 100644 --- a/Userland/Libraries/LibJS/Runtime/Map.cpp +++ b/Userland/Libraries/LibJS/Runtime/Map.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr Map::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().map_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().map_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } Map::Map(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp index ef66637bd5..2410bb6f7c 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind) { - return realm.heap().allocate(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype()); + return realm.heap().allocate(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index bb8427e2fc..87f78c6f38 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -36,7 +36,7 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Saf // 7. Set func.[[Extensible]] to true. // 8. Set func.[[Realm]] to realm. // 9. Set func.[[InitialName]] to null. - auto function = allocating_realm.heap().allocate(allocating_realm, move(behaviour), prototype.value(), *realm.value()); + auto function = allocating_realm.heap().allocate(allocating_realm, move(behaviour), prototype.value(), *realm.value()).release_allocated_value_but_fixme_should_propagate_errors(); // 10. Perform SetFunctionLength(func, length). function->set_function_length(length); @@ -53,7 +53,7 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Saf NonnullGCPtr NativeFunction::create(Realm& realm, DeprecatedFlyString const& name, SafeFunction(VM&)> function) { - return realm.heap().allocate(realm, name, move(function), *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, name, move(function), *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } NativeFunction::NativeFunction(SafeFunction(VM&)> native_function, Object* prototype, Realm& realm) diff --git a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp index 72cfc01548..9a17e3c386 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr NumberObject::create(Realm& realm, double value) { - return realm.heap().allocate(realm, value, *realm.intrinsics().number_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().number_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } NumberObject::NumberObject(double value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 28a463e702..839e331316 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -30,11 +30,10 @@ static HashMap Object::create(Realm& realm, Object* prototype) { if (!prototype) - return realm.heap().allocate(realm, *realm.intrinsics().empty_object_shape()); - else if (prototype == realm.intrinsics().object_prototype()) - return realm.heap().allocate(realm, *realm.intrinsics().new_object_shape()); - else - return realm.heap().allocate(realm, ConstructWithPrototypeTag::Tag, *prototype); + return realm.heap().allocate(realm, *realm.intrinsics().empty_object_shape()).release_allocated_value_but_fixme_should_propagate_errors(); + if (prototype == realm.intrinsics().object_prototype()) + return realm.heap().allocate(realm, *realm.intrinsics().new_object_shape()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, ConstructWithPrototypeTag::Tag, *prototype).release_allocated_value_but_fixme_should_propagate_errors(); } Object::Object(GlobalObjectTag, Realm& realm) diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp index 316ad4f987..108c6e457c 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.cpp +++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr promise_resolve(VM& vm, Object& constructor, Value va NonnullGCPtr Promise::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().promise_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().promise_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } // 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 0ba3dd2cdd..908b3aa405 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -57,7 +57,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor) NonnullGCPtr PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -89,7 +89,7 @@ ThrowCompletionOr PromiseAllResolveElementFunction::resolve_element() NonnullGCPtr PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -130,7 +130,7 @@ ThrowCompletionOr PromiseAllSettledResolveElementFunction::resolve_elemen NonnullGCPtr PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -171,7 +171,7 @@ ThrowCompletionOr PromiseAllSettledRejectElementFunction::resolve_element NonnullGCPtr PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp index e1d7c2ce2f..f519ac73cf 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function) { - return realm.heap().allocate(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index a71a76d8a3..186daca8cd 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -17,7 +17,7 @@ namespace JS { NonnullGCPtr ProxyObject::create(Realm& realm, Object& target, Object& handler) { - return realm.heap().allocate(realm, target, handler, *realm.intrinsics().object_prototype()); + return realm.heap().allocate(realm, target, handler, *realm.intrinsics().object_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp index cbbca774ba..74b52e3000 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -130,12 +130,12 @@ ThrowCompletionOr parse_regex_pattern(VM& vm, StringView patte NonnullGCPtr RegExpObject::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().regexp_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } NonnullGCPtr RegExpObject::create(Realm& realm, Regex regex, DeprecatedString pattern, DeprecatedString flags) { - return realm.heap().allocate(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()); + return realm.heap().allocate(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } RegExpObject::RegExpObject(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp index 0419110055..49a360dd70 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp @@ -12,7 +12,7 @@ namespace JS { // 22.2.7.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator NonnullGCPtr RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode) { - return realm.heap().allocate(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode); + return realm.heap().allocate(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode).release_allocated_value_but_fixme_should_propagate_errors(); } RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode) diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp index f971acc571..40c951415e 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.cpp +++ b/Userland/Libraries/LibJS/Runtime/Set.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr Set::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().set_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().set_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } Set::Set(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp index f75f17e626..5fd1a8dfc9 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind) { - return realm.heap().allocate(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype()); + return realm.heap().allocate(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp index 03dd0e3dbf..532c57bb85 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr StringIterator::create(Realm& realm, String string) { - return realm.heap().allocate(realm, move(string), *realm.intrinsics().string_iterator_prototype()); + return realm.heap().allocate(realm, move(string), *realm.intrinsics().string_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } StringIterator::StringIterator(String string, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index 7778cd909a..9205d6b679 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -17,7 +17,7 @@ namespace JS { // 10.4.3.4 StringCreate ( value, prototype ), https://tc39.es/ecma262/#sec-stringcreate NonnullGCPtr StringObject::create(Realm& realm, PrimitiveString& primitive_string, Object& prototype) { - return realm.heap().allocate(realm, primitive_string, prototype); + return realm.heap().allocate(realm, primitive_string, prototype).release_allocated_value_but_fixme_should_propagate_errors(); } StringObject::StringObject(PrimitiveString& string, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp index b067f5b985..a7edd888a9 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp +++ b/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr SuppressedError::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().suppressed_error_prototype()); + return *realm.heap().allocate(realm, *realm.intrinsics().suppressed_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } SuppressedError::SuppressedError(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp index b59a83401b..2e006d74a9 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr SymbolObject::create(Realm& realm, Symbol& primitive_symbol) { - return realm.heap().allocate(realm, primitive_symbol, *realm.intrinsics().symbol_prototype()); + return realm.heap().allocate(realm, primitive_symbol, *realm.intrinsics().symbol_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } SymbolObject::SymbolObject(Symbol& symbol, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp index 82fe3dc23a..48cb124bf3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp @@ -36,7 +36,7 @@ ThrowCompletionOr Temporal::initialize(Realm& realm) define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.Now, heap().allocate(realm, realm), attr); + define_direct_property(vm.names.Now, MUST_OR_THROW_OOM(heap().allocate(realm, realm)), attr); define_intrinsic_accessor(vm.names.Calendar, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_calendar_constructor(); }); define_intrinsic_accessor(vm.names.Duration, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_duration_constructor(); }); define_intrinsic_accessor(vm.names.Instant, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_instant_constructor(); }); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index 148a61bab3..ccd176bb02 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -420,141 +420,141 @@ void TypedArrayBase::visit_edges(Visitor& visitor) visitor.visit(m_viewed_array_buffer); } -#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \ - ThrowCompletionOr> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \ - { \ - auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \ - auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ - return realm.heap().allocate(realm, *prototype, length, *array_buffer); \ - } \ - \ - ThrowCompletionOr> ClassName::create(Realm& realm, u32 length) \ - { \ - auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ - return create(realm, length, *array_buffer); \ - } \ - \ - NonnullGCPtr ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \ - { \ - return realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer); \ - } \ - \ - ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \ - : TypedArray(prototype, \ - reinterpret_cast(&Intrinsics::snake_name##_constructor), length, array_buffer) \ - { \ - if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \ - m_content_type = ContentType::BigInt; \ - else \ - m_content_type = ContentType::Number; \ - } \ - \ - ClassName::~ClassName() \ - { \ - } \ - \ - DeprecatedFlyString const& ClassName::element_name() const \ - { \ - return vm().names.ClassName.as_string(); \ - } \ - \ - PrototypeName::PrototypeName(Object& prototype) \ - : Object(ConstructWithPrototypeTag::Tag, prototype) \ - { \ - } \ - \ - PrototypeName::~PrototypeName() \ - { \ - } \ - \ - ThrowCompletionOr PrototypeName::initialize(Realm& realm) \ - { \ - auto& vm = this->vm(); \ - MUST_OR_THROW_OOM(Base::initialize(realm)); \ - define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ - \ - return {}; \ - } \ - \ - ConstructorName::ConstructorName(Realm& realm, Object& prototype) \ - : TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \ - { \ - } \ - \ - ConstructorName::~ConstructorName() \ - { \ - } \ - \ - ThrowCompletionOr ConstructorName::initialize(Realm& realm) \ - { \ - auto& vm = this->vm(); \ - MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \ - \ - /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \ - define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \ - \ - /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \ - define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ - \ - define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \ - \ - return {}; \ - } \ - \ - /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ - ThrowCompletionOr ConstructorName::call() \ - { \ - auto& vm = this->vm(); \ - return vm.throw_completion(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \ - } \ - \ - /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ - ThrowCompletionOr> ConstructorName::construct(FunctionObject& new_target) \ - { \ - auto& vm = this->vm(); \ - auto& realm = *vm.current_realm(); \ - \ - if (vm.argument_count() == 0) \ - return TRY(ClassName::create(realm, 0, new_target)); \ - \ - auto first_argument = vm.argument(0); \ - if (first_argument.is_object()) { \ - auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \ - if (first_argument.as_object().is_typed_array()) { \ - auto& arg_typed_array = static_cast(first_argument.as_object()); \ - TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \ - } else if (is(first_argument.as_object())) { \ - auto& array_buffer = static_cast(first_argument.as_object()); \ - TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \ - vm.argument(1), vm.argument(2))); \ - } else { \ - auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \ - if (iterator) { \ - auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \ - TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \ - } else { \ - TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \ - } \ - } \ - return typed_array; \ - } \ - \ - auto array_length_or_error = first_argument.to_index(vm); \ - if (array_length_or_error.is_error()) { \ - auto error = array_length_or_error.release_error(); \ - if (error.value()->is_object() && is(error.value()->as_object())) { \ - /* Re-throw more specific RangeError */ \ - return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ - } \ - return error; \ - } \ - auto array_length = array_length_or_error.release_value(); \ - if (array_length > NumericLimits::max() / sizeof(Type)) \ - return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ - /* FIXME: What is the best/correct behavior here? */ \ - if (Checked::multiplication_would_overflow(array_length, sizeof(Type))) \ - return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ - return TRY(ClassName::create(realm, array_length, new_target)); \ +#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \ + ThrowCompletionOr> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \ + { \ + auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \ + auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, *prototype, length, *array_buffer)); \ + } \ + \ + ThrowCompletionOr> ClassName::create(Realm& realm, u32 length) \ + { \ + auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ + return create(realm, length, *array_buffer); \ + } \ + \ + NonnullGCPtr ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \ + { \ + return realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer).release_allocated_value_but_fixme_should_propagate_errors(); \ + } \ + \ + ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \ + : TypedArray(prototype, \ + reinterpret_cast(&Intrinsics::snake_name##_constructor), length, array_buffer) \ + { \ + if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \ + m_content_type = ContentType::BigInt; \ + else \ + m_content_type = ContentType::Number; \ + } \ + \ + ClassName::~ClassName() \ + { \ + } \ + \ + DeprecatedFlyString const& ClassName::element_name() const \ + { \ + return vm().names.ClassName.as_string(); \ + } \ + \ + PrototypeName::PrototypeName(Object& prototype) \ + : Object(ConstructWithPrototypeTag::Tag, prototype) \ + { \ + } \ + \ + PrototypeName::~PrototypeName() \ + { \ + } \ + \ + ThrowCompletionOr PrototypeName::initialize(Realm& realm) \ + { \ + auto& vm = this->vm(); \ + MUST_OR_THROW_OOM(Base::initialize(realm)); \ + define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ + \ + return {}; \ + } \ + \ + ConstructorName::ConstructorName(Realm& realm, Object& prototype) \ + : TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \ + { \ + } \ + \ + ConstructorName::~ConstructorName() \ + { \ + } \ + \ + ThrowCompletionOr ConstructorName::initialize(Realm& realm) \ + { \ + auto& vm = this->vm(); \ + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \ + \ + /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \ + define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \ + \ + /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \ + define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ + \ + define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \ + \ + return {}; \ + } \ + \ + /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ + ThrowCompletionOr ConstructorName::call() \ + { \ + auto& vm = this->vm(); \ + return vm.throw_completion(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \ + } \ + \ + /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ + ThrowCompletionOr> ConstructorName::construct(FunctionObject& new_target) \ + { \ + auto& vm = this->vm(); \ + auto& realm = *vm.current_realm(); \ + \ + if (vm.argument_count() == 0) \ + return TRY(ClassName::create(realm, 0, new_target)); \ + \ + auto first_argument = vm.argument(0); \ + if (first_argument.is_object()) { \ + auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \ + if (first_argument.as_object().is_typed_array()) { \ + auto& arg_typed_array = static_cast(first_argument.as_object()); \ + TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \ + } else if (is(first_argument.as_object())) { \ + auto& array_buffer = static_cast(first_argument.as_object()); \ + TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \ + vm.argument(1), vm.argument(2))); \ + } else { \ + auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \ + if (iterator) { \ + auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \ + TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \ + } else { \ + TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \ + } \ + } \ + return typed_array; \ + } \ + \ + auto array_length_or_error = first_argument.to_index(vm); \ + if (array_length_or_error.is_error()) { \ + auto error = array_length_or_error.release_error(); \ + if (error.value()->is_object() && is(error.value()->as_object())) { \ + /* Re-throw more specific RangeError */ \ + return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ + } \ + return error; \ + } \ + auto array_length = array_length_or_error.release_value(); \ + if (array_length > NumericLimits::max() / sizeof(Type)) \ + return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ + /* FIXME: What is the best/correct behavior here? */ \ + if (Checked::multiplication_would_overflow(array_length, sizeof(Type))) \ + return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ + return TRY(ClassName::create(realm, array_length, new_target)); \ } #undef __JS_ENUMERATE diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp index 8bcb04ade3..b2d7173b19 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr WeakMap::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().weak_map_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().weak_map_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } WeakMap::WeakMap(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp index 9f80170eb5..eae13f6e63 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp @@ -10,12 +10,12 @@ namespace JS { NonnullGCPtr WeakRef::create(Realm& realm, Object& value) { - return realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } NonnullGCPtr WeakRef::create(Realm& realm, Symbol& value) { - return realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } WeakRef::WeakRef(Object& value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp index ceaf10f6cf..a288695a3f 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr WeakSet::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().weak_set_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().weak_set_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); } WeakSet::WeakSet(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp index 8c220ba39d..45106de2e8 100644 --- a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp @@ -22,7 +22,7 @@ ThrowCompletionOr> WrappedFunction::create(Realm& // 5. Set wrapped.[[WrappedTargetFunction]] to Target. // 6. Set wrapped.[[Realm]] to callerRealm. auto& prototype = *caller_realm.intrinsics().function_prototype(); - auto wrapped = vm.heap().allocate(realm, caller_realm, target, prototype); + auto wrapped = MUST_OR_THROW_OOM(vm.heap().allocate(realm, caller_realm, target, prototype)); // 7. Let result be CopyNameAndLength(wrapped, Target). auto result = copy_name_and_length(vm, *wrapped, target); diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index 0dc0097cc4..ea2b368ac3 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -375,7 +375,7 @@ JS::VM& main_thread_vm() custom_data.root_execution_context = MUST(JS::Realm::initialize_host_defined_realm(*vm, nullptr, nullptr)); auto* root_realm = custom_data.root_execution_context->realm; - auto intrinsics = root_realm->heap().allocate(*root_realm, *root_realm); + auto intrinsics = root_realm->heap().allocate(*root_realm, *root_realm).release_allocated_value_but_fixme_should_propagate_errors(); auto host_defined = make(nullptr, intrinsics); root_realm->set_host_defined(move(host_defined)); custom_data.internal_realm = root_realm; diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index 17c86fdab5..9e24cd8e6f 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -53,7 +53,7 @@ JS::ThrowCompletionOr> OptionConstructor::construct if (vm.argument_count() > 0) { auto text = TRY(vm.argument(0).to_deprecated_string(vm)); if (!text.is_empty()) { - auto new_text_node = vm.heap().allocate(realm, document, text); + auto new_text_node = MUST_OR_THROW_OOM(vm.heap().allocate(realm, document, text)); MUST(option_element->append_child(*new_text_node)); } } diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index ba8e669468..9eb018a51e 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -14,7 +14,7 @@ namespace Web::CSS { CSSFontFaceRule* CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face) { - return realm.heap().allocate(realm, realm, move(font_face)); + return realm.heap().allocate(realm, realm, move(font_face)).release_allocated_value_but_fixme_should_propagate_errors(); } CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face) diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index 3aaa7a4c37..a4bd2c95a9 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -21,7 +21,7 @@ namespace Web::CSS { CSSImportRule* CSSImportRule::create(AK::URL url, DOM::Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, move(url), document); + return realm.heap().allocate(realm, move(url), document).release_allocated_value_but_fixme_should_propagate_errors(); } CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp index 1bdd9c4a04..509e2645bc 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp @@ -14,7 +14,7 @@ namespace Web::CSS { CSSMediaRule* CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules) { - return realm.heap().allocate(realm, realm, media_queries, rules); + return realm.heap().allocate(realm, realm, media_queries, rules).release_allocated_value_but_fixme_should_propagate_errors(); } CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rules) diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp index c44e6cd39b..f6ac28a08e 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -19,7 +19,7 @@ namespace Web::CSS { CSSRuleList* CSSRuleList::create(JS::Realm& realm, JS::MarkedVector const& rules) { - auto rule_list = realm.heap().allocate(realm, realm); + auto rule_list = realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); for (auto* rule : rules) rule_list->m_rules.append(*rule); return rule_list; @@ -32,7 +32,7 @@ CSSRuleList::CSSRuleList(JS::Realm& realm) CSSRuleList* CSSRuleList::create_empty(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } JS::ThrowCompletionOr CSSRuleList::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index 3bdb6d5c3c..cb1d13d229 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -21,7 +21,7 @@ CSSStyleDeclaration::CSSStyleDeclaration(JS::Realm& realm) PropertyOwningCSSStyleDeclaration* PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector properties, HashMap custom_properties) { - return realm.heap().allocate(realm, realm, move(properties), move(custom_properties)); + return realm.heap().allocate(realm, realm, move(properties), move(custom_properties)).release_allocated_value_but_fixme_should_propagate_errors(); } PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector properties, HashMap custom_properties) @@ -41,7 +41,7 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::item(size_t index) const ElementInlineCSSStyleDeclaration* ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector properties, HashMap custom_properties) { auto& realm = element.realm(); - return realm.heap().allocate(realm, element, move(properties), move(custom_properties)); + return realm.heap().allocate(realm, element, move(properties), move(custom_properties)).release_allocated_value_but_fixme_should_propagate_errors(); } ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector properties, HashMap custom_properties) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp index b09449fe1d..792615596e 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp @@ -13,7 +13,7 @@ namespace Web::CSS { CSSStyleRule* CSSStyleRule::create(JS::Realm& realm, NonnullRefPtrVector&& selectors, CSSStyleDeclaration& declaration) { - return realm.heap().allocate(realm, realm, move(selectors), declaration); + return realm.heap().allocate(realm, realm, move(selectors), declaration).release_allocated_value_but_fixme_should_propagate_errors(); } CSSStyleRule::CSSStyleRule(JS::Realm& realm, NonnullRefPtrVector&& selectors, CSSStyleDeclaration& declaration) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index becd498153..18c5ce62c1 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -16,7 +16,7 @@ namespace Web::CSS { CSSStyleSheet* CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) { - return realm.heap().allocate(realm, realm, rules, media, move(location)); + return realm.heap().allocate(realm, realm, rules, media, move(location)).release_allocated_value_but_fixme_should_propagate_errors(); } CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp index 9214d4f03a..7289a0ae30 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp @@ -13,7 +13,7 @@ namespace Web::CSS { CSSSupportsRule* CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr&& supports, CSSRuleList& rules) { - return realm.heap().allocate(realm, realm, move(supports), rules); + return realm.heap().allocate(realm, realm, move(supports), rules).release_allocated_value_but_fixme_should_propagate_errors(); } CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr&& supports, CSSRuleList& rules) diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.cpp b/Userland/Libraries/LibWeb/CSS/MediaList.cpp index b3fbb7b59d..2999141b74 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaList.cpp @@ -14,7 +14,7 @@ namespace Web::CSS { MediaList* MediaList::create(JS::Realm& realm, NonnullRefPtrVector&& media) { - return realm.heap().allocate(realm, realm, move(media)); + return realm.heap().allocate(realm, realm, move(media)).release_allocated_value_but_fixme_should_propagate_errors(); } MediaList::MediaList(JS::Realm& realm, NonnullRefPtrVector&& media) diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp index 90f8192674..c21f4c0bc2 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp @@ -17,7 +17,7 @@ namespace Web::CSS { JS::NonnullGCPtr MediaQueryList::create(DOM::Document& document, NonnullRefPtrVector&& media) { - return document.heap().allocate(document.realm(), document, move(media)); + return document.heap().allocate(document.realm(), document, move(media)).release_allocated_value_but_fixme_should_propagate_errors(); } MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector&& media) diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp index e5f20af1dc..ed8e2bf5a6 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp @@ -12,7 +12,7 @@ namespace Web::CSS { MediaQueryListEvent* MediaQueryListEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 9e713e8871..07f3975f14 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -22,7 +22,7 @@ namespace Web::CSS { ResolvedCSSStyleDeclaration* ResolvedCSSStyleDeclaration::create(DOM::Element& element) { - return element.realm().heap().allocate(element.realm(), element); + return element.realm().heap().allocate(element.realm(), element).release_allocated_value_but_fixme_should_propagate_errors(); } ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element) diff --git a/Userland/Libraries/LibWeb/CSS/Screen.cpp b/Userland/Libraries/LibWeb/CSS/Screen.cpp index 577cc97ca5..2a4ad72df4 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.cpp +++ b/Userland/Libraries/LibWeb/CSS/Screen.cpp @@ -15,7 +15,7 @@ namespace Web::CSS { JS::NonnullGCPtr Screen::create(HTML::Window& window) { - return window.heap().allocate(window.realm(), window); + return window.heap().allocate(window.realm(), window).release_allocated_value_but_fixme_should_propagate_errors(); } Screen::Screen(HTML::Window& window) diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp index 0ac2d9a788..a770b76307 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp @@ -48,7 +48,7 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet) StyleSheetList* StyleSheetList::create(DOM::Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, document); + return realm.heap().allocate(realm, document).release_allocated_value_but_fixme_should_propagate_errors(); } StyleSheetList::StyleSheetList(DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp index 4d06755e9f..04ac2da358 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp @@ -16,7 +16,7 @@ namespace Web::Crypto { JS::NonnullGCPtr Crypto::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } Crypto::Crypto(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index 382000a712..8aefaf0427 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -16,7 +16,7 @@ namespace Web::Crypto { JS::NonnullGCPtr SubtleCrypto::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } SubtleCrypto::SubtleCrypto(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.cpp b/Userland/Libraries/LibWeb/DOM/AbortController.cpp index f306c85cfa..f2d9bc015a 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortController.cpp @@ -13,7 +13,7 @@ namespace Web::DOM { JS::NonnullGCPtr AbortController::construct_impl(JS::Realm& realm) { auto signal = AbortSignal::construct_impl(realm); - return realm.heap().allocate(realm, realm, move(signal)); + return realm.heap().allocate(realm, realm, move(signal)).release_allocated_value_but_fixme_should_propagate_errors(); } // https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp index 709b4f2a32..5b1441f1d5 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp @@ -14,7 +14,7 @@ namespace Web::DOM { JS::NonnullGCPtr AbortSignal::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } AbortSignal::AbortSignal(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp index 3b891968a2..49c5ccff49 100644 --- a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp @@ -15,7 +15,7 @@ namespace Web::DOM { JS::NonnullGCPtr AccessibilityTreeNode::create(Document* document, DOM::Node const* value) { - return *document->heap().allocate(document->realm(), value); + return *document->heap().allocate(document->realm(), value).release_allocated_value_but_fixme_should_propagate_errors(); } AccessibilityTreeNode::AccessibilityTreeNode(JS::GCPtr value) diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp index e171b68b78..92ea77512e 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp @@ -15,12 +15,12 @@ namespace Web::DOM { JS::NonnullGCPtr Attr::create(Document& document, DeprecatedFlyString local_name, DeprecatedString value, Element const* owner_element) { - return document.heap().allocate(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element); + return document.heap().allocate(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Attr::clone(Document& document) { - return *heap().allocate(realm(), document, m_qualified_name, m_value, nullptr); + return *heap().allocate(realm(), document, m_qualified_name, m_value, nullptr).release_allocated_value_but_fixme_should_propagate_errors(); } Attr::Attr(Document& document, QualifiedName qualified_name, DeprecatedString value, Element const* owner_element) diff --git a/Userland/Libraries/LibWeb/DOM/Comment.cpp b/Userland/Libraries/LibWeb/DOM/Comment.cpp index b38a2dbfba..e92cfe911a 100644 --- a/Userland/Libraries/LibWeb/DOM/Comment.cpp +++ b/Userland/Libraries/LibWeb/DOM/Comment.cpp @@ -19,7 +19,7 @@ Comment::Comment(Document& document, DeprecatedString const& data) JS::NonnullGCPtr Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data) { auto& window = verify_cast(realm.global_object()); - return realm.heap().allocate(realm, window.associated_document(), data); + return realm.heap().allocate(realm, window.associated_document(), data).release_allocated_value_but_fixme_should_propagate_errors(); } } diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp index 62632b4187..0acb715b34 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp @@ -13,7 +13,7 @@ namespace Web::DOM { CustomEvent* CustomEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, CustomEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } CustomEvent* CustomEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, CustomEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index 79bed545ed..afd63a80ff 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -20,7 +20,7 @@ namespace Web::DOM { JS::NonnullGCPtr DOMImplementation::create(Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, document); + return realm.heap().allocate(realm, document).release_allocated_value_but_fixme_should_propagate_errors(); } DOMImplementation::DOMImplementation(Document& document) @@ -84,7 +84,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(DeprecatedStr html_document->set_content_type("text/html"); html_document->set_ready_for_post_load_tasks(true); - auto doctype = heap().allocate(realm(), html_document); + auto doctype = heap().allocate(realm(), html_document).release_allocated_value_but_fixme_should_propagate_errors(); doctype->set_name("html"); MUST(html_document->append_child(*doctype)); @@ -98,7 +98,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(DeprecatedStr auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML); MUST(head_element->append_child(title_element)); - auto text_node = heap().allocate(realm(), html_document, title); + auto text_node = heap().allocate(realm(), html_document, title).release_allocated_value_but_fixme_should_propagate_errors(); MUST(title_element->append_child(*text_node)); } diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index 5cac3fa188..ff519dafeb 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -55,7 +55,7 @@ namespace Web::DOM { DOMTokenList* DOMTokenList::create(Element const& associated_element, DeprecatedFlyString associated_attribute) { auto& realm = associated_element.realm(); - return realm.heap().allocate(realm, associated_element, move(associated_attribute)); + return realm.heap().allocate(realm, associated_element, move(associated_attribute)).release_allocated_value_but_fixme_should_propagate_errors(); } // https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2 diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 9a78695bdf..b5ed5db770 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -290,7 +290,7 @@ JS::NonnullGCPtr Document::construct_impl(JS::Realm& realm) JS::NonnullGCPtr Document::create(JS::Realm& realm, AK::URL const& url) { - return realm.heap().allocate(realm, realm, url); + return realm.heap().allocate(realm, realm, url).release_allocated_value_but_fixme_should_propagate_errors(); } Document::Document(JS::Realm& realm, const AK::URL& url) @@ -687,7 +687,7 @@ void Document::set_title(DeprecatedString const& title) } title_element->remove_all_children(true); - MUST(title_element->append_child(heap().allocate(realm(), *this, title))); + MUST(title_element->append_child(heap().allocate(realm(), *this, title).release_allocated_value_but_fixme_should_propagate_errors())); if (auto* page = this->page()) { if (browsing_context() == &page->top_level_browsing_context()) @@ -1230,17 +1230,17 @@ WebIDL::ExceptionOr> Document::create_element_ns(Depre JS::NonnullGCPtr Document::create_document_fragment() { - return heap().allocate(realm(), *this); + return heap().allocate(realm(), *this).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Document::create_text_node(DeprecatedString const& data) { - return heap().allocate(realm(), *this, data); + return heap().allocate(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Document::create_comment(DeprecatedString const& data) { - return heap().allocate(realm(), *this, data); + return heap().allocate(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors(); } // https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction @@ -1251,7 +1251,7 @@ WebIDL::ExceptionOr> Document::create_pr // FIXME: 2. If data contains the string "?>", then throw an "InvalidCharacterError" DOMException. // 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this. - return JS::NonnullGCPtr { *heap().allocate(realm(), *this, data, target) }; + return MUST_OR_THROW_OOM(heap().allocate(realm(), *this, data, target)); } JS::NonnullGCPtr Document::create_range() diff --git a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp index 2853d58945..ff194862d7 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp @@ -37,7 +37,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element) JS::NonnullGCPtr DocumentFragment::construct_impl(JS::Realm& realm) { auto& window = verify_cast(realm.global_object()); - return realm.heap().allocate(realm, window.associated_document()); + return realm.heap().allocate(realm, window.associated_document()).release_allocated_value_but_fixme_should_propagate_errors(); } } diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp index 02161ac44d..e84a647b4d 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp @@ -11,7 +11,7 @@ namespace Web::DOM { JS::NonnullGCPtr DocumentType::create(Document& document) { - return document.heap().allocate(document.realm(), document); + return document.heap().allocate(document.realm(), document).release_allocated_value_but_fixme_should_propagate_errors(); } DocumentType::DocumentType(Document& document) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 144836204f..9d82cf0a79 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1180,7 +1180,7 @@ WebIDL::ExceptionOr> Element::insert_adjacent_element(Depreca WebIDL::ExceptionOr Element::insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data) { // 1. Let text be a new Text node whose data is data and node document is this’s node document. - auto text = heap().allocate(realm(), document(), data); + auto text = MUST_OR_THROW_OOM(heap().allocate(realm(), document(), data)); // 2. Run insert adjacent, given this, where, and text. // Spec Note: This method returns nothing because it existed before we had a chance to design it. diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp index 1b8bab2732..09a521b568 100644 --- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -120,180 +120,180 @@ JS::NonnullGCPtr create_element(Document& document, DeprecatedFlyString auto qualified_name = QualifiedName { local_name, prefix, namespace_ }; if (lowercase_tag_name == HTML::TagNames::a) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::area) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::audio) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::base) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::blink) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::body) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::br) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::button) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::canvas) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::data) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::datalist) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::details) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::dialog) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::dir) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::div) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::dl) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::embed) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::fieldset) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::font) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::form) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::frame) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::frameset) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::head) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::hr) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::html) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::iframe) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::img) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::input) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::label) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::legend) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::li) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::link) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::map) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::marquee) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::menu) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::meta) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::meter) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::object) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::ol) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::optgroup) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::option) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::output) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::p) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::param) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::picture) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); // NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification. if (lowercase_tag_name.is_one_of(HTML::TagNames::pre, HTML::TagNames::listing, HTML::TagNames::xmp)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::progress) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::script) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::select) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::slot) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::source) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::span) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::style) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::caption) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::table) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::tr) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::template_) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::textarea) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::time) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::title) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::track) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::ul) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == HTML::TagNames::video) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.is_one_of( HTML::TagNames::article, HTML::TagNames::section, HTML::TagNames::nav, HTML::TagNames::aside, HTML::TagNames::hgroup, HTML::TagNames::header, HTML::TagNames::footer, HTML::TagNames::address, HTML::TagNames::dt, HTML::TagNames::dd, HTML::TagNames::figure, HTML::TagNames::figcaption, HTML::TagNames::main, HTML::TagNames::em, HTML::TagNames::strong, HTML::TagNames::small, HTML::TagNames::s, HTML::TagNames::cite, HTML::TagNames::dfn, HTML::TagNames::abbr, HTML::TagNames::ruby, HTML::TagNames::rt, HTML::TagNames::rp, HTML::TagNames::code, HTML::TagNames::var, HTML::TagNames::samp, HTML::TagNames::kbd, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::i, HTML::TagNames::b, HTML::TagNames::u, HTML::TagNames::mark, HTML::TagNames::bdi, HTML::TagNames::bdo, HTML::TagNames::wbr, HTML::TagNames::summary, HTML::TagNames::noscript, // Obsolete HTML::TagNames::acronym, HTML::TagNames::basefont, HTML::TagNames::big, HTML::TagNames::center, HTML::TagNames::nobr, HTML::TagNames::noembed, HTML::TagNames::noframes, HTML::TagNames::plaintext, HTML::TagNames::rb, HTML::TagNames::rtc, HTML::TagNames::strike, HTML::TagNames::tt)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::svg) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); // FIXME: Support SVG's mixedCase tag names properly. if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::clipPath)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::circle) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::defs)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::ellipse) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::foreignObject)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::line) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::path) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::polygon) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::polyline) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::rect) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::g) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); if (lowercase_tag_name == SVG::TagNames::text) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); // FIXME: If name is a valid custom element name, then return HTMLElement. - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); } } diff --git a/Userland/Libraries/LibWeb/DOM/Event.cpp b/Userland/Libraries/LibWeb/DOM/Event.cpp index 4ee2e8f1be..796e2a7efd 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.cpp +++ b/Userland/Libraries/LibWeb/DOM/Event.cpp @@ -16,7 +16,7 @@ namespace Web::DOM { JS::NonnullGCPtr Event::create(JS::Realm& realm, DeprecatedFlyString const& event_name, EventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Event::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, EventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp index 1035dd3097..2849e7ac40 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -15,7 +15,7 @@ namespace Web::DOM { JS::NonnullGCPtr HTMLCollection::create(ParentNode& root, Function filter) { - return root.heap().allocate(root.realm(), root, move(filter)); + return root.heap().allocate(root.realm(), root, move(filter)).release_allocated_value_but_fixme_should_propagate_errors(); } HTMLCollection::HTMLCollection(ParentNode& root, Function filter) diff --git a/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp b/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp index 57c2362c74..bae25528f5 100644 --- a/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp +++ b/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp @@ -10,7 +10,7 @@ namespace Web::DOM { JS::NonnullGCPtr IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr callback) { - return realm.heap().allocate(realm, realm, move(callback)); + return realm.heap().allocate(realm, realm, move(callback)).release_allocated_value_but_fixme_should_propagate_errors(); } IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr callback) diff --git a/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp b/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp index 28c7a591a0..062dd4df20 100644 --- a/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp +++ b/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp @@ -12,7 +12,7 @@ namespace Web::DOM { JS::NonnullGCPtr LiveNodeList::create(JS::Realm& realm, Node& root, Function filter) { - return realm.heap().allocate(realm, realm, root, move(filter)); + return realm.heap().allocate(realm, realm, root, move(filter)).release_allocated_value_but_fixme_should_propagate_errors(); } LiveNodeList::LiveNodeList(JS::Realm& realm, Node& root, Function filter) diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp index fc2c9be5b0..915c74ba83 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -13,7 +13,7 @@ namespace Web::DOM { JS::NonnullGCPtr MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr callback) { - return realm.heap().allocate(realm, realm, callback); + return realm.heap().allocate(realm, realm, callback).release_allocated_value_but_fixme_should_propagate_errors(); } // https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp index 2e80f18180..2538066bd7 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp @@ -14,7 +14,7 @@ namespace Web::DOM { JS::NonnullGCPtr MutationRecord::create(JS::Realm& realm, DeprecatedFlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) { - return realm.heap().allocate(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value); + return realm.heap().allocate(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value).release_allocated_value_but_fixme_should_propagate_errors(); } MutationRecord::MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp index c834d7943a..074f9e71ee 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -16,7 +16,7 @@ namespace Web::DOM { JS::NonnullGCPtr NamedNodeMap::create(Element& element) { auto& realm = element.realm(); - return realm.heap().allocate(realm, element); + return realm.heap().allocate(realm, element).release_allocated_value_but_fixme_should_propagate_errors(); } NamedNodeMap::NamedNodeMap(Element& element) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 5c3f757812..8de25502e8 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -743,7 +743,7 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) } else if (is(this)) { // DocumentType auto document_type = verify_cast(this); - auto document_type_copy = heap().allocate(realm(), *document); + auto document_type_copy = heap().allocate(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors(); // Set copy’s name, public ID, and system ID to those of node. document_type_copy->set_name(document_type->name()); @@ -760,26 +760,26 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) auto text = verify_cast(this); // Set copy’s data to that of node. - auto text_copy = heap().allocate(realm(), *document, text->data()); + auto text_copy = heap().allocate(realm(), *document, text->data()).release_allocated_value_but_fixme_should_propagate_errors(); copy = move(text_copy); } else if (is(this)) { // Comment auto comment = verify_cast(this); // Set copy’s data to that of node. - auto comment_copy = heap().allocate(realm(), *document, comment->data()); + auto comment_copy = heap().allocate(realm(), *document, comment->data()).release_allocated_value_but_fixme_should_propagate_errors(); copy = move(comment_copy); } else if (is(this)) { // ProcessingInstruction auto processing_instruction = verify_cast(this); // Set copy’s target and data to those of node. - auto processing_instruction_copy = heap().allocate(realm(), *document, processing_instruction->data(), processing_instruction->target()); + auto processing_instruction_copy = heap().allocate(realm(), *document, processing_instruction->data(), processing_instruction->target()).release_allocated_value_but_fixme_should_propagate_errors(); copy = processing_instruction_copy; } // Otherwise, Do nothing. else if (is(this)) { - copy = heap().allocate(realm(), *document); + copy = heap().allocate(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors(); } // FIXME: 4. Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise. @@ -1179,7 +1179,7 @@ void Node::string_replace_all(DeprecatedString const& string) // 2. If string is not the empty string, then set node to a new Text node whose data is string and node document is parent’s node document. if (!string.is_empty()) - node = heap().allocate(realm(), document(), string); + node = heap().allocate(realm(), document(), string).release_allocated_value_but_fixme_should_propagate_errors(); // 3. Replace all with node within parent. replace_all(node); diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp index 760e909bd0..4b24bc9f85 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp @@ -11,7 +11,7 @@ namespace Web::DOM { JS::NonnullGCPtr NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback) { - return realm.heap().allocate(realm, realm, callback); + return realm.heap().allocate(realm, realm, callback).release_allocated_value_but_fixme_should_propagate_errors(); } NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback) diff --git a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp index 78d833c620..09955fdf02 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp @@ -53,7 +53,7 @@ JS::NonnullGCPtr NodeIterator::create(Node& root, unsigned what_to // 2. Set iterator’s root and iterator’s reference to root. // 3. Set iterator’s pointer before reference to true. auto& realm = root.realm(); - auto iterator = realm.heap().allocate(realm, root); + auto iterator = realm.heap().allocate(realm, root).release_allocated_value_but_fixme_should_propagate_errors(); // 4. Set iterator’s whatToShow to whatToShow. iterator->m_what_to_show = what_to_show; diff --git a/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp b/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp index 1ebd908e0b..91649fc8b2 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp @@ -22,19 +22,19 @@ WebIDL::ExceptionOr> convert_nodes_to_single_node(Vector< // 4. Otherwise, set node to a new DocumentFragment node whose node document is document, and then append each node in nodes, if any, to it. // 5. Return node. - auto potentially_convert_string_to_text_node = [&document](Variant, DeprecatedString> const& node) -> JS::NonnullGCPtr { + auto potentially_convert_string_to_text_node = [&document](Variant, DeprecatedString> const& node) -> JS::ThrowCompletionOr> { if (node.has>()) return *node.get>(); - return document.heap().allocate(document.realm(), document, node.get()); + return MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document, node.get())); }; if (nodes.size() == 1) - return potentially_convert_string_to_text_node(nodes.first()); + return TRY(potentially_convert_string_to_text_node(nodes.first())); - auto document_fragment = document.heap().allocate(document.realm(), document); + auto document_fragment = MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document)); for (auto& unconverted_node : nodes) { - auto node = potentially_convert_string_to_text_node(unconverted_node); + auto node = TRY(potentially_convert_string_to_text_node(unconverted_node)); (void)TRY(document_fragment->append_child(node)); } diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index 2192cea2ba..b77d973f4a 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -35,13 +35,13 @@ JS::NonnullGCPtr Range::create(HTML::Window& window) JS::NonnullGCPtr Range::create(Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, document); + return realm.heap().allocate(realm, document).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) { auto& realm = start_container.realm(); - return realm.heap().allocate(realm, start_container, start_offset, end_container, end_offset); + return realm.heap().allocate(realm, start_container, start_offset, end_container, end_offset).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Range::construct_impl(JS::Realm& realm) @@ -428,12 +428,12 @@ WebIDL::ExceptionOr Range::select_node_contents(Node const& node) JS::NonnullGCPtr Range::clone_range() const { - return heap().allocate(shape().realm(), const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset); + return heap().allocate(shape().realm(), const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Range::inverted() const { - return heap().allocate(shape().realm(), const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset); + return heap().allocate(shape().realm(), const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr Range::normalized() const @@ -587,7 +587,7 @@ WebIDL::ExceptionOr> Range::extract_contents( WebIDL::ExceptionOr> Range::extract() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. - auto fragment = heap().allocate(realm(), const_cast(start_container()->document())); + auto fragment = MUST_OR_THROW_OOM(heap().allocate(realm(), const_cast(start_container()->document()))); // 2. If range is collapsed, then return fragment. if (collapsed()) @@ -916,7 +916,7 @@ WebIDL::ExceptionOr> Range::clone_contents() WebIDL::ExceptionOr> Range::clone_the_contents() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. - auto fragment = heap().allocate(realm(), const_cast(start_container()->document())); + auto fragment = MUST_OR_THROW_OOM(heap().allocate(realm(), const_cast(start_container()->document()))); // 2. If range is collapsed, then return fragment. if (collapsed()) diff --git a/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp b/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp index 76e46ea362..db926c6187 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp @@ -11,7 +11,7 @@ namespace Web::DOM { JS::NonnullGCPtr StaticNodeList::create(JS::Realm& realm, Vector> static_nodes) { - return realm.heap().allocate(realm, realm, move(static_nodes)); + return realm.heap().allocate(realm, realm, move(static_nodes)).release_allocated_value_but_fixme_should_propagate_errors(); } StaticNodeList::StaticNodeList(JS::Realm& realm, Vector> static_nodes) diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp index 13a73fe821..1446c99117 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp @@ -32,7 +32,7 @@ WebIDL::ExceptionOr StaticRange::construct_impl(JS::Realm& realm, return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node."); // 2. Set this’s start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]). - return realm.heap().allocate(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset).ptr(); + return realm.heap().allocate(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset).release_allocated_value_but_fixme_should_propagate_errors().ptr(); } JS::ThrowCompletionOr StaticRange::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 9b99b19365..2ed109be55 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -43,7 +43,7 @@ JS::NonnullGCPtr Text::construct_impl(JS::Realm& realm, DeprecatedString c { // The new Text(data) constructor steps are to set this’s data to data and this’s node document to current global object’s associated Document. auto& window = verify_cast(HTML::current_global_object()); - return realm.heap().allocate(realm, window.associated_document(), data); + return realm.heap().allocate(realm, window.associated_document(), data).release_allocated_value_but_fixme_should_propagate_errors(); } void Text::set_owner_input_element(Badge, HTML::HTMLInputElement& input_element) @@ -69,7 +69,7 @@ WebIDL::ExceptionOr> Text::split_text(size_t offset) auto new_data = TRY(substring_data(offset, count)); // 5. Let new node be a new Text node, with the same node document as node. Set new node’s data to new data. - auto new_node = heap().allocate(realm(), document(), new_data); + auto new_node = MUST_OR_THROW_OOM(heap().allocate(realm(), document(), new_data)); // 6. Let parent be node’s parent. JS::GCPtr parent = this->parent(); diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp index d9a5c83f4d..bd4ba764cf 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp @@ -44,7 +44,7 @@ JS::NonnullGCPtr TreeWalker::create(Node& root, unsigned what_to_sho // 1. Let walker be a new TreeWalker object. // 2. Set walker’s root and walker’s current to root. auto& realm = root.realm(); - auto walker = realm.heap().allocate(realm, root); + auto walker = realm.heap().allocate(realm, root).release_allocated_value_but_fixme_should_propagate_errors(); // 3. Set walker’s whatToShow to whatToShow. walker->m_what_to_show = what_to_show; diff --git a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp index cefafb2d8f..cd5d2e03e6 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp @@ -21,7 +21,7 @@ WebIDL::ExceptionOr> parse_fragment(Depr auto& realm = context_element.realm(); auto new_children = HTML::HTMLParser::parse_html_fragment(context_element, markup); - auto fragment = realm.heap().allocate(realm, context_element.document()); + auto fragment = MUST_OR_THROW_OOM(realm.heap().allocate(realm, context_element.document())); for (auto& child : new_children) { // I don't know if this can throw here, but let's be safe. diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index 3066f16798..c4a8513d47 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -22,7 +22,7 @@ namespace Web::DOMParsing { JS::NonnullGCPtr XMLSerializer::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return (realm.heap().allocate(realm, realm)).release_allocated_value_but_fixme_should_propagate_errors(); } XMLSerializer::XMLSerializer(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp index 63289d0152..5426b24d09 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp @@ -18,7 +18,7 @@ WebIDL::ExceptionOr> TextDecoder::construct_impl(J if (!decoder) return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Invalid encoding {}", encoding) }; - return realm.heap().allocate(realm, realm, *decoder, move(encoding), false, false); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *decoder, move(encoding), false, false)); } // https://encoding.spec.whatwg.org/#dom-textdecoder diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp index 174b976cda..d673df6dfe 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp @@ -13,7 +13,7 @@ namespace Web::Encoding { JS::NonnullGCPtr TextEncoder::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } TextEncoder::TextEncoder(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp index 58e1f81efb..15765ea6e1 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp @@ -43,12 +43,12 @@ WebIDL::ExceptionOr extract_body(JS::Realm& realm, else if (auto const* blob_handle = object.get_pointer>()) { // FIXME: "set stream to the result of running object’s get stream" (void)blob_handle; - stream = realm.heap().allocate(realm, realm); + stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); } // 4. Otherwise, set stream to a new ReadableStream object, and set up stream. else { // FIXME: "set up stream" - stream = realm.heap().allocate(realm, realm); + stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); } // 5. Assert: stream is a ReadableStream object. diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.cpp b/Userland/Libraries/LibWeb/Fetch/Headers.cpp index f6daf4340c..0441b5d8d8 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Headers.cpp @@ -17,7 +17,7 @@ WebIDL::ExceptionOr> Headers::construct_impl(JS::Realm auto& vm = realm.vm(); // The new Headers(init) constructor steps are: - auto headers = realm.heap().allocate(realm, realm, Infrastructure::HeaderList::create(vm)); + auto headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, Infrastructure::HeaderList::create(vm))); // 1. Set this’s guard to "none". headers->m_guard = Guard::None; diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp index 48b5cfa3ad..230d021f79 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -15,7 +15,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm); + auto prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); m_prototypes.set("HeadersIterator"sv, prototype); } @@ -25,7 +25,7 @@ namespace Web::Fetch { JS::NonnullGCPtr HeadersIterator::create(Headers const& headers, JS::Object::PropertyKind iteration_kind) { - return headers.heap().allocate(headers.realm(), headers, iteration_kind); + return headers.heap().allocate(headers.realm(), headers, iteration_kind).release_allocated_value_but_fixme_should_propagate_errors(); } HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind) diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp index 806c867b96..4282d35bda 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp @@ -34,7 +34,7 @@ WebIDL::ExceptionOr Body::clone() const // FIXME: 1. Let « out1, out2 » be the result of teeing body’s stream. // FIXME: 2. Set body’s stream to out1. - auto out2 = vm.heap().allocate(realm, realm); + auto out2 = MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm)); // 3. Return a body whose stream is out2 and other members are copied from body. return Body { JS::make_handle(out2), m_source, m_length }; diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp index 9134ba018b..93d6e1fc17 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -85,14 +85,14 @@ JS::NonnullGCPtr Request::create(JS::Realm& realm, JS::NonnullGCPtr(realm, realm, request); + auto request_object = realm.heap().allocate(realm, realm, request).release_allocated_value_but_fixme_should_propagate_errors(); // 3. Set requestObject’s headers to a new Headers object with realm, whose headers list is request’s headers list and guard is guard. - request_object->m_headers = realm.heap().allocate(realm, realm, request->header_list()); + request_object->m_headers = realm.heap().allocate(realm, realm, request->header_list()).release_allocated_value_but_fixme_should_propagate_errors(); request_object->m_headers->set_guard(guard); // 4. Set requestObject’s signal to a new AbortSignal object with realm. - request_object->m_signal = realm.heap().allocate(realm, realm); + request_object->m_signal = realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); // 5. Return requestObject. return request_object; @@ -104,7 +104,7 @@ WebIDL::ExceptionOr> Request::construct_impl(JS::Realm auto& vm = realm.vm(); // Referred to as 'this' in the spec. - auto request_object = realm.heap().allocate(realm, realm, Infrastructure::Request::create(vm)); + auto request_object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, Infrastructure::Request::create(vm))); // 1. Let request be null. JS::GCPtr input_request; @@ -389,14 +389,14 @@ WebIDL::ExceptionOr> Request::construct_impl(JS::Realm // 28. Set this’s signal to a new AbortSignal object with this’s relevant Realm. auto& this_relevant_realm = HTML::relevant_realm(*request_object); - request_object->m_signal = realm.heap().allocate(this_relevant_realm, this_relevant_realm); + request_object->m_signal = MUST_OR_THROW_OOM(realm.heap().allocate(this_relevant_realm, this_relevant_realm)); // 29. If signal is not null, then make this’s signal follow signal. if (input_signal != nullptr) request_object->m_signal->follow(*input_signal); // 30. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is request’s header list and guard is "request". - request_object->m_headers = realm.heap().allocate(realm, realm, request->header_list()); + request_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, request->header_list())); request_object->m_headers->set_guard(Headers::Guard::Request); // 31. If this’s request’s mode is "no-cors", then: diff --git a/Userland/Libraries/LibWeb/Fetch/Response.cpp b/Userland/Libraries/LibWeb/Fetch/Response.cpp index 1348afac88..0f68b57111 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Response.cpp @@ -77,10 +77,10 @@ JS::NonnullGCPtr Response::create(JS::Realm& realm, JS::NonnullGCPtr(realm, realm, response); + auto response_object = realm.heap().allocate(realm, realm, response).release_allocated_value_but_fixme_should_propagate_errors(); // 3. Set responseObject’s headers to a new Headers object with realm, whose headers list is response’s headers list and guard is guard. - response_object->m_headers = realm.heap().allocate(realm, realm, response->header_list()); + response_object->m_headers = realm.heap().allocate(realm, realm, response->header_list()).release_allocated_value_but_fixme_should_propagate_errors(); response_object->m_headers->set_guard(guard); // 4. Return responseObject. @@ -136,14 +136,14 @@ WebIDL::ExceptionOr> Response::construct_impl(JS::Rea auto& vm = realm.vm(); // Referred to as 'this' in the spec. - auto response_object = realm.heap().allocate(realm, realm, Infrastructure::Response::create(vm)); + auto response_object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, Infrastructure::Response::create(vm))); // 1. Set this’s response to a new response. // NOTE: This is done at the beginning as the 'this' value Response object // cannot exist with a null Infrastructure::Response. // 2. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is this’s response’s header list and guard is "response". - response_object->m_headers = realm.heap().allocate(realm, realm, response_object->response()->header_list()); + response_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, response_object->response()->header_list())); response_object->m_headers->set_guard(Headers::Guard::Response); // 3. Let bodyWithType be null. diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index 673ff7cc17..f9690dd243 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -17,7 +17,7 @@ namespace Web::FileAPI { JS::NonnullGCPtr Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type) { - return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)); + return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)).release_allocated_value_but_fixme_should_propagate_errors(); } // https://w3c.github.io/FileAPI/#convert-line-endings-to-native @@ -145,7 +145,7 @@ WebIDL::ExceptionOr> Blob::create(JS::Realm& realm, Optio { // 1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string. if (!blob_parts.has_value() && !options.has_value()) - return realm.heap().allocate(realm, realm); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); ByteBuffer byte_buffer {}; // 2. Let bytes be the result of processing blob parts given blobParts and options. @@ -170,7 +170,7 @@ WebIDL::ExceptionOr> Blob::create(JS::Realm& realm, Optio } // 4. Return a Blob object referring to bytes as its associated byte sequence, with its size set to the length of bytes, and its type set to the value of t from the substeps above. - return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(byte_buffer), move(type))); } WebIDL::ExceptionOr> Blob::construct_impl(JS::Realm& realm, Optional> const& blob_parts, Optional const& options) @@ -239,7 +239,7 @@ WebIDL::ExceptionOr> Blob::slice(Optional start, Opt // b. S.size = span. // c. S.type = relativeContentType. auto byte_buffer = TRY_OR_THROW_OOM(realm().vm(), m_byte_buffer.slice(relative_start, span)); - return heap().allocate(realm(), realm(), move(byte_buffer), move(relative_content_type)); + return MUST_OR_THROW_OOM(heap().allocate(realm(), realm(), move(byte_buffer), move(relative_content_type))); } // https://w3c.github.io/FileAPI/#dom-blob-text diff --git a/Userland/Libraries/LibWeb/FileAPI/File.cpp b/Userland/Libraries/LibWeb/FileAPI/File.cpp index 4b569d22e5..cf1efb009d 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/File.cpp @@ -66,7 +66,7 @@ WebIDL::ExceptionOr> File::create(JS::Realm& realm, Vecto // 4. F.name is set to n. // 5. F.type is set to t. // 6. F.lastModified is set to d. - return realm.heap().allocate(realm, realm, move(bytes), move(name), move(type), last_modified); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(bytes), move(name), move(type), last_modified)); } WebIDL::ExceptionOr> File::construct_impl(JS::Realm& realm, Vector const& file_bits, DeprecatedString const& file_name, Optional const& options) diff --git a/Userland/Libraries/LibWeb/FileAPI/FileList.cpp b/Userland/Libraries/LibWeb/FileAPI/FileList.cpp index 96f4973a62..a0f610a849 100644 --- a/Userland/Libraries/LibWeb/FileAPI/FileList.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/FileList.cpp @@ -13,7 +13,7 @@ namespace Web::FileAPI { JS::NonnullGCPtr FileList::create(JS::Realm& realm, Vector>&& files) { - return realm.heap().allocate(realm, realm, move(files)); + return realm.heap().allocate(realm, realm, move(files)).release_allocated_value_but_fixme_should_propagate_errors(); } FileList::FileList(JS::Realm& realm, Vector>&& files) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index 20a091c77e..667ad56942 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -12,7 +12,7 @@ namespace Web::Geometry { JS::NonnullGCPtr DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { - return realm.heap().allocate(realm, realm, x, y, z, w); + return realm.heap().allocate(realm, realm, x, y, z, w).release_allocated_value_but_fixme_should_propagate_errors(); } DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp index bbef19a0dd..325d91187a 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp @@ -12,7 +12,7 @@ namespace Web::Geometry { JS::NonnullGCPtr DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { - return realm.heap().allocate(realm, realm, x, y, z, w); + return realm.heap().allocate(realm, realm, x, y, z, w).release_allocated_value_but_fixme_should_propagate_errors(); } DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double z, double w) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp index 54415fa7f0..a85a2beab3 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp @@ -11,7 +11,7 @@ namespace Web::Geometry { JS::NonnullGCPtr DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height) { - return realm.heap().allocate(realm, realm, x, y, width, height); + return realm.heap().allocate(realm, realm, x, y, width, height).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp index 14e5bc4e57..788e6ce56c 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp @@ -16,7 +16,7 @@ JS::NonnullGCPtr DOMRectList::create(JS::Realm& realm, Vector> rects; for (auto& rect : rect_handles) rects.append(*rect); - return realm.heap().allocate(realm, realm, move(rects)); + return realm.heap().allocate(realm, realm, move(rects)).release_allocated_value_but_fixme_should_propagate_errors(); } DOMRectList::DOMRectList(JS::Realm& realm, Vector> rects) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp index a583d500fc..bdc6c64695 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp @@ -11,7 +11,7 @@ namespace Web::Geometry { JS::NonnullGCPtr DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height) { - return realm.heap().allocate(realm, realm, x, y, width, height); + return realm.heap().allocate(realm, realm, x, y, width, height).release_allocated_value_but_fixme_should_propagate_errors(); } DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double width, double height) diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 5ef739105f..1493d5f915 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -115,7 +115,7 @@ JS::NonnullGCPtr BrowsingContext::create_a_new_browsing_context auto realm_execution_context = Bindings::create_a_new_javascript_realm( Bindings::main_thread_vm(), [&](JS::Realm& realm) -> JS::Object* { - browsing_context->m_window_proxy = realm.heap().allocate(realm, realm); + browsing_context->m_window_proxy = realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); // - For the global object, create a new Window object. window = HTML::Window::create(realm); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index c7d07f7849..8b65697dea 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -22,21 +22,21 @@ WebIDL::ExceptionOr> CanvasGradient::create_rad return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"); auto radial_gradient = Gfx::CanvasRadialGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, r0, Gfx::FloatPoint { x1, y1 }, r1); - return realm.heap().allocate(realm, realm, *radial_gradient); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *radial_gradient)); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient JS::NonnullGCPtr CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1) { auto linear_gradient = Gfx::CanvasLinearGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, Gfx::FloatPoint { x1, y1 }); - return realm.heap().allocate(realm, realm, *linear_gradient); + return realm.heap().allocate(realm, realm, *linear_gradient).release_allocated_value_but_fixme_should_propagate_errors(); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient JS::NonnullGCPtr CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y) { auto conic_gradient = Gfx::CanvasConicGradientPaintStyle::create(Gfx::FloatPoint { x, y }, start_angle); - return realm.heap().allocate(realm, realm, *conic_gradient); + return realm.heap().allocate(realm, realm, *conic_gradient).release_allocated_value_but_fixme_should_propagate_errors(); } CanvasGradient::CanvasGradient(JS::Realm& realm, Gfx::GradientPaintStyle& gradient) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index ae0018375c..793144d370 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -26,7 +26,7 @@ namespace Web::HTML { JS::NonnullGCPtr CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element) { - return realm.heap().allocate(realm, realm, element); + return realm.heap().allocate(realm, realm, element).release_allocated_value_but_fixme_should_propagate_errors(); } CanvasRenderingContext2D::CanvasRenderingContext2D(JS::Realm& realm, HTMLCanvasElement& element) diff --git a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp index 866fd6cf9f..7bcf7361c5 100644 --- a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { CloseEvent* CloseEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, CloseEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } CloseEvent* CloseEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, CloseEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp index a89e927b11..df7abd5fab 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp @@ -15,7 +15,7 @@ namespace Web::HTML { WebIDL::ExceptionOr> DOMParser::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); } DOMParser::DOMParser(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index 19729c5d66..19d1a7b7da 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -15,7 +15,7 @@ namespace Web::HTML { JS::NonnullGCPtr DOMStringMap::create(DOM::Element& element) { auto& realm = element.realm(); - return realm.heap().allocate(realm, element); + return realm.heap().allocate(realm, element).release_allocated_value_but_fixme_should_propagate_errors(); } DOMStringMap::DOMStringMap(DOM::Element& element) diff --git a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp index 8e2f4669df..81b3cb0618 100644 --- a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { ErrorEvent* ErrorEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } ErrorEvent* ErrorEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 4cbcf333c4..8fa2fcf654 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -382,13 +382,13 @@ void HTMLInputElement::create_shadow_tree_if_needed() break; } - auto shadow_root = heap().allocate(realm(), document(), *this); + auto shadow_root = heap().allocate(realm(), document(), *this).release_allocated_value_but_fixme_should_propagate_errors(); auto initial_value = m_value; if (initial_value.is_null()) initial_value = DeprecatedString::empty(); auto element = document().create_element(HTML::TagNames::div).release_value(); MUST(element->set_attribute(HTML::AttributeNames::style, "white-space: pre; padding-top: 1px; padding-bottom: 1px; padding-left: 2px; padding-right: 2px")); - m_text_node = heap().allocate(realm(), document(), initial_value); + m_text_node = heap().allocate(realm(), document(), initial_value).release_allocated_value_but_fixme_should_propagate_errors(); m_text_node->set_always_editable(m_type != TypeAttributeState::FileUpload); m_text_node->set_owner_input_element({}, *this); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index c832827131..65d3e80522 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -15,7 +15,7 @@ namespace Web::HTML { JS::NonnullGCPtr HTMLOptionsCollection::create(DOM::ParentNode& root, Function filter) { - return root.heap().allocate(root.realm(), root, move(filter)); + return root.heap().allocate(root.realm(), root, move(filter)).release_allocated_value_but_fixme_should_propagate_errors(); } HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function filter) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index 47df82e552..f52db5b2f2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -22,7 +22,7 @@ JS::ThrowCompletionOr HTMLTemplateElement::initialize(JS::Realm& realm) MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLTemplateElement")); - m_content = heap().allocate(realm, m_document->appropriate_template_contents_owner_document()); + m_content = MUST_OR_THROW_OOM(heap().allocate(realm, m_document->appropriate_template_contents_owner_document())); m_content->set_host(this); return {}; diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 36817a6969..9d30f7e226 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -12,7 +12,7 @@ namespace Web::HTML { JS::NonnullGCPtr History::create(JS::Realm& realm, DOM::Document& document) { - return realm.heap().allocate(realm, realm, document); + return realm.heap().allocate(realm, realm, document).release_allocated_value_but_fixme_should_propagate_errors(); } History::History(JS::Realm& realm, DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.cpp b/Userland/Libraries/LibWeb/HTML/ImageData.cpp index 7b2df06eac..d086fe97fd 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageData.cpp @@ -28,7 +28,7 @@ JS::GCPtr ImageData::create_with_size(JS::Realm& realm, int width, in auto bitmap_or_error = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), data->data().data()); if (bitmap_or_error.is_error()) return nullptr; - return realm.heap().allocate(realm, realm, bitmap_or_error.release_value(), move(data)); + return realm.heap().allocate(realm, realm, bitmap_or_error.release_value(), move(data)).release_allocated_value_but_fixme_should_propagate_errors(); } ImageData::ImageData(JS::Realm& realm, NonnullRefPtr bitmap, JS::NonnullGCPtr data) diff --git a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp index a027cb0f95..1371d63877 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp @@ -13,7 +13,7 @@ namespace Web::HTML { JS::NonnullGCPtr MessageChannel::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } MessageChannel::MessageChannel(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp index 455b84b8d1..4aaba0bc05 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { MessageEvent* MessageEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } MessageEvent* MessageEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index 65eb830882..48d83203fc 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -16,7 +16,7 @@ namespace Web::HTML { JS::NonnullGCPtr MessagePort::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } MessagePort::MessagePort(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.cpp b/Userland/Libraries/LibWeb/HTML/Navigator.cpp index d862e63d45..67d361db7d 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigator.cpp @@ -17,7 +17,7 @@ namespace Web::HTML { JS::NonnullGCPtr Navigator::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } Navigator::Navigator(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp index 7b46fb9a60..e47afddcf4 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { PageTransitionEvent* PageTransitionEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, PageTransitionEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } PageTransitionEvent* PageTransitionEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, PageTransitionEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 78878c422a..8857bd4dd7 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -462,13 +462,13 @@ void HTMLParser::handle_initial(HTMLToken& token) } if (token.is_comment()) { - auto comment = realm().heap().allocate(realm(), document(), token.comment()); + auto comment = realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); MUST(document().append_child(*comment)); return; } if (token.is_doctype()) { - auto doctype = realm().heap().allocate(realm(), document()); + auto doctype = realm().heap().allocate(realm(), document()).release_allocated_value_but_fixme_should_propagate_errors(); doctype->set_name(token.doctype_data().name); doctype->set_public_id(token.doctype_data().public_identifier); doctype->set_system_id(token.doctype_data().system_identifier); @@ -497,7 +497,7 @@ void HTMLParser::handle_before_html(HTMLToken& token) // -> A comment token if (token.is_comment()) { // Insert a comment as the last child of the Document object. - auto comment = realm().heap().allocate(realm(), document(), token.comment()); + auto comment = realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); MUST(document().append_child(*comment)); return; } @@ -759,7 +759,7 @@ AnythingElse: void HTMLParser::insert_comment(HTMLToken& token) { auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); - adjusted_insertion_location.parent->insert_before(realm().heap().allocate(realm(), document(), token.comment()), adjusted_insertion_location.insert_before_sibling); + adjusted_insertion_location.parent->insert_before(realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(), adjusted_insertion_location.insert_before_sibling); } void HTMLParser::handle_in_head(HTMLToken& token) @@ -945,7 +945,7 @@ DOM::Text* HTMLParser::find_character_insertion_node() return nullptr; if (adjusted_insertion_location.parent->last_child() && adjusted_insertion_location.parent->last_child()->is_text()) return verify_cast(adjusted_insertion_location.parent->last_child()); - auto new_text_node = realm().heap().allocate(realm(), document(), ""); + auto new_text_node = realm().heap().allocate(realm(), document(), "").release_allocated_value_but_fixme_should_propagate_errors(); MUST(adjusted_insertion_location.parent->append_child(*new_text_node)); return new_text_node; } @@ -1071,7 +1071,7 @@ void HTMLParser::handle_after_body(HTMLToken& token) if (token.is_comment()) { auto& insertion_location = m_stack_of_open_elements.first(); - MUST(insertion_location.append_child(realm().heap().allocate(realm(), document(), token.comment()))); + MUST(insertion_location.append_child(realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors())); return; } @@ -1107,7 +1107,7 @@ void HTMLParser::handle_after_body(HTMLToken& token) void HTMLParser::handle_after_after_body(HTMLToken& token) { if (token.is_comment()) { - auto comment = realm().heap().allocate(realm(), document(), token.comment()); + auto comment = realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); MUST(document().append_child(*comment)); return; } @@ -3181,7 +3181,7 @@ void HTMLParser::handle_after_frameset(HTMLToken& token) void HTMLParser::handle_after_after_frameset(HTMLToken& token) { if (token.is_comment()) { - auto comment = document().heap().allocate(document().realm(), document(), token.comment()); + auto comment = document().heap().allocate(document().realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); MUST(document().append_child(comment)); return; } diff --git a/Userland/Libraries/LibWeb/HTML/Path2D.cpp b/Userland/Libraries/LibWeb/HTML/Path2D.cpp index f4910ad59e..696cd28bd7 100644 --- a/Userland/Libraries/LibWeb/HTML/Path2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/Path2D.cpp @@ -14,7 +14,7 @@ namespace Web::HTML { JS::NonnullGCPtr Path2D::construct_impl(JS::Realm& realm, Optional, DeprecatedString>> const& path) { - return realm.heap().allocate(realm, realm, path); + return realm.heap().allocate(realm, realm, path).release_allocated_value_but_fixme_should_propagate_errors(); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-path2d diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp index 96faaab3a2..fe9db95293 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { PromiseRejectionEvent* PromiseRejectionEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } PromiseRejectionEvent* PromiseRejectionEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp index a81eb658eb..f060ad2c47 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp @@ -38,7 +38,7 @@ JS::GCPtr JavaScriptModuleScript::create(DeprecatedStrin auto& realm = settings_object.realm(); // 2. Let script be a new module script that this algorithm will subsequently initialize. - auto script = realm.heap().allocate(realm, move(base_url), filename, settings_object); + auto script = realm.heap().allocate(realm, move(base_url), filename, settings_object).release_allocated_value_but_fixme_should_propagate_errors(); // 3. Set script's settings object to settings. // NOTE: This was already done when constructing. diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index ff8585c6ee..870486944b 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -38,7 +38,7 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull // 3. Let settings object be a new environment settings object whose algorithms are defined as follows: // NOTE: See the functions defined for this class. - auto settings_object = realm->heap().allocate(*realm, window, move(execution_context)); + auto settings_object = realm->heap().allocate(*realm, window, move(execution_context)).release_allocated_value_but_fixme_should_propagate_errors(); // 4. If reservedEnvironment is non-null, then: if (reserved_environment.has_value()) { @@ -71,7 +71,7 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull // 7. Set realm's [[HostDefined]] field to settings object. // Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object - auto intrinsics = realm->heap().allocate(*realm, *realm); + auto intrinsics = realm->heap().allocate(*realm, *realm).release_allocated_value_but_fixme_should_propagate_errors(); auto host_defined = make(settings_object, intrinsics); realm->set_host_defined(move(host_defined)); diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h index 28136f3f06..57226e3a68 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h @@ -27,10 +27,10 @@ public: { auto* realm = execution_context->realm; VERIFY(realm); - auto settings_object = realm->heap().allocate(*realm, move(execution_context)); + auto settings_object = realm->heap().allocate(*realm, move(execution_context)).release_allocated_value_but_fixme_should_propagate_errors(); settings_object->target_browsing_context = nullptr; - auto intrinsics = realm->heap().allocate(*realm, *realm); + auto intrinsics = realm->heap().allocate(*realm, *realm).release_allocated_value_but_fixme_should_propagate_errors(); auto host_defined = make(settings_object, intrinsics); realm->set_host_defined(move(host_defined)); diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp index ca325205c8..e258a44a49 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp @@ -12,7 +12,7 @@ namespace Web::HTML { JS::NonnullGCPtr Storage::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } Storage::Storage(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp index f25bdcbccc..3310d1b622 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { SubmitEvent* SubmitEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, SubmitEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } SubmitEvent* SubmitEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, SubmitEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp index acd6002399..0f21286fe6 100644 --- a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp +++ b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { JS::NonnullGCPtr TextMetrics::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } TextMetrics::TextMetrics(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 95e4ba3f84..b49cba669f 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -88,7 +88,7 @@ private: JS::NonnullGCPtr Window::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } Window::Window(JS::Realm& realm) @@ -115,14 +115,14 @@ Window::~Window() = default; HighResolutionTime::Performance& Window::performance() { if (!m_performance) - m_performance = heap().allocate(realm(), *this); + m_performance = heap().allocate(realm(), *this).release_allocated_value_but_fixme_should_propagate_errors(); return *m_performance; } CSS::Screen& Window::screen() { if (!m_screen) - m_screen = heap().allocate(realm(), *this); + m_screen = heap().allocate(realm(), *this).release_allocated_value_but_fixme_should_propagate_errors(); return *m_screen; } @@ -1133,7 +1133,7 @@ void Window::initialize_web_interfaces(Badge) define_native_accessor(realm, "outerWidth", outer_width_getter, {}, attr); define_native_accessor(realm, "outerHeight", outer_height_getter, {}, attr); - define_direct_property("CSS", heap().allocate(realm, realm), 0); + define_direct_property("CSS", heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(), 0); define_native_accessor(realm, "localStorage", local_storage_getter, {}, attr); define_native_accessor(realm, "sessionStorage", session_storage_getter, {}, attr); @@ -1143,9 +1143,9 @@ void Window::initialize_web_interfaces(Badge) // Legacy define_native_accessor(realm, "event", event_getter, event_setter, JS::Attribute::Enumerable); - m_location = heap().allocate(realm, realm); + m_location = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); - m_navigator = heap().allocate(realm, realm); + m_navigator = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); define_direct_property("navigator", m_navigator, JS::Attribute::Enumerable | JS::Attribute::Configurable); define_direct_property("clientInformation", m_navigator, JS::Attribute::Enumerable | JS::Attribute::Configurable); @@ -1153,7 +1153,7 @@ void Window::initialize_web_interfaces(Badge) define_native_accessor(realm, "location", location_getter, location_setter, JS::Attribute::Enumerable); // WebAssembly "namespace" - define_direct_property("WebAssembly", heap().allocate(realm, realm), JS::Attribute::Enumerable | JS::Attribute::Configurable); + define_direct_property("WebAssembly", heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(), JS::Attribute::Enumerable | JS::Attribute::Configurable); // HTML::GlobalEventHandlers and HTML::WindowEventHandlers #define __ENUMERATE(attribute, event_name) \ diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 8581c58c47..caee45dc91 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -77,7 +77,7 @@ WebIDL::ExceptionOr> Worker::create(DeprecatedFlyString // 5. Let worker URL be the resulting URL record. // 6. Let worker be a new Worker object. - auto worker = document.heap().allocate(document.realm(), script_url, options, document); + auto worker = MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), script_url, options, document)); // 7. Let outside port be a new MessagePort in outside settings's Realm. auto outside_port = MessagePort::create(outside_settings.realm()); diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp index 0eadfd0fd8..e43ef7b7b1 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp @@ -13,7 +13,7 @@ namespace Web::HTML { JS::NonnullGCPtr WorkerNavigator::create(WorkerGlobalScope& global_scope) { - return global_scope.heap().allocate(global_scope.realm(), global_scope); + return global_scope.heap().allocate(global_scope.realm(), global_scope).release_allocated_value_but_fixme_should_propagate_errors(); } WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope) diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp index 6cd4f31b68..eaf62f55d7 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -40,7 +40,7 @@ void Performance::visit_edges(Cell::Visitor& visitor) JS::GCPtr Performance::timing() { if (!m_timing) - m_timing = heap().allocate(realm(), *m_window); + m_timing = heap().allocate(realm(), *m_window).release_allocated_value_but_fixme_should_propagate_errors(); return m_timing; } diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp index 1458414f92..0b7c3ddf56 100644 --- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp +++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp @@ -17,7 +17,7 @@ JS::NonnullGCPtr IntersectionObserver::construct_impl(JS:: (void)callback; (void)options; - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } IntersectionObserver::IntersectionObserver(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 7a01fb4803..659bff0487 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -171,7 +171,7 @@ ErrorOr TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element pseudo_element_node->set_generated(true); // FIXME: Handle images, and multiple values if (pseudo_element_content.type == CSS::ContentData::Type::String) { - auto text = document.heap().allocate(document.realm(), document, pseudo_element_content.data); + auto text = document.heap().allocate(document.realm(), document, pseudo_element_content.data).release_allocated_value_but_fixme_should_propagate_errors(); auto text_node = document.heap().allocate_without_realm(document, *text); text_node->set_generated(true); push_parent(verify_cast(*pseudo_element_node)); @@ -302,7 +302,7 @@ ErrorOr TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder:: auto placeholder_style = TRY(style_computer.compute_style(input_element, CSS::Selector::PseudoElement::Placeholder)); auto placeholder = DOM::Element::create_layout_node_for_display_type(document, placeholder_style->display(), placeholder_style, nullptr); - auto text = document.heap().allocate(document.realm(), document, *placeholder_value); + auto text = document.heap().allocate(document.realm(), document, *placeholder_value).release_allocated_value_but_fixme_should_propagate_errors(); auto text_node = document.heap().allocate_without_realm(document, *text); text_node->set_generated(true); diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index 5b89243886..25d585a646 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -142,7 +142,7 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data MUST(head_element->append_child(title_element)); auto basename = LexicalPath::basename(document.url().path()); - auto title_text = document.heap().allocate(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())); + auto title_text = document.heap().allocate(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())).release_allocated_value_but_fixme_should_propagate_errors(); MUST(title_element->append_child(*title_text)); auto body_element = document.create_element("body").release_value(); diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp index 0d79753c58..62f2234ee6 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp @@ -14,7 +14,7 @@ namespace Web::RequestIdleCallback { JS::NonnullGCPtr IdleDeadline::create(JS::Realm& realm, bool did_timeout) { - return realm.heap().allocate(realm, realm, did_timeout); + return realm.heap().allocate(realm, realm, did_timeout).release_allocated_value_but_fixme_should_propagate_errors(); } IdleDeadline::IdleDeadline(JS::Realm& realm, bool did_timeout) diff --git a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp index 4e6e692908..05360dfca8 100644 --- a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp +++ b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp @@ -15,7 +15,7 @@ JS::NonnullGCPtr ResizeObserver::construct_impl(JS::Realm& realm { // FIXME: Implement (void)callback; - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } ResizeObserver::ResizeObserver(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp index 93e84234bc..9dd26537c4 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -11,7 +11,7 @@ namespace Web::SVG { JS::NonnullGCPtr SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) { - return realm.heap().allocate(realm, realm, move(base_val), move(anim_val)); + return realm.heap().allocate(realm, realm, move(base_val), move(anim_val)).release_allocated_value_but_fixme_should_propagate_errors(); } SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp index acd2e386fd..56f6f6e537 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp @@ -11,7 +11,7 @@ namespace Web::SVG { JS::NonnullGCPtr SVGLength::create(JS::Realm& realm, u8 unit_type, float value) { - return realm.heap().allocate(realm, realm, unit_type, value); + return realm.heap().allocate(realm, realm, unit_type, value).release_allocated_value_but_fixme_should_propagate_errors(); } SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value) diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 2d7695d6b4..45297716f1 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -13,7 +13,7 @@ namespace Web::Selection { JS::NonnullGCPtr Selection::create(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) { - return realm->heap().allocate(realm, realm, document); + return realm->heap().allocate(realm, realm, document).release_allocated_value_but_fixme_should_propagate_errors(); } Selection::Selection(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp index 9da7c0cd84..8cc89d00b9 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -14,7 +14,7 @@ namespace Web::Streams { // https://streams.spec.whatwg.org/#rs-constructor WebIDL::ExceptionOr> ReadableStream::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); } ReadableStream::ReadableStream(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp index 10e05fb181..b5f4360e23 100644 --- a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp @@ -11,7 +11,7 @@ namespace Web::UIEvents { FocusEvent* FocusEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, FocusEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } FocusEvent::FocusEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, FocusEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp index 37b0f642cb..da4065cf3e 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp @@ -106,7 +106,7 @@ bool KeyboardEvent::get_modifier_state(DeprecatedString const& key_arg) KeyboardEvent* KeyboardEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } KeyboardEvent* KeyboardEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 0f9a593841..ed5de392e3 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -58,7 +58,7 @@ static i16 determine_button(unsigned mouse_button) MouseEvent* MouseEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, MouseEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } MouseEvent* MouseEvent::create_from_platform_event(JS::Realm& realm, DeprecatedFlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button) diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp index 06bbf93b0d..db7b991ab5 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp @@ -11,12 +11,12 @@ namespace Web::UIEvents { UIEvent* UIEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name) { - return realm.heap().allocate(realm, realm, event_name); + return realm.heap().allocate(realm, realm, event_name).release_allocated_value_but_fixme_should_propagate_errors(); } UIEvent* UIEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name) diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp index 5001070427..cdfaeb56fc 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp @@ -32,7 +32,7 @@ JS::ThrowCompletionOr WheelEvent::initialize(JS::Realm& realm) WheelEvent* WheelEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } WheelEvent* WheelEvent::create_from_platform_event(JS::Realm& realm, DeprecatedFlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button) diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index 5aefd55fa3..ecdd6a9e67 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -15,7 +15,7 @@ namespace Web::URL { JS::NonnullGCPtr URL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr query) { - return realm.heap().allocate(realm, realm, move(url), move(query)); + return realm.heap().allocate(realm, realm, move(url), move(query)).release_allocated_value_but_fixme_should_propagate_errors(); } WebIDL::ExceptionOr> URL::construct_impl(JS::Realm& realm, DeprecatedString const& url, DeprecatedString const& base) diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index c31e068ae5..1d4eaa7f50 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -91,7 +91,7 @@ Vector url_decode(StringView input) JS::NonnullGCPtr URLSearchParams::create(JS::Realm& realm, Vector list) { - return realm.heap().allocate(realm, realm, move(list)); + return realm.heap().allocate(realm, realm, move(list)).release_allocated_value_but_fixme_should_propagate_errors(); } // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp index 2ac44893fe..8adb432af7 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp @@ -15,7 +15,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm); + auto prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); m_prototypes.set("URLSearchParamsIterator"sv, prototype); } @@ -25,7 +25,7 @@ namespace Web::URL { JS::NonnullGCPtr URLSearchParamsIterator::create(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind) { - return url_search_params.heap().allocate(url_search_params.realm(), url_search_params, iteration_kind); + return url_search_params.heap().allocate(url_search_params.realm(), url_search_params, iteration_kind).release_allocated_value_but_fixme_should_propagate_errors(); } URLSearchParamsIterator::URLSearchParamsIterator(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp index 373b5425d5..a733b94fa8 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp @@ -36,7 +36,7 @@ JS::ThrowCompletionOr> WebAssemblyInstanceConstruct return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Module"); auto& module_object = static_cast(*module_argument); auto result = TRY(WebAssemblyObject::instantiate_module(vm, module_object.module())); - return heap().allocate(realm, realm, result); + return MUST_OR_THROW_OOM(heap().allocate(realm, realm, result)); } JS::ThrowCompletionOr WebAssemblyInstanceConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp index 66782bc1d5..a517018129 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp @@ -35,34 +35,38 @@ JS::ThrowCompletionOr WebAssemblyInstanceObject::initialize(JS::Realm& rea auto& instance = this->instance(); auto& cache = this->cache(); for (auto& export_ : instance.exports()) { - export_.value().visit( - [&](Wasm::FunctionAddress const& address) { + TRY(export_.value().visit( + [&](Wasm::FunctionAddress const& address) -> JS::ThrowCompletionOr { Optional object = cache.function_instances.get(address); if (!object.has_value()) { object = create_native_function(vm, address, export_.name()); cache.function_instances.set(address, *object); } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); + return {}; }, - [&](Wasm::MemoryAddress const& address) { + [&](Wasm::MemoryAddress const& address) -> JS::ThrowCompletionOr { Optional object = cache.memory_instances.get(address); if (!object.has_value()) { - object = heap().allocate(realm, realm, address); + object = MUST_OR_THROW_OOM(heap().allocate(realm, realm, address)); cache.memory_instances.set(address, *object); } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); + return {}; }, - [&](Wasm::TableAddress const& address) { + [&](Wasm::TableAddress const& address) -> JS::ThrowCompletionOr { Optional object = cache.table_instances.get(address); if (!object.has_value()) { - object = heap().allocate(realm, realm, address); + object = MUST_OR_THROW_OOM(heap().allocate(realm, realm, address)); cache.table_instances.set(address, *object); } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); + return {}; }, - [&](auto const&) { + [&](auto const&) -> JS::ThrowCompletionOr { // FIXME: Implement other exports! - }); + return {}; + })); } MUST(m_exports_object->set_integrity_level(IntegrityLevel::Frozen)); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp index 69d111b9a6..21be84b718 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp @@ -46,7 +46,7 @@ JS::ThrowCompletionOr> WebAssemblyMemoryConstructor if (!address.has_value()) return vm.throw_completion("Wasm Memory allocation failed"); - return vm.heap().allocate(realm, realm, *address); + return MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, *address)); } JS::ThrowCompletionOr WebAssemblyMemoryConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp index b859445833..c8563f6ccf 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp @@ -33,7 +33,7 @@ JS::ThrowCompletionOr> WebAssemblyModuleConstructor auto* buffer_object = TRY(vm.argument(0).to_object(vm)); auto result = TRY(parse_module(vm, buffer_object)); - return heap().allocate(realm, realm, result); + return MUST_OR_THROW_OOM(heap().allocate(realm, realm, result)); } JS::ThrowCompletionOr WebAssemblyModuleConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp index d7d1bd37cf..b37ff741ad 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp @@ -157,7 +157,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::compile) if (result.is_error()) promise->reject(*result.release_error().value()); else - promise->fulfill(vm.heap().allocate(realm, realm, result.release_value())); + promise->fulfill(MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, result.release_value()))); return promise; } @@ -337,10 +337,10 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::instantiate) if (result.is_error()) { promise->reject(*result.release_error().value()); } else { - auto instance_object = vm.heap().allocate(realm, realm, result.release_value()); + auto instance_object = MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, result.release_value())); if (should_return_module) { auto object = JS::Object::create(realm, nullptr); - object->define_direct_property("module", vm.heap().allocate(realm, realm, s_compiled_modules.size() - 1), JS::default_attributes); + object->define_direct_property("module", MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, s_compiled_modules.size() - 1)), JS::default_attributes); object->define_direct_property("instance", instance_object, JS::default_attributes); promise->fulfill(object); } else { @@ -355,7 +355,7 @@ JS::Value to_js_value(JS::VM& vm, Wasm::Value& wasm_value) auto& realm = *vm.current_realm(); switch (wasm_value.type().kind()) { case Wasm::ValueType::I64: - return realm.heap().allocate(realm, ::Crypto::SignedBigInteger { wasm_value.to().value() }); + return realm.heap().allocate(realm, ::Crypto::SignedBigInteger { wasm_value.to().value() }).release_allocated_value_but_fixme_should_propagate_errors(); case Wasm::ValueType::I32: return JS::Value(wasm_value.to().value()); case Wasm::ValueType::F64: diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp index bc9717ff95..9d1dac1221 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp @@ -77,7 +77,7 @@ JS::ThrowCompletionOr> WebAssemblyTableConstructor: for (auto& element : table.elements()) element = reference; - return vm.heap().allocate(realm, realm, *address); + return MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, *address)); } JS::ThrowCompletionOr WebAssemblyTableConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp index 92f913e016..95580d9f86 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp @@ -11,7 +11,7 @@ namespace Web::WebGL { WebGLContextEvent* WebGLContextEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WebGLContextEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } WebGLContextEvent* WebGLContextEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, WebGLContextEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp index 9c9d4fe731..7f166290ed 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp @@ -46,7 +46,7 @@ JS::ThrowCompletionOr> WebGLRenderingContext::c fire_webgl_context_creation_error(canvas_element); return JS::GCPtr { nullptr }; } - return realm.heap().allocate(realm, realm, canvas_element, context_or_error.release_value(), context_attributes, context_attributes); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, canvas_element, context_or_error.release_value(), context_attributes, context_attributes)); } WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters) diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp index ccbcdbfaf0..309ef1d2d5 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp @@ -11,12 +11,12 @@ namespace Web::WebIDL { JS::NonnullGCPtr DOMException::create(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message) { - return realm.heap().allocate(realm, realm, name, message); + return realm.heap().allocate(realm, realm, name, message).release_allocated_value_but_fixme_should_propagate_errors(); } JS::NonnullGCPtr DOMException::construct_impl(JS::Realm& realm, DeprecatedFlyString const& message, DeprecatedFlyString const& name) { - return realm.heap().allocate(realm, realm, name, message); + return realm.heap().allocate(realm, realm, name, message).release_allocated_value_but_fixme_should_propagate_errors(); } DOMException::DOMException(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message) diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index 84e2eac861..84fd063c28 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -57,7 +57,7 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::R return WebIDL::SyntaxError::create(realm, "Presence of URL fragment is invalid"); // 5. If `protocols` is a string, set `protocols` to a sequence consisting of just that string // 6. If any of the values in `protocols` occur more than once or otherwise fail to match the requirements, throw SyntaxError - return realm.heap().allocate(realm, window, url_record); + return MUST_OR_THROW_OOM(realm.heap().allocate(realm, window, url_record)); } WebSocket::WebSocket(HTML::Window& window, AK::URL& url) diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp index ccc3e52ec0..86befaa11d 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp @@ -11,7 +11,7 @@ namespace Web::XHR { ProgressEvent* ProgressEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, ProgressEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.heap().allocate(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); } ProgressEvent* ProgressEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, ProgressEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index d9dac15961..e577e23a6d 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -45,7 +45,7 @@ JS::NonnullGCPtr XMLHttpRequest::construct_impl(JS::Realm& realm { auto& window = verify_cast(realm.global_object()); auto author_request_headers = Fetch::Infrastructure::HeaderList::create(realm.vm()); - return realm.heap().allocate(realm, window, *author_request_headers); + return realm.heap().allocate(realm, window, *author_request_headers).release_allocated_value_but_fixme_should_propagate_errors(); } XMLHttpRequest::XMLHttpRequest(HTML::Window& window, Fetch::Infrastructure::HeaderList& author_request_headers) diff --git a/Userland/Services/WebContent/WebContentConsoleClient.cpp b/Userland/Services/WebContent/WebContentConsoleClient.cpp index 268723d7ab..313bc66b50 100644 --- a/Userland/Services/WebContent/WebContentConsoleClient.cpp +++ b/Userland/Services/WebContent/WebContentConsoleClient.cpp @@ -25,7 +25,7 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, JS::Realm , m_client(client) { auto& window = verify_cast(realm.global_object()); - m_console_global_environment_extensions = realm.heap().allocate(realm, realm, window).ptr(); + m_console_global_environment_extensions = realm.heap().allocate(realm, realm, window).release_allocated_value_but_fixme_should_propagate_errors().ptr(); } void WebContentConsoleClient::handle_input(DeprecatedString const& js_source)