mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:47:45 +00:00
LibJS+js+test-js: Add GC debug mode that keeps cells "alive" as zombies
This patch adds a `-z` option to js and test-js. When run in this mode, garbage cells are never actually destroyed. We instead keep them around in a special zombie state. This allows us to validate that zombies don't get marked in future GC scans (since there were not supposed to be any more references!) :^) Cells get notified when they become a zombie (via did_become_zombie()) and this is used by WeakContainer cells to deregister themselves from the heap.
This commit is contained in:
parent
57371f7608
commit
c364520c24
10 changed files with 33 additions and 1 deletions
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
private:
|
||||
virtual void visit_edges(Visitor& visitor) override;
|
||||
virtual void did_become_zombie() override { deregister(); }
|
||||
|
||||
FunctionObject* m_cleanup_callback { nullptr };
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) override;
|
||||
|
||||
private:
|
||||
virtual void did_become_zombie() override { deregister(); }
|
||||
|
||||
HashMap<Cell*, Value> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
|
||||
};
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
|
||||
private:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
virtual void did_become_zombie() override { deregister(); }
|
||||
|
||||
Object* m_value { nullptr };
|
||||
u32 m_last_execution_generation { 0 };
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) override;
|
||||
|
||||
private:
|
||||
virtual void did_become_zombie() override { deregister(); }
|
||||
|
||||
HashTable<Cell*> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue