aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-21 00:39:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-21 00:39:43 +0000
commit6f3bd427e748fc798274eb176716849227cc7fdb (patch)
treef5a1cf1ffbc8402209ed83911a6d30222df26ca4 /gc.c
parentdce4bdf141365939cb0f2dae966f809f37cbc5d6 (diff)
downloadruby-6f3bd427e748fc798274eb176716849227cc7fdb.tar.gz
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
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c16
1 files 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<<gc_stress_no_major))
reason &= ~GPR_FLAG_MAJOR_MASK;
else
reason |= GPR_FLAG_MAJOR_BY_STRESS;
- immediate_sweep = !(flag & 0x02);
+ immediate_sweep = !(flag & (1<<gc_stress_no_immediate_sweep));
}
else {
if (!GC_ENABLE_LAZY_SWEEP || objspace->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