diff options
Diffstat (limited to 'gc.c')
-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. |