mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 23:56:06 +00:00
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:
parent
2a5dbedad4
commit
9b79a686eb
Notes:
github-actions[bot]
2024-11-13 21:52:48 +00:00
Author: https://github.com/shannonbooth
Commit: 9b79a686eb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2322
Reviewed-by: https://github.com/gmta
326 changed files with 697 additions and 714 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue