summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorfleuria <[email protected]>2013-07-24 14:05:49 +0800
committerfleuria <[email protected]>2013-07-24 16:17:53 +0800
commit9cc43a970cf84f2d16f616e7875d480797d3660f (patch)
tree8e3a2807c280d6611e99a4166eeff72bab5a8890 /src
parentbe419485ba048c1545fdbc10f75aaf3a0a8f082c (diff)
downloadmruby-9cc43a970cf84f2d16f616e7875d480797d3660f.tar.gz
mruby-9cc43a970cf84f2d16f616e7875d480797d3660f.zip
introduce incremental_gc_step()
Diffstat (limited to 'src')
-rw-r--r--src/gc.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/gc.c b/src/gc.c
index cfe48df68..1dcaf4dd0 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -919,6 +919,20 @@ incremental_gc_until(mrb_state *mrb, enum gc_state to_state)
}
static void
+incremental_gc_step(mrb_state *mrb)
+{
+ size_t limit = 0, result = 0;
+ limit = (GC_STEP_SIZE/100) * mrb->gc_step_ratio;
+ while (result < limit) {
+ result += incremental_gc(mrb, limit);
+ if (mrb->gc_state == GC_STATE_NONE)
+ break;
+ }
+
+ mrb->gc_threshold = mrb->live + GC_STEP_SIZE;
+}
+
+static void
clear_all_old(mrb_state *mrb)
{
size_t origin_mode = mrb->is_generational_gc_mode;
@@ -947,13 +961,7 @@ mrb_incremental_gc(mrb_state *mrb)
incremental_gc_until(mrb, GC_STATE_NONE);
}
else {
- size_t limit = 0, result = 0;
- limit = (GC_STEP_SIZE/100) * mrb->gc_step_ratio;
- while (result < limit) {
- result += incremental_gc(mrb, limit);
- if (mrb->gc_state == GC_STATE_NONE)
- break;
- }
+ incremental_gc_step(mrb);
}
if (mrb->gc_state == GC_STATE_NONE) {
@@ -962,6 +970,7 @@ mrb_incremental_gc(mrb_state *mrb)
if (mrb->gc_threshold < GC_STEP_SIZE) {
mrb->gc_threshold = GC_STEP_SIZE;
}
+
if (is_major_gc(mrb)) {
mrb->majorgc_old_threshold = mrb->gc_live_after_mark/100 * DEFAULT_MAJOR_GC_INC_RATIO;
mrb->gc_full = FALSE;
@@ -973,10 +982,6 @@ mrb_incremental_gc(mrb_state *mrb)
}
}
}
- else {
- mrb->gc_threshold = mrb->live + GC_STEP_SIZE;
- }
-
GC_TIME_STOP_AND_REPORT;
}