Skip to content

Commit

Permalink
Always use the longer version of TRY_WITH_GC
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 28, 2022
1 parent 09bce06 commit a05b261
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 | \
Expand All @@ -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.
Expand Down

0 comments on commit a05b261

Please sign in to comment.