diff options
| author | fleuria <[email protected]> | 2013-07-24 14:05:49 +0800 |
|---|---|---|
| committer | fleuria <[email protected]> | 2013-07-24 16:17:53 +0800 |
| commit | 9cc43a970cf84f2d16f616e7875d480797d3660f (patch) | |
| tree | 8e3a2807c280d6611e99a4166eeff72bab5a8890 | |
| parent | be419485ba048c1545fdbc10f75aaf3a0a8f082c (diff) | |
| download | mruby-9cc43a970cf84f2d16f616e7875d480797d3660f.tar.gz mruby-9cc43a970cf84f2d16f616e7875d480797d3660f.zip | |
introduce incremental_gc_step()
| -rw-r--r-- | src/gc.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -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; } |
