LibGC+Everywhere: Factor out a LibGC from LibJS

Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
This commit is contained in:
Shannon Booth
2024-11-15 04:01:23 +13:00
committed by Andreas Kling
parent ce23efc5f6
commit f87041bf3a
1722 changed files with 9939 additions and 9906 deletions

View File

@@ -14,7 +14,7 @@ namespace Web::PerformanceTimeline {
struct PerformanceEntryTuple {
// https://www.w3.org/TR/performance-timeline/#dfn-performance-entry-buffer
// A performance entry buffer to store PerformanceEntry objects, that is initially empty.
Vector<JS::NonnullGCPtr<PerformanceEntry>> performance_entry_buffer;
Vector<GC::Ref<PerformanceEntry>> performance_entry_buffer;
// https://www.w3.org/TR/performance-timeline/#dfn-maxbuffersize
// An integer maxBufferSize, initialized to the registry value for this entry type.

View File

@@ -16,14 +16,14 @@
namespace Web::PerformanceTimeline {
JS_DEFINE_ALLOCATOR(PerformanceObserver);
GC_DEFINE_ALLOCATOR(PerformanceObserver);
WebIDL::ExceptionOr<JS::NonnullGCPtr<PerformanceObserver>> PerformanceObserver::construct_impl(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
WebIDL::ExceptionOr<GC::Ref<PerformanceObserver>> PerformanceObserver::construct_impl(JS::Realm& realm, GC::Ptr<WebIDL::CallbackType> callback)
{
return realm.create<PerformanceObserver>(realm, callback);
}
PerformanceObserver::PerformanceObserver(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
PerformanceObserver::PerformanceObserver(JS::Realm& realm, GC::Ptr<WebIDL::CallbackType> callback)
: Bindings::PlatformObject(realm)
, m_callback(move(callback))
{
@@ -207,10 +207,10 @@ void PerformanceObserver::disconnect()
}
// https://w3c.github.io/performance-timeline/#dom-performanceobserver-takerecords
Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>> PerformanceObserver::take_records()
Vector<GC::Root<PerformanceTimeline::PerformanceEntry>> PerformanceObserver::take_records()
{
// The takeRecords() method must return a copy of this's observer buffer, and also empty this's observer buffer.
Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>> records;
Vector<GC::Root<PerformanceTimeline::PerformanceEntry>> records;
for (auto& record : m_observer_buffer)
records.append(*record);
m_observer_buffer.clear();
@@ -218,7 +218,7 @@ Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>> PerformanceObserver::t
}
// https://w3c.github.io/performance-timeline/#dom-performanceobserver-supportedentrytypes
JS::NonnullGCPtr<JS::Object> PerformanceObserver::supported_entry_types(JS::VM& vm)
GC::Ref<JS::Object> PerformanceObserver::supported_entry_types(JS::VM& vm)
{
// 1. Let globalObject be the environment settings object's global object.
auto* window_or_worker = dynamic_cast<HTML::WindowOrWorkerGlobalScopeMixin*>(&vm.get_global_object());
@@ -233,7 +233,7 @@ void PerformanceObserver::unset_requires_dropped_entries(Badge<HTML::WindowOrWor
m_requires_dropped_entries = false;
}
void PerformanceObserver::append_to_observer_buffer(Badge<HTML::WindowOrWorkerGlobalScopeMixin>, JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry> entry)
void PerformanceObserver::append_to_observer_buffer(Badge<HTML::WindowOrWorkerGlobalScopeMixin>, GC::Ref<PerformanceTimeline::PerformanceEntry> entry)
{
m_observer_buffer.append(entry);
}

View File

@@ -21,7 +21,7 @@ struct PerformanceObserverInit {
// https://w3c.github.io/performance-timeline/#dom-performanceobserver
class PerformanceObserver final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(PerformanceObserver, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(PerformanceObserver);
GC_DECLARE_ALLOCATOR(PerformanceObserver);
public:
enum class ObserverType {
@@ -30,12 +30,12 @@ public:
Multiple,
};
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PerformanceObserver>> construct_impl(JS::Realm&, JS::GCPtr<WebIDL::CallbackType>);
static WebIDL::ExceptionOr<GC::Ref<PerformanceObserver>> construct_impl(JS::Realm&, GC::Ptr<WebIDL::CallbackType>);
virtual ~PerformanceObserver() override;
WebIDL::ExceptionOr<void> observe(PerformanceObserverInit& options);
void disconnect();
Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>> take_records();
Vector<GC::Root<PerformanceTimeline::PerformanceEntry>> take_records();
bool requires_dropped_entries() const { return m_requires_dropped_entries; }
void unset_requires_dropped_entries(Badge<HTML::WindowOrWorkerGlobalScopeMixin>);
@@ -44,23 +44,23 @@ public:
WebIDL::CallbackType& callback() { return *m_callback; }
void append_to_observer_buffer(Badge<HTML::WindowOrWorkerGlobalScopeMixin>, JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>);
void append_to_observer_buffer(Badge<HTML::WindowOrWorkerGlobalScopeMixin>, GC::Ref<PerformanceTimeline::PerformanceEntry>);
static JS::NonnullGCPtr<JS::Object> supported_entry_types(JS::VM&);
static GC::Ref<JS::Object> supported_entry_types(JS::VM&);
private:
PerformanceObserver(JS::Realm&, JS::GCPtr<WebIDL::CallbackType>);
PerformanceObserver(JS::Realm&, GC::Ptr<WebIDL::CallbackType>);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
// https://w3c.github.io/performance-timeline/#dfn-observer-callback
// A PerformanceObserverCallback observer callback set on creation.
JS::GCPtr<WebIDL::CallbackType> m_callback;
GC::Ptr<WebIDL::CallbackType> m_callback;
// https://w3c.github.io/performance-timeline/#dfn-observer-buffer
// A PerformanceEntryList object called the observer buffer that is initially empty.
Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> m_observer_buffer;
Vector<GC::Ref<PerformanceTimeline::PerformanceEntry>> m_observer_buffer;
// https://w3c.github.io/performance-timeline/#dfn-observer-type
// A DOMString observer type which is initially "undefined".

View File

@@ -13,9 +13,9 @@
namespace Web::PerformanceTimeline {
JS_DEFINE_ALLOCATOR(PerformanceObserverEntryList);
GC_DEFINE_ALLOCATOR(PerformanceObserverEntryList);
PerformanceObserverEntryList::PerformanceObserverEntryList(JS::Realm& realm, Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>>&& entry_list)
PerformanceObserverEntryList::PerformanceObserverEntryList(JS::Realm& realm, Vector<GC::Ref<PerformanceTimeline::PerformanceEntry>>&& entry_list)
: Bindings::PlatformObject(realm)
, m_entry_list(move(entry_list))
{
@@ -36,10 +36,10 @@ void PerformanceObserverEntryList::visit_edges(Cell::Visitor& visitor)
}
// https://www.w3.org/TR/performance-timeline/#dfn-filter-buffer-by-name-and-type
ErrorOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> filter_buffer_by_name_and_type(Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> const& buffer, Optional<String> name, Optional<String> type)
ErrorOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> filter_buffer_by_name_and_type(Vector<GC::Ref<PerformanceTimeline::PerformanceEntry>> const& buffer, Optional<String> name, Optional<String> type)
{
// 1. Let result be an initially empty list.
Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>> result;
Vector<GC::Root<PerformanceTimeline::PerformanceEntry>> result;
// 2. For each PerformanceEntry entry in buffer, run the following steps:
for (auto const& entry : buffer) {
@@ -65,7 +65,7 @@ ErrorOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> filter_buffer
}
// https://w3c.github.io/performance-timeline/#dom-performanceobserverentrylist-getentries
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> PerformanceObserverEntryList::get_entries() const
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> PerformanceObserverEntryList::get_entries() const
{
// Returns a PerformanceEntryList object returned by filter buffer by name and type algorithm with this's entry list,
// name and type set to null.
@@ -73,7 +73,7 @@ WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> P
}
// https://w3c.github.io/performance-timeline/#dom-performanceobserverentrylist-getentriesbytype
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> PerformanceObserverEntryList::get_entries_by_type(String const& type) const
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> PerformanceObserverEntryList::get_entries_by_type(String const& type) const
{
// Returns a PerformanceEntryList object returned by filter buffer by name and type algorithm with this's entry list,
// name set to null, and type set to the method's input type parameter.
@@ -81,7 +81,7 @@ WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> P
}
// https://w3c.github.io/performance-timeline/#dom-performanceobserverentrylist-getentriesbyname
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> PerformanceObserverEntryList::get_entries_by_name(String const& name, Optional<String> type) const
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> PerformanceObserverEntryList::get_entries_by_name(String const& name, Optional<String> type) const
{
// Returns a PerformanceEntryList object returned by filter buffer by name and type algorithm with this's entry list,
// name set to the method input name parameter, and type set to null if optional entryType is omitted, or set to the

View File

@@ -13,17 +13,17 @@ namespace Web::PerformanceTimeline {
// https://w3c.github.io/performance-timeline/#performanceobserverentrylist-interface
class PerformanceObserverEntryList final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(PerformanceObserverEntryList, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(PerformanceObserverEntryList);
GC_DECLARE_ALLOCATOR(PerformanceObserverEntryList);
public:
virtual ~PerformanceObserverEntryList() override;
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries() const;
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_type(String const& type) const;
WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_name(String const& name, Optional<String> type) const;
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> get_entries() const;
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> get_entries_by_type(String const& type) const;
WebIDL::ExceptionOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> get_entries_by_name(String const& name, Optional<String> type) const;
private:
PerformanceObserverEntryList(JS::Realm&, Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>>&&);
PerformanceObserverEntryList(JS::Realm&, Vector<GC::Ref<PerformanceTimeline::PerformanceEntry>>&&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@@ -31,9 +31,9 @@ private:
// https://w3c.github.io/performance-timeline/#dfn-entry-list
// Returns a PerformanceEntryList object returned by filter buffer by name and type algorithm with this's entry list,
// name and type set to null.
Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> m_entry_list;
Vector<GC::Ref<PerformanceTimeline::PerformanceEntry>> m_entry_list;
};
ErrorOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> filter_buffer_by_name_and_type(Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> const& buffer, Optional<String> name, Optional<String> type);
ErrorOr<Vector<GC::Root<PerformanceTimeline::PerformanceEntry>>> filter_buffer_by_name_and_type(Vector<GC::Ref<PerformanceTimeline::PerformanceEntry>> const& buffer, Optional<String> name, Optional<String> type);
}