LibJS+LibWeb: Use realm.create<T> instead of heap.allocate<T>

The main motivation behind this is to remove JS specifics of the Realm
from the implementation of the Heap.

As a side effect of this change, this is a bit nicer to read than the
previous approach, and in my opinion, also makes it a little more clear
that this method is specific to a JavaScript Realm.
This commit is contained in:
Shannon Booth 2024-11-14 05:50:17 +13:00 committed by Tim Flynn
parent 2a5dbedad4
commit 9b79a686eb
Notes: github-actions[bot] 2024-11-13 21:52:48 +00:00
326 changed files with 697 additions and 714 deletions

View file

@ -1742,7 +1742,7 @@ inline ThrowCompletionOr<Object*> get_object_property_iterator(VM& vm, Value val
}
},
1, vm.names.next);
return vm.heap().allocate<IteratorRecord>(realm, realm, object, callback, false).ptr();
return realm.create<IteratorRecord>(realm, object, callback, false).ptr();
}
ByteString Instruction::to_byte_string(Bytecode::Executable const& executable) const

View file

@ -32,8 +32,8 @@ void $262Object::initialize(Realm& realm)
{
Base::initialize(realm);
m_agent = vm().heap().allocate<AgentObject>(realm, realm);
m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(realm, realm);
m_agent = realm.create<AgentObject>(realm);
m_is_htmldda = realm.create<IsHTMLDDA>(realm);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr);

View file

@ -20,7 +20,7 @@ void GlobalObject::initialize(Realm& realm)
{
Base::initialize(realm);
m_$262 = vm().heap().allocate<$262Object>(realm, realm);
m_$262 = realm.create<$262Object>(realm);
// https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions
u8 attr = Attribute::Writable | Attribute::Configurable;

View file

@ -45,18 +45,6 @@ public:
return *static_cast<T*>(memory);
}
template<typename T, typename... Args>
NonnullGCPtr<T> allocate(Realm& realm, Args&&... args)
{
auto* memory = allocate_cell<T>();
defer_gc();
new (memory) T(forward<Args>(args)...);
undefer_gc();
auto* cell = static_cast<T*>(memory);
memory->initialize(realm);
return *cell;
}
enum class CollectionType {
CollectGarbage,
CollectEverything,

View file

@ -147,7 +147,7 @@ ThrowCompletionOr<Object*> Module::get_module_namespace(VM& vm)
}
// d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames).
namespace_ = module_namespace_create(vm, unambiguous_names);
namespace_ = module_namespace_create(unambiguous_names);
VERIFY(m_namespace);
// Note: This set the local variable 'namespace' and not the member variable which is done by ModuleNamespaceCreate
}
@ -157,7 +157,7 @@ ThrowCompletionOr<Object*> Module::get_module_namespace(VM& vm)
}
// 10.4.6.12 ModuleNamespaceCreate ( module, exports ), https://tc39.es/ecma262/#sec-modulenamespacecreate
Object* Module::module_namespace_create(VM& vm, Vector<DeprecatedFlyString> unambiguous_names)
Object* Module::module_namespace_create(Vector<DeprecatedFlyString> unambiguous_names)
{
auto& realm = this->realm();
@ -171,7 +171,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 = realm.create<ModuleNamespaceObject>(realm, this, move(unambiguous_names));
// 9. Set module.[[Namespace]] to M.
m_namespace = make_handle(module_namespace);

View file

@ -128,7 +128,7 @@ protected:
}
private:
Object* module_namespace_create(VM& vm, Vector<DeprecatedFlyString> unambiguous_names);
Object* module_namespace_create(Vector<DeprecatedFlyString> unambiguous_names);
// These handles are only safe as long as the VM they live in is valid.
// But evaluated modules SHOULD be stored in the VM so unless you intentionally

View file

@ -1087,7 +1087,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 = realm.create<ArgumentsObject>(realm, environment);
// 14. Let index be 0.
// 15. Repeat, while index < len,

View file

@ -147,7 +147,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 realm.create<T>(forward<Args>(args)..., *prototype);
}
// 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(AggregateError);
NonnullGCPtr<AggregateError> AggregateError::create(Realm& realm)
{
return realm.heap().allocate<AggregateError>(realm, realm.intrinsics().aggregate_error_prototype());
return realm.create<AggregateError>(realm.intrinsics().aggregate_error_prototype());
}
AggregateError::AggregateError(Object& prototype)

View file

@ -35,7 +35,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 = realm.create<Array>(*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 }));

View file

@ -19,17 +19,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 realm.create<ArrayBuffer>(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.create<ArrayBuffer>(move(buffer), realm.intrinsics().array_buffer_prototype());
}
NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer* buffer)
{
return realm.heap().allocate<ArrayBuffer>(realm, buffer, realm.intrinsics().array_buffer_prototype());
return realm.create<ArrayBuffer>(buffer, realm.intrinsics().array_buffer_prototype());
}
ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype)

View file

@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(ArrayIterator);
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.create<ArrayIterator>(array, iteration_kind, realm.intrinsics().array_iterator_prototype());
}
ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(AsyncFromSyncIterator);
NonnullGCPtr<AsyncFromSyncIterator> AsyncFromSyncIterator::create(Realm& realm, NonnullGCPtr<IteratorRecord> sync_iterator_record)
{
return realm.heap().allocate<AsyncFromSyncIterator>(realm, realm, sync_iterator_record);
return realm.create<AsyncFromSyncIterator>(realm, sync_iterator_record);
}
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, NonnullGCPtr<IteratorRecord> sync_iterator_record)

View file

@ -211,7 +211,7 @@ NonnullGCPtr<IteratorRecord> create_async_from_sync_iterator(VM& vm, NonnullGCPt
auto next_method = MUST(async_iterator->get(vm.names.next));
// 4. Let iteratorRecord be the Iterator Record { [[Iterator]]: asyncIterator, [[NextMethod]]: nextMethod, [[Done]]: false }.
auto iterator_record = vm.heap().allocate<IteratorRecord>(realm, realm, async_iterator, next_method, false);
auto iterator_record = realm.create<IteratorRecord>(realm, async_iterator, next_method, false);
// 5. Return iteratorRecord.
return iterator_record;

View file

@ -21,7 +21,7 @@ NonnullGCPtr<Promise> AsyncFunctionDriverWrapper::create(Realm& realm, Generator
{
auto top_level_promise = Promise::create(realm);
// Note: The top_level_promise is also kept alive by this Wrapper
auto wrapper = realm.heap().allocate<AsyncFunctionDriverWrapper>(realm, realm, *generator_object, *top_level_promise);
auto wrapper = realm.create<AsyncFunctionDriverWrapper>(realm, *generator_object, *top_level_promise);
// Prime the generator:
// This runs until the first `await value;`
wrapper->continue_async_execution(realm.vm(), js_undefined(), true, IsInitialExecution::Yes);

View file

@ -22,7 +22,7 @@ ThrowCompletionOr<NonnullGCPtr<AsyncGenerator>> AsyncGenerator::create(Realm& re
// This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
auto 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<AsyncGenerator>(realm, realm, generating_function_prototype_object, move(execution_context));
auto object = realm.create<AsyncGenerator>(realm, generating_function_prototype_object, move(execution_context));
object->m_generating_function = generating_function;
object->m_previous_value = initial_value;
return object;

View file

@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(BigIntObject);
NonnullGCPtr<BigIntObject> BigIntObject::create(Realm& realm, BigInt& bigint)
{
return realm.heap().allocate<BigIntObject>(realm, bigint, realm.intrinsics().bigint_prototype());
return realm.create<BigIntObject>(bigint, realm.intrinsics().bigint_prototype());
}
BigIntObject::BigIntObject(BigInt& bigint, Object& prototype)

View file

@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(BooleanObject);
NonnullGCPtr<BooleanObject> BooleanObject::create(Realm& realm, bool value)
{
return realm.heap().allocate<BooleanObject>(realm, value, realm.intrinsics().boolean_prototype());
return realm.create<BooleanObject>(value, realm.intrinsics().boolean_prototype());
}
BooleanObject::BooleanObject(bool value, Object& prototype)

View file

@ -28,7 +28,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 = realm.create<BoundFunction>(realm, target_function, bound_this, move(bound_arguments), prototype);
// 10. Return obj.
return object;

View file

@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(ConsoleObject);
static NonnullGCPtr<ConsoleObjectPrototype> create_console_prototype(Realm& realm)
{
return realm.heap().allocate<ConsoleObjectPrototype>(realm, realm);
return realm.create<ConsoleObjectPrototype>(realm);
}
ConsoleObject::ConsoleObject(Realm& realm)
@ -37,7 +37,7 @@ void ConsoleObject::initialize(Realm& realm)
{
auto& vm = this->vm();
Base::initialize(realm);
m_console = vm.heap().allocate<Console>(realm, realm);
m_console = realm.create<Console>(realm);
u8 attr = Attribute::Writable | Attribute::Enumerable | Attribute::Configurable;
define_native_function(realm, vm.names.assert, assert_, 0, attr);
define_native_function(realm, vm.names.clear, clear, 0, attr);

View file

@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(DataView);
NonnullGCPtr<DataView> DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, ByteLength byte_length, size_t byte_offset)
{
return realm.heap().allocate<DataView>(realm, viewed_buffer, move(byte_length), byte_offset, realm.intrinsics().data_view_prototype());
return realm.create<DataView>(viewed_buffer, move(byte_length), byte_offset, realm.intrinsics().data_view_prototype());
}
DataView::DataView(ArrayBuffer* viewed_buffer, ByteLength byte_length, size_t byte_offset, Object& prototype)

View file

@ -27,7 +27,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.create<Date>(date_value, realm.intrinsics().date_prototype());
}
Date::Date(double date_value, Object& prototype)

View file

@ -50,12 +50,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, move(local_variables_names), parent_environment, private_environment, *prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name));
return realm.create<ECMAScriptFunctionObject>(move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, *prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name));
}
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, FunctionParsingInsights parsing_insights, 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, move(local_variables_names), parent_environment, private_environment, prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name));
return realm.create<ECMAScriptFunctionObject>(move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name));
}
ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, FunctionParsingInsights parsing_insights, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)

View file

@ -36,7 +36,7 @@ SourceRange const& TracebackFrame::source_range() const
NonnullGCPtr<Error> Error::create(Realm& realm)
{
return realm.heap().allocate<Error>(realm, realm.intrinsics().error_prototype());
return realm.create<Error>(realm.intrinsics().error_prototype());
}
NonnullGCPtr<Error> Error::create(Realm& realm, String message)
@ -160,7 +160,7 @@ String Error::stack_string(CompactTraceback compact) const
JS_DEFINE_ALLOCATOR(ClassName); \
NonnullGCPtr<ClassName> ClassName::create(Realm& realm) \
{ \
return realm.heap().allocate<ClassName>(realm, realm.intrinsics().snake_name##_prototype()); \
return realm.create<ClassName>(realm.intrinsics().snake_name##_prototype()); \
} \
\
NonnullGCPtr<ClassName> ClassName::create(Realm& realm, String message) \

View file

@ -30,7 +30,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 = realm.create<GeneratorObject>(realm, generating_function_prototype_object, move(execution_context));
object->m_generating_function = generating_function;
object->m_previous_value = initial_value;
return object;

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CollatorCompareFunction);
NonnullGCPtr<CollatorCompareFunction> CollatorCompareFunction::create(Realm& realm, Collator& collator)
{
return realm.heap().allocate<CollatorCompareFunction>(realm, realm, collator);
return realm.create<CollatorCompareFunction>(realm, collator);
}
CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator)

View file

@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(DateTimeFormatFunction);
// 11.5.4 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.create<DateTimeFormatFunction>(date_time_format, realm.intrinsics().function_prototype());
}
DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype)

View file

@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(Locale);
NonnullGCPtr<Locale> Locale::create(Realm& realm, NonnullGCPtr<Locale> source_locale, String locale_tag)
{
auto locale = realm.heap().allocate<Locale>(realm, realm.intrinsics().intl_locale_prototype());
auto locale = realm.create<Locale>(realm.intrinsics().intl_locale_prototype());
locale->set_locale(move(locale_tag));
locale->m_calendar = source_locale->m_calendar;

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(NumberFormatFunction);
// 15.5.2 Number Format Functions, https://tc39.es/ecma402/#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.create<NumberFormatFunction>(number_format, realm.intrinsics().function_prototype());
}
NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype)

View file

@ -21,7 +21,7 @@ NonnullGCPtr<SegmentIterator> SegmentIterator::create(Realm& realm, Unicode::Seg
// 4. Set iterator.[[IteratedString]] to string.
// 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0.
// 6. Return iterator.
return realm.heap().allocate<SegmentIterator>(realm, realm, segmenter, string, segments);
return realm.create<SegmentIterator>(realm, segmenter, string, segments);
}
// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects

View file

@ -20,7 +20,7 @@ NonnullGCPtr<Segments> Segments::create(Realm& realm, Unicode::Segmenter const&
// 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.create<Segments>(realm, segmenter, move(string));
}
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects

View file

@ -198,33 +198,33 @@ ThrowCompletionOr<void> Intrinsics::initialize_intrinsics(Realm& realm)
m_iterator_result_object_value_offset = m_iterator_result_object_shape->lookup(vm.names.value.to_string_or_symbol()).value().offset;
m_iterator_result_object_done_offset = m_iterator_result_object_shape->lookup(vm.names.done.to_string_or_symbol()).value().offset;
// Normally Heap::allocate() takes care of this, but these are allocated via allocate_without_realm().
// Normally Realm::create() takes care of this, but these are allocated via Heap::allocate_without_realm().
m_function_prototype->initialize(realm);
m_object_prototype->initialize(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 = realm.create<ClassName##Prototype>(realm);
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_wrap_for_valid_iterator_prototype = heap().allocate<WrapForValidIteratorPrototype>(realm, realm);
m_async_from_sync_iterator_prototype = realm.create<AsyncFromSyncIteratorPrototype>(realm);
m_async_generator_prototype = realm.create<AsyncGeneratorPrototype>(realm);
m_generator_prototype = realm.create<GeneratorPrototype>(realm);
m_intl_segments_prototype = realm.create<Intl::SegmentsPrototype>(realm);
m_wrap_for_valid_iterator_prototype = realm.create<WrapForValidIteratorPrototype>(realm);
// 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 = realm.create<ErrorPrototype>(realm);
m_error_constructor = realm.create<ErrorConstructor>(realm);
m_function_constructor = realm.create<FunctionConstructor>(realm);
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
m_proxy_constructor = heap().allocate<ProxyConstructor>(realm, realm);
m_proxy_constructor = realm.create<ProxyConstructor>(realm);
// Global object functions
m_eval_function = NativeFunction::create(realm, GlobalObject::eval, 1, vm.names.eval, &realm);
@ -239,7 +239,7 @@ ThrowCompletionOr<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 = realm.create<ObjectConstructor>(realm);
// 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror%
m_throw_type_error_function = NativeFunction::create(
@ -292,11 +292,11 @@ JS_ENUMERATE_TYPED_ARRAYS
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()); \
m_##snake_namespace##snake_name##_prototype = m_realm->create<Namespace::PrototypeName>(*typed_array_prototype()); \
m_##snake_namespace##snake_name##_constructor = m_realm->create<Namespace::ConstructorName>(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); \
m_##snake_namespace##snake_name##_prototype = m_realm->create<Namespace::PrototypeName>(m_realm); \
m_##snake_namespace##snake_name##_constructor = m_realm->create<Namespace::ConstructorName>(m_realm); \
} \
\
/* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \
@ -351,12 +351,12 @@ JS_ENUMERATE_TEMPORAL_OBJECTS
#undef __JS_ENUMERATE_INNER
#define __JS_ENUMERATE(ClassName, snake_name) \
NonnullGCPtr<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) \
NonnullGCPtr<ClassName> Intrinsics::snake_name##_object() \
{ \
if (!m_##snake_name##_object) \
m_##snake_name##_object = m_realm->create<ClassName>(m_realm); \
return *m_##snake_name##_object; \
}
JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
#undef __JS_ENUMERATE

View file

@ -21,7 +21,7 @@ JS_DEFINE_ALLOCATOR(IteratorRecord);
NonnullGCPtr<Iterator> Iterator::create(Realm& realm, Object& prototype, NonnullGCPtr<IteratorRecord> iterated)
{
return realm.heap().allocate<Iterator>(realm, prototype, move(iterated));
return realm.create<Iterator>(prototype, move(iterated));
}
Iterator::Iterator(Object& prototype, NonnullGCPtr<IteratorRecord> iterated)
@ -31,7 +31,7 @@ Iterator::Iterator(Object& prototype, NonnullGCPtr<IteratorRecord> iterated)
}
Iterator::Iterator(Object& prototype)
: Iterator(prototype, prototype.heap().allocate<IteratorRecord>(prototype.shape().realm(), prototype.shape().realm(), nullptr, js_undefined(), false))
: Iterator(prototype, prototype.shape().realm().create<IteratorRecord>(prototype.shape().realm(), nullptr, js_undefined(), false))
{
}
@ -44,7 +44,7 @@ ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_direct(VM& vm, Obje
// 2. Let iteratorRecord be Record { [[Iterator]]: obj, [[NextMethod]]: nextMethod, [[Done]]: false }.
// 3. Return iteratorRecord.
auto& realm = *vm.current_realm();
return vm.heap().allocate<IteratorRecord>(realm, realm, object, next_method, false);
return realm.create<IteratorRecord>(realm, object, next_method, false);
}
// 7.4.3 GetIteratorFromMethod ( obj, method ), https://tc39.es/ecma262/#sec-getiteratorfrommethod
@ -62,7 +62,7 @@ ThrowCompletionOr<NonnullGCPtr<IteratorRecord>> get_iterator_from_method(VM& vm,
// 4. Let iteratorRecord be the Iterator Record { [[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false }.
auto& realm = *vm.current_realm();
auto iterator_record = vm.heap().allocate<IteratorRecord>(realm, realm, iterator.as_object(), next_method, false);
auto iterator_record = realm.create<IteratorRecord>(realm, iterator.as_object(), next_method, false);
// 5. Return iteratorRecord.
return iterator_record;

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(IteratorHelper);
ThrowCompletionOr<NonnullGCPtr<IteratorHelper>> IteratorHelper::create(Realm& realm, NonnullGCPtr<IteratorRecord> underlying_iterator, NonnullGCPtr<Closure> closure, GCPtr<AbruptClosure> abrupt_closure)
{
return realm.heap().allocate<IteratorHelper>(realm, realm, realm.intrinsics().iterator_helper_prototype(), move(underlying_iterator), closure, abrupt_closure);
return realm.create<IteratorHelper>(realm, realm.intrinsics().iterator_helper_prototype(), move(underlying_iterator), closure, abrupt_closure);
}
IteratorHelper::IteratorHelper(Realm& realm, Object& prototype, NonnullGCPtr<IteratorRecord> underlying_iterator, NonnullGCPtr<Closure> closure, GCPtr<AbruptClosure> abrupt_closure)

View file

@ -413,7 +413,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::flat_map)
// 4. Let iterated be ? GetIteratorDirect(O).
auto iterated = TRY(get_iterator_direct(vm, object));
auto flat_map_iterator = vm.heap().allocate<FlatMapIterator>(realm);
auto flat_map_iterator = realm.create<FlatMapIterator>();
// 5. Let closure be a new Abstract Closure with no parameters that captures iterated and mapper and performs the following steps when called:
auto closure = JS::create_heap_function(realm.heap(), [flat_map_iterator, mapper = NonnullGCPtr { mapper.as_function() }](VM& vm, IteratorHelper& iterator) mutable -> ThrowCompletionOr<Value> {

View file

@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(Map);
NonnullGCPtr<Map> Map::create(Realm& realm)
{
return realm.heap().allocate<Map>(realm, realm.intrinsics().map_prototype());
return realm.create<Map>(realm.intrinsics().map_prototype());
}
Map::Map(Object& prototype)

View file

@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(MapIterator);
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.create<MapIterator>(map, iteration_kind, realm.intrinsics().map_iterator_prototype());
}
MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)

View file

@ -53,7 +53,7 @@ NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& allocating_realm, Fun
// 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, JS::create_heap_function(vm.heap(), move(behaviour)), prototype.value(), *realm.value());
auto function = allocating_realm.create<NativeFunction>(JS::create_heap_function(vm.heap(), move(behaviour)), prototype.value(), *realm.value());
// 10. Perform SetFunctionLength(func, length).
function->set_function_length(length);
@ -70,7 +70,7 @@ NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& allocating_realm, Fun
NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& realm, DeprecatedFlyString const& name, Function<ThrowCompletionOr<Value>(VM&)> function)
{
return realm.heap().allocate<NativeFunction>(realm, name, JS::create_heap_function(realm.heap(), move(function)), realm.intrinsics().function_prototype());
return realm.create<NativeFunction>(name, JS::create_heap_function(realm.heap(), move(function)), realm.intrinsics().function_prototype());
}
NativeFunction::NativeFunction(JS::GCPtr<JS::HeapFunction<ThrowCompletionOr<Value>(VM&)>> native_function, Object* prototype, Realm& realm)

View file

@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(NumberObject);
NonnullGCPtr<NumberObject> NumberObject::create(Realm& realm, double value)
{
return realm.heap().allocate<NumberObject>(realm, value, realm.intrinsics().number_prototype());
return realm.create<NumberObject>(value, realm.intrinsics().number_prototype());
}
NumberObject::NumberObject(double value, Object& prototype)

View file

@ -31,10 +31,10 @@ static HashMap<GCPtr<Object const>, HashMap<DeprecatedFlyString, Object::Intrins
NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
{
if (!prototype)
return realm.heap().allocate<Object>(realm, realm.intrinsics().empty_object_shape());
return realm.create<Object>(realm.intrinsics().empty_object_shape());
if (prototype == realm.intrinsics().object_prototype())
return realm.heap().allocate<Object>(realm, realm.intrinsics().new_object_shape());
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype);
return realm.create<Object>(realm.intrinsics().new_object_shape());
return realm.create<Object>(ConstructWithPrototypeTag::Tag, *prototype);
}
NonnullGCPtr<Object> Object::create_prototype(Realm& realm, Object* prototype)
@ -42,12 +42,12 @@ NonnullGCPtr<Object> Object::create_prototype(Realm& realm, Object* prototype)
auto shape = realm.heap().allocate_without_realm<Shape>(realm);
if (prototype)
shape->set_prototype_without_transition(prototype);
return realm.heap().allocate<Object>(realm, shape);
return realm.create<Object>(shape);
}
NonnullGCPtr<Object> Object::create_with_premade_shape(Shape& shape)
{
return shape.heap().allocate<Object>(shape.realm(), shape);
return shape.realm().create<Object>(shape);
}
Object::Object(GlobalObjectTag, Realm& realm, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)

View file

@ -46,7 +46,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.create<Promise>(realm.intrinsics().promise_prototype());
}
// 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects

View file

@ -63,7 +63,7 @@ ThrowCompletionOr<NonnullGCPtr<PromiseCapability>> new_promise_capability(VM& vm
// 2. NOTE: C is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see 27.2.3.1).
// 3. Let resolvingFunctions be the Record { [[Resolve]]: undefined, [[Reject]]: undefined }.
auto resolving_functions = vm.heap().allocate<ResolvingFunctions>(realm);
auto resolving_functions = realm.create<ResolvingFunctions>();
// 4. Let executorClosure be a new Abstract Closure with parameters (resolve, reject) that captures resolvingFunctions and performs the following steps when called:
auto executor_closure = [resolving_functions](auto& vm) -> ThrowCompletionOr<Value> {

View file

@ -62,7 +62,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor)
NonnullGCPtr<PromiseAllResolveElementFunction> PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype());
return realm.create<PromiseAllResolveElementFunction>(index, values, capability, remaining_elements, realm.intrinsics().function_prototype());
}
PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)
@ -94,7 +94,7 @@ ThrowCompletionOr<Value> PromiseAllResolveElementFunction::resolve_element()
NonnullGCPtr<PromiseAllSettledResolveElementFunction> PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype());
return realm.create<PromiseAllSettledResolveElementFunction>(index, values, capability, remaining_elements, realm.intrinsics().function_prototype());
}
PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)
@ -135,7 +135,7 @@ ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_elemen
NonnullGCPtr<PromiseAllSettledRejectElementFunction> PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype());
return realm.create<PromiseAllSettledRejectElementFunction>(index, values, capability, remaining_elements, realm.intrinsics().function_prototype());
}
PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)
@ -176,7 +176,7 @@ ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element
NonnullGCPtr<PromiseAnyRejectElementFunction> PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, realm.intrinsics().function_prototype());
return realm.create<PromiseAnyRejectElementFunction>(index, errors, capability, remaining_elements, realm.intrinsics().function_prototype());
}
PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)

View file

@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(PromiseResolvingFunction);
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.create<PromiseResolvingFunction>(promise, already_resolved, move(function), realm.intrinsics().function_prototype());
}
PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype)

View file

@ -38,7 +38,7 @@ struct RecursionDepthUpdater {
NonnullGCPtr<ProxyObject> ProxyObject::create(Realm& realm, Object& target, Object& handler)
{
return realm.heap().allocate<ProxyObject>(realm, target, handler, realm.intrinsics().object_prototype());
return realm.create<ProxyObject>(target, handler, realm.intrinsics().object_prototype());
}
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)

View file

@ -14,6 +14,7 @@
#include <LibJS/Bytecode/Builtins.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/CellAllocator.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/Intrinsics.h>
#include <LibJS/Runtime/Value.h>
@ -31,6 +32,14 @@ public:
virtual void visit_edges(Cell::Visitor&) { }
};
template<typename T, typename... Args>
NonnullGCPtr<T> create(Args&&... args)
{
auto object = heap().allocate_without_realm<T>(forward<Args>(args)...);
static_cast<Cell*>(object)->initialize(*this);
return *object;
}
static ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> initialize_host_defined_realm(VM&, Function<Object*(Realm&)> create_global_object, Function<Object*(Realm&)> create_global_this_value);
[[nodiscard]] Object& global_object() const { return *m_global_object; }

View file

@ -148,12 +148,12 @@ ThrowCompletionOr<ByteString> parse_regex_pattern(VM& vm, StringView pattern, bo
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
{
return realm.heap().allocate<RegExpObject>(realm, realm.intrinsics().regexp_prototype());
return realm.create<RegExpObject>(realm.intrinsics().regexp_prototype());
}
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, ByteString pattern, ByteString flags)
{
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype());
return realm.create<RegExpObject>(move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype());
}
RegExpObject::RegExpObject(Object& prototype)

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(RegExpStringIterator);
// 22.2.9.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.create<RegExpStringIterator>(realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode);
}
RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode)

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(Set);
NonnullGCPtr<Set> Set::create(Realm& realm)
{
return realm.heap().allocate<Set>(realm, realm.intrinsics().set_prototype());
return realm.create<Set>(realm.intrinsics().set_prototype());
}
Set::Set(Object& prototype)

View file

@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(SetIterator);
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.create<SetIterator>(set, iteration_kind, realm.intrinsics().set_iterator_prototype());
}
SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype)

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(StringIterator);
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, String string)
{
return realm.heap().allocate<StringIterator>(realm, move(string), realm.intrinsics().string_iterator_prototype());
return realm.create<StringIterator>(move(string), realm.intrinsics().string_iterator_prototype());
}
StringIterator::StringIterator(String string, Object& prototype)

View file

@ -28,7 +28,7 @@ NonnullGCPtr<StringObject> StringObject::create(Realm& realm, PrimitiveString& p
// 7. Let length be the length of value.
// 8. Perform ! DefinePropertyOrThrow(S, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }).
// 9. Return S.
return realm.heap().allocate<StringObject>(realm, primitive_string, prototype);
return realm.create<StringObject>(primitive_string, prototype);
}
StringObject::StringObject(PrimitiveString& string, Object& prototype)

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SuppressedError);
NonnullGCPtr<SuppressedError> SuppressedError::create(Realm& realm)
{
return realm.heap().allocate<SuppressedError>(realm, realm.intrinsics().suppressed_error_prototype());
return realm.create<SuppressedError>(realm.intrinsics().suppressed_error_prototype());
}
SuppressedError::SuppressedError(Object& prototype)

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SymbolObject);
NonnullGCPtr<SymbolObject> SymbolObject::create(Realm& realm, Symbol& primitive_symbol)
{
return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, realm.intrinsics().symbol_prototype());
return realm.create<SymbolObject>(primitive_symbol, realm.intrinsics().symbol_prototype());
}
SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)

View file

@ -38,7 +38,7 @@ void Temporal::initialize(Realm& realm)
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"_string), 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, realm.create<Now>(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(); });

View file

@ -453,7 +453,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
{ \
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); \
return realm.create<ClassName>(*prototype, length, *array_buffer); \
} \
\
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
@ -464,7 +464,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
\
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); \
return realm.create<ClassName>(realm.intrinsics().snake_name##_prototype(), length, array_buffer); \
} \
\
ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \

View file

@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(WeakMap);
NonnullGCPtr<WeakMap> WeakMap::create(Realm& realm)
{
return realm.heap().allocate<WeakMap>(realm, realm.intrinsics().weak_map_prototype());
return realm.create<WeakMap>(realm.intrinsics().weak_map_prototype());
}
WeakMap::WeakMap(Object& prototype)

View file

@ -12,12 +12,12 @@ JS_DEFINE_ALLOCATOR(WeakRef);
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Object& value)
{
return realm.heap().allocate<WeakRef>(realm, value, realm.intrinsics().weak_ref_prototype());
return realm.create<WeakRef>(value, realm.intrinsics().weak_ref_prototype());
}
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Symbol& value)
{
return realm.heap().allocate<WeakRef>(realm, value, realm.intrinsics().weak_ref_prototype());
return realm.create<WeakRef>(value, realm.intrinsics().weak_ref_prototype());
}
WeakRef::WeakRef(Object& value, Object& prototype)

View file

@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(WeakSet);
NonnullGCPtr<WeakSet> WeakSet::create(Realm& realm)
{
return realm.heap().allocate<WeakSet>(realm, realm.intrinsics().weak_set_prototype());
return realm.create<WeakSet>(realm.intrinsics().weak_set_prototype());
}
WeakSet::WeakSet(Object& prototype)

View file

@ -24,7 +24,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 = realm.create<WrappedFunction>(caller_realm, target, prototype);
// 7. Let result be CopyNameAndLength(wrapped, Target).
auto result = copy_name_and_length(vm, *wrapped, target);

View file

@ -284,7 +284,7 @@ inline JSFileResult TestRunner::run_file_test(ByteString const& test_path)
*g_vm,
[&](JS::Realm& realm_) -> JS::GlobalObject* {
realm = &realm_;
global_object = g_vm->heap().allocate<TestRunnerGlobalObject>(*realm, *realm);
global_object = realm->create<TestRunnerGlobalObject>(*realm);
return global_object;
},
nullptr));

View file

@ -28,7 +28,7 @@ JS_DEFINE_ALLOCATOR(Animation);
JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, Optional<JS::GCPtr<AnimationTimeline>> timeline)
{
// 1. Let animation be a new Animation object.
auto animation = realm.heap().allocate<Animation>(realm, realm);
auto animation = realm.create<Animation>(realm);
// 2. Run the procedure to set the timeline of an animation on animation passing timeline as the new timeline or, if
// a timeline argument is missing, passing the default document timeline of the Document associated with the

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(AnimationPlaybackEvent);
JS::NonnullGCPtr<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
{
return realm.heap().allocate<AnimationPlaybackEvent>(realm, realm, type, event_init);
return realm.create<AnimationPlaybackEvent>(realm, type, event_init);
}
// https://www.w3.org/TR/web-animations-1/#dom-animationplaybackevent-animationplaybackevent

View file

@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(DocumentTimeline);
JS::NonnullGCPtr<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time)
{
auto timeline = realm.heap().allocate<DocumentTimeline>(realm, realm, document, origin_time);
auto timeline = realm.create<DocumentTimeline>(realm, document, origin_time);
auto current_time = document.last_animation_frame_timestamp();
if (!current_time.has_value()) {
// The document hasn't processed an animation frame yet, so just use the exact current time

View file

@ -648,7 +648,7 @@ int KeyframeEffect::composite_order(JS::NonnullGCPtr<KeyframeEffect> a, JS::Nonn
JS::NonnullGCPtr<KeyframeEffect> KeyframeEffect::create(JS::Realm& realm)
{
return realm.heap().allocate<KeyframeEffect>(realm, realm);
return realm.create<KeyframeEffect>(realm);
}
// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-keyframeeffect
@ -658,10 +658,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> KeyframeEffect::construct_
Optional<JS::Handle<JS::Object>> const& keyframes,
Variant<double, KeyframeEffectOptions> options)
{
auto& vm = realm.vm();
// 1. Create a new KeyframeEffect object, effect.
auto effect = vm.heap().allocate<KeyframeEffect>(realm, realm);
auto effect = realm.create<KeyframeEffect>(realm);
// 2. Set the target element of effect to target.
effect->set_target(target);
@ -721,10 +719,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> KeyframeEffect::construct_
// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-keyframeeffect-source
WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> KeyframeEffect::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<KeyframeEffect> source)
{
auto& vm = realm.vm();
// 1. Create a new KeyframeEffect object, effect.
auto effect = vm.heap().allocate<KeyframeEffect>(realm, realm);
auto effect = realm.create<KeyframeEffect>(realm);
// 2. Set the following properties of effect using the corresponding values of source:

View file

@ -585,11 +585,11 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
.underlying_realm = realm,
// 7. Set settings's module map to a new module map, initially empty.
.module_map = realm.heap().allocate<HTML::ModuleMap>(realm),
.module_map = realm.create<HTML::ModuleMap>(),
};
// 8. Set realm.[[HostDefined]] to settings.
realm.set_host_defined(make<Bindings::SyntheticHostDefined>(move(settings), realm.heap().allocate<Bindings::Intrinsics>(realm, realm)));
realm.set_host_defined(make<Bindings::SyntheticHostDefined>(move(settings), realm.create<Bindings::Intrinsics>(realm)));
// 9. Set realm.[[GlobalObject]] to globalObject.
realm.set_global_object(global_object);

View file

@ -57,7 +57,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct
if (vm.argument_count() > 0) {
auto text = TRY(vm.argument(0).to_string(vm));
if (!text.is_empty()) {
auto new_text_node = vm.heap().allocate<DOM::Text>(realm, document, text);
auto new_text_node = realm.create<DOM::Text>(document, text);
MUST(option_element->append_child(*new_text_node));
}
}

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(AnimationEvent);
JS::NonnullGCPtr<AnimationEvent> AnimationEvent::create(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
{
return realm.heap().allocate<AnimationEvent>(realm, realm, type, event_init);
return realm.create<AnimationEvent>(realm, type, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationEvent>> AnimationEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)

View file

@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(CSSAnimation);
JS::NonnullGCPtr<CSSAnimation> CSSAnimation::create(JS::Realm& realm)
{
return realm.heap().allocate<CSSAnimation>(realm, realm);
return realm.create<CSSAnimation>(realm);
}
// https://www.w3.org/TR/css-animations-2/#animation-composite-order

View file

@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(CSSFontFaceRule);
JS::NonnullGCPtr<CSSFontFaceRule> CSSFontFaceRule::create(JS::Realm& realm, ParsedFontFace&& font_face)
{
return realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face));
return realm.create<CSSFontFaceRule>(realm, move(font_face));
}
CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, ParsedFontFace&& font_face)

View file

@ -25,7 +25,7 @@ JS_DEFINE_ALLOCATOR(CSSImportRule);
JS::NonnullGCPtr<CSSImportRule> CSSImportRule::create(URL::URL url, DOM::Document& document)
{
auto& realm = document.realm();
return realm.heap().allocate<CSSImportRule>(realm, move(url), document);
return realm.create<CSSImportRule>(move(url), document);
}
CSSImportRule::CSSImportRule(URL::URL url, DOM::Document& document)

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSKeyframeRule);
JS::NonnullGCPtr<CSSKeyframeRule> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::PropertyOwningCSSStyleDeclaration& declarations)
{
return realm.heap().allocate<CSSKeyframeRule>(realm, realm, key, declarations);
return realm.create<CSSKeyframeRule>(realm, key, declarations);
}
CSSKeyframeRule::CSSKeyframeRule(JS::Realm& realm, CSS::Percentage key, PropertyOwningCSSStyleDeclaration& declarations)

View file

@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(CSSKeyframesRule);
JS::NonnullGCPtr<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, FlyString name, JS::NonnullGCPtr<CSSRuleList> css_rules)
{
return realm.heap().allocate<CSSKeyframesRule>(realm, realm, move(name), move(css_rules));
return realm.create<CSSKeyframesRule>(realm, move(name), move(css_rules));
}
CSSKeyframesRule::CSSKeyframesRule(JS::Realm& realm, FlyString name, JS::NonnullGCPtr<CSSRuleList> keyframes)

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSLayerBlockRule);
JS::NonnullGCPtr<CSSLayerBlockRule> CSSLayerBlockRule::create(JS::Realm& realm, FlyString name, CSSRuleList& rules)
{
return realm.heap().allocate<CSSLayerBlockRule>(realm, realm, move(name), rules);
return realm.create<CSSLayerBlockRule>(realm, move(name), rules);
}
FlyString CSSLayerBlockRule::next_unique_anonymous_layer_name()

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSLayerStatementRule);
JS::NonnullGCPtr<CSSLayerStatementRule> CSSLayerStatementRule::create(JS::Realm& realm, Vector<FlyString> name_list)
{
return realm.heap().allocate<CSSLayerStatementRule>(realm, realm, move(name_list));
return realm.create<CSSLayerStatementRule>(realm, move(name_list));
}
CSSLayerStatementRule::CSSLayerStatementRule(JS::Realm& realm, Vector<FlyString> name_list)

View file

@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(CSSMediaRule);
JS::NonnullGCPtr<CSSMediaRule> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
{
return realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules);
return realm.create<CSSMediaRule>(realm, media_queries, rules);
}
CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rules)

View file

@ -25,7 +25,7 @@ CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional<FlyString> prefix,
JS::NonnullGCPtr<CSSNamespaceRule> CSSNamespaceRule::create(JS::Realm& realm, Optional<FlyString> prefix, FlyString namespace_uri)
{
return realm.heap().allocate<CSSNamespaceRule>(realm, realm, move(prefix), move(namespace_uri));
return realm.create<CSSNamespaceRule>(realm, move(prefix), move(namespace_uri));
}
void CSSNamespaceRule::initialize(JS::Realm& realm)

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSNestedDeclarations);
JS::NonnullGCPtr<CSSNestedDeclarations> CSSNestedDeclarations::create(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration)
{
return realm.heap().allocate<CSSNestedDeclarations>(realm, realm, declaration);
return realm.create<CSSNestedDeclarations>(realm, declaration);
}
CSSNestedDeclarations::CSSNestedDeclarations(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration)

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSPropertyRule);
JS::NonnullGCPtr<CSSPropertyRule> CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value)
{
return realm.heap().allocate<CSSPropertyRule>(realm, realm, move(name), move(syntax), inherits, move(initial_value));
return realm.create<CSSPropertyRule>(realm, move(name), move(syntax), inherits, move(initial_value));
}
CSSPropertyRule::CSSPropertyRule(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value)

View file

@ -23,7 +23,7 @@ JS_DEFINE_ALLOCATOR(CSSRuleList);
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
{
auto rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
auto rule_list = realm.create<CSSRuleList>(realm);
for (auto* rule : rules)
rule_list->m_rules.append(*rule);
return rule_list;
@ -37,7 +37,7 @@ CSSRuleList::CSSRuleList(JS::Realm& realm)
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create_empty(JS::Realm& realm)
{
return realm.heap().allocate<CSSRuleList>(realm, realm);
return realm.create<CSSRuleList>(realm);
}
void CSSRuleList::initialize(JS::Realm& realm)

View file

@ -39,7 +39,7 @@ JS::GCPtr<CSSRule> CSSStyleDeclaration::parent_rule() const
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
{
return realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties));
return realm.create<PropertyOwningCSSStyleDeclaration>(realm, move(properties), move(custom_properties));
}
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
@ -69,7 +69,7 @@ String PropertyOwningCSSStyleDeclaration::item(size_t index) const
JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
{
auto& realm = element.realm();
return realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties));
return realm.create<ElementInlineCSSStyleDeclaration>(element, move(properties), move(custom_properties));
}
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)

View file

@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(CSSStyleRule);
JS::NonnullGCPtr<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)
{
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration, nested_rules);
return realm.create<CSSStyleRule>(realm, move(selectors), declaration, nested_rules);
}
CSSStyleRule::CSSStyleRule(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)

View file

@ -25,7 +25,7 @@ JS_DEFINE_ALLOCATOR(CSSStyleSheet);
JS::NonnullGCPtr<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<URL::URL> location)
{
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location));
return realm.create<CSSStyleSheet>(realm, rules, media, move(location));
}
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssstylesheet

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSSupportsRule);
JS::NonnullGCPtr<CSSSupportsRule> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
{
return realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules);
return realm.create<CSSSupportsRule>(realm, move(supports), rules);
}
CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)

View file

@ -24,7 +24,7 @@ JS::NonnullGCPtr<CSSTransition> CSSTransition::start_a_transition(DOM::Element&
NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
{
auto& realm = element.realm();
return realm.heap().allocate<CSSTransition>(realm, realm, element, property_id, transition_generation, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor);
return realm.create<CSSTransition>(realm, element, property_id, transition_generation, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor);
}
Animations::AnimationClass CSSTransition::animation_class() const

View file

@ -107,7 +107,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
if (buffer.is_empty() && sources.is_empty())
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "FontFace constructor: Invalid font source"_string));
auto font = realm.heap().allocate<FontFace>(realm, realm, promise, move(sources), move(buffer), move(family), descriptors);
auto font = realm.create<FontFace>(realm, promise, move(sources), move(buffer), move(family), descriptors);
// 1. (continued) Return font face. If font faces status is "error", terminate this algorithm;
// otherwise, complete the rest of these steps asynchronously.

View file

@ -37,7 +37,7 @@ JS::NonnullGCPtr<FontFaceSet> FontFaceSet::construct_impl(JS::Realm& realm, Vect
for (auto const& face : initial_faces)
set_entries->set_add(face);
return realm.heap().allocate<FontFaceSet>(realm, realm, ready_promise, set_entries);
return realm.create<FontFaceSet>(realm, ready_promise, set_entries);
}
JS::NonnullGCPtr<FontFaceSet> FontFaceSet::create(JS::Realm& realm)

View file

@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(MediaList);
JS::NonnullGCPtr<MediaList> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
{
return realm.heap().allocate<MediaList>(realm, realm, move(media));
return realm.create<MediaList>(realm, move(media));
}
MediaList::MediaList(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)

View file

@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(MediaQueryList);
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
{
return document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
return document.realm().create<MediaQueryList>(document, move(media));
}
MediaQueryList::MediaQueryList(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)

View file

@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(MediaQueryListEvent);
JS::NonnullGCPtr<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
{
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init);
return realm.create<MediaQueryListEvent>(realm, event_name, event_init);
}
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)

View file

@ -47,7 +47,7 @@ JS_DEFINE_ALLOCATOR(ResolvedCSSStyleDeclaration);
JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> ResolvedCSSStyleDeclaration::create(DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element)
{
return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element, move(pseudo_element));
return element.realm().create<ResolvedCSSStyleDeclaration>(element, move(pseudo_element));
}
ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)

View file

@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(Screen);
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
{
return window.heap().allocate<Screen>(window.realm(), window);
return window.realm().create<Screen>(window);
}
Screen::Screen(HTML::Window& window)

View file

@ -26,7 +26,7 @@ void ScreenOrientation::initialize(JS::Realm& realm)
JS::NonnullGCPtr<ScreenOrientation> ScreenOrientation::create(JS::Realm& realm)
{
return realm.heap().allocate<ScreenOrientation>(realm, realm);
return realm.create<ScreenOrientation>(realm);
}
// https://w3c.github.io/screen-orientation/#lock-method

View file

@ -131,7 +131,7 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
JS::NonnullGCPtr<StyleSheetList> StyleSheetList::create(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root)
{
auto& realm = document_or_shadow_root->realm();
return realm.heap().allocate<StyleSheetList>(realm, document_or_shadow_root);
return realm.create<StyleSheetList>(document_or_shadow_root);
}
StyleSheetList::StyleSheetList(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root)

View file

@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(VisualViewport);
JS::NonnullGCPtr<VisualViewport> VisualViewport::create(DOM::Document& document)
{
return document.heap().allocate<VisualViewport>(document.realm(), document);
return document.realm().create<VisualViewport>(document);
}
VisualViewport::VisualViewport(DOM::Document& document)

View file

@ -23,7 +23,7 @@ JS_DEFINE_ALLOCATOR(Clipboard);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Clipboard>> Clipboard::construct_impl(JS::Realm& realm)
{
return realm.heap().allocate<Clipboard>(realm, realm);
return realm.create<Clipboard>(realm);
}
Clipboard::Clipboard(JS::Realm& realm)

View file

@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(ClipboardEvent);
JS::NonnullGCPtr<ClipboardEvent> ClipboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init)
{
return realm.heap().allocate<ClipboardEvent>(realm, realm, event_name, event_init);
return realm.create<ClipboardEvent>(realm, event_name, event_init);
}
ClipboardEvent::ClipboardEvent(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init)

View file

@ -21,7 +21,7 @@ JS_DEFINE_ALLOCATOR(Crypto);
JS::NonnullGCPtr<Crypto> Crypto::create(JS::Realm& realm)
{
return realm.heap().allocate<Crypto>(realm, realm);
return realm.create<Crypto>(realm);
}
Crypto::Crypto(JS::Realm& realm)

View file

@ -18,12 +18,12 @@ JS_DEFINE_ALLOCATOR(CryptoKeyPair);
JS::NonnullGCPtr<CryptoKey> CryptoKey::create(JS::Realm& realm, InternalKeyData key_data)
{
return realm.heap().allocate<CryptoKey>(realm, realm, move(key_data));
return realm.create<CryptoKey>(realm, move(key_data));
}
JS::NonnullGCPtr<CryptoKey> CryptoKey::create(JS::Realm& realm)
{
return realm.heap().allocate<CryptoKey>(realm, realm);
return realm.create<CryptoKey>(realm);
}
CryptoKey::CryptoKey(JS::Realm& realm, InternalKeyData key_data)
@ -82,7 +82,7 @@ String CryptoKey::algorithm_name() const
JS::NonnullGCPtr<CryptoKeyPair> CryptoKeyPair::create(JS::Realm& realm, JS::NonnullGCPtr<CryptoKey> public_key, JS::NonnullGCPtr<CryptoKey> private_key)
{
return realm.heap().allocate<CryptoKeyPair>(realm, realm, public_key, private_key);
return realm.create<CryptoKeyPair>(realm, public_key, private_key);
}
CryptoKeyPair::CryptoKeyPair(JS::Realm& realm, JS::NonnullGCPtr<CryptoKey> public_key, JS::NonnullGCPtr<CryptoKey> private_key)

View file

@ -36,7 +36,7 @@ static JS::ThrowCompletionOr<T*> impl_from(JS::VM& vm, StringView Name)
JS::NonnullGCPtr<KeyAlgorithm> KeyAlgorithm::create(JS::Realm& realm)
{
return realm.heap().allocate<KeyAlgorithm>(realm, realm);
return realm.create<KeyAlgorithm>(realm);
}
KeyAlgorithm::KeyAlgorithm(JS::Realm& realm)
@ -66,7 +66,7 @@ void KeyAlgorithm::visit_edges(Visitor& visitor)
JS::NonnullGCPtr<RsaKeyAlgorithm> RsaKeyAlgorithm::create(JS::Realm& realm)
{
return realm.heap().allocate<RsaKeyAlgorithm>(realm, realm);
return realm.create<RsaKeyAlgorithm>(realm);
}
RsaKeyAlgorithm::RsaKeyAlgorithm(JS::Realm& realm)
@ -132,7 +132,7 @@ JS_DEFINE_NATIVE_FUNCTION(RsaKeyAlgorithm::public_exponent_getter)
JS::NonnullGCPtr<EcKeyAlgorithm> EcKeyAlgorithm::create(JS::Realm& realm)
{
return realm.heap().allocate<EcKeyAlgorithm>(realm, realm);
return realm.create<EcKeyAlgorithm>(realm);
}
EcKeyAlgorithm::EcKeyAlgorithm(JS::Realm& realm)
@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(EcKeyAlgorithm::named_curve_getter)
JS::NonnullGCPtr<RsaHashedKeyAlgorithm> RsaHashedKeyAlgorithm::create(JS::Realm& realm)
{
return realm.heap().allocate<RsaHashedKeyAlgorithm>(realm, realm);
return realm.create<RsaHashedKeyAlgorithm>(realm);
}
RsaHashedKeyAlgorithm::RsaHashedKeyAlgorithm(JS::Realm& realm)
@ -186,7 +186,7 @@ JS_DEFINE_NATIVE_FUNCTION(RsaHashedKeyAlgorithm::hash_getter)
JS::NonnullGCPtr<AesKeyAlgorithm> AesKeyAlgorithm::create(JS::Realm& realm)
{
return realm.heap().allocate<AesKeyAlgorithm>(realm, realm);
return realm.create<AesKeyAlgorithm>(realm);
}
AesKeyAlgorithm::AesKeyAlgorithm(JS::Realm& realm)

Some files were not shown because too many files have changed in this diff Show more