* gc.c (garbage_collect_force): sweep is completely ended.
* gc.c (os_obj_of): invoke garbage_collect_force() when freelist none. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f8ed3b245a
commit
5b72919469
@ -1,3 +1,9 @@
|
|||||||
|
Fri Jul 4 11:08:37 2008 nari <authorNari@gmail.com>
|
||||||
|
|
||||||
|
* gc.c (garbage_collect_force): sweep is completely ended.
|
||||||
|
|
||||||
|
* gc.c (os_obj_of): invoke garbage_collect_force() when freelist none.
|
||||||
|
|
||||||
Fri Jul 4 05:01:26 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
Fri Jul 4 05:01:26 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* numeric.c (rb_num2uint, rb_fix2uint): typo.
|
* numeric.c (rb_num2uint, rb_fix2uint): typo.
|
||||||
|
19
gc.c
19
gc.c
@ -191,6 +191,7 @@ typedef struct rb_objspace {
|
|||||||
struct gc_list *global_list;
|
struct gc_list *global_list;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
int gc_stress;
|
int gc_stress;
|
||||||
|
int gc_not_lazy_sweep;
|
||||||
} rb_objspace_t;
|
} rb_objspace_t;
|
||||||
|
|
||||||
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
|
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
|
||||||
@ -226,6 +227,7 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress;
|
|||||||
#define mark_stack_overflow objspace->markstack.overflow
|
#define mark_stack_overflow objspace->markstack.overflow
|
||||||
#define global_List objspace->global_list
|
#define global_List objspace->global_list
|
||||||
#define ruby_gc_stress objspace->gc_stress
|
#define ruby_gc_stress objspace->gc_stress
|
||||||
|
#define ruby_gc_not_lazy_sweep objspace->gc_not_lazy_sweep
|
||||||
|
|
||||||
#define need_call_final (finalizer_table && finalizer_table->num_entries)
|
#define need_call_final (finalizer_table && finalizer_table->num_entries)
|
||||||
|
|
||||||
@ -1446,7 +1448,6 @@ heap_sweep(rb_objspace_t *objspace)
|
|||||||
|
|
||||||
#define GC_NOT_LAZY_SWEEP 0
|
#define GC_NOT_LAZY_SWEEP 0
|
||||||
|
|
||||||
#ifdef GC_NOT_LAZY_SWEEP
|
|
||||||
static void
|
static void
|
||||||
heap_all_sweep(rb_objspace_t *objspace)
|
heap_all_sweep(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
@ -1455,7 +1456,6 @@ heap_all_sweep(rb_objspace_t *objspace)
|
|||||||
heaps_sweep_index++;
|
heaps_sweep_index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
gc_lazy_sweep(rb_objspace_t *objspace, rb_thread_t *th)
|
gc_lazy_sweep(rb_objspace_t *objspace, rb_thread_t *th)
|
||||||
@ -1468,9 +1468,9 @@ gc_lazy_sweep(rb_objspace_t *objspace, rb_thread_t *th)
|
|||||||
heap_sweep(objspace);
|
heap_sweep(objspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GC_NOT_LAZY_SWEEP
|
if (ruby_gc_not_lazy_sweep || GC_NOT_LAZY_SWEEP) {
|
||||||
if (GC_NOT_LAZY_SWEEP) heap_all_sweep(objspace);
|
heap_all_sweep(objspace);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (!freelist) {
|
if (!freelist) {
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
@ -1813,13 +1813,17 @@ gc_marks(rb_objspace_t *objspace, rb_thread_t *th)
|
|||||||
static int
|
static int
|
||||||
garbage_collect_force(rb_objspace_t *objspace)
|
garbage_collect_force(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
|
int is_gc_success;
|
||||||
|
|
||||||
if (malloc_increase > malloc_limit) {
|
if (malloc_increase > malloc_limit) {
|
||||||
malloc_limit += (malloc_increase - malloc_limit) * (double)live / (heaps_used * HEAP_OBJ_LIMIT);
|
malloc_limit += (malloc_increase - malloc_limit) * (double)live / (heaps_used * HEAP_OBJ_LIMIT);
|
||||||
if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
|
if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
|
||||||
}
|
}
|
||||||
malloc_increase = 0;
|
malloc_increase = 0;
|
||||||
gc_marks(objspace, GET_THREAD());
|
ruby_gc_not_lazy_sweep = Qtrue;
|
||||||
return garbage_collect(objspace);
|
is_gc_success = garbage_collect(objspace);
|
||||||
|
ruby_gc_not_lazy_sweep = Qfalse;
|
||||||
|
return is_gc_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1966,6 +1970,7 @@ os_obj_of(rb_objspace_t *objspace, VALUE of)
|
|||||||
|
|
||||||
p = heaps[i].slot; pend = p + heaps[i].limit;
|
p = heaps[i].slot; pend = p + heaps[i].limit;
|
||||||
for (;p < pend; p++) {
|
for (;p < pend; p++) {
|
||||||
|
if (!freelist) garbage_collect_force(objspace);
|
||||||
if (p->as.basic.flags) {
|
if (p->as.basic.flags) {
|
||||||
switch (BUILTIN_TYPE(p)) {
|
switch (BUILTIN_TYPE(p)) {
|
||||||
case T_NONE:
|
case T_NONE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user