diff --git a/gc.c b/gc.c index 55b6a7b5d4..8913f15d61 100644 --- a/gc.c +++ b/gc.c @@ -327,6 +327,14 @@ rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val) #define GC_OLDMALLOC_LIMIT_MAX (128 * 1024 * 1024 /* 128MB */) #endif +#ifndef GC_CAN_COMPILE_COMPACTION +#if defined(__wasi__) /* WebAssembly doesn't support signals */ +# define GC_CAN_COMPILE_COMPACTION 0 +#else +# define GC_CAN_COMPILE_COMPACTION 1 +#endif +#endif + #ifndef PRINT_MEASURE_LINE #define PRINT_MEASURE_LINE 0 #endif @@ -2249,6 +2257,7 @@ heap_assign_page(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t * heap_add_freepage(heap, page); } +#if GC_CAN_COMPILE_COMPACTION static void heap_add_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, size_t add) { @@ -2262,6 +2271,7 @@ heap_add_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *he GC_ASSERT(size_pool->allocatable_pages == 0); } +#endif static size_t minimum_pages_for_size_pool(rb_objspace_t *objspace, int size_pool_idx) @@ -5183,14 +5193,8 @@ gc_unprotect_pages(rb_objspace_t *objspace, rb_heap_t *heap) } static void gc_update_references(rb_objspace_t * objspace); +#if GC_CAN_COMPILE_COMPACTION static void invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page); - -#ifndef GC_CAN_COMPILE_COMPACTION -#if defined(__wasi__) /* WebAssembly doesn't support signals */ -# define GC_CAN_COMPILE_COMPACTION 0 -#else -# define GC_CAN_COMPILE_COMPACTION 1 -#endif #endif #if defined(__MINGW32__) || defined(_WIN32) @@ -5879,6 +5883,7 @@ gc_sweep_continue(rb_objspace_t *objspace, rb_size_pool_t *sweep_size_pool, rb_h gc_sweeping_exit(objspace); } +#if GC_CAN_COMPILE_COMPACTION static void invalidate_moved_plane(rb_objspace_t *objspace, struct heap_page *page, uintptr_t p, bits_t bitset) { @@ -5951,6 +5956,7 @@ invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page) p += BITS_BITLENGTH * BASE_SLOT_SIZE; } } +#endif static void gc_compact_start(rb_objspace_t *objspace)