ruby-200-backport-r41325.patch

Narihiro Nakamura, 06/21/2013 02:57 PM

Download (2.4 KB)

View differences:

gc.c
209 209
    struct {
210 210
	size_t limit;
211 211
	size_t increase;
212
	size_t increase2;
212 213
#if CALC_EXACT_MALLOC_SIZE
213 214
	size_t allocated_size;
214 215
	size_t allocations;
......
271 272
#endif
272 273
#define malloc_limit		objspace->malloc_params.limit
273 274
#define malloc_increase 	objspace->malloc_params.increase
275
#define malloc_increase2 	objspace->malloc_params.increase2
274 276
#define heaps			objspace->heap.ptr
275 277
#define heaps_length		objspace->heap.length
276 278
#define heaps_used		objspace->heap.used
......
1976 1978
    objspace->heap.free_num = 0;
1977 1979
    objspace->heap.free_slots = NULL;
1978 1980

  
1981
    malloc_increase2 += ATOMIC_SIZE_EXCHANGE(malloc_increase,0);
1982

  
1979 1983
    /* sweep unlinked method entries */
1980 1984
    if (GET_VM()->unlinked_method_entry_list) {
1981 1985
	rb_sweep_method_entry(GET_VM());
......
1994 1998
    }
1995 1999

  
1996 2000
    inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
2001
    inc += malloc_increase2;
2002
    malloc_increase2 = 0;
2003

  
1997 2004
    if (inc > malloc_limit) {
1998 2005
	malloc_limit +=
1999 2006
	  (size_t)((inc - malloc_limit) * (double)objspace->heap.marked_num / (heaps_used * HEAP_OBJ_LIMIT));
......
3479 3486
    size += sizeof(size_t);
3480 3487
#endif
3481 3488

  
3489
    ATOMIC_SIZE_ADD(malloc_increase, size);
3482 3490
    if ((ruby_gc_stress && !ruby_disable_gc_stress) ||
3483
	(malloc_increase+size) > malloc_limit) {
3491
	malloc_increase > malloc_limit) {
3484 3492
	garbage_collect_with_gvl(objspace);
3485 3493
    }
3486 3494

  
......
3490 3498
static inline void *
3491 3499
vm_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
3492 3500
{
3493
    ATOMIC_SIZE_ADD(malloc_increase, size);
3494

  
3495 3501
#if CALC_EXACT_MALLOC_SIZE
3496 3502
    ATOMIC_SIZE_ADD(objspace->malloc_params.allocated_size, size);
3497 3503
    ATOMIC_SIZE_INC(objspace->malloc_params.allocations);
......
4077 4083
    if (objspace->profile.run) {
4078 4084
        gc_profile_record *record = &objspace->profile.record[objspace->profile.count];
4079 4085
        if (record) {
4080
            record->allocate_increase = malloc_increase;
4086
            record->allocate_increase = malloc_increase + malloc_increase2;
4081 4087
            record->allocate_limit = malloc_limit;
4082 4088
        }
4083 4089
    }