1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-04-21 21:54:17 +00:00
parent 2abb976deb
commit 5890cb9d2d
2 changed files with 12 additions and 3 deletions

View file

@ -1,4 +1,7 @@
Tue Apr 22 06:53:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Apr 22 06:54:15 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 * gc.c (objspace_malloc_increase): run GC after realloc not only
malloc and calloc by GC.stress. [ruby-core:62103] [Feature #9761] malloc and calloc by GC.stress. [ruby-core:62103] [Feature #9761]

10
gc.c
View file

@ -5020,9 +5020,13 @@ rb_global_variable(VALUE *var)
enum { enum {
gc_stress_no_major, gc_stress_no_major,
gc_stress_no_immediate_sweep, gc_stress_no_immediate_sweep,
gc_stress_full_mark_after_malloc,
gc_stress_max 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 static int
garbage_collect_body(rb_objspace_t *objspace, int full_mark, int immediate_sweep, int reason) garbage_collect_body(rb_objspace_t *objspace, int full_mark, int immediate_sweep, int reason)
{ {
@ -5653,6 +5657,7 @@ gc_stress_get(VALUE self)
* flag can be true, false, or a fixnum bit-ORed following flags. * flag can be true, false, or a fixnum bit-ORed following flags.
* 0x01:: no major GC * 0x01:: no major GC
* 0x02:: no immediate sweep * 0x02:: no immediate sweep
* 0x04:: full mark after malloc/calloc/realloc
*/ */
static VALUE static VALUE
@ -6093,8 +6098,9 @@ objspace_malloc_increase(rb_objspace_t *objspace, void *mem, size_t new_size, si
} }
if (type == MEMOP_TYPE_MALLOC || type == MEMOP_TYPE_REALLOC) { 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()) { 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 { else {
retry: retry:
@ -6103,7 +6109,7 @@ objspace_malloc_increase(rb_objspace_t *objspace, void *mem, size_t new_size, si
gc_rest_sweep(objspace); /* rest_sweep can reduce malloc_increase */ gc_rest_sweep(objspace); /* rest_sweep can reduce malloc_increase */
goto retry; goto retry;
} }
garbage_collect_with_gvl(objspace, FALSE, TRUE, GPR_FLAG_MALLOC); garbage_collect_with_gvl(objspace, full_mark, TRUE, GPR_FLAG_MALLOC);
} }
} }
} }