mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c: support `USE_RGENGC == 0'.
* test/ruby/test_gc.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
989373b243
commit
4369806ff0
3 changed files with 48 additions and 22 deletions
|
@ -1,3 +1,9 @@
|
|||
Mon Jun 30 15:07:34 2014 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* gc.c: support `USE_RGENGC == 0'.
|
||||
|
||||
* test/ruby/test_gc.rb: ditto.
|
||||
|
||||
Mon Jun 30 11:36:04 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||
|
||||
* file.c: [DOC] document File.join returns a string.
|
||||
|
|
33
gc.c
33
gc.c
|
@ -3038,6 +3038,7 @@ gc_after_sweep(rb_objspace_t *objspace)
|
|||
(int)heap->total_slots, (int)heap_pages_swept_slots, (int)heap_pages_min_free_slots);
|
||||
|
||||
if (heap_pages_swept_slots < heap_pages_min_free_slots) {
|
||||
#if USE_RGENGC
|
||||
if (objspace->rgengc.during_minor_gc && objspace->profile.count - objspace->rgengc.last_major_gc > 2 /* magic number */) {
|
||||
objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_NOFREE;
|
||||
}
|
||||
|
@ -3045,6 +3046,10 @@ gc_after_sweep(rb_objspace_t *objspace)
|
|||
heap_set_increment(objspace, heap_extend_pages(objspace));
|
||||
heap_increment(objspace, heap);
|
||||
}
|
||||
#else
|
||||
heap_set_increment(objspace, heap_extend_pages(objspace));
|
||||
heap_increment(objspace, heap);
|
||||
#endif
|
||||
}
|
||||
|
||||
gc_prof_set_heap_info(objspace);
|
||||
|
@ -3709,6 +3714,7 @@ rb_gc_resurrect(VALUE obj)
|
|||
!is_swept_object(objspace, obj)) {
|
||||
gc_mark_ptr(objspace, obj);
|
||||
|
||||
#if USE_RGENGC
|
||||
/* unmarked old objects means the last GC is major GC */
|
||||
/* at major GC, old object count is reset. */
|
||||
/* So that resurrect also increment old object count */
|
||||
|
@ -3720,6 +3726,7 @@ rb_gc_resurrect(VALUE obj)
|
|||
else if (RVALUE_YOUNG_P(obj)) {
|
||||
objspace->rgengc.young_object_count++;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -4518,20 +4525,22 @@ gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char
|
|||
|
||||
#endif /* RGENGC_CHECK_MODE >= 2 */
|
||||
|
||||
#if USE_RGENGC
|
||||
|
||||
struct verify_internal_consistency_struct {
|
||||
rb_objspace_t *objspace;
|
||||
int err_count;
|
||||
size_t live_object_count;
|
||||
size_t zombie_object_count;
|
||||
|
||||
#if USE_RGENGC
|
||||
VALUE parent;
|
||||
size_t old_object_count;
|
||||
#if RGENGC_AGE2_PROMOTION
|
||||
size_t young_object_count;
|
||||
#endif
|
||||
size_t zombie_object_count;
|
||||
VALUE parent;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if USE_RGENGC
|
||||
static void
|
||||
verify_internal_consistency_reachable_i(VALUE child, void *ptr)
|
||||
{
|
||||
|
@ -4549,6 +4558,7 @@ verify_internal_consistency_reachable_i(VALUE child, void *ptr)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, void *ptr)
|
||||
|
@ -4558,9 +4568,10 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, v
|
|||
|
||||
for (v = (VALUE)page_start; v != (VALUE)page_end; v += stride) {
|
||||
if (is_live_object(data->objspace, v)) {
|
||||
|
||||
/* count objects */
|
||||
data->live_object_count++;
|
||||
|
||||
#if USE_RGENGC
|
||||
if (RVALUE_OLD_P(v)) {
|
||||
data->old_object_count++;
|
||||
}
|
||||
|
@ -4574,6 +4585,7 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, v
|
|||
/* reachable objects from an oldgen object should be old or (young with remember) */
|
||||
rb_objspace_reachable_objects_from(v, verify_internal_consistency_reachable_i, (void *)data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
if (BUILTIN_TYPE(v) == T_ZOMBIE) {
|
||||
|
@ -4586,8 +4598,6 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, v
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* USE_RGENGC */
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* GC.verify_internal_consistency -> nil
|
||||
|
@ -4601,9 +4611,8 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, v
|
|||
static VALUE
|
||||
gc_verify_internal_consistency(VALUE self)
|
||||
{
|
||||
#if USE_RGENGC
|
||||
struct verify_internal_consistency_struct data = {0};
|
||||
rb_objspace_t *objspace = &rb_objspace;
|
||||
struct verify_internal_consistency_struct data = {0};
|
||||
data.objspace = objspace;
|
||||
|
||||
{
|
||||
|
@ -4612,16 +4621,15 @@ gc_verify_internal_consistency(VALUE self)
|
|||
eo_args.data = (void *)&data;
|
||||
objspace_each_objects((VALUE)&eo_args);
|
||||
}
|
||||
|
||||
if (data.err_count != 0) {
|
||||
#if RGENGC_CHECK_MODE >= 4
|
||||
rb_objspace_t *objspace = &rb_objspace;
|
||||
objspace->rgengc.error_count = data.err_count;
|
||||
gc_marks_check(objspace, NULL, NULL);
|
||||
allrefs_dump(objspace);
|
||||
#endif
|
||||
rb_bug("gc_verify_internal_consistency: found internal inconsistency.");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!is_lazy_sweeping(heap_eden) && !finalizing) {
|
||||
if (objspace_live_slot(objspace) != data.live_object_count) {
|
||||
|
@ -4630,6 +4638,8 @@ gc_verify_internal_consistency(VALUE self)
|
|||
rb_bug("inconsistent live slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace_live_slot(objspace), data.live_object_count);
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_RGENGC
|
||||
if (objspace->rgengc.old_object_count != data.old_object_count) {
|
||||
rb_bug("inconsistent old slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.old_object_count, data.old_object_count);
|
||||
}
|
||||
|
@ -4637,6 +4647,7 @@ gc_verify_internal_consistency(VALUE self)
|
|||
if (objspace->rgengc.young_object_count != data.young_object_count) {
|
||||
rb_bug("inconsistent young slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.young_object_count, data.young_object_count);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!finalizing) {
|
||||
|
|
|
@ -35,6 +35,10 @@ class TestGc < Test::Unit::TestCase
|
|||
GC.stress = prev_stress
|
||||
end
|
||||
|
||||
def use_rgengc?
|
||||
GC::OPTS.include? 'USE_RGENGC'.freeze
|
||||
end
|
||||
|
||||
def test_enable_disable
|
||||
GC.enable
|
||||
assert_equal(false, GC.enable)
|
||||
|
@ -49,6 +53,8 @@ class TestGc < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_start_full_mark
|
||||
return unless use_rgengc?
|
||||
|
||||
GC.start(full_mark: false)
|
||||
assert_nil GC.latest_gc_info(:major_by)
|
||||
|
||||
|
@ -112,7 +118,7 @@ class TestGc < Test::Unit::TestCase
|
|||
assert_equal :newobj, GC.latest_gc_info[:gc_by]
|
||||
|
||||
GC.start
|
||||
assert_equal :nofree, GC.latest_gc_info[:major_by]
|
||||
assert_equal :nofree, GC.latest_gc_info[:major_by] if use_rgengc?
|
||||
assert_equal :method, GC.latest_gc_info[:gc_by]
|
||||
assert_equal true, GC.latest_gc_info[:immediate_sweep]
|
||||
|
||||
|
@ -190,8 +196,9 @@ class TestGc < Test::Unit::TestCase
|
|||
}
|
||||
assert_normal_exit("exit", "", :child_env => env)
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0\.9/, "")
|
||||
|
||||
# always full GC when RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR < 1.0
|
||||
assert_in_out_err([env, "-e", "1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "")
|
||||
assert_in_out_err([env, "-e", "1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "") if use_rgengc?
|
||||
|
||||
# check obsolete
|
||||
assert_in_out_err([{'RUBY_FREE_MIN' => '100'}, '-w', '-eexit'], '', [],
|
||||
|
@ -209,15 +216,17 @@ class TestGc < Test::Unit::TestCase
|
|||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_MALLOC_LIMIT_MAX=16000000/, "")
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=2.0/, "")
|
||||
|
||||
env = {
|
||||
"RUBY_GC_OLDMALLOC_LIMIT" => "60000000",
|
||||
"RUBY_GC_OLDMALLOC_LIMIT_MAX" => "160000000",
|
||||
"RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR" => "2.0"
|
||||
}
|
||||
assert_normal_exit("exit", "", :child_env => env)
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT=6000000/, "")
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_MAX=16000000/, "")
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=2.0/, "")
|
||||
if use_rgengc?
|
||||
env = {
|
||||
"RUBY_GC_OLDMALLOC_LIMIT" => "60000000",
|
||||
"RUBY_GC_OLDMALLOC_LIMIT_MAX" => "160000000",
|
||||
"RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR" => "2.0"
|
||||
}
|
||||
assert_normal_exit("exit", "", :child_env => env)
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT=6000000/, "")
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_MAX=16000000/, "")
|
||||
assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=2.0/, "")
|
||||
end
|
||||
end
|
||||
|
||||
def test_profiler_enabled
|
||||
|
|
Loading…
Add table
Reference in a new issue