From 52283b44ffff21a5f79c084bbb5bb6a256842cbd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Sep 2025 14:15:55 +0900 Subject: [PATCH 1/3] Compile `RGENGC_OBJ_INFO` case statically Make this macro condition as compile-time constant instead of a preprocess-time constant, and compile the body always. --- gc.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/gc.c b/gc.c index c412da188130e5..0433da2e67c282 100644 --- a/gc.c +++ b/gc.c @@ -4965,12 +4965,6 @@ rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj) #undef APPEND_F #undef BUFF_ARGS -#if RGENGC_OBJ_INFO -#define OBJ_INFO_BUFFERS_NUM 10 -#define OBJ_INFO_BUFFERS_SIZE 0x100 -static rb_atomic_t obj_info_buffers_index = 0; -static char obj_info_buffers[OBJ_INFO_BUFFERS_NUM][OBJ_INFO_BUFFERS_SIZE]; - /* Increments *var atomically and resets *var to 0 when maxval is * reached. Returns the wraparound old *var value (0...maxval). */ static rb_atomic_t @@ -4988,17 +4982,18 @@ atomic_inc_wraparound(rb_atomic_t *var, const rb_atomic_t maxval) static const char * obj_info(VALUE obj) { - rb_atomic_t index = atomic_inc_wraparound(&obj_info_buffers_index, OBJ_INFO_BUFFERS_NUM); - char *const buff = obj_info_buffers[index]; - return rb_raw_obj_info(buff, OBJ_INFO_BUFFERS_SIZE, obj); -} -#else -static const char * -obj_info(VALUE obj) -{ + if (RGENGC_OBJ_INFO) { + static struct { + rb_atomic_t index; + char buffers[10][0x100]; + } info = {0}; + + rb_atomic_t index = atomic_inc_wraparound(&info.index, numberof(info.buffers)); + char *const buff = info.buffers[index]; + return rb_raw_obj_info(buff, sizeof(info.buffers[0]), obj); + } return obj_type_name(obj); } -#endif /* ------------------------ Extended allocator ------------------------ From 4491c6737d686a426865f8bf518b19a6857907da Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Sep 2025 14:28:57 +0900 Subject: [PATCH 2/3] Remove `RGENGC_OBJ_INFO` compilations check Now it is always compiled (and will be optimized away). --- .github/workflows/compilers.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml index cf456bc5bb88e6..3bb8220d8282f1 100644 --- a/.github/workflows/compilers.yml +++ b/.github/workflows/compilers.yml @@ -281,7 +281,6 @@ jobs: - { uses: './.github/actions/compilers', name: 'GC_PROFILE_MORE_DETAIL', with: { cppflags: '-DGC_PROFILE_MORE_DETAIL' } } - { uses: './.github/actions/compilers', name: 'MALLOC_ALLOCATED_SIZE_CHECK', with: { cppflags: '-DMALLOC_ALLOCATED_SIZE_CHECK' } } - { uses: './.github/actions/compilers', name: 'RGENGC_ESTIMATE_OLDMALLOC', with: { cppflags: '-DRGENGC_ESTIMATE_OLDMALLOC' } } - - { uses: './.github/actions/compilers', name: 'RGENGC_OBJ_INFO', with: { cppflags: '-DRGENGC_OBJ_INFO' } } - { uses: './.github/actions/compilers', name: 'RGENGC_PROFILE', with: { cppflags: '-DRGENGC_PROFILE' } } compileC: From 214ba4074d11ba3e610546700298caba89a35071 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 14 Sep 2025 17:25:11 +0900 Subject: [PATCH 3/3] win32: Also ruby/confg.h depends on the ABI version header --- win32/Makefile.sub | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/Makefile.sub b/win32/Makefile.sub index ade48d5e7575c2..c91c05584e6331 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -649,7 +649,8 @@ config.status: nul guard = INCLUDE_RUBY_CONFIG_H -$(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub +$(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub \ + $(ABI_VERSION_HDR) @echo Creating config.h !if !exist("$(arch_hdrdir)") @md $(arch_hdrdir:/=\)