1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-29 09:47:45 +00:00
serenity/Ports/citron/patches/0005-Disable-GC-on-serenity.patch
2023-08-16 15:32:42 +03:30

57 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
Date: Fri, 11 Feb 2022 18:29:07 +0330
Subject: [PATCH] Disable GC on serenity
---
src/memory.c | 4 ++++
src/system.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/src/memory.c b/src/memory.c
index 3694dbbc47ae5ea132176e5246b3422b2fcfb96f..e660b776f04e649f082d66b0e128470f5fc30629 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -91,6 +91,7 @@ void* ctr_heap_allocate(size_t size)
/* Check whether we can afford to allocate this much */
ctr_gc_alloc = GC_get_heap_size() - GC_get_free_bytes() - GC_get_unmapped_bytes();
+#ifndef __serenity__
if (ctr_gc_memlimit < ctr_gc_alloc) {
ctr_gc_sweep(0);
if (ctr_gc_memlimit < ctr_gc_alloc) {
@@ -104,6 +105,7 @@ void* ctr_heap_allocate(size_t size)
}
}
}
+#endif
/* Perform allocation and check result */
slice_of_memory = calloc(size, 1);
@@ -225,10 +227,12 @@ size_t ctr_heap_get_latest_tracking_id() { return numberOfMemBlocks - 1; }
*/
void ctr_heap_free_rest()
{
+#ifndef __serenity__
size_t i;
for (i = 0; i < numberOfMemBlocks; i++) {
ctr_heap_free(memBlocks[i].space);
}
+#endif
}
/**
diff --git a/src/system.c b/src/system.c
index f4dd7aee322403ce996255f18a105eb2f408139e..949f0365d3a599c71ad06af8de853a820e69974d 100644
--- a/src/system.c
+++ b/src/system.c
@@ -426,6 +426,9 @@ void ctr_gc_mark(ctr_object* object, int last_vector_index)
*/
void ctr_gc_sweep(int all)
{
+#ifdef __serenity
+ return;
+#endif
ctr_object* previousObject = NULL;
ctr_object* currentObject = ctr_first_object;
ctr_object* nextObject = NULL;