Compile debugging code for stress to class always

This commit is contained in:
Nobuyoshi Nakada 2023-06-28 22:03:03 +09:00
Родитель 7a0a218dff
Коммит 5204ad56e1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3582D74E1FEE4465
2 изменённых файлов: 11 добавлений и 13 удалений

2
.github/workflows/compilers.yml поставляемый
Просмотреть файл

@ -181,7 +181,7 @@ jobs:
# - { name: DEBUG_INTEGER_PACK, env: { cppflags: '-DDEBUG_INTEGER_PACK' } }
# - { name: ENABLE_PATH_CHECK, env: { cppflags: '-DENABLE_PATH_CHECK' } }
- { name: GC_DEBUG_STRESS_TO_CLASS, env: { cppflags: '-DGC_DEBUG_STRESS_TO_CLASS' } }
# - { name: GC_DEBUG_STRESS_TO_CLASS, env: { cppflags: '-DGC_DEBUG_STRESS_TO_CLASS' } }
# - { name: GC_ENABLE_LAZY_SWEEP=0, env: { cppflags: '-DGC_ENABLE_LAZY_SWEEP=0' } }
# - { name: GC_PROFILE_DETAIL_MEMOTY, env: { cppflags: '-DGC_PROFILE_DETAIL_MEMOTY' } }
# - { name: GC_PROFILE_MORE_DETAIL, env: { cppflags: '-DGC_PROFILE_MORE_DETAIL' } }

22
gc.c
Просмотреть файл

@ -492,7 +492,7 @@ int ruby_rgengc_debug;
#endif
#ifndef GC_DEBUG_STRESS_TO_CLASS
#define GC_DEBUG_STRESS_TO_CLASS 0
#define GC_DEBUG_STRESS_TO_CLASS RUBY_DEBUG
#endif
#ifndef RGENGC_OBJ_INFO
@ -1044,8 +1044,10 @@ VALUE *ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress;
#define ruby_gc_stress_mode objspace->gc_stress_mode
#if GC_DEBUG_STRESS_TO_CLASS
#define stress_to_class objspace->stress_to_class
#define set_stress_to_class(c) (stress_to_class = (c))
#else
#define stress_to_class 0
#define stress_to_class (objspace, 0)
#define set_stress_to_class(c) (objspace, (c))
#endif
#if 0
@ -2845,14 +2847,12 @@ newobj_of0(VALUE klass, VALUE flags, int wb_protected, rb_ractor_t *cr, size_t a
RB_DEBUG_COUNTER_INC(obj_newobj);
(void)RB_DEBUG_COUNTER_INC_IF(obj_newobj_wb_unprotected, !wb_protected);
#if GC_DEBUG_STRESS_TO_CLASS
if (UNLIKELY(stress_to_class)) {
long i, cnt = RARRAY_LEN(stress_to_class);
for (i = 0; i < cnt; ++i) {
if (klass == RARRAY_AREF(stress_to_class, i)) rb_memerror();
}
}
#endif
size_t size_pool_idx = size_pool_idx_for_size(alloc_size);
@ -13805,7 +13805,6 @@ rb_gcdebug_sentinel(VALUE obj, const char *name)
#endif /* GC_DEBUG */
#if GC_DEBUG_STRESS_TO_CLASS
/*
* call-seq:
* GC.add_stress_to_class(class[, ...])
@ -13819,7 +13818,7 @@ rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
rb_objspace_t *objspace = &rb_objspace;
if (!stress_to_class) {
stress_to_class = rb_ary_hidden_new(argc);
set_stress_to_class(rb_ary_hidden_new(argc));
}
rb_ary_cat(stress_to_class, argv, argc);
return self;
@ -13844,12 +13843,11 @@ rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
rb_ary_delete_same(stress_to_class, argv[i]);
}
if (RARRAY_LEN(stress_to_class) == 0) {
stress_to_class = 0;
set_stress_to_class(0);
}
}
return Qnil;
}
#endif
/*
* Document-module: ObjectSpace
@ -13975,10 +13973,10 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "verify_compaction_references", rb_f_notimplement, -1);
}
#if GC_DEBUG_STRESS_TO_CLASS
rb_define_singleton_method(rb_mGC, "add_stress_to_class", rb_gcdebug_add_stress_to_class, -1);
rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
#endif
if (GC_DEBUG_STRESS_TO_CLASS) {
rb_define_singleton_method(rb_mGC, "add_stress_to_class", rb_gcdebug_add_stress_to_class, -1);
rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
}
{
VALUE opts;