don't need to sweep rest.

`transient_heap_evacuate()` disables GC using `rb_gc_disable()`
to prohibt GC invocation because of new allocation for evacuated
memory. However, `rb_gc_disable()` sweep all rest of unswept pages.
We don't need to cancel lazy sweep so this patch introduce
`rb_gc_disable_no_rest()` which doesn't cancel lazy sweep.
This commit is contained in:
Koichi Sasada 2019-05-16 16:44:30 +09:00 committed by Koichi Sasada
parent a160b2f567
commit 88449100bc
3 changed files with 13 additions and 6 deletions

15
gc.c
View File

@ -8938,6 +8938,15 @@ rb_gc_enable(void)
return old ? Qtrue : Qfalse; return old ? Qtrue : Qfalse;
} }
VALUE
rb_gc_disable_no_rest(void)
{
rb_objspace_t *objspace = &rb_objspace;
int old = dont_gc;
dont_gc = TRUE;
return old ? Qtrue : Qfalse;
}
/* /*
* call-seq: * call-seq:
* GC.disable -> true or false * GC.disable -> true or false
@ -8954,12 +8963,8 @@ VALUE
rb_gc_disable(void) rb_gc_disable(void)
{ {
rb_objspace_t *objspace = &rb_objspace; rb_objspace_t *objspace = &rb_objspace;
int old = dont_gc;
gc_rest(objspace); gc_rest(objspace);
return rb_gc_disable_no_rest();
dont_gc = TRUE;
return old ? Qtrue : Qfalse;
} }
static int static int

2
gc.h
View File

@ -94,6 +94,8 @@ const char *rb_obj_info(VALUE obj);
const char *rb_raw_obj_info(char *buff, const int buff_size, VALUE obj); const char *rb_raw_obj_info(char *buff, const int buff_size, VALUE obj);
void rb_obj_info_dump(VALUE obj); void rb_obj_info_dump(VALUE obj);
VALUE rb_gc_disable_no_rest(void);
struct rb_thread_struct; struct rb_thread_struct;
RUBY_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN

View File

@ -730,7 +730,7 @@ transient_heap_evacuate(void *dmy)
if (TRANSIENT_HEAP_DEBUG >= 1) fprintf(stderr, "!! transient_heap_evacuate: skip while transient_heap_marking\n"); if (TRANSIENT_HEAP_DEBUG >= 1) fprintf(stderr, "!! transient_heap_evacuate: skip while transient_heap_marking\n");
} }
else { else {
VALUE gc_disabled = rb_gc_disable(); VALUE gc_disabled = rb_gc_disable_no_rest();
struct transient_heap_block* block; struct transient_heap_block* block;
if (TRANSIENT_HEAP_DEBUG >= 1) { if (TRANSIENT_HEAP_DEBUG >= 1) {