ruby-changes:33574
From: nobu <ko1@a...>
Date: Tue, 22 Apr 2014 06:54:40 +0900 (JST)
Subject: [ruby-changes:33574] nobu:r45655 (trunk): gc.c: full mark after malloc/realloc
nobu 2014-04-22 06:54:17 +0900 (Tue, 22 Apr 2014) New Revision: 45655 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45655 Log: gc.c: full mark after malloc/realloc * gc.c (objspace_malloc_increase): run full mark if 0x04 bit is set in ruby_gc_stress. [ruby-core:62103] [Feature #9761] Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 45654) +++ ChangeLog (revision 45655) @@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Tue Apr 22 06:53:30 2014 Nobuyoshi Nakada <nobu@r...> +Tue Apr 22 06:54:15 2014 Nobuyoshi Nakada <nobu@r...> + + * gc.c (objspace_malloc_increase): run full mark if 0x04 bit is + set in ruby_gc_stress. [ruby-core:62103] [Feature #9761] * gc.c (objspace_malloc_increase): run GC after realloc not only malloc and calloc by GC.stress. [ruby-core:62103] [Feature #9761] Index: gc.c =================================================================== --- gc.c (revision 45654) +++ gc.c (revision 45655) @@ -5020,9 +5020,13 @@ rb_global_variable(VALUE *var) https://github.com/ruby/ruby/blob/trunk/gc.c#L5020 enum { gc_stress_no_major, gc_stress_no_immediate_sweep, + gc_stress_full_mark_after_malloc, gc_stress_max }; +#define gc_stress_full_mark_after_malloc_p() \ + (FIXNUM_P(ruby_gc_stress) && (FIX2LONG(ruby_gc_stress) & (1<<gc_stress_full_mark_after_malloc))) + static int garbage_collect_body(rb_objspace_t *objspace, int full_mark, int immediate_sweep, int reason) { @@ -5653,6 +5657,7 @@ gc_stress_get(VALUE self) https://github.com/ruby/ruby/blob/trunk/gc.c#L5657 * flag can be true, false, or a fixnum bit-ORed following flags. * 0x01:: no major GC * 0x02:: no immediate sweep + * 0x04:: full mark after malloc/calloc/realloc */ static VALUE @@ -6093,8 +6098,9 @@ objspace_malloc_increase(rb_objspace_t * https://github.com/ruby/ruby/blob/trunk/gc.c#L6098 } if (type == MEMOP_TYPE_MALLOC || type == MEMOP_TYPE_REALLOC) { + int full_mark = gc_stress_full_mark_after_malloc_p(); if (ruby_gc_stress && !ruby_disable_gc_stress && ruby_native_thread_p()) { - garbage_collect_with_gvl(objspace, FALSE, TRUE, GPR_FLAG_MALLOC); + garbage_collect_with_gvl(objspace, full_mark, TRUE, GPR_FLAG_MALLOC); } else { retry: @@ -6103,7 +6109,7 @@ objspace_malloc_increase(rb_objspace_t * https://github.com/ruby/ruby/blob/trunk/gc.c#L6109 gc_rest_sweep(objspace); /* rest_sweep can reduce malloc_increase */ goto retry; } - garbage_collect_with_gvl(objspace, FALSE, TRUE, GPR_FLAG_MALLOC); + garbage_collect_with_gvl(objspace, full_mark, TRUE, GPR_FLAG_MALLOC); } } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/