Project

General

Profile

patch-1.9.2-gc-methods.patch

patch for GC parameters getters and setters - funny_falcon (Yura Sokolov), 03/06/2011 06:07 PM

View differences:

gc.c
3201 3201
}
3202 3202

  
3203 3203
/*
3204
 *  call-seq:
3205
 *     GC.malloc_limit -> Integer
3206
 *
3207
 *  The size of the malloc limit (minimum heap size).
3208
 *
3209
 *  It returns the bare minimum size of the heap.
3210
 */
3211
 
3212
static VALUE
3213
gc_malloc_limit_get(VALUE self)
3214
{
3215
    rb_objspace_t *objspace = &rb_objspace;
3216
    return UINT2NUM(malloc_limit);
3217
}
3218

  
3219
/*
3220
 *
3221
 *  call-seq:
3222
 *     GC.malloc_limit = integer   -> Integer
3223
 *
3224
 *  Updates the size of the malloc limit (minimum heap size).
3225
 *
3226
 *  It returns the new bare minimum size of the heap.
3227
 */
3228
 
3229
static VALUE
3230
gc_malloc_limit_set(VALUE self, VALUE new_limit)
3231
{
3232
    rb_objspace_t *objspace = &rb_objspace;
3233
    malloc_limit = initial_malloc_limit = NUM2UINT(new_limit);
3234
    return new_limit;
3235
}
3236

  
3237
/*
3238
 *  call-seq:
3239
 *     GC.heap_min_slots -> Integer
3240
 *
3241
 *  The minimum number of slots in each heap slab.
3242
 *
3243
 *  It returns the number of slots to allocate for each heap slab.
3244
 */
3245
 
3246
static VALUE
3247
gc_heap_min_slots_get(VALUE self)
3248
{
3249
    return UINT2NUM(initial_heap_min_slots);
3250
}
3251

  
3252
/*
3253
 *
3254
 *  call-seq:
3255
 *     GC.heap_min_slots = integer   -> Integer
3256
 *
3257
 *  Updates the minimum number of slots in each heap slab.
3258
 *
3259
 *  It returns the new number of slots to allocate for each heap slab.
3260
 */
3261
 
3262
static VALUE
3263
gc_heap_min_slots_set(VALUE self, VALUE new_num_slots)
3264
{
3265
    initial_heap_min_slots = NUM2UINT(new_num_slots);
3266
    return new_num_slots;
3267
}
3268

  
3269
/*
3270
 *  call-seq:
3271
 *     GC.free_min -> Integer
3272
 *
3273
 *  The minimum number of free slots after gc.
3274
 *
3275
 *  It returns minimum number of free slots after garbage collection
3276
 *  which do not lead to allocation of new heaps
3277
 */
3278

  
3279
static VALUE
3280
gc_free_min_get(VALUE self)
3281
{
3282
    return UINT2NUM(initial_free_min);
3283
}
3284

  
3285
/*
3286
 *  call-seq:
3287
 *     GC.free_min = integer -> Integer
3288
 *
3289
 *  Updates the minimum number of free slots.
3290
 *
3291
 *  It return the new minimum number of free slots.
3292
 */
3293

  
3294
static VALUE
3295
gc_free_min_set(VALUE self, VALUE new_free_min)
3296
{
3297
    initial_free_min = NUM2UINT(new_free_min);
3298
    return new_free_min;
3299
}
3300

  
3301
/*
3204 3302
 *  The <code>GC</code> module provides an interface to Ruby's mark and
3205 3303
 *  sweep garbage collection mechanism. Some of the underlying methods
3206 3304
 *  are also available via the <code>ObjectSpace</code> module.
......
3219 3317
    rb_define_singleton_method(rb_mGC, "stress", gc_stress_get, 0);
3220 3318
    rb_define_singleton_method(rb_mGC, "stress=", gc_stress_set, 1);
3221 3319
    rb_define_singleton_method(rb_mGC, "count", gc_count, 0);
3320
    rb_define_singleton_method(rb_mGC, "malloc_limit", gc_malloc_limit_get, 0);
3321
    rb_define_singleton_method(rb_mGC, "malloc_limit=", gc_malloc_limit_set, 1);
3322
    rb_define_singleton_method(rb_mGC, "heap_min_slots", gc_heap_min_slots_get, 0);
3323
    rb_define_singleton_method(rb_mGC, "heap_min_slots=", gc_heap_min_slots_set, 1);
3324
    rb_define_singleton_method(rb_mGC, "free_min", gc_free_min_get, 0);
3325
    rb_define_singleton_method(rb_mGC, "free_min=", gc_free_min_set, 1);
3222 3326
    rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);
3223 3327

  
3224 3328
    rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler");