Ruby  1.9.3p551(2014-11-13revision48407)
Data Structures | Macros | Typedefs | Functions | Variables
gc.c File Reference
#include "ruby/ruby.h"
#include "ruby/st.h"
#include "ruby/re.h"
#include "ruby/io.h"
#include "ruby/util.h"
#include "eval_intern.h"
#include "vm_core.h"
#include "internal.h"
#include "gc.h"
#include "constant.h"
#include "ruby_atomic.h"
#include <stdio.h>
#include <setjmp.h>
#include <sys/types.h>
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  ruby_gc_params_t
 
struct  gc_profile_record
 
struct  RVALUE
 
struct  heaps_slot
 
struct  sorted_heaps_slot
 
struct  gc_list
 
struct  stack_chunk
 
struct  mark_stack
 
struct  rb_objspace
 
struct  mark_tbl_arg
 
struct  each_obj_args
 
struct  os_each_struct
 
struct  force_finalize_list
 

Macros

#define VALGRIND_MAKE_MEM_DEFINED(p, n)   /* empty */
 
#define VALGRIND_MAKE_MEM_UNDEFINED(p, n)   /* empty */
 
#define rb_setjmp(env)   RUBY_SETJMP(env)
 
#define rb_jmp_buf   rb_jmpbuf_t
 
#define GC_MALLOC_LIMIT   8000000
 
#define HEAP_MIN_SLOTS   10000
 
#define FREE_MIN   4096
 
#define nomem_error   GET_VM()->special_exceptions[ruby_error_nomemory]
 
#define nonspecial_obj_id(obj)   (VALUE)((SIGNED_VALUE)(obj)|FIXNUM_FLAG)
 
#define obj_id_to_ref(objid)   ((objid) ^ FIXNUM_FLAG) /* unset FIXNUM_FLAG */
 
#define GC_PROFILE_MORE_DETAIL   0
 
#define GC_PROF_TIMER_START
 
#define GC_PROF_TIMER_STOP(marked)
 
#define INIT_GC_PROF_PARAMS
 
#define GC_PROF_MARK_TIMER_START
 
#define GC_PROF_MARK_TIMER_STOP
 
#define GC_PROF_SWEEP_TIMER_START
 
#define GC_PROF_SWEEP_TIMER_STOP
 
#define GC_PROF_SET_MALLOC_INFO
 
#define GC_PROF_SET_HEAP_INFO(record)
 
#define GC_PROF_INC_LIVE_NUM
 
#define GC_PROF_DEC_LIVE_NUM
 
#define STACK_CHUNK_SIZE   500
 
#define CALC_EXACT_MALLOC_SIZE   0
 
#define rb_objspace   (*GET_VM()->objspace)
 
#define ruby_initial_gc_stress   initial_params.gc_stress
 
#define malloc_limit   objspace->malloc_params.limit
 
#define malloc_increase   objspace->malloc_params.increase
 
#define heaps   objspace->heap.ptr
 
#define heaps_length   objspace->heap.length
 
#define heaps_used   objspace->heap.used
 
#define freelist   objspace->heap.freelist
 
#define lomem   objspace->heap.range[0]
 
#define himem   objspace->heap.range[1]
 
#define heaps_inc   objspace->heap.increment
 
#define heaps_freed   objspace->heap.freed
 
#define dont_gc   objspace->flags.dont_gc
 
#define during_gc   objspace->flags.during_gc
 
#define finalizing   objspace->flags.finalizing
 
#define finalizer_table   objspace->final.table
 
#define deferred_final_list   objspace->final.deferred
 
#define global_List   objspace->global_list
 
#define ruby_gc_stress   objspace->gc_stress
 
#define initial_malloc_limit   initial_params.initial_malloc_limit
 
#define initial_heap_min_slots   initial_params.initial_heap_min_slots
 
#define initial_free_min   initial_params.initial_free_min
 
#define HEAP_SIZE   0x4000
 
#define HEAP_OBJ_LIMIT   (unsigned int)(HEAP_SIZE / sizeof(struct RVALUE))
 
#define TRY_WITH_GC(alloc)
 
#define RANY(o)   ((RVALUE*)(o))
 
#define SET_STACK_END   SET_MACHINE_STACK_END(&th->machine_stack_end)
 
#define STACK_START   (th->machine_stack_start)
 
#define STACK_END   (th->machine_stack_end)
 
#define STACK_LEVEL_MAX   (th->machine_stack_maxsize/sizeof(VALUE))
 
#define STACK_LENGTH
 
#define STACKFRAME_FOR_CALL_CFUNC   512
 
#define MARK_STACK_EMPTY   (mark_stack_ptr == mark_stack)
 
#define rb_gc_mark_locations(start, end)   gc_mark_locations(objspace, (start), (end))
 
#define STR_ASSOC   FL_USER3 /* copied from string.c */
 
#define GC_NOTIFY   0
 
#define GET_STACK_BOUNDS(start, end, appendix)
 
#define numberof(array)   (int)(sizeof(array) / sizeof((array)[0]))
 
#define NUM2PTR(x)   NUM2ULONG(x)
 
#define COUNT_TYPE(t)   case (t): type = ID2SYM(rb_intern(#t)); break;
 

Typedefs

typedef struct gc_profile_record gc_profile_record
 
typedef struct RVALUE RVALUE
 
typedef struct stack_chunk stack_chunk_t
 
typedef struct mark_stack mark_stack_t
 
typedef struct rb_objspace rb_objspace_t
 
typedef int each_obj_callback (void *, void *, size_t, void *)
 

Functions

void * alloca ()
 
static double getrusage_time (void)
 
static void rb_objspace_call_finalizer (rb_objspace_t *objspace)
 
rb_objspace_trb_objspace_alloc (void)
 
static void initial_expand_heap (rb_objspace_t *objspace)
 
static void init_mark_stack (mark_stack_t *stack)
 
void rb_gc_set_params (void)
 
static void gc_sweep (rb_objspace_t *)
 
static void slot_sweep (rb_objspace_t *, struct heaps_slot *)
 
static void rest_sweep (rb_objspace_t *)
 
static void free_stack_chunks (mark_stack_t *)
 
void rb_objspace_free (rb_objspace_t *objspace)
 
static void run_final (rb_objspace_t *objspace, VALUE obj)
 
static int garbage_collect (rb_objspace_t *objspace)
 
static int gc_lazy_sweep (rb_objspace_t *objspace)
 
void rb_global_variable (VALUE *var)
 
static void * ruby_memerror_body (void *dummy)
 
static void ruby_memerror (void)
 
void rb_memerror (void)
 
static VALUE gc_stress_get (VALUE self)
 
static VALUE gc_stress_set (VALUE self, VALUE flag)
 
static VALUE gc_profile_enable_get (VALUE self)
 
static VALUE gc_profile_enable (void)
 
static VALUE gc_profile_disable (void)
 
static VALUE gc_profile_clear (void)
 
static void * negative_size_allocation_error_with_gvl (void *ptr)
 
static void negative_size_allocation_error (const char *msg)
 
static void * gc_with_gvl (void *ptr)
 
static int garbage_collect_with_gvl (rb_objspace_t *objspace)
 
static void vm_xfree (rb_objspace_t *objspace, void *ptr)
 
static size_t vm_malloc_prepare (rb_objspace_t *objspace, size_t size)
 
static void * vm_malloc_fixup (rb_objspace_t *objspace, void *mem, size_t size)
 
static void * vm_xmalloc (rb_objspace_t *objspace, size_t size)
 
static void * vm_xrealloc (rb_objspace_t *objspace, void *ptr, size_t size)
 
void * ruby_xmalloc (size_t size)
 
static size_t xmalloc2_size (size_t n, size_t size)
 
void * ruby_xmalloc2 (size_t n, size_t size)
 
static void * vm_xcalloc (rb_objspace_t *objspace, size_t count, size_t elsize)
 
void * ruby_xcalloc (size_t n, size_t size)
 
void * ruby_xrealloc (void *ptr, size_t size)
 
void * ruby_xrealloc2 (void *ptr, size_t n, size_t size)
 
void ruby_xfree (void *x)
 
VALUE rb_gc_enable (void)
 
VALUE rb_gc_disable (void)
 
void rb_gc_register_mark_object (VALUE obj)
 
void rb_gc_register_address (VALUE *addr)
 
void rb_gc_unregister_address (VALUE *addr)
 
static void allocate_sorted_heaps (rb_objspace_t *objspace, size_t next_heaps_length)
 
static void assign_heap_slot (rb_objspace_t *objspace)
 
static void add_heap_slots (rb_objspace_t *objspace, size_t add)
 
static void init_heap (rb_objspace_t *objspace)
 
static void set_heaps_increment (rb_objspace_t *objspace)
 
static int heaps_increment (rb_objspace_t *objspace)
 
int rb_during_gc (void)
 
VALUE rb_newobj (void)
 
NODErb_node_newnode (enum node_type type, VALUE a0, VALUE a1, VALUE a2)
 
VALUE rb_data_object_alloc (VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
 
VALUE rb_data_typed_object_alloc (VALUE klass, void *datap, const rb_data_type_t *type)
 
size_t rb_objspace_data_type_memsize (VALUE obj)
 
const char * rb_objspace_data_type_name (VALUE obj)
 
int ruby_get_stack_grow_direction (volatile VALUE *addr)
 
static void push_mark_stack (mark_stack_t *, VALUE)
 
static int pop_mark_stack (mark_stack_t *, VALUE *)
 
static void shrink_stack_chunk_cache (mark_stack_t *stack)
 
static stack_chunk_tstack_chunk_alloc (void)
 
static int is_mark_stask_empty (mark_stack_t *stack)
 
static void add_stack_chunk_cache (mark_stack_t *stack, stack_chunk_t *chunk)
 
static void push_mark_stack_chunk (mark_stack_t *stack)
 
static void pop_mark_stack_chunk (mark_stack_t *stack)
 
size_t ruby_stack_length (VALUE **p)
 
static int stack_check (int water_mark)
 
int ruby_stack_check (void)
 
static void gc_mark (rb_objspace_t *objspace, VALUE ptr)
 
static void gc_mark_children (rb_objspace_t *objspace, VALUE ptr)
 
static void gc_mark_stacked_objects (rb_objspace_t *objspace)
 
static int is_pointer_to_heap (rb_objspace_t *objspace, void *ptr)
 
static void mark_locations_array (rb_objspace_t *objspace, register VALUE *x, register long n)
 
static void gc_mark_locations (rb_objspace_t *objspace, VALUE *start, VALUE *end)
 
void rb_gc_mark_locations (VALUE *start, VALUE *end)
 
static int mark_entry (ID key, VALUE value, st_data_t data)
 
static void mark_tbl (rb_objspace_t *objspace, st_table *tbl)
 
static int mark_key (VALUE key, VALUE value, st_data_t data)
 
static void mark_set (rb_objspace_t *objspace, st_table *tbl)
 
void rb_mark_set (st_table *tbl)
 
static int mark_keyvalue (VALUE key, VALUE value, st_data_t data)
 
static void mark_hash (rb_objspace_t *objspace, st_table *tbl)
 
void rb_mark_hash (st_table *tbl)
 
static void mark_method_entry (rb_objspace_t *objspace, const rb_method_entry_t *me)
 
void rb_mark_method_entry (const rb_method_entry_t *me)
 
static int mark_method_entry_i (ID key, const rb_method_entry_t *me, st_data_t data)
 
static void mark_m_tbl (rb_objspace_t *objspace, st_table *tbl)
 
static int free_method_entry_i (ID key, rb_method_entry_t *me, st_data_t data)
 
void rb_free_m_table (st_table *tbl)
 
static int mark_const_entry_i (ID key, const rb_const_entry_t *ce, st_data_t data)
 
static void mark_const_tbl (rb_objspace_t *objspace, st_table *tbl)
 
static int free_const_entry_i (ID key, rb_const_entry_t *ce, st_data_t data)
 
void rb_free_const_table (st_table *tbl)
 
void rb_mark_tbl (st_table *tbl)
 
void rb_gc_mark_maybe (VALUE obj)
 
void rb_gc_mark (VALUE ptr)
 
static int obj_free (rb_objspace_t *, VALUE)
 
static void add_freelist (rb_objspace_t *objspace, RVALUE *p)
 
static void finalize_list (rb_objspace_t *objspace, RVALUE *p)
 
static void unlink_heap_slot (rb_objspace_t *objspace, struct heaps_slot *slot)
 
static void free_unused_heaps (rb_objspace_t *objspace)
 
static int ready_to_gc (rb_objspace_t *objspace)
 
static void before_gc_sweep (rb_objspace_t *objspace)
 
static void after_gc_sweep (rb_objspace_t *objspace)
 
static int lazy_sweep (rb_objspace_t *objspace)
 
static void gc_marks (rb_objspace_t *objspace)
 
void rb_gc_force_recycle (VALUE p)
 
static void make_deferred (RVALUE *p)
 
static void make_io_deferred (RVALUE *p)
 
static void mark_current_machine_context (rb_objspace_t *objspace, rb_thread_t *th)
 
int rb_garbage_collect (void)
 
void rb_gc_mark_machine_stack (rb_thread_t *th)
 
VALUE rb_gc_start (void)
 
void Init_stack (volatile VALUE *addr)
 
void Init_heap (void)
 
static VALUE lazy_sweep_enable (void)
 
static VALUE objspace_each_objects (VALUE arg)
 
void rb_objspace_each_objects (each_obj_callback *callback, void *data)
 
static int os_obj_of_i (void *vstart, void *vend, size_t stride, void *data)
 
static VALUE os_obj_of (VALUE of)
 
static VALUE os_each_obj (int argc, VALUE *argv, VALUE os)
 
static VALUE undefine_final (VALUE os, VALUE obj)
 
static VALUE define_final (int argc, VALUE *argv, VALUE os)
 
void rb_gc_copy_finalizer (VALUE dest, VALUE obj)
 
static VALUE run_single_final (VALUE arg)
 
static void run_finalizer (rb_objspace_t *objspace, VALUE objid, VALUE table)
 
static void finalize_deferred (rb_objspace_t *objspace)
 
void rb_gc_finalize_deferred (void)
 
static int force_chain_object (st_data_t key, st_data_t val, st_data_t arg)
 
void rb_gc_call_finalizer_at_exit (void)
 
void rb_gc (void)
 
static VALUE id2ref (VALUE obj, VALUE objid)
 
VALUE rb_obj_id (VALUE obj)
 
static int set_zero (st_data_t key, st_data_t val, st_data_t arg)
 
static VALUE count_objects (int argc, VALUE *argv, VALUE os)
 
static VALUE gc_count (VALUE self)
 
static VALUE gc_stat (int argc, VALUE *argv, VALUE self)
 
static VALUE gc_profile_record_get (void)
 
static VALUE gc_profile_result (void)
 
static VALUE gc_profile_report (int argc, VALUE *argv, VALUE self)
 
static VALUE gc_profile_total_time (VALUE self)
 
void Init_GC (void)
 

Variables

ruby_gc_params_t initial_params
 
int ruby_gc_debug_indent = 0
 
int * ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress
 
st_tablerb_class_tbl
 
int ruby_disable_gc_stress = 0
 
VALUE rb_mGC
 
int ruby_stack_grow_direction
 

Macro Definition Documentation

#define CALC_EXACT_MALLOC_SIZE   0

Definition at line 349 of file gc.c.

#define COUNT_TYPE (   t)    case (t): type = ID2SYM(rb_intern(#t)); break;
#define deferred_final_list   objspace->final.deferred

Definition at line 421 of file gc.c.

Referenced by finalize_deferred(), rb_objspace_call_finalizer(), and slot_sweep().

#define dont_gc   objspace->flags.dont_gc

Definition at line 417 of file gc.c.

Referenced by garbage_collect_with_gvl(), rb_gc_disable(), rb_gc_enable(), rb_newobj(), and ready_to_gc().

#define during_gc   objspace->flags.during_gc
#define finalizer_table   objspace->final.table
#define finalizing   objspace->flags.finalizing

Definition at line 419 of file gc.c.

Referenced by rb_gc(), rb_gc_finalize_deferred(), rb_objspace_call_finalizer(), and slot_sweep().

#define FREE_MIN   4096

Definition at line 83 of file gc.c.

#define freelist   objspace->heap.freelist
#define GC_MALLOC_LIMIT   8000000

Definition at line 80 of file gc.c.

#define GC_NOTIFY   0

Definition at line 2500 of file gc.c.

Referenced by garbage_collect().

#define GC_PROF_DEC_LIVE_NUM

Definition at line 272 of file gc.c.

Referenced by finalize_list(), and rb_gc_force_recycle().

#define GC_PROF_INC_LIVE_NUM

Definition at line 271 of file gc.c.

Referenced by rb_newobj().

#define GC_PROF_MARK_TIMER_START

Definition at line 259 of file gc.c.

Referenced by gc_marks().

#define GC_PROF_MARK_TIMER_STOP

Definition at line 260 of file gc.c.

Referenced by gc_marks().

#define GC_PROF_SET_HEAP_INFO (   record)
Value:
do {\
live = objspace->heap.live_num;\
(record).heap_total_objects = total;\
(record).heap_use_size = live * sizeof(RVALUE);\
(record).heap_total_size = total * sizeof(RVALUE);\
} while(0)

Definition at line 264 of file gc.c.

#define GC_PROF_SET_MALLOC_INFO

Definition at line 263 of file gc.c.

Referenced by after_gc_sweep(), and gc_lazy_sweep().

#define GC_PROF_SWEEP_TIMER_START

Definition at line 261 of file gc.c.

Referenced by garbage_collect(), and gc_lazy_sweep().

#define GC_PROF_SWEEP_TIMER_STOP

Definition at line 262 of file gc.c.

Referenced by garbage_collect(), and gc_lazy_sweep().

#define GC_PROF_TIMER_START
Value:
do {\
if (objspace->profile.run) {\
if (!objspace->profile.record) {\
objspace->profile.size = 1000;\
objspace->profile.record = malloc(sizeof(gc_profile_record) * objspace->profile.size);\
}\
if (count >= objspace->profile.size) {\
objspace->profile.size += 1000;\
objspace->profile.record = realloc(objspace->profile.record, sizeof(gc_profile_record) * objspace->profile.size);\
}\
if (!objspace->profile.record) {\
rb_bug("gc_profile malloc or realloc miss");\
}\
MEMZERO(&objspace->profile.record[count], gc_profile_record, 1);\
gc_time = getrusage_time();\
objspace->profile.record[count].gc_invoke_time = gc_time - objspace->profile.invoke_time;\
}\
} while(0)

Definition at line 174 of file gc.c.

Referenced by garbage_collect(), and gc_lazy_sweep().

#define GC_PROF_TIMER_STOP (   marked)
Value:
do {\
if (objspace->profile.run) {\
gc_time = getrusage_time() - gc_time;\
if (gc_time < 0) gc_time = 0;\
objspace->profile.record[count].gc_time = gc_time;\
objspace->profile.record[count].is_marked = !!(marked);\
GC_PROF_SET_HEAP_INFO(objspace->profile.record[count]);\
objspace->profile.count++;\
}\
} while(0)

Definition at line 193 of file gc.c.

Referenced by garbage_collect(), and gc_lazy_sweep().

#define GC_PROFILE_MORE_DETAIL   0

Definition at line 117 of file gc.c.

#define GET_STACK_BOUNDS (   start,
  end,
  appendix 
)
Value:
((start) = STACK_END, (end) = STACK_START) : ((start) = STACK_START, (end) = STACK_END+(appendix)))

Definition at line 2507 of file gc.c.

Referenced by mark_current_machine_context(), and rb_gc_mark_machine_stack().

#define global_List   objspace->global_list

Definition at line 422 of file gc.c.

Referenced by gc_marks(), rb_gc_register_address(), rb_gc_unregister_address(), and rb_objspace_free().

#define HEAP_MIN_SLOTS   10000

Definition at line 82 of file gc.c.

Referenced by init_heap().

#define HEAP_OBJ_LIMIT   (unsigned int)(HEAP_SIZE / sizeof(struct RVALUE))
#define HEAP_SIZE   0x4000

Definition at line 531 of file gc.c.

Referenced by assign_heap_slot().

#define heaps   objspace->heap.ptr
#define heaps_freed   objspace->heap.freed

Definition at line 416 of file gc.c.

Referenced by free_unused_heaps().

#define heaps_inc   objspace->heap.increment

Definition at line 415 of file gc.c.

Referenced by add_heap_slots(), heaps_increment(), and set_heaps_increment().

#define heaps_length   objspace->heap.length

Definition at line 410 of file gc.c.

Referenced by add_heap_slots(), allocate_sorted_heaps(), and set_heaps_increment().

#define heaps_used   objspace->heap.used
#define himem   objspace->heap.range[1]

Definition at line 414 of file gc.c.

Referenced by assign_heap_slot(), and is_pointer_to_heap().

#define INIT_GC_PROF_PARAMS
Value:
double gc_time = 0;\
size_t count = objspace->profile.count, total = 0, live = 0

Definition at line 257 of file gc.c.

Referenced by garbage_collect(), and gc_lazy_sweep().

#define initial_free_min   initial_params.initial_free_min

Definition at line 426 of file gc.c.

Referenced by before_gc_sweep(), and rb_gc_set_params().

#define initial_heap_min_slots   initial_params.initial_heap_min_slots

Definition at line 425 of file gc.c.

Referenced by initial_expand_heap(), and rb_gc_set_params().

#define initial_malloc_limit   initial_params.initial_malloc_limit

Definition at line 424 of file gc.c.

Referenced by after_gc_sweep(), rb_gc_set_params(), and rb_objspace_alloc().

#define lomem   objspace->heap.range[0]

Definition at line 413 of file gc.c.

Referenced by assign_heap_slot().

#define malloc_increase   objspace->malloc_params.increase

Definition at line 408 of file gc.c.

Referenced by after_gc_sweep(), vm_malloc_fixup(), vm_malloc_prepare(), and vm_xrealloc().

#define malloc_limit   objspace->malloc_params.limit

Definition at line 407 of file gc.c.

Referenced by after_gc_sweep(), rb_objspace_alloc(), and vm_malloc_prepare().

#define MARK_STACK_EMPTY   (mark_stack_ptr == mark_stack)

Definition at line 1495 of file gc.c.

#define nomem_error   GET_VM()->special_exceptions[ruby_error_nomemory]

Definition at line 101 of file gc.c.

Referenced by Init_GC(), and rb_memerror().

#define nonspecial_obj_id (   obj)    (VALUE)((SIGNED_VALUE)(obj)|FIXNUM_FLAG)

Definition at line 104 of file gc.c.

Referenced by rb_obj_id().

#define NUM2PTR (   x)    NUM2ULONG(x)
#define numberof (   array)    (int)(sizeof(array) / sizeof((array)[0]))

Definition at line 2512 of file gc.c.

Referenced by mark_current_machine_context().

#define obj_id_to_ref (   objid)    ((objid) ^ FIXNUM_FLAG) /* unset FIXNUM_FLAG */

Definition at line 105 of file gc.c.

Referenced by id2ref().

#define RANY (   o)    ((RVALUE*)(o))
#define rb_gc_mark_locations (   start,
  end 
)    gc_mark_locations(objspace, (start), (end))
#define rb_jmp_buf   rb_jmpbuf_t

Definition at line 56 of file gc.c.

Referenced by mark_current_machine_context().

#define rb_objspace   (*GET_VM()->objspace)
#define rb_setjmp (   env)    RUBY_SETJMP(env)

Definition at line 55 of file gc.c.

Referenced by mark_current_machine_context().

#define ruby_gc_stress   objspace->gc_stress
#define ruby_initial_gc_stress   initial_params.gc_stress

Definition at line 401 of file gc.c.

Referenced by rb_objspace_alloc().

#define SET_STACK_END   SET_MACHINE_STACK_END(&th->machine_stack_end)

Definition at line 1297 of file gc.c.

Referenced by gc_marks(), mark_current_machine_context(), ruby_stack_length(), and stack_check().

#define STACK_CHUNK_SIZE   500

Definition at line 333 of file gc.c.

Referenced by init_mark_stack().

#define STACK_END   (th->machine_stack_end)

Definition at line 1301 of file gc.c.

Referenced by mark_current_machine_context(), and ruby_stack_length().

#define STACK_LENGTH
Value:
: (size_t)(STACK_END - STACK_START + 1))

Definition at line 1309 of file gc.c.

Referenced by ruby_stack_length(), and stack_check().

#define STACK_LEVEL_MAX   (th->machine_stack_maxsize/sizeof(VALUE))

Definition at line 1302 of file gc.c.

Referenced by stack_check().

#define STACK_START   (th->machine_stack_start)

Definition at line 1300 of file gc.c.

Referenced by mark_current_machine_context(), and ruby_stack_length().

#define STACKFRAME_FOR_CALL_CFUNC   512

Definition at line 1483 of file gc.c.

Referenced by ruby_stack_check().

#define STR_ASSOC   FL_USER3 /* copied from string.c */

Referenced by gc_mark_children().

#define TRY_WITH_GC (   alloc)
Value:
do { \
if (!(alloc) && \
(!garbage_collect_with_gvl(objspace) || \
!(alloc))) { \
ruby_memerror(); \
} \
} while (0)

Definition at line 784 of file gc.c.

Referenced by vm_xcalloc(), and vm_xmalloc().

#define VALGRIND_MAKE_MEM_DEFINED (   p,
 
)    /* empty */

Definition at line 51 of file gc.c.

Referenced by mark_locations_array().

#define VALGRIND_MAKE_MEM_UNDEFINED (   p,
 
)    /* empty */

Definition at line 52 of file gc.c.

Referenced by add_freelist().

Typedef Documentation

typedef int each_obj_callback(void *, void *, size_t, void *)

Definition at line 2706 of file gc.c.

typedef struct mark_stack mark_stack_t
typedef struct rb_objspace rb_objspace_t
typedef struct RVALUE RVALUE
typedef struct stack_chunk stack_chunk_t

Function Documentation

static void add_freelist ( rb_objspace_t objspace,
RVALUE p 
)
inlinestatic

Definition at line 2044 of file gc.c.

References RVALUE::as, RVALUE::free, freelist, p, and VALGRIND_MAKE_MEM_UNDEFINED.

Referenced by finalize_list(), rb_gc_force_recycle(), and slot_sweep().

static void add_heap_slots ( rb_objspace_t objspace,
size_t  add 
)
static

Definition at line 1110 of file gc.c.

References add, allocate_sorted_heaps(), assign_heap_slot(), heaps_inc, heaps_length, heaps_used, and i.

Referenced by init_heap(), and initial_expand_heap().

static void add_stack_chunk_cache ( mark_stack_t stack,
stack_chunk_t chunk 
)
static

Definition at line 1350 of file gc.c.

References mark_stack::cache, mark_stack::cache_size, and stack_chunk::next.

Referenced by init_mark_stack(), and pop_mark_stack_chunk().

static void after_gc_sweep ( rb_objspace_t objspace)
static
void* alloca ( )
static void allocate_sorted_heaps ( rb_objspace_t objspace,
size_t  next_heaps_length 
)
static
static void assign_heap_slot ( rb_objspace_t objspace)
static
static void before_gc_sweep ( rb_objspace_t objspace)
static
static VALUE count_objects ( int  argc,
VALUE argv,
VALUE  os 
)
static
static VALUE define_final ( int  argc,
VALUE argv,
VALUE  os 
)
static
static void finalize_deferred ( rb_objspace_t objspace)
static
static void finalize_list ( rb_objspace_t objspace,
RVALUE p 
)
static
static int force_chain_object ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
)
static
static int free_const_entry_i ( ID  key,
rb_const_entry_t ce,
st_data_t  data 
)
static

Definition at line 1721 of file gc.c.

References ST_CONTINUE, and xfree().

Referenced by rb_free_const_table().

static int free_method_entry_i ( ID  key,
rb_method_entry_t me,
st_data_t  data 
)
static

Definition at line 1688 of file gc.c.

References rb_method_entry_struct::mark, rb_free_method_entry(), and ST_CONTINUE.

Referenced by rb_free_m_table().

static void free_stack_chunks ( mark_stack_t stack)
static

Definition at line 1404 of file gc.c.

References mark_stack::chunk, free(), heaps_slot::next, stack_chunk::next, and NULL.

Referenced by rb_objspace_free().

static void free_unused_heaps ( rb_objspace_t objspace)
static
static int garbage_collect ( rb_objspace_t objspace)
static
static int garbage_collect_with_gvl ( rb_objspace_t objspace)
static
static VALUE gc_count ( VALUE  self)
static

Definition at line 3409 of file gc.c.

References count, and UINT2NUM().

Referenced by gc_profile_result(), and Init_GC().

static int gc_lazy_sweep ( rb_objspace_t objspace)
static
static void gc_mark ( rb_objspace_t objspace,
VALUE  ptr 
)
static
static void gc_mark_children ( rb_objspace_t objspace,
VALUE  ptr 
)
static

Definition at line 1770 of file gc.c.

References RVALUE::array, RVALUE::as, RString::as, RArray::as, RVALUE::basic, BUILTIN_TYPE, RNode::cnt, RVALUE::complex, RVALUE::data, DATA_PTR, RRational::den, RData::dmark, rb_data_type_struct::dmark, ELTS_SHARED, rb_io_t::encs, RVALUE::file, FL_ANY, FL_EXIVAR, FL_MARK, FL_TEST, RBasic::flags, RFile::fptr, rb_data_type_struct::function, gc_mark(), RVALUE::hash, rb_objspace::heap, RString::heap, RArray::heap, i, if(), RHash::ifnone, RComplex::imag, is_pointer_to_heap(), RBasic::klass, len, rb_objspace::live_num, mark_const_tbl(), mark_hash(), mark_locations_array(), mark_m_tbl(), mark_tbl(), RVALUE::match, nd_type, RNode::node, RVALUE::node, NODE_ALIAS, NODE_ALLOCA, NODE_AND, NODE_ARGS, NODE_ARGS_AUX, NODE_ARGSCAT, NODE_ARRAY, NODE_BACK_REF, NODE_BLOCK, NODE_BLOCK_ARG, NODE_BLOCK_PASS, NODE_BREAK, NODE_CALL, NODE_CASE, NODE_CDECL, NODE_CLASS, NODE_COLON2, NODE_COLON3, NODE_CVAR, NODE_CVASGN, NODE_DASGN, NODE_DASGN_CURR, NODE_DEFINED, NODE_DEFN, NODE_DEFS, NODE_DOT2, NODE_DOT3, NODE_DREGX, NODE_DREGX_ONCE, NODE_DSTR, NODE_DVAR, NODE_DXSTR, NODE_ENSURE, NODE_ERRINFO, NODE_EVSTR, NODE_FALSE, NODE_FCALL, NODE_FLIP2, NODE_FLIP3, NODE_FOR, NODE_GASGN, NODE_GVAR, NODE_HASH, NODE_IASGN, NODE_IASGN2, NODE_IF, NODE_ITER, NODE_IVAR, NODE_LASGN, NODE_LIT, NODE_LVAR, NODE_MASGN, NODE_MATCH, NODE_MATCH2, NODE_MATCH3, NODE_MODULE, NODE_NEXT, NODE_NIL, NODE_NTH_REF, NODE_OP_ASGN1, NODE_OP_ASGN_AND, NODE_OP_ASGN_OR, NODE_OPT_ARG, NODE_OPT_N, NODE_OPTBLOCK, NODE_OR, NODE_POSTEXE, NODE_REDO, NODE_RESBODY, NODE_RESCUE, NODE_RETRY, NODE_RETURN, NODE_SCLASS, NODE_SCOPE, NODE_SELF, NODE_SPLAT, NODE_STR, NODE_SUPER, NODE_TO_ARY, NODE_TRUE, NODE_UNDEF, NODE_UNTIL, NODE_VALIAS, NODE_VCALL, NODE_WHEN, NODE_WHILE, NODE_XSTR, NODE_YIELD, NODE_ZARRAY, NODE_ZSUPER, RHash::ntbl, RRational::num, rb_io_t::pathv, RANY, RARRAY_LEN, RARRAY_PTR, RVALUE::rational, rb_bug(), rb_mark_generic_ivar(), rb_special_const_p(), RCLASS_CONST_TBL, RCLASS_IV_TBL, RCLASS_M_TBL, RCLASS_SUPER, RComplex::real, RMatch::regexp, RVALUE::regexp, ROBJECT_IVPTR, ROBJECT_NUMIV, RSTRING_NOEMBED, RSTRUCT_LEN, RSTRUCT_PTR, RTYPEDDATA_P, RRegexp::src, RMatch::str, STR_ASSOC, RVALUE::string, T_ARRAY, T_BIGNUM, T_CLASS, T_COMPLEX, T_DATA, T_FILE, T_FIXNUM, T_FLOAT, T_HASH, T_ICLASS, T_MATCH, T_MODULE, T_NIL, T_NODE, T_OBJECT, T_RATIONAL, T_REGEXP, T_STRING, T_STRUCT, T_ZOMBIE, rb_io_t::tied_io_for_writing, RTypedData::type, RVALUE::typeddata, RNode::u1, RNode::u2, RNode::u3, RNode::value, rb_io_t::write_lock, rb_io_t::writeconv_asciicompat, and rb_io_t::writeconv_pre_ecopts.

Referenced by gc_mark_stacked_objects().

static void gc_mark_locations ( rb_objspace_t objspace,
VALUE start,
VALUE end 
)
static

Definition at line 1556 of file gc.c.

References mark_locations_array(), and sorted_heaps_slot::start.

Referenced by rb_gc_mark_locations().

static void gc_mark_stacked_objects ( rb_objspace_t objspace)
static
static void gc_marks ( rb_objspace_t objspace)
static
static VALUE gc_profile_clear ( void  )
static

Definition at line 690 of file gc.c.

References rb_objspace::count, MEMZERO, rb_objspace::profile, Qnil, rb_objspace, rb_objspace::record, and rb_objspace::size.

Referenced by Init_GC().

static VALUE gc_profile_disable ( void  )
static

Definition at line 673 of file gc.c.

References FALSE, rb_objspace::profile, Qnil, rb_objspace, and rb_objspace::run.

Referenced by Init_GC().

static VALUE gc_profile_enable ( void  )
static

Definition at line 656 of file gc.c.

References rb_objspace::profile, Qnil, rb_objspace, rb_objspace::run, and TRUE.

Referenced by Init_GC().

static VALUE gc_profile_enable_get ( VALUE  self)
static

Definition at line 641 of file gc.c.

References rb_objspace::profile, Qfalse, Qtrue, rb_objspace, and rb_objspace::run.

Referenced by Init_GC().

static VALUE gc_profile_record_get ( void  )
static
static VALUE gc_profile_report ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 3610 of file gc.c.

References gc_profile_result(), Qnil, rb_io_write(), rb_scan_args(), and rb_stdout.

Referenced by Init_GC().

static VALUE gc_profile_result ( void  )
static
static VALUE gc_profile_total_time ( VALUE  self)
static
static VALUE gc_stat ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE gc_stress_get ( VALUE  self)
static

Definition at line 606 of file gc.c.

References Qfalse, Qtrue, rb_objspace, and ruby_gc_stress.

Referenced by Init_GC().

static VALUE gc_stress_set ( VALUE  self,
VALUE  flag 
)
static

Definition at line 625 of file gc.c.

References rb_objspace, rb_secure(), RTEST, and ruby_gc_stress.

Referenced by Init_GC().

static void gc_sweep ( rb_objspace_t objspace)
static
static void* gc_with_gvl ( void *  ptr)
static

Definition at line 723 of file gc.c.

References garbage_collect().

Referenced by garbage_collect_with_gvl().

static double getrusage_time ( void  )
static

Definition at line 139 of file gc.c.

References getrusage(), timeval::tv_sec, and timeval::tv_usec.

Referenced by init_heap().

static int heaps_increment ( rb_objspace_t objspace)
static

Definition at line 1170 of file gc.c.

References assign_heap_slot(), FALSE, heaps_inc, and TRUE.

Referenced by after_gc_sweep(), gc_lazy_sweep(), lazy_sweep(), and ready_to_gc().

static VALUE id2ref ( VALUE  obj,
VALUE  objid 
)
static
void Init_GC ( void  )
static void init_heap ( rb_objspace_t objspace)
static
void Init_heap ( void  )

Definition at line 2692 of file gc.c.

References init_heap().

Referenced by ruby_init().

static void init_mark_stack ( mark_stack_t stack)
static
void Init_stack ( volatile VALUE addr)

Definition at line 2655 of file gc.c.

References ruby_init_stack().

static void initial_expand_heap ( rb_objspace_t objspace)
static

Definition at line 1144 of file gc.c.

References add_heap_slots(), HEAP_OBJ_LIMIT, heaps_used, and initial_heap_min_slots.

Referenced by rb_gc_set_params().

static int is_mark_stask_empty ( mark_stack_t stack)
inlinestatic

Definition at line 1344 of file gc.c.

References mark_stack::chunk, and NULL.

Referenced by pop_mark_stack().

static int is_pointer_to_heap ( rb_objspace_t objspace,
void *  ptr 
)
inlinestatic
static int lazy_sweep ( rb_objspace_t objspace)
static
static VALUE lazy_sweep_enable ( void  )
static

Definition at line 2698 of file gc.c.

References rb_objspace::dont_lazy_sweep, FALSE, rb_objspace::flags, Qnil, and rb_objspace.

Referenced by rb_objspace_each_objects().

static void make_deferred ( RVALUE p)
inlinestatic

Definition at line 2358 of file gc.c.

References RVALUE::as, RVALUE::basic, RBasic::flags, T_MASK, and T_ZOMBIE.

Referenced by make_io_deferred(), obj_free(), and rb_objspace_call_finalizer().

static void make_io_deferred ( RVALUE p)
inlinestatic
static int mark_const_entry_i ( ID  key,
const rb_const_entry_t ce,
st_data_t  data 
)
static

Definition at line 1704 of file gc.c.

References arg, gc_mark(), mark_tbl_arg::objspace, ST_CONTINUE, and rb_const_entry_struct::value.

Referenced by mark_const_tbl().

static void mark_const_tbl ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 1712 of file gc.c.

References mark_const_entry_i(), mark_tbl_arg::objspace, and st_foreach.

Referenced by gc_mark_children().

static void mark_current_machine_context ( rb_objspace_t objspace,
rb_thread_t th 
)
static
static int mark_entry ( ID  key,
VALUE  value,
st_data_t  data 
)
static

Definition at line 1578 of file gc.c.

References arg, gc_mark(), mark_tbl_arg::objspace, and ST_CONTINUE.

Referenced by mark_tbl().

static void mark_hash ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 1627 of file gc.c.

References mark_keyvalue(), mark_tbl_arg::objspace, and st_foreach.

Referenced by gc_mark_children(), and rb_mark_hash().

static int mark_key ( VALUE  key,
VALUE  value,
st_data_t  data 
)
static

Definition at line 1595 of file gc.c.

References arg, gc_mark(), mark_tbl_arg::objspace, and ST_CONTINUE.

Referenced by mark_set().

static int mark_keyvalue ( VALUE  key,
VALUE  value,
st_data_t  data 
)
static

Definition at line 1618 of file gc.c.

References arg, gc_mark(), mark_tbl_arg::objspace, and ST_CONTINUE.

Referenced by mark_hash().

static void mark_locations_array ( rb_objspace_t objspace,
register VALUE x,
register long  n 
)
static
static void mark_m_tbl ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 1679 of file gc.c.

References mark_method_entry_i(), mark_tbl_arg::objspace, and st_foreach.

Referenced by gc_mark_children().

static void mark_method_entry ( rb_objspace_t objspace,
const rb_method_entry_t me 
)
static
static int mark_method_entry_i ( ID  key,
const rb_method_entry_t me,
st_data_t  data 
)
static

Definition at line 1671 of file gc.c.

References arg, mark_method_entry(), mark_tbl_arg::objspace, and ST_CONTINUE.

Referenced by mark_m_tbl().

static void mark_set ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 1603 of file gc.c.

References mark_key(), mark_tbl_arg::objspace, and st_foreach.

Referenced by rb_mark_set().

static void mark_tbl ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 1586 of file gc.c.

References mark_entry(), st_table::num_entries, mark_tbl_arg::objspace, and st_foreach.

Referenced by gc_mark_children(), gc_marks(), and rb_mark_tbl().

static void negative_size_allocation_error ( const char *  msg)
static
static void* negative_size_allocation_error_with_gvl ( void *  ptr)
static

Definition at line 699 of file gc.c.

References rb_eNoMemError, and rb_raise().

Referenced by negative_size_allocation_error().

static int obj_free ( rb_objspace_t objspace,
VALUE  obj 
)
static
static VALUE objspace_each_objects ( VALUE  arg)
static
static VALUE os_each_obj ( int  argc,
VALUE argv,
VALUE  os 
)
static

Definition at line 2887 of file gc.c.

References os_each_struct::of, os_obj_of(), rb_scan_args(), rb_secure(), and RETURN_ENUMERATOR.

Referenced by Init_GC().

static VALUE os_obj_of ( VALUE  of)
static

Definition at line 2840 of file gc.c.

References os_each_struct::num, os_each_struct::of, os_obj_of_i(), rb_objspace_each_objects(), and SIZET2NUM.

Referenced by os_each_obj().

static int os_obj_of_i ( void *  vstart,
void *  vend,
size_t  stride,
void *  data 
)
static
static int pop_mark_stack ( mark_stack_t stack,
VALUE data 
)
static
static void pop_mark_stack_chunk ( mark_stack_t stack)
static
static void push_mark_stack ( mark_stack_t stack,
VALUE  data 
)
static

Definition at line 1418 of file gc.c.

References mark_stack::chunk, stack_chunk::data, mark_stack::index, mark_stack::limit, and push_mark_stack_chunk().

Referenced by gc_mark().

static void push_mark_stack_chunk ( mark_stack_t stack)
static
VALUE rb_data_object_alloc ( VALUE  klass,
void *  datap,
RUBY_DATA_FUNC  dmark,
RUBY_DATA_FUNC  dfree 
)

Definition at line 1244 of file gc.c.

References Check_Type, NEWOBJ, OBJSETUP, T_CLASS, and T_DATA.

VALUE rb_data_typed_object_alloc ( VALUE  klass,
void *  datap,
const rb_data_type_t type 
)

Definition at line 1257 of file gc.c.

References Check_Type, NEWOBJ, OBJSETUP, T_CLASS, T_DATA, and type.

int rb_during_gc ( void  )

Definition at line 1181 of file gc.c.

References during_gc, and rb_objspace.

void rb_free_const_table ( st_table tbl)

Definition at line 1728 of file gc.c.

References free_const_entry_i(), st_foreach, and st_free_table.

Referenced by init_copy(), obj_free(), and rb_mod_init_copy().

void rb_free_m_table ( st_table tbl)

Definition at line 1697 of file gc.c.

References free_method_entry_i(), st_foreach, and st_free_table.

Referenced by obj_free(), and rb_mod_init_copy().

int rb_garbage_collect ( void  )

Definition at line 2616 of file gc.c.

References garbage_collect().

void rb_gc ( void  )
void rb_gc_call_finalizer_at_exit ( void  )

Definition at line 3082 of file gc.c.

References rb_objspace_call_finalizer().

Referenced by ruby_finalize_1().

void rb_gc_copy_finalizer ( VALUE  dest,
VALUE  obj 
)

Definition at line 2968 of file gc.c.

References finalizer_table, FL_FINALIZE, FL_SET, FL_TEST, rb_objspace, st_insert, and st_lookup.

Referenced by init_copy().

VALUE rb_gc_disable ( void  )
VALUE rb_gc_enable ( void  )
void rb_gc_finalize_deferred ( void  )
void rb_gc_force_recycle ( VALUE  p)
void rb_gc_mark ( VALUE  ptr)
void rb_gc_mark_locations ( VALUE start,
VALUE end 
)

Definition at line 1566 of file gc.c.

References gc_mark_locations().

void rb_gc_mark_machine_stack ( rb_thread_t th)

Definition at line 2622 of file gc.c.

References GET_STACK_BOUNDS, rb_gc_mark_locations, and rb_objspace.

Referenced by rb_thread_mark().

void rb_gc_mark_maybe ( VALUE  obj)
void rb_gc_register_address ( VALUE addr)

Definition at line 978 of file gc.c.

References ALLOC, global_List, gc_list::next, rb_objspace, and gc_list::varptr.

Referenced by Init_coverage(), Init_curses(), Init_iconv(), and rb_global_variable().

void rb_gc_register_mark_object ( VALUE  obj)
void rb_gc_set_params ( void  )
VALUE rb_gc_start ( void  )

Definition at line 2646 of file gc.c.

References Qnil, and rb_gc().

Referenced by Init_GC().

void rb_gc_unregister_address ( VALUE addr)

Definition at line 990 of file gc.c.

References global_List, gc_list::next, rb_objspace, gc_list::varptr, and xfree().

Referenced by curses_finalize().

void rb_global_variable ( VALUE var)
void rb_mark_hash ( st_table tbl)

Definition at line 1636 of file gc.c.

References mark_hash().

Referenced by Init_win32ole(), mark_dump_arg(), and mark_load_arg().

void rb_mark_method_entry ( const rb_method_entry_t me)

Definition at line 1665 of file gc.c.

References mark_method_entry().

Referenced by bm_mark(), rb_gc_mark_unlinked_live_method_entries(), and rb_thread_mark().

void rb_mark_set ( st_table tbl)

Definition at line 1612 of file gc.c.

References mark_set().

Referenced by mark_dump_arg().

void rb_mark_tbl ( st_table tbl)
void rb_memerror ( void  )
VALUE rb_newobj ( void  )
NODE* rb_node_newnode ( enum node_type  type,
VALUE  a0,
VALUE  a1,
VALUE  a2 
)

Definition at line 1229 of file gc.c.

References RNode::flags, nd_set_type, rb_newobj(), T_NODE, RNode::u1, RNode::u2, RNode::u3, and RNode::value.

VALUE rb_obj_id ( VALUE  obj)
rb_objspace_t* rb_objspace_alloc ( void  )
read

Definition at line 432 of file gc.c.

References initial_malloc_limit, malloc(), malloc_limit, ruby_gc_stress, and ruby_initial_gc_stress.

Referenced by Init_BareVM().

static void rb_objspace_call_finalizer ( rb_objspace_t objspace)
static
size_t rb_objspace_data_type_memsize ( VALUE  obj)

Definition at line 1273 of file gc.c.

References RTYPEDDATA_DATA, RTYPEDDATA_P, and RTYPEDDATA_TYPE.

Referenced by memsize_of().

const char* rb_objspace_data_type_name ( VALUE  obj)

Definition at line 1284 of file gc.c.

References RTYPEDDATA_P, and RTYPEDDATA_TYPE.

Referenced by cto_i().

void rb_objspace_each_objects ( each_obj_callback callback,
void *  data 
)
void rb_objspace_free ( rb_objspace_t objspace)
static int ready_to_gc ( rb_objspace_t objspace)
static

Definition at line 2189 of file gc.c.

References dont_gc, during_gc, FALSE, freelist, heaps_increment(), set_heaps_increment(), and TRUE.

Referenced by garbage_collect(), and gc_lazy_sweep().

static void rest_sweep ( rb_objspace_t objspace)
static
int ruby_get_stack_grow_direction ( volatile VALUE addr)

Definition at line 1315 of file gc.c.

References ruby_stack_grow_direction, and SET_MACHINE_STACK_END.

static void ruby_memerror ( void  )
static
static void* ruby_memerror_body ( void *  dummy)
static

Definition at line 556 of file gc.c.

References rb_memerror().

Referenced by ruby_memerror().

int ruby_stack_check ( void  )

Definition at line 1486 of file gc.c.

References stack_check(), and STACKFRAME_FOR_CALL_CFUNC.

Referenced by stack_check().

size_t ruby_stack_length ( VALUE **  p)

Definition at line 1457 of file gc.c.

References GET_THREAD, SET_STACK_END, STACK_END, STACK_LENGTH, STACK_START, and STACK_UPPER.

void* ruby_xcalloc ( size_t  n,
size_t  size 
)

Definition at line 894 of file gc.c.

References vm_xcalloc().

void ruby_xfree ( void *  x)
void* ruby_xmalloc ( size_t  size)

Definition at line 859 of file gc.c.

References vm_xmalloc().

Referenced by rb_dl_malloc(), and rb_dlptr_malloc().

void* ruby_xmalloc2 ( size_t  n,
size_t  size 
)

Definition at line 875 of file gc.c.

References vm_xmalloc(), and xmalloc2_size().

void* ruby_xrealloc ( void *  ptr,
size_t  size 
)

Definition at line 900 of file gc.c.

References vm_xrealloc().

Referenced by rb_dl_realloc(), and ruby_xrealloc2().

void* ruby_xrealloc2 ( void *  ptr,
size_t  n,
size_t  size 
)

Definition at line 906 of file gc.c.

References len, rb_eArgError, rb_raise(), and ruby_xrealloc().

static void run_final ( rb_objspace_t objspace,
VALUE  obj 
)
static
static void run_finalizer ( rb_objspace_t objspace,
VALUE  objid,
VALUE  table 
)
static
static VALUE run_single_final ( VALUE  arg)
static

Definition at line 2983 of file gc.c.

References args, Qnil, and rb_eval_cmd().

Referenced by run_finalizer().

static void set_heaps_increment ( rb_objspace_t objspace)
static

Definition at line 1154 of file gc.c.

References allocate_sorted_heaps(), heaps_inc, heaps_length, and heaps_used.

Referenced by after_gc_sweep(), gc_lazy_sweep(), and ready_to_gc().

static int set_zero ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
)
static

Definition at line 3288 of file gc.c.

References hash(), INT2FIX, rb_hash_aset(), and ST_CONTINUE.

Referenced by count_objects().

static void shrink_stack_chunk_cache ( mark_stack_t stack)
static
static void slot_sweep ( rb_objspace_t objspace,
struct heaps_slot sweep_slot 
)
static
static int stack_check ( int  water_mark)
static

Definition at line 1467 of file gc.c.

References GET_THREAD, SET_STACK_END, STACK_LENGTH, and STACK_LEVEL_MAX.

Referenced by ruby_stack_check().

static stack_chunk_t* stack_chunk_alloc ( void  )
static

Definition at line 1332 of file gc.c.

References malloc(), and rb_memerror().

Referenced by init_mark_stack(), and push_mark_stack_chunk().

static VALUE undefine_final ( VALUE  os,
VALUE  obj 
)
static

Definition at line 2911 of file gc.c.

References finalizer_table, FL_FINALIZE, FL_UNSET, rb_check_frozen, rb_objspace, and st_delete.

Referenced by Init_GC().

static void unlink_heap_slot ( rb_objspace_t objspace,
struct heaps_slot slot 
)
static

Definition at line 2076 of file gc.c.

References rb_objspace::heap, heaps, heaps_slot::next, NULL, heaps_slot::prev, and rb_objspace::sweep_slots.

Referenced by slot_sweep().

static void* vm_malloc_fixup ( rb_objspace_t objspace,
void *  mem,
size_t  size 
)
inlinestatic

Definition at line 770 of file gc.c.

References malloc_increase, rb_objspace::malloc_params, and size.

Referenced by vm_xcalloc(), and vm_xmalloc().

static size_t vm_malloc_prepare ( rb_objspace_t objspace,
size_t  size 
)
inlinestatic
static void* vm_xcalloc ( rb_objspace_t objspace,
size_t  count,
size_t  elsize 
)
static

Definition at line 881 of file gc.c.

References calloc, size, TRY_WITH_GC, vm_malloc_fixup(), vm_malloc_prepare(), and xmalloc2_size().

Referenced by ruby_xcalloc().

static void vm_xfree ( rb_objspace_t objspace,
void *  ptr 
)
static

Definition at line 845 of file gc.c.

References free(), rb_objspace::malloc_params, and size.

Referenced by ruby_xfree(), and vm_xrealloc().

static void* vm_xmalloc ( rb_objspace_t objspace,
size_t  size 
)
static

Definition at line 793 of file gc.c.

References malloc(), TRY_WITH_GC, vm_malloc_fixup(), and vm_malloc_prepare().

Referenced by ruby_xmalloc(), ruby_xmalloc2(), and vm_xrealloc().

static void* vm_xrealloc ( rb_objspace_t objspace,
void *  ptr,
size_t  size 
)
static
static size_t xmalloc2_size ( size_t  n,
size_t  size 
)
inlinestatic

Definition at line 865 of file gc.c.

References len, rb_eArgError, and rb_raise().

Referenced by ruby_xmalloc2(), and vm_xcalloc().

Variable Documentation

ruby_gc_params_t initial_params
Initial value:

Definition at line 92 of file gc.c.

VALUE rb_mGC

Definition at line 968 of file gc.c.

Referenced by Init_GC().

int ruby_disable_gc_stress = 0

Definition at line 543 of file gc.c.

Referenced by rb_newobj(), vm_malloc_prepare(), and vm_xrealloc().

int ruby_gc_debug_indent = 0

Definition at line 114 of file gc.c.

int* ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress

Definition at line 402 of file gc.c.

Referenced by set_debug_option().

int ruby_stack_grow_direction

Definition at line 1313 of file gc.c.

Referenced by ruby_get_stack_grow_direction().