1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

LibJS: Add a basic mark&sweep garbage collector :^)

Objects can now be allocated via the interpreter's heap. Objects that
are allocated in this way will need to be provably reachable from at
least one of the known object graph roots.

The roots are currently determined by Heap::collect_roots().

Anything that wants be collectable garbage should inherit from Cell,
the fundamental atom of the GC heap.

This is pretty neat! :^)
This commit is contained in:
Andreas Kling 2020-03-08 19:23:58 +01:00
parent 6da131d5db
commit 63e4b744ed
13 changed files with 498 additions and 6 deletions

View file

@ -32,8 +32,9 @@
namespace JS {
Interpreter::Interpreter()
: m_heap(*this)
{
m_global_object = new Object;
m_global_object = heap().allocate<Object>();
}
Interpreter::~Interpreter()