diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-09-28 22:07:50 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-09-28 23:51:38 +0900 |
commit | a05b2614645594df896aaf44a2e5701ee7fb5fec (patch) | |
tree | 610f1d3e79baed4ea8ee7bb32b1fdd97cc851340 | |
parent | 09bce061afa3f5710e8d6aafebf865096f11b957 (diff) | |
download | ruby-a05b2614645594df896aaf44a2e5701ee7fb5fec.tar.gz |
Always use the longer version of `TRY_WITH_GC`
-rw-r--r-- | gc.c | 30 |
1 files changed, 12 insertions, 18 deletions
@@ -12121,10 +12121,16 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size) } #if defined(__GNUC__) && RUBY_DEBUG -#define RB_BUG_INSTEAD_OF_RB_MEMERROR +#define RB_BUG_INSTEAD_OF_RB_MEMERROR 1 #endif -#ifdef RB_BUG_INSTEAD_OF_RB_MEMERROR +#ifndef RB_BUG_INSTEAD_OF_RB_MEMERROR +# define RB_BUG_INSTEAD_OF_RB_MEMERROR 0 +#endif + +#define GC_MEMERROR(...) \ + ((RB_BUG_INSTEAD_OF_RB_MEMERROR+0) ? rb_bug("" __VA_ARGS__) : rb_memerror()) + #define TRY_WITH_GC(siz, expr) do { \ const gc_profile_record_flag gpr = \ GPR_FLAG_FULL_MARK | \ @@ -12138,29 +12144,17 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size) } \ else if (!garbage_collect_with_gvl(objspace, gpr)) { \ /* @shyouhei thinks this doesn't happen */ \ - rb_bug("TRY_WITH_GC: could not GC"); \ + GC_MEMERROR("TRY_WITH_GC: could not GC"); \ } \ else if ((expr)) { \ /* Success on 2nd try */ \ } \ else { \ - rb_bug("TRY_WITH_GC: could not allocate:" \ - "%"PRIdSIZE" bytes for %s", \ - siz, # expr); \ + GC_MEMERROR("TRY_WITH_GC: could not allocate:" \ + "%"PRIdSIZE" bytes for %s", \ + siz, # expr); \ } \ } while (0) -#else -#define TRY_WITH_GC(siz, alloc) do { \ - objspace_malloc_gc_stress(objspace); \ - if (!(alloc) && \ - (!garbage_collect_with_gvl(objspace, GPR_FLAG_FULL_MARK | \ - GPR_FLAG_IMMEDIATE_MARK | GPR_FLAG_IMMEDIATE_SWEEP | \ - GPR_FLAG_MALLOC) || \ - !(alloc))) { \ - ruby_memerror(); \ - } \ - } while (0) -#endif /* these shouldn't be called directly. * objspace_* functions do not check allocation size. |