1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

LibJS: Always allocate ExecutionContext objects on the malloc heap

Instead of allocating these in a mixture of ways, we now always put
them on the malloc heap, and keep an intrusive linked list of them
that we can iterate for GC marking purposes.
This commit is contained in:
Andreas Kling 2023-11-27 16:45:45 +01:00
parent 845da3901d
commit 3dc5f467a8
38 changed files with 251 additions and 217 deletions

View file

@ -450,6 +450,9 @@ void Heap::mark_live_cells(HashMap<Cell*, HeapRoot> const& roots)
MarkingVisitor visitor(*this, roots);
for (auto& execution_context : m_execution_contexts)
execution_context.visit_edges(visitor);
vm().bytecode_interpreter().visit_edges(visitor);
visitor.mark_all_live_cells();

View file

@ -23,6 +23,7 @@
#include <LibJS/Heap/Internals.h>
#include <LibJS/Heap/MarkedVector.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/ExecutionContext.h>
#include <LibJS/Runtime/WeakContainer.h>
namespace JS {
@ -77,6 +78,9 @@ public:
void did_create_weak_container(Badge<WeakContainer>, WeakContainer&);
void did_destroy_weak_container(Badge<WeakContainer>, WeakContainer&);
void did_create_execution_context(Badge<ExecutionContext>, ExecutionContext&);
void did_destroy_execution_context(Badge<ExecutionContext>, ExecutionContext&);
BlockAllocator& block_allocator() { return m_block_allocator; }
void uproot_cell(Cell* cell);
@ -144,6 +148,7 @@ private:
HandleImpl::List m_handles;
MarkedVectorBase::List m_marked_vectors;
WeakContainer::List m_weak_containers;
ExecutionContext::List m_execution_contexts;
Vector<GCPtr<Cell>> m_uprooted_cells;
@ -191,4 +196,16 @@ inline void Heap::did_destroy_weak_container(Badge<WeakContainer>, WeakContainer
m_weak_containers.remove(set);
}
inline void Heap::did_create_execution_context(Badge<ExecutionContext>, ExecutionContext& set)
{
VERIFY(!m_execution_contexts.contains(set));
m_execution_contexts.append(set);
}
inline void Heap::did_destroy_execution_context(Badge<ExecutionContext>, ExecutionContext& set)
{
VERIFY(m_execution_contexts.contains(set));
m_execution_contexts.remove(set);
}
}