summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Heap/Heap.h
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS/Heap/Heap.h')
-rw-r--r--Libraries/LibJS/Heap/Heap.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/Libraries/LibJS/Heap/Heap.h b/Libraries/LibJS/Heap/Heap.h
index 6544021b5a..c12805bfb9 100644
--- a/Libraries/LibJS/Heap/Heap.h
+++ b/Libraries/LibJS/Heap/Heap.h
@@ -46,13 +46,23 @@ public:
~Heap();
template<typename T, typename... Args>
- T* allocate(Args&&... args)
+ T* allocate_without_global_object(Args&&... args)
{
auto* memory = allocate_cell(sizeof(T));
new (memory) T(forward<Args>(args)...);
return static_cast<T*>(memory);
}
+ template<typename T, typename... Args>
+ T* allocate(GlobalObject& global_object, Args&&... args)
+ {
+ auto* memory = allocate_cell(sizeof(T));
+ new (memory) T(forward<Args>(args)...);
+ auto* cell = static_cast<T*>(memory);
+ cell->initialize(m_interpreter, global_object);
+ return cell;
+ }
+
enum class CollectionType {
CollectGarbage,
CollectEverything,