ruby-193-backport-r41325.patch

Narihiro Nakamura, 06/21/2013 03:48 PM

Download (2.49 KB)

View differences:

gc.c
236 236
#define GC_PROF_SET_MALLOC_INFO do {\
237 237
	if (objspace->profile.run) {\
238 238
	    gc_profile_record *record = &objspace->profile.record[objspace->profile.count];\
239
	    record->allocate_increase = malloc_increase;\
239
	    record->allocate_increase = malloc_increase + malloc_increase2;\
240 240
	    record->allocate_limit = malloc_limit; \
241 241
	}\
242 242
    } while(0)
......
352 352
    struct {
353 353
	size_t limit;
354 354
	size_t increase;
355
	size_t increase2;
355 356
#if CALC_EXACT_MALLOC_SIZE
356 357
	size_t allocated_size;
357 358
	size_t allocations;
......
405 406
#endif
406 407
#define malloc_limit		objspace->malloc_params.limit
407 408
#define malloc_increase 	objspace->malloc_params.increase
409
#define malloc_increase2 	objspace->malloc_params.increase2
408 410
#define heaps			objspace->heap.ptr
409 411
#define heaps_length		objspace->heap.length
410 412
#define heaps_used		objspace->heap.used
......
756 758
    size += sizeof(size_t);
757 759
#endif
758 760

  
761
    malloc_increase += size;
759 762
    if ((ruby_gc_stress && !ruby_disable_gc_stress) ||
760
	(malloc_increase+size) > malloc_limit) {
763
	malloc_increase > malloc_limit) {
761 764
	garbage_collect_with_gvl(objspace);
762 765
    }
763 766

  
......
767 770
static inline void *
768 771
vm_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
769 772
{
770
    malloc_increase += size;
771

  
772 773
#if CALC_EXACT_MALLOC_SIZE
773 774
    objspace->malloc_params.allocated_size += size;
774 775
    objspace->malloc_params.allocations++;
......
2211 2212
    objspace->heap.sweep_slots = heaps;
2212 2213
    objspace->heap.free_num = 0;
2213 2214

  
2215
    malloc_increase2 += ATOMIC_SIZE_EXCHANGE(malloc_increase,0);
2216

  
2214 2217
    /* sweep unlinked method entries */
2215 2218
    if (GET_VM()->unlinked_method_entry_list) {
2216 2219
	rb_sweep_method_entry(GET_VM());
......
2227 2230
        heaps_increment(objspace);
2228 2231
    }
2229 2232

  
2230
    if (malloc_increase > malloc_limit) {
2233
    if ((malloc_increase + malloc_increase2) > malloc_limit) {
2231 2234
	malloc_limit += (size_t)((malloc_increase - malloc_limit) * (double)objspace->heap.live_num / (heaps_used * HEAP_OBJ_LIMIT));
2232 2235
	if (malloc_limit < initial_malloc_limit) malloc_limit = initial_malloc_limit;
2233 2236
    }
2234 2237
    malloc_increase = 0;
2238
    malloc_increase2 = 0;
2235 2239

  
2236 2240
    free_unused_heaps(objspace);
2237 2241
}