ruby-changes:60387
From: Nobuyoshi <ko1@a...>
Date: Fri, 13 Mar 2020 22:09:22 +0900 (JST)
Subject: [ruby-changes:60387] 9f504bb474 (ruby_2_7): Separate objspace argument for rb_gc_disable and rb_gc_enable
https://git.ruby-lang.org/ruby.git/commit/?id=9f504bb474 From 9f504bb474770f1cac68988eac2a410e41c4bbb8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 9 Feb 2020 16:56:40 +0900 Subject: Separate objspace argument for rb_gc_disable and rb_gc_enable (cherry picked from commit aeaf0dc55595b8a5bfdd92007fb85ef13855c632) diff --git a/gc.c b/gc.c index 8f2b8a4..0c007df 100644 --- a/gc.c +++ b/gc.c @@ -1062,6 +1062,7 @@ static int gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, https://github.com/ruby/ruby/blob/trunk/gc.c#L1062 static int gc_verify_heap_pages(rb_objspace_t *objspace); static void gc_stress_set(rb_objspace_t *objspace, VALUE flag); +static VALUE gc_disable_no_rest(rb_objspace_t *); static double getrusage_time(void); static inline void gc_prof_setup_new_record(rb_objspace_t *objspace, int reason); @@ -5863,7 +5864,7 @@ gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func, https://github.com/ruby/ruby/blob/trunk/gc.c#L5864 #if RGENGC_ESTIMATE_OLDMALLOC size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase; #endif - VALUE already_disabled = rb_gc_disable(); + VALUE already_disabled = rb_objspace_gc_disable(objspace); objspace->rgengc.allrefs_table = objspace_allrefs(objspace); @@ -5881,7 +5882,7 @@ gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func, https://github.com/ruby/ruby/blob/trunk/gc.c#L5882 objspace_allrefs_destruct(objspace->rgengc.allrefs_table); objspace->rgengc.allrefs_table = 0; - if (already_disabled == Qfalse) rb_gc_enable(); + if (already_disabled == Qfalse) rb_objspace_gc_enable(objspace); objspace->malloc_params.increase = saved_malloc_increase; #if RGENGC_ESTIMATE_OLDMALLOC objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase; @@ -8548,7 +8549,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8549 } VALUE moved_list_head; - VALUE disabled = rb_gc_disable(); + VALUE disabled = rb_objspace_gc_disable(objspace); if (use_toward_empty) { moved_list_head = gc_compact_heap(objspace, compare_free_slots); @@ -8559,7 +8560,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8560 heap_eden->freelist = NULL; gc_update_references(objspace); - if (!RTEST(disabled)) rb_gc_enable(); + if (!RTEST(disabled)) rb_objspace_gc_enable(objspace); if (use_verifier) { gc_check_references_for_moved(objspace); @@ -9210,6 +9211,12 @@ VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L9211 rb_gc_enable(void) { rb_objspace_t *objspace = &rb_objspace; + return rb_objspace_gc_enable(objspace); +} + +VALUE +rb_objspace_gc_enable(rb_objspace_t *objspace) +{ int old = dont_gc; dont_gc = FALSE; @@ -9226,18 +9233,29 @@ VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L9233 rb_gc_disable_no_rest(void) { rb_objspace_t *objspace = &rb_objspace; + return gc_disable_no_rest(objspace); +} + +static VALUE +gc_disable_no_rest(rb_objspace_t *objspace) +{ int old = dont_gc; dont_gc = TRUE; return old ? Qtrue : Qfalse; } - VALUE rb_gc_disable(void) { rb_objspace_t *objspace = &rb_objspace; + return rb_objspace_gc_disable(objspace); +} + +VALUE +rb_objspace_gc_disable(rb_objspace_t *objspace) +{ gc_rest(objspace); - return rb_gc_disable_no_rest(); + return gc_disable_no_rest(objspace); } static VALUE diff --git a/internal.h b/internal.h index baefb36..98df7a4 100644 --- a/internal.h +++ b/internal.h @@ -1635,6 +1635,8 @@ void Init_heap(void); https://github.com/ruby/ruby/blob/trunk/internal.h#L1635 void *ruby_mimmalloc(size_t size) RUBY_ATTR_MALLOC; void ruby_mimfree(void *ptr); void rb_objspace_set_event_hook(const rb_event_flag_t event); +VALUE rb_objspace_gc_enable(struct rb_objspace *); +VALUE rb_objspace_gc_disable(struct rb_objspace *); #if USE_RGENGC void rb_gc_writebarrier_remember(VALUE obj); #else @@ -2339,6 +2341,7 @@ enum method_missing_reason { https://github.com/ruby/ruby/blob/trunk/internal.h#L2341 struct rb_callable_method_entry_struct; struct rb_method_definition_struct; struct rb_execution_context_struct; +struct rb_objspace; /* in vm_core.h */ struct rb_control_frame_struct; struct rb_calling_info; struct rb_call_data; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/