From 6f3bd427e748fc798274eb176716849227cc7fdb Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 21 Apr 2014 00:39:43 +0000 Subject: [PATCH] gc.c: fixnum GC stress * gc.c (garbage_collect_body): name magic numbers. * gc.c (gc_stress_set): GC.stress accepts not only boolean but also Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index 170a95f1f4..f8172131ac 100644 --- a/gc.c +++ b/gc.c @@ -5017,17 +5017,23 @@ rb_global_variable(VALUE *var) #define GC_NOTIFY 0 +enum { + gc_stress_no_major, + gc_stress_no_immediate_sweep, + gc_stress_max +}; + static int garbage_collect_body(rb_objspace_t *objspace, int full_mark, int immediate_sweep, int reason) { if (ruby_gc_stress && !ruby_disable_gc_stress) { int flag = FIXNUM_P(ruby_gc_stress) ? FIX2INT(ruby_gc_stress) : 0; - if (flag & 0x01) + if (flag & (1<flags.dont_lazy_sweep) { @@ -5635,7 +5641,7 @@ gc_stress_get(VALUE self) /* * call-seq: - * GC.stress = bool -> bool + * GC.stress = flag -> flag * * Updates the GC stress mode. * @@ -5643,6 +5649,10 @@ gc_stress_get(VALUE self) * all memory and object allocations. * * Enabling stress mode will degrade performance, it is only for debugging. + * + * flag can be true, false, or a fixnum bit-ORed following flags. + * 0x01:: no major GC + * 0x02:: no immediate sweep */ static VALUE