mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:27:45 +00:00
LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate cells. Callers in infallible contexts get a FIXME.
This commit is contained in:
parent
109b190a19
commit
b75b7f0c0d
178 changed files with 565 additions and 565 deletions
|
@ -28,8 +28,8 @@ ThrowCompletionOr<void> $262Object::initialize(Realm& realm)
|
|||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
m_agent = vm().heap().allocate<AgentObject>(realm, realm);
|
||||
m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(realm, realm);
|
||||
m_agent = MUST_OR_THROW_OOM(vm().heap().allocate<AgentObject>(realm, realm));
|
||||
m_is_htmldda = MUST_OR_THROW_OOM(vm().heap().allocate<IsHTMLDDA>(realm, realm));
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr);
|
||||
|
|
|
@ -18,7 +18,7 @@ ThrowCompletionOr<void> 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;
|
||||
|
|
|
@ -41,15 +41,12 @@ public:
|
|||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
NonnullGCPtr<T> allocate(Realm& realm, Args&&... args)
|
||||
ThrowCompletionOr<NonnullGCPtr<T>> allocate(Realm& realm, Args&&... args)
|
||||
{
|
||||
auto* memory = allocate_cell(sizeof(T));
|
||||
new (memory) T(forward<Args>(args)...);
|
||||
auto* cell = static_cast<T*>(memory);
|
||||
|
||||
// FIXME: Propagate this error.
|
||||
(void)memory->initialize(realm);
|
||||
|
||||
MUST_OR_THROW_OOM(memory->initialize(realm));
|
||||
return *cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ Object* Module::module_namespace_create(VM& vm, Vector<DeprecatedFlyString> 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<ModuleNamespaceObject>(realm, realm, this, move(unambiguous_names));
|
||||
auto module_namespace = vm.heap().allocate<ModuleNamespaceObject>(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);
|
||||
|
|
|
@ -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<ArgumentsObject>(realm, realm, environment);
|
||||
auto object = vm.heap().allocate<ArgumentsObject>(realm, realm, environment).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 14. Let index be 0.
|
||||
// 15. Repeat, while index < len,
|
||||
|
|
|
@ -146,7 +146,7 @@ ThrowCompletionOr<NonnullGCPtr<T>> 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<T>(realm, forward<Args>(args)..., *prototype);
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<T>(realm, forward<Args>(args)..., *prototype));
|
||||
}
|
||||
|
||||
// 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<AggregateError> AggregateError::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<AggregateError>(realm, *realm.intrinsics().aggregate_error_prototype());
|
||||
return realm.heap().allocate<AggregateError>(realm, *realm.intrinsics().aggregate_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
AggregateError::AggregateError(Object& prototype)
|
||||
|
|
|
@ -32,7 +32,7 @@ ThrowCompletionOr<NonnullGCPtr<Array>> 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<Array>(realm, *prototype);
|
||||
auto array = MUST_OR_THROW_OOM(realm.heap().allocate<Array>(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 }));
|
||||
|
|
|
@ -17,17 +17,17 @@ ThrowCompletionOr<NonnullGCPtr<ArrayBuffer>> ArrayBuffer::create(Realm& realm, s
|
|||
if (buffer.is_error())
|
||||
return realm.vm().throw_completion<RangeError>(ErrorType::NotEnoughMemoryToAllocate, byte_length);
|
||||
|
||||
return realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype());
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype()));
|
||||
}
|
||||
|
||||
NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer buffer)
|
||||
{
|
||||
return realm.heap().allocate<ArrayBuffer>(realm, move(buffer), *realm.intrinsics().array_buffer_prototype());
|
||||
return realm.heap().allocate<ArrayBuffer>(realm, move(buffer), *realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer* buffer)
|
||||
{
|
||||
return realm.heap().allocate<ArrayBuffer>(realm, buffer, *realm.intrinsics().array_buffer_prototype());
|
||||
return realm.heap().allocate<ArrayBuffer>(realm, buffer, *realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype());
|
||||
return realm.heap().allocate<ArrayIterator>(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)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<AsyncFromSyncIterator> AsyncFromSyncIterator::create(Realm& realm, Iterator sync_iterator_record)
|
||||
{
|
||||
return realm.heap().allocate<AsyncFromSyncIterator>(realm, realm, sync_iterator_record);
|
||||
return realm.heap().allocate<AsyncFromSyncIterator>(realm, realm, sync_iterator_record).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace JS {
|
|||
|
||||
ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::create(Realm& realm, GeneratorObject* generator_object)
|
||||
{
|
||||
auto wrapper = realm.heap().allocate<AsyncFunctionDriverWrapper>(realm, realm, generator_object);
|
||||
auto wrapper = MUST_OR_THROW_OOM(realm.heap().allocate<AsyncFunctionDriverWrapper>(realm, realm, generator_object));
|
||||
return wrapper->react_to_async_task_completion(realm.vm(), js_undefined(), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<BigIntObject> BigIntObject::create(Realm& realm, BigInt& bigint)
|
||||
{
|
||||
return realm.heap().allocate<BigIntObject>(realm, bigint, *realm.intrinsics().bigint_prototype());
|
||||
return realm.heap().allocate<BigIntObject>(realm, bigint, *realm.intrinsics().bigint_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
BigIntObject::BigIntObject(BigInt& bigint, Object& prototype)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<BooleanObject> BooleanObject::create(Realm& realm, bool value)
|
||||
{
|
||||
return realm.heap().allocate<BooleanObject>(realm, value, *realm.intrinsics().boolean_prototype());
|
||||
return realm.heap().allocate<BooleanObject>(realm, value, *realm.intrinsics().boolean_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
BooleanObject::BooleanObject(bool value, Object& prototype)
|
||||
|
|
|
@ -26,7 +26,7 @@ ThrowCompletionOr<NonnullGCPtr<BoundFunction>> 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<BoundFunction>(realm, realm, target_function, bound_this, move(bound_arguments), prototype);
|
||||
auto object = MUST_OR_THROW_OOM(realm.heap().allocate<BoundFunction>(realm, realm, target_function, bound_this, move(bound_arguments), prototype));
|
||||
|
||||
// 10. Return obj.
|
||||
return object;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<DataView> DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset)
|
||||
{
|
||||
return realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype());
|
||||
return realm.heap().allocate<DataView>(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)
|
||||
|
|
|
@ -25,7 +25,7 @@ Crypto::SignedBigInteger const ns_per_day_bigint { static_cast<i64>(ns_per_day)
|
|||
|
||||
NonnullGCPtr<Date> Date::create(Realm& realm, double date_value)
|
||||
{
|
||||
return realm.heap().allocate<Date>(realm, date_value, *realm.intrinsics().date_prototype());
|
||||
return realm.heap().allocate<Date>(realm, date_value, *realm.intrinsics().date_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Date::Date(double date_value, Object& prototype)
|
||||
|
|
|
@ -45,12 +45,12 @@ NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& r
|
|||
prototype = realm.intrinsics().async_generator_function_prototype();
|
||||
break;
|
||||
}
|
||||
return realm.heap().allocate<ECMAScriptFunctionObject>(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<ECMAScriptFunctionObject>(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> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> 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<PropertyKey, PrivateName, Empty> class_field_initializer_name)
|
||||
{
|
||||
return realm.heap().allocate<ECMAScriptFunctionObject>(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<ECMAScriptFunctionObject>(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<FunctionParameter> 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<PropertyKey, PrivateName, Empty> class_field_initializer_name)
|
||||
|
@ -114,7 +114,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::initialize(Realm& realm)
|
|||
Object* prototype = nullptr;
|
||||
switch (m_kind) {
|
||||
case FunctionKind::Normal:
|
||||
prototype = vm.heap().allocate<Object>(realm, *realm.intrinsics().new_ordinary_function_prototype_object_shape());
|
||||
prototype = MUST_OR_THROW_OOM(vm.heap().allocate<Object>(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:
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<Error> Error::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype());
|
||||
return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NonnullGCPtr<Error> 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> ClassName::create(Realm& realm) \
|
||||
{ \
|
||||
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
|
||||
} \
|
||||
\
|
||||
NonnullGCPtr<ClassName> 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> ClassName::create(Realm& realm) \
|
||||
{ \
|
||||
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
} \
|
||||
\
|
||||
NonnullGCPtr<ClassName> 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
|
||||
|
|
|
@ -28,7 +28,7 @@ ThrowCompletionOr<NonnullGCPtr<GeneratorObject>> 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<GeneratorObject>(realm, realm, *generating_function_prototype_object, move(execution_context));
|
||||
auto object = MUST_OR_THROW_OOM(realm.heap().allocate<GeneratorObject>(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;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace JS::Intl {
|
|||
|
||||
NonnullGCPtr<CollatorCompareFunction> CollatorCompareFunction::create(Realm& realm, Collator& collator)
|
||||
{
|
||||
return realm.heap().allocate<CollatorCompareFunction>(realm, realm, collator);
|
||||
return realm.heap().allocate<CollatorCompareFunction>(realm, realm, collator).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace JS::Intl {
|
|||
// 11.5.5 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions
|
||||
NonnullGCPtr<DateTimeFormatFunction> DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format)
|
||||
{
|
||||
return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace JS::Intl {
|
|||
|
||||
ThrowCompletionOr<NonnullGCPtr<Locale>> Locale::create(Realm& realm, ::Locale::LocaleID locale_id)
|
||||
{
|
||||
auto locale = realm.heap().allocate<Locale>(realm, *realm.intrinsics().intl_locale_prototype());
|
||||
auto locale = MUST_OR_THROW_OOM(realm.heap().allocate<Locale>(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) {
|
||||
|
|
|
@ -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> NumberFormatFunction::create(Realm& realm, NumberFormat& number_format)
|
||||
{
|
||||
return realm.heap().allocate<NumberFormatFunction>(realm, number_format, *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<NumberFormatFunction>(realm, number_format, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype)
|
||||
|
|
|
@ -19,7 +19,7 @@ NonnullGCPtr<SegmentIterator> 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<SegmentIterator>(realm, realm, segmenter, move(string), segments);
|
||||
return realm.heap().allocate<SegmentIterator>(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
|
||||
|
|
|
@ -18,7 +18,7 @@ NonnullGCPtr<Segments> 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<Segments>(realm, realm, segmenter, move(string));
|
||||
return realm.heap().allocate<Segments>(realm, realm, segmenter, move(string)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects
|
||||
|
|
|
@ -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<ClassName##Prototype>(realm, realm);
|
||||
m_##snake_name##_prototype = heap().allocate<ClassName##Prototype>(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<AsyncFromSyncIteratorPrototype>(realm, realm);
|
||||
m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(realm, realm);
|
||||
m_generator_prototype = heap().allocate<GeneratorPrototype>(realm, realm);
|
||||
m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(realm, realm);
|
||||
m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_generator_prototype = heap().allocate<GeneratorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(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<ErrorPrototype>(realm, realm);
|
||||
m_error_constructor = heap().allocate<ErrorConstructor>(realm, realm);
|
||||
m_function_constructor = heap().allocate<FunctionConstructor>(realm, realm);
|
||||
m_error_prototype = heap().allocate<ErrorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_error_constructor = heap().allocate<ErrorConstructor>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_function_constructor = heap().allocate<FunctionConstructor>(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<ProxyConstructor>(realm, realm);
|
||||
m_proxy_constructor = heap().allocate<ProxyConstructor>(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<ObjectConstructor>(realm, realm);
|
||||
m_object_constructor = heap().allocate<ObjectConstructor>(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<Namespace::ConstructorName>) { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, *typed_array_prototype()); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm, *typed_array_constructor()); \
|
||||
} else { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, m_realm); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm); \
|
||||
} \
|
||||
\
|
||||
/* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \
|
||||
if constexpr (IsSame<Namespace::ConstructorName, BigIntConstructor>) \
|
||||
initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, BooleanConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, FunctionConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, NumberConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, RegExpConstructor>) \
|
||||
initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, StringConstructor>) \
|
||||
initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, SymbolConstructor>) \
|
||||
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<Namespace::ConstructorName>) { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, *typed_array_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm, *typed_array_constructor()).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
} else { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(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<Namespace::ConstructorName, BigIntConstructor>) \
|
||||
initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, BooleanConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, FunctionConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, NumberConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, RegExpConstructor>) \
|
||||
initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, StringConstructor>) \
|
||||
initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, SymbolConstructor>) \
|
||||
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<ClassName>(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<ClassName>(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
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<Map> Map::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<Map>(realm, *realm.intrinsics().map_prototype());
|
||||
return realm.heap().allocate<Map>(realm, *realm.intrinsics().map_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Map::Map(Object& prototype)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<MapIterator> MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return realm.heap().allocate<MapIterator>(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype());
|
||||
return realm.heap().allocate<MapIterator>(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)
|
||||
|
|
|
@ -36,7 +36,7 @@ NonnullGCPtr<NativeFunction> 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<NativeFunction>(allocating_realm, move(behaviour), prototype.value(), *realm.value());
|
||||
auto function = allocating_realm.heap().allocate<NativeFunction>(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> NativeFunction::create(Realm& allocating_realm, Saf
|
|||
|
||||
NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& realm, DeprecatedFlyString const& name, SafeFunction<ThrowCompletionOr<Value>(VM&)> function)
|
||||
{
|
||||
return realm.heap().allocate<NativeFunction>(realm, name, move(function), *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<NativeFunction>(realm, name, move(function), *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NativeFunction::NativeFunction(SafeFunction<ThrowCompletionOr<Value>(VM&)> native_function, Object* prototype, Realm& realm)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<NumberObject> NumberObject::create(Realm& realm, double value)
|
||||
{
|
||||
return realm.heap().allocate<NumberObject>(realm, value, *realm.intrinsics().number_prototype());
|
||||
return realm.heap().allocate<NumberObject>(realm, value, *realm.intrinsics().number_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NumberObject::NumberObject(double value, Object& prototype)
|
||||
|
|
|
@ -30,11 +30,10 @@ static HashMap<Object const*, HashMap<DeprecatedFlyString, Object::IntrinsicAcce
|
|||
NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
|
||||
{
|
||||
if (!prototype)
|
||||
return realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape());
|
||||
else if (prototype == realm.intrinsics().object_prototype())
|
||||
return realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape());
|
||||
else
|
||||
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype);
|
||||
return realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
if (prototype == realm.intrinsics().object_prototype())
|
||||
return realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Object::Object(GlobalObjectTag, Realm& realm)
|
||||
|
|
|
@ -44,7 +44,7 @@ ThrowCompletionOr<Object*> promise_resolve(VM& vm, Object& constructor, Value va
|
|||
|
||||
NonnullGCPtr<Promise> Promise::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<Promise>(realm, *realm.intrinsics().promise_prototype());
|
||||
return realm.heap().allocate<Promise>(realm, *realm.intrinsics().promise_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects
|
||||
|
|
|
@ -57,7 +57,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor)
|
|||
|
||||
NonnullGCPtr<PromiseAllResolveElementFunction> PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
|
||||
{
|
||||
return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<PromiseAllResolveElementFunction>(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<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
@ -89,7 +89,7 @@ ThrowCompletionOr<Value> PromiseAllResolveElementFunction::resolve_element()
|
|||
|
||||
NonnullGCPtr<PromiseAllSettledResolveElementFunction> PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
|
||||
{
|
||||
return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(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<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
@ -130,7 +130,7 @@ ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_elemen
|
|||
|
||||
NonnullGCPtr<PromiseAllSettledRejectElementFunction> PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
|
||||
{
|
||||
return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(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<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
@ -171,7 +171,7 @@ ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element
|
|||
|
||||
NonnullGCPtr<PromiseAnyRejectElementFunction> PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
|
||||
{
|
||||
return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<PromiseAnyRejectElementFunction>(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<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<PromiseResolvingFunction> PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function)
|
||||
{
|
||||
return realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype());
|
||||
return realm.heap().allocate<PromiseResolvingFunction>(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)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<ProxyObject> ProxyObject::create(Realm& realm, Object& target, Object& handler)
|
||||
{
|
||||
return realm.heap().allocate<ProxyObject>(realm, target, handler, *realm.intrinsics().object_prototype());
|
||||
return realm.heap().allocate<ProxyObject>(realm, target, handler, *realm.intrinsics().object_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)
|
||||
|
|
|
@ -130,12 +130,12 @@ ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView patte
|
|||
|
||||
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype());
|
||||
return realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
|
||||
{
|
||||
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype());
|
||||
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
RegExpObject::RegExpObject(Object& prototype)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
// 22.2.7.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator
|
||||
NonnullGCPtr<RegExpStringIterator> RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode)
|
||||
{
|
||||
return realm.heap().allocate<RegExpStringIterator>(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode);
|
||||
return realm.heap().allocate<RegExpStringIterator>(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)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<Set> Set::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype());
|
||||
return realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Set::Set(Object& prototype)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<SetIterator> SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return realm.heap().allocate<SetIterator>(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype());
|
||||
return realm.heap().allocate<SetIterator>(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)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, String string)
|
||||
{
|
||||
return realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype());
|
||||
return realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
StringIterator::StringIterator(String string, Object& prototype)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace JS {
|
|||
// 10.4.3.4 StringCreate ( value, prototype ), https://tc39.es/ecma262/#sec-stringcreate
|
||||
NonnullGCPtr<StringObject> StringObject::create(Realm& realm, PrimitiveString& primitive_string, Object& prototype)
|
||||
{
|
||||
return realm.heap().allocate<StringObject>(realm, primitive_string, prototype);
|
||||
return realm.heap().allocate<StringObject>(realm, primitive_string, prototype).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
StringObject::StringObject(PrimitiveString& string, Object& prototype)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<SuppressedError> SuppressedError::create(Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<SuppressedError>(realm, *realm.intrinsics().suppressed_error_prototype());
|
||||
return *realm.heap().allocate<SuppressedError>(realm, *realm.intrinsics().suppressed_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
SuppressedError::SuppressedError(Object& prototype)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<SymbolObject> SymbolObject::create(Realm& realm, Symbol& primitive_symbol)
|
||||
{
|
||||
return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype());
|
||||
return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)
|
||||
|
|
|
@ -36,7 +36,7 @@ ThrowCompletionOr<void> 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<Now>(realm, realm), attr);
|
||||
define_direct_property(vm.names.Now, MUST_OR_THROW_OOM(heap().allocate<Now>(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(); });
|
||||
|
|
|
@ -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<NonnullGCPtr<ClassName>> 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<ClassName>(realm, *prototype, length, *array_buffer); \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
|
||||
{ \
|
||||
auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
|
||||
return create(realm, length, *array_buffer); \
|
||||
} \
|
||||
\
|
||||
NonnullGCPtr<ClassName> ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \
|
||||
{ \
|
||||
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer); \
|
||||
} \
|
||||
\
|
||||
ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \
|
||||
: TypedArray(prototype, \
|
||||
reinterpret_cast<TypedArrayBase::IntrinsicConstructor>(&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<void> 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<void> 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<Value> ConstructorName::call() \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
|
||||
} \
|
||||
\
|
||||
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> 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<TypedArrayBase&>(first_argument.as_object()); \
|
||||
TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
|
||||
} else if (is<ArrayBuffer>(first_argument.as_object())) { \
|
||||
auto& array_buffer = static_cast<ArrayBuffer&>(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<RangeError>(error.value()->as_object())) { \
|
||||
/* Re-throw more specific RangeError */ \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
} \
|
||||
return error; \
|
||||
} \
|
||||
auto array_length = array_length_or_error.release_value(); \
|
||||
if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
/* FIXME: What is the best/correct behavior here? */ \
|
||||
if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \
|
||||
return vm.throw_completion<RangeError>(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<NonnullGCPtr<ClassName>> 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<ClassName>(realm, *prototype, length, *array_buffer)); \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
|
||||
{ \
|
||||
auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
|
||||
return create(realm, length, *array_buffer); \
|
||||
} \
|
||||
\
|
||||
NonnullGCPtr<ClassName> ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \
|
||||
{ \
|
||||
return realm.heap().allocate<ClassName>(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<TypedArrayBase::IntrinsicConstructor>(&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<void> 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<void> 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<Value> ConstructorName::call() \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
|
||||
} \
|
||||
\
|
||||
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> 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<TypedArrayBase&>(first_argument.as_object()); \
|
||||
TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
|
||||
} else if (is<ArrayBuffer>(first_argument.as_object())) { \
|
||||
auto& array_buffer = static_cast<ArrayBuffer&>(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<RangeError>(error.value()->as_object())) { \
|
||||
/* Re-throw more specific RangeError */ \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
} \
|
||||
return error; \
|
||||
} \
|
||||
auto array_length = array_length_or_error.release_value(); \
|
||||
if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
/* FIXME: What is the best/correct behavior here? */ \
|
||||
if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
return TRY(ClassName::create(realm, array_length, new_target)); \
|
||||
}
|
||||
|
||||
#undef __JS_ENUMERATE
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<WeakMap> WeakMap::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<WeakMap>(realm, *realm.intrinsics().weak_map_prototype());
|
||||
return realm.heap().allocate<WeakMap>(realm, *realm.intrinsics().weak_map_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
WeakMap::WeakMap(Object& prototype)
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Object& value)
|
||||
{
|
||||
return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
|
||||
return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Symbol& value)
|
||||
{
|
||||
return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
|
||||
return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
WeakRef::WeakRef(Object& value, Object& prototype)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<WeakSet> WeakSet::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<WeakSet>(realm, *realm.intrinsics().weak_set_prototype());
|
||||
return realm.heap().allocate<WeakSet>(realm, *realm.intrinsics().weak_set_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
WeakSet::WeakSet(Object& prototype)
|
||||
|
|
|
@ -22,7 +22,7 @@ ThrowCompletionOr<NonnullGCPtr<WrappedFunction>> 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<WrappedFunction>(realm, caller_realm, target, prototype);
|
||||
auto wrapped = MUST_OR_THROW_OOM(vm.heap().allocate<WrappedFunction>(realm, caller_realm, target, prototype));
|
||||
|
||||
// 7. Let result be CopyNameAndLength(wrapped, Target).
|
||||
auto result = copy_name_and_length(vm, *wrapped, target);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue