LibJS+LibWeb: Make Console, ConsoleClient & subclasses GC-allocated

These objects had confusing ownership semantics. Let's just throw them
all on the GC heap and stop worrying about it.
This commit is contained in:
Andreas Kling 2024-04-20 21:19:51 +02:00
commit 4db1712f90
Notes: sideshowbarker 2024-07-17 06:20:50 +09:00
13 changed files with 95 additions and 34 deletions

View file

@ -16,14 +16,22 @@ JS_DEFINE_ALLOCATOR(ConsoleObject);
ConsoleObject::ConsoleObject(Realm& realm)
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
, m_console(make<Console>(realm))
{
}
ConsoleObject::~ConsoleObject() = default;
void ConsoleObject::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_console);
}
void ConsoleObject::initialize(Realm& realm)
{
auto& vm = this->vm();
Base::initialize(realm);
m_console = vm.heap().allocate<Console>(realm, 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);