aboutsummaryrefslogtreecommitdiffstats
path: root/gclib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gclib.cpp')
-rw-r--r--gclib.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/gclib.cpp b/gclib.cpp
index 3181dcd..0d2d84e 100644
--- a/gclib.cpp
+++ b/gclib.cpp
@@ -22,23 +22,25 @@
extern "C" {
+static const size_t COLLECT_SIZE = 8 * 1024 * 1024; // 8 MiB
+
void
-tuplr_gc_initialize(unsigned heapSize)
+tuplr_gc_collect()
{
- //printf("LLVM GC INIT %u\n", heapSize);
+ Object::pool.collect(Object::pool.roots());
}
void*
-tuplr_gc_allocate(unsigned size)
+tuplr_gc_allocate(unsigned size, uint8_t tag)
{
- //printf("LLVM GC ALLOC %u\n", size);
- return malloc(size);
-}
+ static size_t allocated = 0;
+ allocated += size;
+ if (allocated > COLLECT_SIZE) {
+ tuplr_gc_collect();
+ allocated = 0;
+ }
-void
-tuplr_gc_collect()
-{
- //printf("LLVM GC COLLECT\n");
+ return Object::pool.alloc(size, (GC::Tag)tag);
}
}