This project is closed and read-only.
Backport #8554 ยป ruby-200-backport-r41325.patch
| gc.c | ||
|---|---|---|
|
struct {
|
||
|
size_t limit;
|
||
|
size_t increase;
|
||
|
size_t increase2;
|
||
|
#if CALC_EXACT_MALLOC_SIZE
|
||
|
size_t allocated_size;
|
||
|
size_t allocations;
|
||
| ... | ... | |
|
#endif
|
||
|
#define malloc_limit objspace->malloc_params.limit
|
||
|
#define malloc_increase objspace->malloc_params.increase
|
||
|
#define malloc_increase2 objspace->malloc_params.increase2
|
||
|
#define heaps objspace->heap.ptr
|
||
|
#define heaps_length objspace->heap.length
|
||
|
#define heaps_used objspace->heap.used
|
||
| ... | ... | |
|
objspace->heap.free_num = 0;
|
||
|
objspace->heap.free_slots = NULL;
|
||
|
malloc_increase2 += ATOMIC_SIZE_EXCHANGE(malloc_increase,0);
|
||
|
/* sweep unlinked method entries */
|
||
|
if (GET_VM()->unlinked_method_entry_list) {
|
||
|
rb_sweep_method_entry(GET_VM());
|
||
| ... | ... | |
|
}
|
||
|
inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
|
||
|
inc += malloc_increase2;
|
||
|
malloc_increase2 = 0;
|
||
|
if (inc > malloc_limit) {
|
||
|
malloc_limit +=
|
||
|
(size_t)((inc - malloc_limit) * (double)objspace->heap.marked_num / (heaps_used * HEAP_OBJ_LIMIT));
|
||
| ... | ... | |
|
size += sizeof(size_t);
|
||
|
#endif
|
||
|
ATOMIC_SIZE_ADD(malloc_increase, size);
|
||
|
if ((ruby_gc_stress && !ruby_disable_gc_stress) ||
|
||
|
(malloc_increase+size) > malloc_limit) {
|
||
|
malloc_increase > malloc_limit) {
|
||
|
garbage_collect_with_gvl(objspace);
|
||
|
}
|
||
| ... | ... | |
|
static inline void *
|
||
|
vm_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
|
||
|
{
|
||
|
ATOMIC_SIZE_ADD(malloc_increase, size);
|
||
|
#if CALC_EXACT_MALLOC_SIZE
|
||
|
ATOMIC_SIZE_ADD(objspace->malloc_params.allocated_size, size);
|
||
|
ATOMIC_SIZE_INC(objspace->malloc_params.allocations);
|
||
| ... | ... | |
|
if (objspace->profile.run) {
|
||
|
gc_profile_record *record = &objspace->profile.record[objspace->profile.count];
|
||
|
if (record) {
|
||
|
record->allocate_increase = malloc_increase;
|
||
|
record->allocate_increase = malloc_increase + malloc_increase2;
|
||
|
record->allocate_limit = malloc_limit;
|
||
|
}
|
||
|
}
|
||