From 2891d2b260997c9edd064090cde8eb9853935f83 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 18 Oct 2020 18:41:18 -0500 Subject: [PATCH] Address #489 Add gc pressure when resizing fiber stack. --- src/core/fiber.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/fiber.c b/src/core/fiber.c index 1d6e5783..35262951 100644 --- a/src/core/fiber.c +++ b/src/core/fiber.c @@ -103,12 +103,15 @@ static void janet_fiber_refresh_memory(JanetFiber *fiber) { /* Ensure that the fiber has enough extra capacity */ void janet_fiber_setcapacity(JanetFiber *fiber, int32_t n) { + int32_t old_size = fiber->capacity; + int32_t diff = n - old_size; Janet *newData = realloc(fiber->data, sizeof(Janet) * n); if (NULL == newData) { JANET_OUT_OF_MEMORY; } fiber->data = newData; fiber->capacity = n; + janet_vm_next_collection += sizeof(Janet) * diff; } /* Grow fiber if needed */