mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibJS: Don't use a Handle<Realm> in FinalizationRegistry
Instead just treat it like a normal GC cell edge.
This commit is contained in:
parent
63cc2650e3
commit
7fce5f102f
Notes:
sideshowbarker
2024-07-17 07:32:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7fce5f102f
@ -12,7 +12,7 @@ namespace JS {
|
||||
FinalizationRegistry::FinalizationRegistry(Realm& realm, JobCallback cleanup_callback, Object& prototype)
|
||||
: Object(prototype)
|
||||
, WeakContainer(heap())
|
||||
, m_realm(make_handle(realm))
|
||||
, m_realm(realm)
|
||||
, m_cleanup_callback(move(cleanup_callback))
|
||||
{
|
||||
}
|
||||
@ -82,6 +82,7 @@ ThrowCompletionOr<void> FinalizationRegistry::cleanup(Optional<JobCallback> call
|
||||
void FinalizationRegistry::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_realm.ptr());
|
||||
for (auto& record : m_records) {
|
||||
visitor.visit(record.held_value);
|
||||
visitor.visit(record.unregister_token);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/SinglyLinkedList.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/JobCallback.h>
|
||||
@ -30,8 +31,8 @@ public:
|
||||
|
||||
virtual void remove_dead_cells(Badge<Heap>) override;
|
||||
|
||||
Realm& realm() { return *m_realm.cell(); }
|
||||
Realm const& realm() const { return *m_realm.cell(); }
|
||||
Realm& realm() { return *m_realm; }
|
||||
Realm const& realm() const { return *m_realm; }
|
||||
|
||||
JobCallback& cleanup_callback() { return m_cleanup_callback; }
|
||||
JobCallback const& cleanup_callback() const { return m_cleanup_callback; }
|
||||
@ -41,7 +42,7 @@ private:
|
||||
|
||||
virtual void visit_edges(Visitor& visitor) override;
|
||||
|
||||
Handle<Realm> m_realm;
|
||||
NonnullGCPtr<Realm> m_realm;
|
||||
JobCallback m_cleanup_callback;
|
||||
|
||||
struct FinalizationRecord {
|
||||
|
Loading…
Reference in New Issue
Block a user