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
Notes: github-actions[bot] 2024-11-15 13:50:17 +00:00
1722 changed files with 9939 additions and 9906 deletions

View file

@ -11,68 +11,68 @@
namespace Web::WebIDL {
JS_DEFINE_ALLOCATOR(BufferableObjectBase);
JS_DEFINE_ALLOCATOR(ArrayBufferView);
JS_DEFINE_ALLOCATOR(BufferSource);
GC_DEFINE_ALLOCATOR(BufferableObjectBase);
GC_DEFINE_ALLOCATOR(ArrayBufferView);
GC_DEFINE_ALLOCATOR(BufferSource);
u32 BufferableObjectBase::byte_length() const
{
return m_bufferable_object.visit(
[](JS::NonnullGCPtr<JS::TypedArrayBase> typed_array) {
[](GC::Ref<JS::TypedArrayBase> typed_array) {
auto typed_array_record = JS::make_typed_array_with_buffer_witness_record(typed_array, JS::ArrayBuffer::Order::SeqCst);
return JS::typed_array_byte_length(typed_array_record);
},
[](JS::NonnullGCPtr<JS::DataView> data_view) {
[](GC::Ref<JS::DataView> data_view) {
auto view_record = JS::make_data_view_with_buffer_witness_record(data_view, JS::ArrayBuffer::Order::SeqCst);
return JS::get_view_byte_length(view_record);
},
[](JS::NonnullGCPtr<JS::ArrayBuffer> array_buffer) { return static_cast<u32>(array_buffer->byte_length()); });
[](GC::Ref<JS::ArrayBuffer> array_buffer) { return static_cast<u32>(array_buffer->byte_length()); });
}
JS::NonnullGCPtr<JS::Object> BufferableObjectBase::raw_object()
GC::Ref<JS::Object> BufferableObjectBase::raw_object()
{
return m_bufferable_object.visit([](auto const& obj) -> JS::NonnullGCPtr<JS::Object> { return obj; });
return m_bufferable_object.visit([](auto const& obj) -> GC::Ref<JS::Object> { return obj; });
}
JS::GCPtr<JS::ArrayBuffer> BufferableObjectBase::viewed_array_buffer()
GC::Ptr<JS::ArrayBuffer> BufferableObjectBase::viewed_array_buffer()
{
return m_bufferable_object.visit(
[](JS::NonnullGCPtr<JS::ArrayBuffer> array_buffer) -> JS::GCPtr<JS::ArrayBuffer> { return array_buffer; },
[](auto const& view) -> JS::GCPtr<JS::ArrayBuffer> { return view->viewed_array_buffer(); });
[](GC::Ref<JS::ArrayBuffer> array_buffer) -> GC::Ptr<JS::ArrayBuffer> { return array_buffer; },
[](auto const& view) -> GC::Ptr<JS::ArrayBuffer> { return view->viewed_array_buffer(); });
}
BufferableObject BufferableObjectBase::bufferable_object_from_raw_object(JS::NonnullGCPtr<JS::Object> object)
BufferableObject BufferableObjectBase::bufferable_object_from_raw_object(GC::Ref<JS::Object> object)
{
if (is<JS::TypedArrayBase>(*object))
return JS::NonnullGCPtr { static_cast<JS::TypedArrayBase&>(*object) };
return GC::Ref { static_cast<JS::TypedArrayBase&>(*object) };
if (is<JS::DataView>(*object))
return JS::NonnullGCPtr { static_cast<JS::DataView&>(*object) };
return GC::Ref { static_cast<JS::DataView&>(*object) };
if (is<JS::ArrayBuffer>(*object))
return JS::NonnullGCPtr { static_cast<JS::ArrayBuffer&>(*object) };
return GC::Ref { static_cast<JS::ArrayBuffer&>(*object) };
VERIFY_NOT_REACHED();
}
BufferableObjectBase::BufferableObjectBase(JS::NonnullGCPtr<JS::Object> object)
BufferableObjectBase::BufferableObjectBase(GC::Ref<JS::Object> object)
: m_bufferable_object(bufferable_object_from_raw_object(object))
{
}
bool BufferableObjectBase::is_typed_array_base() const
{
return m_bufferable_object.has<JS::NonnullGCPtr<JS::TypedArrayBase>>();
return m_bufferable_object.has<GC::Ref<JS::TypedArrayBase>>();
}
bool BufferableObjectBase::is_data_view() const
{
return m_bufferable_object.has<JS::NonnullGCPtr<JS::DataView>>();
return m_bufferable_object.has<GC::Ref<JS::DataView>>();
}
bool BufferableObjectBase::is_array_buffer() const
{
return m_bufferable_object.has<JS::NonnullGCPtr<JS::ArrayBuffer>>();
return m_bufferable_object.has<GC::Ref<JS::ArrayBuffer>>();
}
void BufferableObjectBase::visit_edges(Visitor& visitor)
@ -86,7 +86,7 @@ ArrayBufferView::~ArrayBufferView() = default;
u32 ArrayBufferView::byte_offset() const
{
return m_bufferable_object.visit(
[](JS::NonnullGCPtr<JS::ArrayBuffer>) -> u32 { VERIFY_NOT_REACHED(); },
[](GC::Ref<JS::ArrayBuffer>) -> u32 { VERIFY_NOT_REACHED(); },
[](auto& view) -> u32 { return static_cast<u32>(view->byte_offset()); });
}