wingo pushed a commit to branch wip-whippet
in repository guile.

commit 0318770266e0ec6535d0151881fda1536e874b3e
Author: Andy Wingo <wi...@igalia.com>
AuthorDate: Wed Dec 11 15:11:56 2024 +0100

    pcc: abstract space that has blocks paged out and in
---
 src/pcc.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/pcc.c b/src/pcc.c
index 485981d70..8dba8f32f 100644
--- a/src/pcc.c
+++ b/src/pcc.c
@@ -80,6 +80,10 @@ static inline struct copy_space* 
heap_allocation_space(struct gc_heap *heap) {
   // The space into which small objects are allocated.
   return heap_copy_space(heap);
 }
+static inline struct copy_space* heap_resizable_space(struct gc_heap *heap) {
+  // The space that gets resized.
+  return heap_copy_space(heap);
+}
 static inline struct large_object_space* heap_large_object_space(struct 
gc_heap *heap) {
   return &heap->large_object_space;
 }
@@ -284,7 +288,7 @@ static void heap_reset_large_object_pages(struct gc_heap 
*heap, size_t npages) {
   GC_ASSERT(npages <= previous);
   size_t bytes = (previous - npages) <<
     heap_large_object_space(heap)->page_size_log2;
-  copy_space_reacquire_memory(heap_copy_space(heap), bytes);
+  copy_space_reacquire_memory(heap_resizable_space(heap), bytes);
 }
 
 static void wait_for_mutators_to_stop(struct gc_heap *heap) {
@@ -330,9 +334,9 @@ static void resize_heap(struct gc_heap *heap, size_t 
new_size) {
   DEBUG("------ old heap size: %zu bytes\n", heap->size);
   DEBUG("------ new heap size: %zu bytes\n", new_size);
   if (new_size < heap->size)
-    copy_space_shrink(heap_copy_space(heap), heap->size - new_size);
+    copy_space_shrink(heap_resizable_space(heap), heap->size - new_size);
   else
-    copy_space_expand(heap_copy_space(heap), new_size - heap->size);
+    copy_space_expand(heap_resizable_space(heap), new_size - heap->size);
 
   heap->size = new_size;
   HEAP_EVENT(heap, heap_resized, new_size);
@@ -485,9 +489,9 @@ static void* allocate_large(struct gc_mutator *mut, size_t 
size) {
 
   size_t npages = large_object_space_npages(space, size);
 
-  copy_space_request_release_memory(heap_copy_space(heap),
-                                     npages << space->page_size_log2);
-  while 
(!copy_space_page_out_blocks_until_memory_released(heap_copy_space(heap)))
+  copy_space_request_release_memory(heap_resizable_space(heap),
+                                    npages << space->page_size_log2);
+  while 
(!copy_space_page_out_blocks_until_memory_released(heap_resizable_space(heap)))
     trigger_collection(mut, GC_COLLECTION_COMPACTING);
   atomic_fetch_add(&heap->large_object_pages, npages);
 

Reply via email to