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 "gc.h"
#include <stdio.h>
#include <setjmp.h>
#include <sys/types.h>

Include dependency graph for gc.c:

Go to the source code of this file.

Data Structures

struct  gc_profile_record
struct  RVALUE
struct  heaps_slot
struct  gc_list
struct  rb_objspace
struct  mark_tbl_arg
struct  os_each_struct
struct  force_finalize_list

Defines

#define VALGRIND_MAKE_MEM_DEFINED(p, n)
#define VALGRIND_MAKE_MEM_UNDEFINED(p, n)
#define rb_setjmp(env)   RUBY_SETJMP(env)
#define rb_jmp_buf   rb_jmpbuf_t
#define GC_MALLOC_LIMIT   8000000
#define nomem_error   GET_VM()->special_exceptions[ruby_error_nomemory]
#define MARK_STACK_MAX   1024
#define GC_PROFILE_MORE_DETAIL   0
#define GC_PROF_TIMER_START
#define GC_PROF_TIMER_STOP
#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
#define HEAP_MIN_SLOTS   10000
#define FREE_MIN   4096
#define CALC_EXACT_MALLOC_SIZE   0
#define rb_objspace   (*GET_VM()->objspace)
#define malloc_limit   objspace->malloc_params.limit
#define malloc_increase   objspace->malloc_params.increase
#define heap_slots   objspace->heap.slots
#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 finalizer_table   objspace->final.table
#define deferred_final_list   objspace->final.deferred
#define mark_stack   objspace->markstack.buffer
#define mark_stack_ptr   objspace->markstack.ptr
#define mark_stack_overflow   objspace->markstack.overflow
#define global_List   objspace->global_list
#define ruby_gc_stress   objspace->gc_stress
#define need_call_final   (finalizer_table && finalizer_table->num_entries)
#define HEAP_SIZE   0x4000
#define HEAP_OBJ_LIMIT   (HEAP_SIZE / sizeof(struct RVALUE))
#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 GC_WATER_MARK   512
#define MARK_STACK_EMPTY   (mark_stack_ptr == mark_stack)
#define rb_gc_mark_locations(start, end)   gc_mark_locations(objspace, start, end)
#define GC_LEVEL_MAX   250
#define STR_ASSOC   FL_USER3
#define GC_NOTIFY   0
#define GET_STACK_BOUNDS(start, end, appendix)
#define NUM2PTR(x)   NUM2ULONG(x)
#define COUNT_TYPE(t)   case t: type = ID2SYM(rb_intern(#t)); break;

Typedefs

typedef rb_objspace rb_objspace_t

Functions

int rb_io_fptr_finalize (struct rb_io_t *)
void * alloca ()
static double getrusage_time (void)
static void rb_objspace_call_finalizer (rb_objspace_t *objspace)
rb_objspace_trb_objspace_alloc (void)
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)
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 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)
void * ruby_xmalloc2 (size_t n, size_t size)
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_heaps (rb_objspace_t *objspace, size_t next_heaps_length)
static void assign_heap_slot (rb_objspace_t *objspace)
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)
static VALUE rb_newobj_from_heap (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)
size_t ruby_stack_length (VALUE **p)
static int stack_check (void)
int ruby_stack_check (void)
static void init_mark_stack (rb_objspace_t *objspace)
static void gc_mark (rb_objspace_t *objspace, VALUE ptr, int lev)
static void gc_mark_children (rb_objspace_t *objspace, VALUE ptr, int lev)
static void gc_mark_all (rb_objspace_t *objspace)
static void gc_mark_rest (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, int lev)
static int mark_key (VALUE key, VALUE value, st_data_t data)
static void mark_set (rb_objspace_t *objspace, st_table *tbl, int lev)
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, int lev)
void rb_mark_hash (st_table *tbl)
static void mark_method_entry (rb_objspace_t *objspace, const rb_method_entry_t *me, int lev)
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, int lev)
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)
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 free_unused_heaps (rb_objspace_t *objspace)
static void gc_sweep (rb_objspace_t *objspace)
void rb_gc_force_recycle (VALUE p)
static void make_deferred (RVALUE *p)
static void make_io_deferred (RVALUE *p)
void rb_vm_mark (void *ptr)
static void mark_current_machine_context (rb_objspace_t *objspace, rb_thread_t *th)
void rb_gc_mark_encodings (void)
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)
void rb_objspace_each_objects (int(*callback)(void *vstart, void *vend, size_t stride, void *d), 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 obj, VALUE objid, VALUE table)
static void finalize_deferred (rb_objspace_t *objspace)
static void gc_finalize_deferred (rb_objspace_t *objspace)
void rb_gc_finalize_deferred (void)
static int chain_finalized_object (st_data_t key, st_data_t val, st_data_t arg)
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_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

int ruby_gc_debug_indent = 0
static int ruby_initial_gc_stress = 0
int * ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress
VALUE rb_cMutex
st_tablerb_class_tbl
int ruby_disable_gc_stress = 0
VALUE rb_mGC
int ruby_stack_grow_direction


Define Documentation

#define CALC_EXACT_MALLOC_SIZE   0

Definition at line 294 of file gc.c.

#define COUNT_TYPE (  )     case t: type = ID2SYM(rb_intern(#t)); break;

#define deferred_final_list   objspace->final.deferred

Definition at line 361 of file gc.c.

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

#define dont_gc   objspace->flags.dont_gc

Definition at line 358 of file gc.c.

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

#define during_gc   objspace->flags.during_gc

Definition at line 359 of file gc.c.

Referenced by allocate_heaps(), assign_heap_slot(), garbage_collect(), rb_during_gc(), rb_newobj(), rb_newobj_from_heap(), and rb_objspace_call_finalizer().

#define finalizer_table   objspace->final.table

Definition at line 360 of file gc.c.

Referenced by define_final(), garbage_collect(), rb_gc_copy_finalizer(), rb_objspace_call_finalizer(), run_final(), and undefine_final().

#define FREE_MIN   4096

Definition at line 287 of file gc.c.

Referenced by gc_sweep().

#define freelist   objspace->heap.freelist

Definition at line 353 of file gc.c.

Referenced by add_freelist(), assign_heap_slot(), Balloc(), Bfree(), garbage_collect(), gc_sweep(), and rb_newobj_from_heap().

#define GC_LEVEL_MAX   250

Definition at line 1489 of file gc.c.

Referenced by gc_mark().

#define GC_MALLOC_LIMIT   8000000

Definition at line 78 of file gc.c.

Referenced by rb_objspace_alloc().

#define GC_NOTIFY   0

Definition at line 2097 of file gc.c.

Referenced by garbage_collect().

#define GC_PROF_MARK_TIMER_START

Definition at line 225 of file gc.c.

Referenced by garbage_collect().

#define GC_PROF_MARK_TIMER_STOP

Definition at line 226 of file gc.c.

Referenced by garbage_collect().

#define GC_PROF_SET_HEAP_INFO

Value:

do {\
        if (objspace->profile.run) {\
            gc_profile_record *record = &objspace->profile.record[objspace->profile.count];\
            record->heap_total_objects = heaps_used * HEAP_OBJ_LIMIT;\
            record->heap_use_size = live * sizeof(RVALUE); \
            record->heap_total_size = heaps_used * HEAP_SIZE;\
        }\
    } while(0)

Definition at line 230 of file gc.c.

#define GC_PROF_SET_MALLOC_INFO

Definition at line 229 of file gc.c.

#define GC_PROF_SWEEP_TIMER_START

Definition at line 227 of file gc.c.

Referenced by garbage_collect().

#define GC_PROF_SWEEP_TIMER_STOP

Definition at line 228 of file gc.c.

Referenced by garbage_collect().

#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 144 of file gc.c.

Referenced by garbage_collect().

#define GC_PROF_TIMER_STOP

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.count++;\
        }\
    } while(0)

Definition at line 163 of file gc.c.

Referenced by garbage_collect().

#define GC_PROFILE_MORE_DETAIL   0

Definition at line 88 of file gc.c.

#define GC_WATER_MARK   512

Definition at line 1198 of file gc.c.

Referenced by stack_check().

#define GET_STACK_BOUNDS ( start,
end,
appendix   ) 

Value:

((STACK_END < STACK_START) ? \
     (start = STACK_END, end = STACK_START) : (start = STACK_START, end = STACK_END+appendix))

Definition at line 2106 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 365 of file gc.c.

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

#define HEAP_MIN_SLOTS   10000

Definition at line 286 of file gc.c.

Referenced by init_heap().

#define HEAP_OBJ_LIMIT   (HEAP_SIZE / sizeof(struct RVALUE))

Definition at line 428 of file gc.c.

Referenced by assign_heap_slot(), gc_sweep(), and init_heap().

#define HEAP_SIZE   0x4000

Definition at line 420 of file gc.c.

Referenced by assign_heap_slot().

#define heap_slots   objspace->heap.slots

Definition at line 349 of file gc.c.

#define heaps   objspace->heap.ptr

Definition at line 350 of file gc.c.

Referenced by allocate_heaps(), assign_heap_slot(), count_objects(), free_unused_heaps(), garbage_collect(), gc_mark_all(), gc_sweep(), is_pointer_to_heap(), rb_objspace_call_finalizer(), rb_objspace_each_objects(), and rb_objspace_free().

#define heaps_freed   objspace->heap.freed

Definition at line 357 of file gc.c.

Referenced by free_unused_heaps().

#define heaps_inc   objspace->heap.increment

Definition at line 356 of file gc.c.

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

#define heaps_length   objspace->heap.length

Definition at line 351 of file gc.c.

Referenced by allocate_heaps(), init_heap(), and set_heaps_increment().

#define heaps_used   objspace->heap.used

Definition at line 352 of file gc.c.

Referenced by allocate_heaps(), assign_heap_slot(), count_objects(), free_unused_heaps(), gc_mark_all(), gc_sweep(), init_heap(), is_pointer_to_heap(), rb_objspace_call_finalizer(), rb_objspace_each_objects(), rb_objspace_free(), and set_heaps_increment().

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

Definition at line 355 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

Definition at line 223 of file gc.c.

Referenced by garbage_collect().

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

Definition at line 354 of file gc.c.

Referenced by assign_heap_slot().

#define malloc_increase   objspace->malloc_params.increase

Definition at line 348 of file gc.c.

Referenced by vm_xmalloc(), and vm_xrealloc().

#define malloc_limit   objspace->malloc_params.limit

Definition at line 347 of file gc.c.

Referenced by rb_objspace_alloc(), and vm_xmalloc().

#define mark_stack   objspace->markstack.buffer

Definition at line 362 of file gc.c.

Referenced by gc_mark(), gc_mark_rest(), and init_mark_stack().

#define MARK_STACK_EMPTY   (mark_stack_ptr == mark_stack)

Definition at line 1242 of file gc.c.

Referenced by garbage_collect().

#define MARK_STACK_MAX   1024

Definition at line 83 of file gc.c.

Referenced by gc_mark(), and gc_mark_rest().

#define mark_stack_overflow   objspace->markstack.overflow

Definition at line 364 of file gc.c.

Referenced by garbage_collect(), gc_mark(), and init_mark_stack().

#define mark_stack_ptr   objspace->markstack.ptr

Definition at line 363 of file gc.c.

Referenced by gc_mark(), gc_mark_rest(), and init_mark_stack().

#define need_call_final   (finalizer_table && finalizer_table->num_entries)

Definition at line 368 of file gc.c.

Referenced by gc_sweep().

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

Definition at line 81 of file gc.c.

Referenced by Init_GC(), and rb_memerror().

#define NUM2PTR (  )     NUM2ULONG(x)

#define RANY (  )     ((RVALUE*)(o))

Definition at line 1006 of file gc.c.

Referenced by gc_mark(), gc_mark_children(), is_pointer_to_heap(), obj_free(), rb_newobj_from_heap(), and rb_objspace_call_finalizer().

#define rb_gc_mark_locations ( start,
end   )     gc_mark_locations(objspace, start, end)

Definition at line 1340 of file gc.c.

Referenced by cont_mark(), env_mark(), mark_current_machine_context(), name_err_mesg_mark(), rb_gc_mark_machine_stack(), rb_gc_mark_symbols(), rb_thread_mark(), and rb_vm_mark().

#define rb_jmp_buf   rb_jmpbuf_t

Definition at line 54 of file gc.c.

Referenced by mark_current_machine_context().

#define rb_objspace   (*GET_VM()->objspace)

Definition at line 340 of file gc.c.

Referenced by count_objects(), define_final(), gc_count(), gc_profile_clear(), gc_profile_disable(), gc_profile_enable(), gc_profile_enable_get(), gc_profile_record_get(), gc_profile_result(), gc_profile_total_time(), gc_stress_get(), gc_stress_set(), id2ref(), Init_heap(), rb_during_gc(), rb_garbage_collect(), rb_gc(), rb_gc_call_finalizer_at_exit(), rb_gc_copy_finalizer(), rb_gc_disable(), rb_gc_enable(), rb_gc_finalize_deferred(), rb_gc_force_recycle(), rb_gc_mark(), rb_gc_mark_locations(), rb_gc_mark_machine_stack(), rb_gc_mark_maybe(), rb_gc_register_address(), rb_gc_unregister_address(), rb_mark_hash(), rb_mark_method_entry(), rb_mark_set(), rb_mark_tbl(), rb_newobj(), rb_objspace_each_objects(), ruby_xfree(), ruby_xmalloc(), ruby_xmalloc2(), ruby_xrealloc(), and undefine_final().

#define rb_setjmp ( env   )     RUBY_SETJMP(env)

Definition at line 53 of file gc.c.

Referenced by mark_current_machine_context().

#define ruby_gc_stress   objspace->gc_stress

Definition at line 366 of file gc.c.

Referenced by gc_stress_get(), gc_stress_set(), rb_newobj_from_heap(), rb_objspace_alloc(), vm_xmalloc(), and vm_xrealloc().

#define SET_STACK_END   SET_MACHINE_STACK_END(&th->machine_stack_end)

Definition at line 1170 of file gc.c.

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

#define STACK_END   (th->machine_stack_end)

Definition at line 1174 of file gc.c.

Referenced by mark_current_machine_context(), and ruby_stack_length().

#define STACK_LENGTH

Value:

((STACK_END < STACK_START) ? (size_t)(STACK_START - STACK_END) \
                        : (size_t)(STACK_END - STACK_START + 1))

Definition at line 1182 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 1175 of file gc.c.

Referenced by stack_check().

#define STACK_START   (th->machine_stack_start)

Definition at line 1173 of file gc.c.

Referenced by mark_current_machine_context(), and ruby_stack_length().

#define STR_ASSOC   FL_USER3

Referenced by gc_mark_children(), rb_str_associate(), rb_str_new_frozen(), str_buf_cat(), and str_replace().

#define VALGRIND_MAKE_MEM_DEFINED ( p,
 ) 

Definition at line 47 of file gc.c.

#define VALGRIND_MAKE_MEM_UNDEFINED ( p,
 ) 

Definition at line 48 of file gc.c.


Typedef Documentation

typedef struct rb_objspace rb_objspace_t


Function Documentation

static void add_freelist ( rb_objspace_t objspace,
RVALUE p 
) [inline, static]

Definition at line 1795 of file gc.c.

References freelist, and VALGRIND_MAKE_MEM_UNDEFINED.

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

void* alloca (  ) 

static void allocate_heaps ( rb_objspace_t objspace,
size_t  next_heaps_length 
) [static]

Definition at line 875 of file gc.c.

References during_gc, heaps, heaps_length, heaps_used, malloc, rb_memerror(), realloc, and size.

Referenced by init_heap(), and set_heaps_increment().

static void assign_heap_slot ( rb_objspace_t objspace  )  [static]

Definition at line 898 of file gc.c.

References RVALUE::as, during_gc, FALSE, RVALUE::free, freelist, HEAP_OBJ_LIMIT, HEAP_SIZE, heaps, heaps_used, himem, lomem, malloc, heaps_slot::membase, MEMMOVE, PRIuVALUE, rb_bug(), and rb_memerror().

Referenced by heaps_increment(), and init_heap().

static int chain_finalized_object ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
) [static]

Definition at line 2639 of file gc.c.

References RVALUE::as, RVALUE::basic, BUILTIN_TYPE, FL_FINALIZE, FL_MARK, RBasic::flags, RDATA, ST_CONTINUE, and T_ZOMBIE.

Referenced by rb_objspace_call_finalizer().

static VALUE count_objects ( int  argc,
VALUE argv,
VALUE  os 
) [static]

Definition at line 2904 of file gc.c.

References RVALUE::as, RVALUE::basic, BUILTIN_TYPE, RBasic::flags, hash(), heaps, heaps_used, rb_eTypeError, rb_objspace, rb_raise(), rb_scan_args(), T_HASH, T_MASK, and TYPE.

Referenced by Init_GC().

static VALUE define_final ( int  argc,
VALUE argv,
VALUE  os 
) [static]

Definition at line 2510 of file gc.c.

References finalizer_table, FL_ABLE, FL_FINALIZE, INT2FIX, OBJ_FREEZE, OBJ_FROZEN, rb_ary_new3(), rb_ary_push(), rb_block_proc(), rb_eArgError, rb_error_frozen(), rb_intern, rb_obj_classname(), rb_objspace, rb_raise(), rb_respond_to(), rb_safe_level, rb_scan_args(), RBASIC, st_add_direct, st_init_numtable, and st_lookup.

Referenced by Init_GC().

static void finalize_deferred ( rb_objspace_t objspace  )  [static]

Definition at line 2615 of file gc.c.

References deferred_final_list, and finalize_list().

Referenced by gc_finalize_deferred(), and rb_objspace_call_finalizer().

static void finalize_list ( rb_objspace_t objspace,
RVALUE p 
) [static]

Definition at line 1804 of file gc.c.

References add_freelist(), RVALUE::as, FL_SINGLETON, FL_TEST, RVALUE::free, mark_tbl_arg::objspace, RDATA, run_final(), and heaps_slot::slot.

Referenced by finalize_deferred().

static int force_chain_object ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
) [static]

Definition at line 2660 of file gc.c.

References ALLOC, force_finalize_list::next, force_finalize_list::obj, ST_CONTINUE, and force_finalize_list::table.

Referenced by rb_objspace_call_finalizer().

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

Definition at line 1462 of file gc.c.

References rb_free_method_entry(), and ST_CONTINUE.

Referenced by rb_free_m_table().

static void free_unused_heaps ( rb_objspace_t objspace  )  [static]

Definition at line 1821 of file gc.c.

References free, heaps, heaps_freed, heaps_used, last, heaps_slot::limit, and heaps_slot::membase.

Referenced by gc_finalize_deferred().

static int garbage_collect ( rb_objspace_t objspace  )  [static]

Definition at line 2141 of file gc.c.

References rb_objspace::count, dont_gc, during_gc, FALSE, finalizer_table, freelist, gc_mark_all(), gc_mark_rest(), GC_NOTIFY, GC_PROF_MARK_TIMER_START, GC_PROF_MARK_TIMER_STOP, GC_PROF_SWEEP_TIMER_START, GC_PROF_SWEEP_TIMER_STOP, GC_PROF_TIMER_START, GC_PROF_TIMER_STOP, gc_sweep(), GET_THREAD, global_List, heaps, heaps_increment(), INIT_GC_PROF_PARAMS, init_mark_stack(), list, mark_current_machine_context(), MARK_STACK_EMPTY, mark_stack_overflow, mark_tbl(), rb_class_tbl, rb_gc_mark(), rb_gc_mark_encodings(), rb_gc_mark_global_tbl(), rb_gc_mark_maybe(), rb_gc_mark_parser(), rb_gc_mark_symbols(), rb_gc_mark_threads(), rb_mark_end_proc(), rb_mark_generic_ivar_tbl(), rb_sweep_method_entry(), rb_vm_mark(), rb_vm_struct::self, set_heaps_increment(), SET_STACK_END, TRUE, rb_vm_struct::unlinked_method_entry_list, and rb_thread_struct::vm.

Referenced by garbage_collect_with_gvl(), gc_with_gvl(), rb_garbage_collect(), rb_gc(), and rb_newobj_from_heap().

static int garbage_collect_with_gvl ( rb_objspace_t objspace  )  [static]

Definition at line 620 of file gc.c.

References dont_gc, EXIT_FAILURE, garbage_collect(), gc_with_gvl(), rb_thread_call_with_gvl(), ruby_native_thread_p, ruby_thread_has_gvl_p(), and TRUE.

Referenced by vm_xmalloc(), and vm_xrealloc().

static VALUE gc_count ( VALUE  self  )  [static]

Definition at line 2996 of file gc.c.

References count, rb_objspace, and UINT2NUM().

Referenced by gc_profile_result(), and Init_GC().

static void gc_finalize_deferred ( rb_objspace_t objspace  )  [static]

Definition at line 2626 of file gc.c.

References finalize_deferred(), and free_unused_heaps().

Referenced by rb_gc(), and rb_gc_finalize_deferred().

static void gc_mark ( rb_objspace_t objspace,
VALUE  ptr,
int  lev 
) [static]

Definition at line 1492 of file gc.c.

References RVALUE::as, RVALUE::basic, FL_MARK, RBasic::flags, GC_LEVEL_MAX, gc_mark_children(), mark_stack, MARK_STACK_MAX, mark_stack_overflow, mark_stack_ptr, mark_tbl_arg::objspace, RANY, rb_special_const_p(), and stack_check().

Referenced by gc_mark_children(), mark_entry(), mark_key(), mark_keyvalue(), mark_locations_array(), mark_method_entry(), rb_gc_mark(), and rb_gc_mark_maybe().

static void gc_mark_all ( rb_objspace_t objspace  )  [static]

Definition at line 1248 of file gc.c.

References RVALUE::as, RVALUE::basic, FL_MARK, RBasic::flags, gc_mark_children(), heaps, heaps_used, init_mark_stack(), and heaps_slot::slot.

Referenced by garbage_collect().

static void gc_mark_children ( rb_objspace_t objspace,
VALUE  ptr,
int  lev 
) [static]

Definition at line 1524 of file gc.c.

References RVALUE::array, RString::as, RArray::as, RVALUE::as, RVALUE::basic, BUILTIN_TYPE, RNode::cnt, RVALUE::complex, RVALUE::data, DATA_PTR, RRational::den, RData::dmark, rb_data_type_struct::dmark, rb_io_t::rb_io_enc_t::ecopts, ELTS_SHARED, rb_io_t::encs, RVALUE::file, FL_ANY, FL_EXIVAR, FL_MARK, FL_TEST, RBasic::flags, RFile::fptr, gc_mark(), RVALUE::hash, RString::heap, RArray::heap, if(), RHash::ifnone, RComplex::imag, is_pointer_to_heap(), RBasic::klass, len, 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, mark_tbl_arg::objspace, rb_io_t::pathv, RANY, RARRAY_LEN, RARRAY_PTR, RVALUE::rational, rb_bug(), rb_mark_generic_ivar(), rb_special_const_p(), 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(), gc_mark_all(), and gc_mark_rest().

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

Definition at line 1325 of file gc.c.

References mark_locations_array().

Referenced by rb_gc_mark_locations().

static void gc_mark_rest ( rb_objspace_t objspace  )  [static]

Definition at line 1267 of file gc.c.

References gc_mark_children(), init_mark_stack(), mark_stack, MARK_STACK_MAX, mark_stack_ptr, and MEMCPY.

Referenced by garbage_collect().

static VALUE gc_profile_clear ( void   )  [static]

Definition at line 581 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 564 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 546 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 530 of file gc.c.

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

Referenced by Init_GC().

static VALUE gc_profile_record_get ( void   )  [static]

Definition at line 3034 of file gc.c.

References gc_profile_record::allocate_increase, gc_profile_record::allocate_limit, rb_objspace::count, DBL2NUM, gc_profile_record::gc_invoke_time, gc_profile_record::gc_mark_time, gc_profile_record::gc_sweep_time, gc_profile_record::gc_time, gc_profile_record::have_finalize, gc_profile_record::heap_free_objects, gc_profile_record::heap_live_objects, gc_profile_record::heap_total_objects, gc_profile_record::heap_total_size, gc_profile_record::heap_use_size, gc_profile_record::heap_use_slots, ID2SYM, rb_objspace::profile, Qnil, rb_ary_new(), rb_ary_push(), rb_hash_aset(), rb_hash_new(), rb_intern, rb_objspace, rb_uint2inum(), rb_objspace::record, and rb_objspace::run.

Referenced by gc_profile_result().

static VALUE gc_profile_report ( int  argc,
VALUE argv,
VALUE  self 
) [static]

Definition at line 3133 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]

Definition at line 3081 of file gc.c.

References rb_objspace::count, gc_count(), gc_profile_record_get(), ID2SYM, NUM2DBL, NUM2INT, rb_objspace::profile, RARRAY_LEN, RARRAY_PTR, rb_hash_aref(), rb_intern, rb_objspace, rb_sprintf(), rb_str_cat2(), rb_str_catf(), rb_str_new2, result, and rb_objspace::run.

Referenced by gc_profile_report(), and Init_GC().

static VALUE gc_profile_total_time ( VALUE  self  )  [static]

Definition at line 3156 of file gc.c.

References rb_objspace::count, DBL2NUM, gc_profile_record::gc_time, rb_objspace::profile, rb_objspace, rb_objspace::record, and rb_objspace::run.

Referenced by Init_GC().

static VALUE gc_stress_get ( VALUE  self  )  [static]

Definition at line 495 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 514 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]

Definition at line 1855 of file gc.c.

References add_freelist(), RVALUE::as, RVALUE::basic, BUILTIN_TYPE, deferred_final_list, heaps_slot::finalize_flag, FL_FINALIZE, FL_MARK, FL_SINGLETON, FL_TEST, RBasic::flags, RVALUE::free, free, FREE_MIN, freelist, HEAP_OBJ_LIMIT, heaps, heaps_used, if(), heaps_slot::limit, need_call_final, obj_free(), RBASIC, RDATA, T_ZOMBIE, and TRUE.

Referenced by garbage_collect().

static void* gc_with_gvl ( void *  ptr  )  [static]

Definition at line 614 of file gc.c.

References garbage_collect().

Referenced by garbage_collect_with_gvl().

static double getrusage_time ( void   )  [static]

Definition at line 109 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 996 of file gc.c.

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

Referenced by garbage_collect(), and rb_newobj_from_heap().

static VALUE id2ref ( VALUE  obj,
VALUE  objid 
) [static]

Definition at line 2769 of file gc.c.

References BUILTIN_TYPE, FIXNUM_FLAG, FIXNUM_P, ID2SYM, is_pointer_to_heap(), NUM2PTR, Qfalse, Qnil, Qtrue, rb_eRangeError, rb_id2name(), rb_objspace, rb_raise(), rb_secure(), RBASIC, T_FIXNUM, and T_ICLASS.

Referenced by Init_GC().

void Init_GC ( void   ) 

Definition at line 3177 of file gc.c.

References count_objects(), define_final(), gc_count(), gc_profile_clear(), gc_profile_disable(), gc_profile_enable(), gc_profile_enable_get(), gc_profile_report(), gc_profile_result(), gc_profile_total_time(), gc_stress_get(), gc_stress_set(), id2ref(), nomem_error, OBJ_FREEZE, OBJ_TAINT, os_each_obj(), rb_define_method(), rb_define_module(), rb_define_module_function(), rb_define_module_under(), rb_define_singleton_method(), rb_eNoMemError, rb_exc_new3(), rb_gc_disable(), rb_gc_enable(), rb_gc_start(), rb_mGC, rb_mKernel, rb_obj_freeze(), rb_obj_id(), rb_str_new2, and undefine_final().

void Init_heap ( void   ) 

Definition at line 2299 of file gc.c.

References init_heap(), and rb_objspace.

Referenced by ruby_init().

static void init_heap ( rb_objspace_t objspace  )  [static]

Definition at line 957 of file gc.c.

References add, allocate_heaps(), assign_heap_slot(), getrusage_time(), HEAP_MIN_SLOTS, HEAP_OBJ_LIMIT, heaps_inc, heaps_length, heaps_used, rb_objspace::invoke_time, and rb_objspace::profile.

Referenced by Init_heap().

static void init_mark_stack ( rb_objspace_t objspace  )  [static]

Definition at line 1236 of file gc.c.

References mark_stack, mark_stack_overflow, and mark_stack_ptr.

Referenced by garbage_collect(), gc_mark_all(), and gc_mark_rest().

void Init_stack ( volatile VALUE addr  ) 

Definition at line 2262 of file gc.c.

References ruby_init_stack().

static int is_pointer_to_heap ( rb_objspace_t objspace,
void *  ptr 
) [inline, static]

Definition at line 1283 of file gc.c.

References FALSE, heaps, heaps_used, himem, heaps_slot::limit, RANY, heaps_slot::slot, and TRUE.

Referenced by gc_mark_children(), id2ref(), mark_locations_array(), and rb_gc_mark_maybe().

static void make_deferred ( RVALUE p  )  [inline, static]

Definition at line 1958 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  )  [inline, static]

Definition at line 1964 of file gc.c.

References RVALUE::as, RData::data, RVALUE::data, RData::dfree, RVALUE::file, RFile::fptr, make_deferred(), and rb_io_fptr_finalize().

Referenced by obj_free().

static void mark_current_machine_context ( rb_objspace_t objspace,
rb_thread_t th 
) [static]

Definition at line 2112 of file gc.c.

References FLUSH_REGISTER_WINDOWS, GET_STACK_BOUNDS, mark_locations_array(), rb_gc_mark_locations, rb_jmp_buf, rb_setjmp, SET_STACK_END, STACK_END, and STACK_START.

Referenced by garbage_collect().

static int mark_entry ( ID  key,
VALUE  value,
st_data_t  data 
) [static]

Definition at line 1348 of file gc.c.

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

Referenced by mark_tbl().

static void mark_hash ( rb_objspace_t objspace,
st_table tbl,
int  lev 
) [static]

Definition at line 1399 of file gc.c.

References mark_tbl_arg::lev, 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 1366 of file gc.c.

References gc_mark(), mark_tbl_arg::lev, 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 1390 of file gc.c.

References gc_mark(), mark_tbl_arg::lev, 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]

Definition at line 1311 of file gc.c.

References gc_mark(), is_pointer_to_heap(), and VALGRIND_MAKE_MEM_DEFINED.

Referenced by gc_mark_children(), gc_mark_locations(), and mark_current_machine_context().

static void mark_m_tbl ( rb_objspace_t objspace,
st_table tbl,
int  lev 
) [static]

Definition at line 1452 of file gc.c.

References mark_tbl_arg::lev, 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,
int  lev 
) [static]

Definition at line 1415 of file gc.c.

References rb_method_definition_struct::attr, rb_method_definition_struct::body, rb_method_entry_struct::def, gc_mark(), rb_method_definition_struct::iseq, rb_method_entry_struct::klass, rb_method_attr_struct::location, mark_tbl_arg::objspace, rb_method_definition_struct::proc, rb_iseq_struct::self, rb_method_definition_struct::type, VM_METHOD_TYPE_ATTRSET, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_ISEQ, and VM_METHOD_TYPE_IVAR.

Referenced by mark_method_entry_i(), and rb_mark_method_entry().

static int mark_method_entry_i ( ID  key,
const rb_method_entry_t me,
st_data_t  data 
) [static]

Definition at line 1444 of file gc.c.

References mark_tbl_arg::lev, 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,
int  lev 
) [static]

Definition at line 1374 of file gc.c.

References mark_tbl_arg::lev, 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,
int  lev 
) [static]

Definition at line 1356 of file gc.c.

References mark_tbl_arg::lev, mark_entry(), mark_tbl_arg::objspace, and st_foreach.

Referenced by garbage_collect(), gc_mark_children(), rb_mark_tbl(), and rb_objspace_call_finalizer().

static void negative_size_allocation_error ( const char *  msg  )  [static]

Definition at line 597 of file gc.c.

References EXIT_FAILURE, negative_size_allocation_error_with_gvl(), rb_eNoMemError, rb_raise(), rb_thread_call_with_gvl(), ruby_native_thread_p, and ruby_thread_has_gvl_p().

Referenced by vm_xmalloc(), and vm_xrealloc().

static void* negative_size_allocation_error_with_gvl ( void *  ptr  )  [static]

Definition at line 590 of file gc.c.

References rb_eNoMemError, and rb_raise().

Referenced by negative_size_allocation_error().

static int obj_free ( rb_objspace_t ,
VALUE   
) [static]

Definition at line 1973 of file gc.c.

References BUILTIN_TYPE, rmatch::char_offset, DATA_PTR, FL_EXIVAR, FL_TEST, FL_UNSET, make_deferred(), make_io_deferred(), nd_type, NODE_ALLOCA, NODE_SCOPE, onig_free(), onig_region_free(), RANY, rb_ary_free(), rb_bug(), rb_clear_cache_by_class(), rb_free_generic_ivar(), rb_free_m_table(), rb_str_free(), RBASIC, RBIGNUM_DIGITS, RBIGNUM_EMBED_FLAG, RCLASS_IV_INDEX_TBL, RCLASS_IV_TBL, RCLASS_M_TBL, RDATA, rmatch::regs, ROBJECT_EMBED, RSTRUCT_EMBED_LEN_MASK, RTYPEDDATA_P, st_free_table, T_ARRAY, T_BIGNUM, T_CLASS, T_COMPLEX, T_DATA, T_FALSE, 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_TRUE, and xfree.

Referenced by gc_sweep().

static VALUE os_each_obj ( int  argc,
VALUE argv,
VALUE  os 
) [static]

Definition at line 2465 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 2418 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]

Definition at line 2386 of file gc.c.

References RVALUE::as, RVALUE::basic, BUILTIN_TYPE, FL_SINGLETON, FL_TEST, RBasic::flags, if(), os_each_struct::num, os_each_struct::of, rb_obj_is_kind_of(), rb_yield(), T_CLASS, T_ICLASS, T_NODE, T_NONE, and T_ZOMBIE.

Referenced by os_obj_of().

VALUE rb_data_object_alloc ( VALUE  klass,
void *  datap,
RUBY_DATA_FUNC  dmark,
RUBY_DATA_FUNC  dfree 
)

Definition at line 1117 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 1130 of file gc.c.

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

int rb_during_gc ( void   ) 

Definition at line 1055 of file gc.c.

References during_gc, and rb_objspace.

void rb_free_m_table ( st_table tbl  ) 

Definition at line 1469 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 2223 of file gc.c.

References garbage_collect(), and rb_objspace.

void rb_gc ( void   ) 

Definition at line 2748 of file gc.c.

References garbage_collect(), gc_finalize_deferred(), and rb_objspace.

Referenced by bug_str_cstr_term(), dir_initialize(), getDevice(), iconv_create(), rb_fdopen(), rb_gc_start(), rb_pipe(), rb_sysopen(), rsock_s_accept(), rsock_socket(), and ruby_dup().

void rb_gc_call_finalizer_at_exit ( void   ) 

Definition at line 2672 of file gc.c.

References rb_objspace, and rb_objspace_call_finalizer().

Referenced by ruby_finalize_1().

void rb_gc_copy_finalizer ( VALUE  dest,
VALUE  obj 
)

Definition at line 2548 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   ) 

Definition at line 820 of file gc.c.

References dont_gc, Qfalse, Qtrue, rb_objspace, and TRUE.

Referenced by cbsubst_scan_args(), Init_GC(), ip_ruby_cmd(), lib_merge_tklist(), lib_split_tklist_core(), tcl_protect_core(), and tk_conv_args().

VALUE rb_gc_enable ( void   ) 

Definition at line 798 of file gc.c.

References dont_gc, FALSE, Qfalse, Qtrue, and rb_objspace.

Referenced by Init_GC(), ip_ruby_cmd(), lib_merge_tklist(), lib_split_tklist_core(), tcl_protect_core(), and tk_conv_args().

void rb_gc_finalize_deferred ( void   ) 

Definition at line 2633 of file gc.c.

References gc_finalize_deferred(), and rb_objspace.

Referenced by rb_threadptr_execute_interrupts_rec().

void rb_gc_force_recycle ( VALUE  p  ) 

Definition at line 1951 of file gc.c.

References add_freelist(), and rb_objspace.

Referenced by call_queue_handler(), dispose_string(), eval_queue_handler(), fixup_nodes(), Init_prelude(), invoke_queue_handler(), literal_concat_gen(), parser_heredoc_restore(), parser_yylex(), rb_ary_decrement_share(), rb_parser_free(), ruby_vm_destruct(), and yyparse().

void rb_gc_mark ( VALUE  ptr  ) 

Definition at line 1518 of file gc.c.

References gc_mark(), and rb_objspace.

Referenced by _thread_call_proc_arg_mark(), addrinfo_mark(), argf_mark(), barrier_mark(), bm_mark(), call_queue_mark(), cont_mark(), cparse_params_mark(), dir_mark(), enumerator_mark(), eval_queue_mark(), fiber_mark(), garbage_collect(), generator_mark(), givar_mark_i(), gzfile_mark(), invoke_queue_mark(), mark_dump_arg(), mark_event_hooks(), mark_marshal_compat_i(), parser_mark(), random_mark(), rb_mark_end_proc(), rb_thread_mark(), rb_vm_mark(), strio_mark(), strscan_mark(), subst_mark(), syck_mark_emitter(), syck_mark_parser(), syck_node_mark(), time_mark(), vm_mark_each_thread_func(), yielder_mark(), and zstream_mark().

void rb_gc_mark_encodings ( void   ) 

Definition at line 173 of file encoding.c.

Referenced by garbage_collect().

void rb_gc_mark_locations ( VALUE start,
VALUE end 
)

Definition at line 1335 of file gc.c.

References gc_mark_locations(), and rb_objspace.

void rb_gc_mark_machine_stack ( rb_thread_t th  ) 

Definition at line 2229 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  ) 

Definition at line 1482 of file gc.c.

References gc_mark(), is_pointer_to_heap(), and rb_objspace.

Referenced by garbage_collect(), JSON_mark(), mark_global_entry(), syck_mark_parser(), syck_node_mark(), val_marker(), and var_marker().

void rb_gc_register_address ( VALUE addr  ) 

Definition at line 839 of file gc.c.

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

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

void rb_gc_register_mark_object ( VALUE  obj  ) 

Definition at line 832 of file gc.c.

References GET_THREAD, and rb_ary_push().

Referenced by Init_Encoding(), Init_IO(), Init_load(), Init_marshal(), Init_VM(), Init_win32ole(), make_patterns(), power_cache_get_power0(), rb_define_class_id_under(), rb_define_module_id_under(), ruby_process_options(), and sym_to_proc().

VALUE rb_gc_start ( void   ) 

Definition at line 2253 of file gc.c.

References Qnil, and rb_gc().

Referenced by Init_GC().

void rb_gc_unregister_address ( VALUE addr  ) 

Definition at line 851 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  ) 

Definition at line 439 of file gc.c.

References rb_gc_register_address().

Referenced by Init_RandomSeed(), Init_Regexp(), Init_syck(), Init_tcltklib(), and Init_tkutil().

int rb_io_fptr_finalize ( struct rb_io_t  ) 

Definition at line 3529 of file io.c.

Referenced by make_io_deferred(), pipe_atexit(), and rb_io_close_read().

void rb_mark_hash ( st_table tbl  ) 

Definition at line 1409 of file gc.c.

References mark_hash(), and rb_objspace.

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 1438 of file gc.c.

References mark_method_entry(), and rb_objspace.

Referenced by bm_mark().

void rb_mark_set ( st_table tbl  ) 

Definition at line 1384 of file gc.c.

References mark_set(), and rb_objspace.

Referenced by mark_dump_arg().

void rb_mark_tbl ( st_table tbl  ) 

Definition at line 1476 of file gc.c.

References mark_tbl(), and rb_objspace.

Referenced by autoload_mark(), mark_load_arg(), rb_gc_mark_symbols(), rb_mark_generic_ivar(), rb_thread_mark(), and rb_vm_mark().

void rb_memerror ( void   ) 

Definition at line 470 of file gc.c.

References EXIT_FAILURE, GET_THREAD, JUMP_TAG, nomem_error, RAISED_NOMEMORY, rb_exc_raise(), rb_safe_level, rb_thread_raised_clear, rb_thread_raised_p, rb_thread_raised_set, and TAG_RAISE.

Referenced by allocate_heaps(), assign_heap_slot(), nsdr(), rb_newobj_from_heap(), ruby_memerror(), and ruby_memerror_body().

VALUE rb_newobj ( void   ) 

Definition at line 1062 of file gc.c.

References dont_gc, during_gc, GET_THREAD, rb_vm_struct::objspace, rb_bug(), rb_newobj_from_heap(), rb_objspace, RBASIC, and rb_thread_struct::vm.

Referenced by rb_node_newnode().

static VALUE rb_newobj_from_heap ( rb_objspace_t objspace  )  [static]

Definition at line 1009 of file gc.c.

References during_gc, freelist, garbage_collect(), heaps_increment(), MEMZERO, RANY, rb_memerror(), rb_sourcefile(), rb_sourceline(), ruby_disable_gc_stress, and ruby_gc_stress.

Referenced by rb_newobj().

NODE* rb_node_newnode ( enum node_type  type,
VALUE  a0,
VALUE  a1,
VALUE  a2 
)

Definition at line 1102 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  ) 

Definition at line 2835 of file gc.c.

References FIXNUM_FLAG, LONG2NUM, SIGNED_VALUE, SPECIAL_CONST_P, SYM2ID, T_SYMBOL, and TYPE.

Referenced by exec_recursive(), Init_GC(), rb_exec_recursive_paired(), rb_obj_hash(), rb_objspace_call_finalizer(), and run_final().

rb_objspace_t* rb_objspace_alloc ( void   ) 

Definition at line 374 of file gc.c.

References GC_MALLOC_LIMIT, malloc, malloc_limit, ruby_gc_stress, and ruby_initial_gc_stress.

Referenced by Init_BareVM().

void rb_objspace_call_finalizer ( rb_objspace_t objspace  )  [static]

Definition at line 2678 of file gc.c.

References BUILTIN_TYPE, chain_finalized_object(), DATA_PTR, deferred_final_list, during_gc, finalize_deferred(), finalizer_table, force_chain_object(), heaps, heaps_used, if(), list, make_deferred(), mark_tbl(), force_finalize_list::next, force_finalize_list::obj, RANY, rb_cMutex, rb_cThread, rb_obj_id(), RDATA, RTYPEDDATA_P, run_finalizer(), st_delete, st_foreach, st_free_table, T_DATA, force_finalize_list::table, and xfree.

Referenced by rb_gc_call_finalizer_at_exit(), and rb_objspace_free().

size_t rb_objspace_data_type_memsize ( VALUE  obj  ) 

Definition at line 1146 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 1157 of file gc.c.

References RTYPEDDATA_P, and RTYPEDDATA_TYPE.

void rb_objspace_each_objects ( int(*)(void *vstart, void *vend, size_t stride, void *d)  callback,
void *  data 
)

Definition at line 2341 of file gc.c.

References RVALUE::as, RVALUE::basic, RBasic::flags, heaps, heaps_used, and rb_objspace.

void rb_objspace_free ( rb_objspace_t objspace  ) 

Definition at line 385 of file gc.c.

References free, global_List, heaps, heaps_used, list, gc_list::next, rb_objspace::profile, rb_objspace_call_finalizer(), and rb_objspace::record.

Referenced by ruby_vm_destruct().

void rb_vm_mark ( void *  ptr  ) 

Definition at line 1491 of file vm.c.

References rb_vm_struct::cmd, rb_vm_struct::coverages, rb_vm_struct::event_hooks, rb_vm_struct::living_threads, rb_vm_struct::load_path, rb_vm_struct::loaded_features, rb_vm_struct::loading_table, mark_event_hooks(), rb_vm_struct::mark_object_ary, rb_gc_mark(), rb_gc_mark_locations, rb_mark_tbl(), RUBY_GC_INFO, RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUBY_MARK_UNLESS_NULL, RUBY_NSIG, ruby_special_error_count, rb_vm_struct::special_exceptions, st_foreach, rb_vm_struct::thgroup_default, rb_vm_struct::top_self, rb_vm_struct::trap_list, and vm_mark_each_thread_func().

Referenced by garbage_collect().

int ruby_get_stack_grow_direction ( volatile VALUE addr  ) 

Definition at line 1188 of file gc.c.

References SET_MACHINE_STACK_END.

static void ruby_memerror ( void   )  [static]

Definition at line 452 of file gc.c.

References EXIT_FAILURE, rb_memerror(), rb_thread_call_with_gvl(), ruby_memerror_body(), ruby_native_thread_p, and ruby_thread_has_gvl_p().

Referenced by vm_xmalloc(), and vm_xrealloc().

static void* ruby_memerror_body ( void *  dummy  )  [static]

Definition at line 445 of file gc.c.

References rb_memerror().

Referenced by ruby_memerror().

int ruby_stack_check ( void   ) 

Definition at line 1226 of file gc.c.

References stack_check().

Referenced by stack_check().

size_t ruby_stack_length ( VALUE **  p  ) 

Definition at line 1201 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 752 of file gc.c.

References ruby_xmalloc2().

void ruby_xfree ( void *  x  ) 

Definition at line 777 of file gc.c.

References rb_objspace, and vm_xfree().

Referenced by binding_free(), compile_data_free(), cont_free(), cState_array_nl_set(), cState_indent_set(), cState_object_nl_set(), cState_space_before_set(), cState_space_set(), env_free(), fbuffer_free(), fbuffer_free_only_buffer(), free_sdbm(), Init_dl(), iseq_free(), JSON_free(), mutex_free(), ossl_cipher_free(), ossl_hmac_free(), proc_free(), rb_dl_free(), rb_thread_recycle_stack_release(), ruby_vm_destruct(), State_free(), strscan_free(), and thread_free().

void* ruby_xmalloc ( size_t  size  ) 

Definition at line 736 of file gc.c.

References rb_objspace, and vm_xmalloc().

Referenced by rb_dl_malloc(), and rb_dlptr_malloc().

void* ruby_xmalloc2 ( size_t  n,
size_t  size 
)

Definition at line 742 of file gc.c.

References len, rb_eArgError, rb_objspace, rb_raise(), and vm_xmalloc().

Referenced by ruby_xcalloc().

void* ruby_xrealloc ( void *  ptr,
size_t  size 
)

Definition at line 761 of file gc.c.

References rb_objspace, and vm_xrealloc().

Referenced by rb_dl_realloc(), and ruby_xrealloc2().

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

Definition at line 767 of file gc.c.

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

static void run_final ( rb_objspace_t objspace,
VALUE  obj 
) [static]

Definition at line 2590 of file gc.c.

References DATA_PTR, finalizer_table, rb_obj_id(), RBASIC, RDATA, RTYPEDDATA_P, RTYPEDDATA_TYPE, run_finalizer(), and st_delete.

Referenced by finalize_list().

static void run_finalizer ( rb_objspace_t objspace,
VALUE  obj,
VALUE  objid,
VALUE  table 
) [static]

Definition at line 2570 of file gc.c.

References FIX2INT, RARRAY_LEN, RARRAY_PTR, rb_ary_new3(), rb_obj_freeze(), rb_protect(), rb_safe_level, and run_single_final().

Referenced by rb_objspace_call_finalizer(), and run_final().

static VALUE run_single_final ( VALUE  arg  )  [static]

Definition at line 2562 of file gc.c.

References Qnil, and rb_eval_cmd().

Referenced by run_finalizer().

static void set_heaps_increment ( rb_objspace_t objspace  )  [static]

Definition at line 980 of file gc.c.

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

Referenced by garbage_collect().

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

Definition at line 2875 of file gc.c.

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

static int stack_check ( void   )  [static]

Definition at line 1210 of file gc.c.

References GC_WATER_MARK, GET_THREAD, SET_STACK_END, STACK_LENGTH, and STACK_LEVEL_MAX.

Referenced by check_funcall(), gc_mark(), raise_method_missing(), rb_call0(), and ruby_stack_check().

static VALUE undefine_final ( VALUE  os,
VALUE  obj 
) [static]

Definition at line 2489 of file gc.c.

References finalizer_table, FL_FINALIZE, FL_UNSET, OBJ_FROZEN, rb_error_frozen(), rb_objspace, and st_delete.

Referenced by Init_GC().

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

Definition at line 722 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 641 of file gc.c.

References garbage_collect_with_gvl(), malloc, malloc_increase, malloc_limit, rb_objspace::malloc_params, negative_size_allocation_error(), ruby_disable_gc_stress, ruby_gc_stress, and ruby_memerror().

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

static void* vm_xrealloc ( rb_objspace_t objspace,
void *  ptr,
size_t  size 
) [static]

Definition at line 680 of file gc.c.

References garbage_collect_with_gvl(), malloc_increase, negative_size_allocation_error(), realloc, ruby_disable_gc_stress, ruby_gc_stress, ruby_memerror(), vm_xfree(), and vm_xmalloc().

Referenced by ruby_xrealloc().


Variable Documentation

VALUE rb_cMutex

Definition at line 60 of file thread.c.

Referenced by Init_Thread(), rb_mutex_new(), and rb_objspace_call_finalizer().

VALUE rb_mGC

Definition at line 829 of file gc.c.

Referenced by Init_GC().

int ruby_disable_gc_stress = 0

Definition at line 433 of file gc.c.

Referenced by rb_newobj_from_heap(), vm_xmalloc(), and vm_xrealloc().

int ruby_gc_debug_indent = 0

Definition at line 85 of file gc.c.

int ruby_initial_gc_stress = 0 [static]

Definition at line 341 of file gc.c.

Referenced by rb_objspace_alloc().

int* ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress

Definition at line 342 of file gc.c.

int ruby_stack_grow_direction

Definition at line 1186 of file gc.c.


Generated on Wed Aug 10 09:18:34 2011 for Ruby by  doxygen 1.4.7