зеркало из https://github.com/github/ruby.git
Separate objspace argument for rb_gc_disable and rb_gc_enable
This commit is contained in:
Родитель
c47cd4be28
Коммит
aeaf0dc555
30
gc.c
30
gc.c
|
@ -1095,6 +1095,7 @@ static int gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page,
|
||||||
static int gc_verify_heap_pages(rb_objspace_t *objspace);
|
static int gc_verify_heap_pages(rb_objspace_t *objspace);
|
||||||
|
|
||||||
static void gc_stress_set(rb_objspace_t *objspace, VALUE flag);
|
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 double getrusage_time(void);
|
||||||
static inline void gc_prof_setup_new_record(rb_objspace_t *objspace, int reason);
|
static inline void gc_prof_setup_new_record(rb_objspace_t *objspace, int reason);
|
||||||
|
@ -5902,7 +5903,7 @@ gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func,
|
||||||
#if RGENGC_ESTIMATE_OLDMALLOC
|
#if RGENGC_ESTIMATE_OLDMALLOC
|
||||||
size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase;
|
size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase;
|
||||||
#endif
|
#endif
|
||||||
VALUE already_disabled = rb_gc_disable();
|
VALUE already_disabled = rb_objspace_gc_disable(objspace);
|
||||||
|
|
||||||
objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
|
objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
|
||||||
|
|
||||||
|
@ -5920,7 +5921,7 @@ gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func,
|
||||||
objspace_allrefs_destruct(objspace->rgengc.allrefs_table);
|
objspace_allrefs_destruct(objspace->rgengc.allrefs_table);
|
||||||
objspace->rgengc.allrefs_table = 0;
|
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;
|
objspace->malloc_params.increase = saved_malloc_increase;
|
||||||
#if RGENGC_ESTIMATE_OLDMALLOC
|
#if RGENGC_ESTIMATE_OLDMALLOC
|
||||||
objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase;
|
objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase;
|
||||||
|
@ -8585,7 +8586,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE moved_list_head;
|
VALUE moved_list_head;
|
||||||
VALUE disabled = rb_gc_disable();
|
VALUE disabled = rb_objspace_gc_disable(objspace);
|
||||||
|
|
||||||
if (use_toward_empty) {
|
if (use_toward_empty) {
|
||||||
moved_list_head = gc_compact_heap(objspace, compare_free_slots);
|
moved_list_head = gc_compact_heap(objspace, compare_free_slots);
|
||||||
|
@ -8596,7 +8597,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl
|
||||||
heap_eden->freelist = NULL;
|
heap_eden->freelist = NULL;
|
||||||
|
|
||||||
gc_update_references(objspace);
|
gc_update_references(objspace);
|
||||||
if (!RTEST(disabled)) rb_gc_enable();
|
if (!RTEST(disabled)) rb_objspace_gc_enable(objspace);
|
||||||
|
|
||||||
if (use_verifier) {
|
if (use_verifier) {
|
||||||
gc_check_references_for_moved(objspace);
|
gc_check_references_for_moved(objspace);
|
||||||
|
@ -9208,6 +9209,12 @@ VALUE
|
||||||
rb_gc_enable(void)
|
rb_gc_enable(void)
|
||||||
{
|
{
|
||||||
rb_objspace_t *objspace = &rb_objspace;
|
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;
|
int old = dont_gc;
|
||||||
|
|
||||||
dont_gc = FALSE;
|
dont_gc = FALSE;
|
||||||
|
@ -9224,18 +9231,29 @@ VALUE
|
||||||
rb_gc_disable_no_rest(void)
|
rb_gc_disable_no_rest(void)
|
||||||
{
|
{
|
||||||
rb_objspace_t *objspace = &rb_objspace;
|
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;
|
int old = dont_gc;
|
||||||
dont_gc = TRUE;
|
dont_gc = TRUE;
|
||||||
return old ? Qtrue : Qfalse;
|
return old ? Qtrue : Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_gc_disable(void)
|
rb_gc_disable(void)
|
||||||
{
|
{
|
||||||
rb_objspace_t *objspace = &rb_objspace;
|
rb_objspace_t *objspace = &rb_objspace;
|
||||||
|
return rb_objspace_gc_disable(objspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_objspace_gc_disable(rb_objspace_t *objspace)
|
||||||
|
{
|
||||||
gc_rest(objspace);
|
gc_rest(objspace);
|
||||||
return rb_gc_disable_no_rest();
|
return gc_disable_no_rest(objspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "ruby/ruby.h" /* for rb_event_flag_t */
|
#include "ruby/ruby.h" /* for rb_event_flag_t */
|
||||||
|
|
||||||
struct rb_execution_context_struct; /* in vm_core.h */
|
struct rb_execution_context_struct; /* in vm_core.h */
|
||||||
|
struct rb_objspace; /* in vm_core.h */
|
||||||
|
|
||||||
#ifdef NEWOBJ_OF
|
#ifdef NEWOBJ_OF
|
||||||
# undef NEWOBJ_OF
|
# undef NEWOBJ_OF
|
||||||
|
@ -60,6 +61,8 @@ extern int ruby_disable_gc;
|
||||||
void *ruby_mimmalloc(size_t size) RUBY_ATTR_MALLOC;
|
void *ruby_mimmalloc(size_t size) RUBY_ATTR_MALLOC;
|
||||||
void ruby_mimfree(void *ptr);
|
void ruby_mimfree(void *ptr);
|
||||||
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
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 *);
|
||||||
void ruby_gc_set_params(void);
|
void ruby_gc_set_params(void);
|
||||||
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
|
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
|
||||||
#if __has_attribute(alloc_align)
|
#if __has_attribute(alloc_align)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче