gc.c File Reference

#include "ruby/ruby.h"
#include "ruby/st.h"
#include "ruby/re.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "ruby/debug.h"
#include "eval_intern.h"
#include "vm_core.h"
#include "internal.h"
#include "gc.h"
#include "constant.h"
#include "ruby_atomic.h"
#include "probes.h"
#include <stdio.h>
#include <stdarg.h>
#include <setjmp.h>
#include <sys/types.h>
#include <assert.h>
#include "regint.h"

Go to the source code of this file.

Data Structures

struct  ruby_gc_params_t
struct  gc_profile_record
struct  RVALUE
struct  heap_page_header
struct  heap_page_body
struct  gc_list
struct  stack_chunk
struct  mark_stack
struct  rb_heap_struct
struct  rb_objspace
struct  rb_objspace::mark_func_data_struct
struct  heap_page
struct  each_obj_args
struct  os_each_struct
struct  force_finalize_list
struct  mark_tbl_arg
struct  verify_internal_consistency_struct
struct  objspace_and_reason
struct  root_objects_data
struct  weakmap
struct  wmap_iter_arg

Defines

#define __has_feature(x)   0
#define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
#define rb_setjmp(env)   RUBY_SETJMP(env)
#define rb_jmp_buf   rb_jmpbuf_t
#define GC_HEAP_FREE_SLOTS   4096
#define GC_HEAP_INIT_SLOTS   10000
#define GC_HEAP_GROWTH_FACTOR   1.8
#define GC_HEAP_GROWTH_MAX_SLOTS   0
#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR   2.0
#define GC_MALLOC_LIMIT_MIN   (16 * 1024 * 1024 /* 16MB */)
#define GC_MALLOC_LIMIT_MAX   (32 * 1024 * 1024 /* 32MB */)
#define GC_MALLOC_LIMIT_GROWTH_FACTOR   1.4
#define GC_OLDMALLOC_LIMIT_MIN   (16 * 1024 * 1024 /* 16MB */)
#define GC_OLDMALLOC_LIMIT_GROWTH_FACTOR   1.2
#define GC_OLDMALLOC_LIMIT_MAX   (128 * 1024 * 1024 /* 128MB */)
#define GC_DEBUG   0
#define RGENGC_DEBUG   0
#define RGENGC_CHECK_MODE   0
#define RGENGC_PROFILE   0
#define RGENGC_THREEGEN   0
#define RGENGC_ESTIMATE_OLDMALLOC   1
#define GC_PROFILE_MORE_DETAIL   0
#define GC_PROFILE_DETAIL_MEMORY   0
#define GC_ENABLE_LAZY_SWEEP   1
#define CALC_EXACT_MALLOC_SIZE   0
#define MALLOC_ALLOCATED_SIZE   0
#define MALLOC_ALLOCATED_SIZE_CHECK   0
#define STACK_CHUNK_SIZE   500
#define HEAP_ALIGN_LOG   14
#define CEILDIV(i, mod)   (((i) + (mod) - 1)/(mod))
#define GET_PAGE_BODY(x)   ((struct heap_page_body *)((bits_t)(x) & ~(HEAP_ALIGN_MASK)))
#define GET_PAGE_HEADER(x)   (&GET_PAGE_BODY(x)->header)
#define GET_HEAP_PAGE(x)   (GET_PAGE_HEADER(x)->page)
#define GET_HEAP_MARK_BITS(x)   (&GET_HEAP_PAGE(x)->mark_bits[0])
#define GET_HEAP_REMEMBERSET_BITS(x)   (&GET_HEAP_PAGE(x)->rememberset_bits[0])
#define GET_HEAP_OLDGEN_BITS(x)   (&GET_HEAP_PAGE(x)->oldgen_bits[0])
#define NUM_IN_PAGE(p)   (((bits_t)(p) & HEAP_ALIGN_MASK)/sizeof(RVALUE))
#define BITMAP_INDEX(p)   (NUM_IN_PAGE(p) / BITS_BITLENGTH )
#define BITMAP_OFFSET(p)   (NUM_IN_PAGE(p) & (BITS_BITLENGTH-1))
#define BITMAP_BIT(p)   ((bits_t)1 << BITMAP_OFFSET(p))
#define MARKED_IN_BITMAP(bits, p)   ((bits)[BITMAP_INDEX(p)] & BITMAP_BIT(p))
#define MARK_IN_BITMAP(bits, p)   ((bits)[BITMAP_INDEX(p)] = (bits)[BITMAP_INDEX(p)] | BITMAP_BIT(p))
#define CLEAR_IN_BITMAP(bits, p)   ((bits)[BITMAP_INDEX(p)] = (bits)[BITMAP_INDEX(p)] & ~BITMAP_BIT(p))
#define rb_objspace   (*GET_VM()->objspace)
#define ruby_initial_gc_stress   gc_params.gc_stress
#define malloc_limit   objspace->malloc_params.limit
#define malloc_increase   objspace->malloc_params.increase
#define malloc_allocated_size   objspace->malloc_params.allocated_size
#define heap_pages_sorted   objspace->heap_pages.sorted
#define heap_pages_used   objspace->heap_pages.used
#define heap_pages_length   objspace->heap_pages.length
#define heap_pages_lomem   objspace->heap_pages.range[0]
#define heap_pages_himem   objspace->heap_pages.range[1]
#define heap_pages_swept_slots   objspace->heap_pages.swept_slots
#define heap_pages_increment   objspace->heap_pages.increment
#define heap_pages_min_free_slots   objspace->heap_pages.min_free_slots
#define heap_pages_max_free_slots   objspace->heap_pages.max_free_slots
#define heap_pages_final_slots   objspace->heap_pages.final_slots
#define heap_pages_deferred_final   objspace->heap_pages.deferred_final
#define heap_eden   (&objspace->eden_heap)
#define heap_tomb   (&objspace->tomb_heap)
#define dont_gc   objspace->flags.dont_gc
#define during_gc   objspace->flags.during_gc
#define finalizing   objspace->flags.finalizing
#define finalizer_table   objspace->finalizer_table
#define global_List   objspace->global_list
#define ruby_gc_stress   objspace->gc_stress
#define monitor_level   objspace->rgengc.monitor_level
#define monitored_object_table   objspace->rgengc.monitored_object_table
#define is_lazy_sweeping(heap)   ((heap)->sweep_pages != 0)
#define nonspecial_obj_id(obj)   (VALUE)((SIGNED_VALUE)(obj)|FIXNUM_FLAG)
#define obj_id_to_ref(objid)   ((objid) ^ FIXNUM_FLAG)
#define RANY(o)   ((RVALUE*)(o))
#define nomem_error   GET_VM()->special_exceptions[ruby_error_nomemory]
#define gc_prof_record(objspace)   (objspace)->profile.current_record
#define gc_prof_enabled(objspace)   ((objspace)->profile.run && (objspace)->profile.current_record)
#define rgengc_report   if (RGENGC_DEBUG) rgengc_report_body
#define FL_TEST2(x, f)   ((RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) ? (rb_bug("FL_TEST2: SPECIAL_CONST"), 0) : FL_TEST_RAW((x),(f)) != 0)
#define FL_SET2(x, f)   do {if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) rb_bug("FL_SET2: SPECIAL_CONST"); RBASIC(x)->flags |= (f);} while (0)
#define FL_UNSET2(x, f)   do {if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) rb_bug("FL_UNSET2: SPECIAL_CONST"); RBASIC(x)->flags &= ~(f);} while (0)
#define RVALUE_WB_PROTECTED_RAW(obj)   FL_TEST2((obj), FL_WB_PROTECTED)
#define RVALUE_WB_PROTECTED(obj)   RVALUE_WB_PROTECTED_RAW(check_gen_consistency((VALUE)obj))
#define RVALUE_OLDGEN_BITMAP(obj)   MARKED_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), (obj))
#define gc_event_hook(objspace, event, data)
#define NUM2PTR(x)   NUM2ULONG(x)
#define COUNT_TYPE(t)   case (t): type = ID2SYM(rb_intern(#t)); break;
#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 rb_gc_mark_locations(start, end)   gc_mark_locations(objspace, (start), (end))
#define GET_STACK_BOUNDS(start, end, appendix)
#define STR_ASSOC   FL_USER3
#define RGENGC_PRINT_TICK   0
#define MARK_CHECKPOINT_PRINT_TICK(category)
#define MARK_CHECKPOINT(category)
#define I(s)   ID_##s = rb_intern(#s);
#define GC_NOTIFY   0
#define S(s)   sym_##s = ID2SYM(rb_intern_const(#s))
#define SET(name, attr)
#define S(s)   sym_##s = ID2SYM(rb_intern_const(#s))
#define SET(name, attr)
#define TRY_WITH_GC(alloc)
#define WMAP_DELETE_DEAD_OBJECT_IN_MARK   0
#define GC_PROFILE_RECORD_DEFAULT_SIZE   100
#define TYPE_NAME(t)   case (t): return #t;
#define OPT(o)   if (o) rb_ary_push(opts, rb_str_new2(#o))

Typedefs

typedef uintptr_t bits_t
typedef stack_chunk stack_chunk_t
typedef mark_stack mark_stack_t
typedef rb_heap_struct rb_heap_t
typedef rb_objspace rb_objspace_t
typedef int each_obj_callback (void *, void *, size_t, void *)

Enumerations

enum  gc_profile_record_flag {
  GPR_FLAG_NONE = 0x000, GPR_FLAG_MAJOR_BY_NOFREE = 0x001, GPR_FLAG_MAJOR_BY_OLDGEN = 0x002, GPR_FLAG_MAJOR_BY_SHADY = 0x004,
  GPR_FLAG_MAJOR_BY_RESCAN = 0x008, GPR_FLAG_MAJOR_BY_STRESS = 0x010, GPR_FLAG_MAJOR_BY_OLDMALLOC = 0x020, GPR_FLAG_MAJOR_MASK = 0x0ff,
  GPR_FLAG_NEWOBJ = 0x100, GPR_FLAG_MALLOC = 0x200, GPR_FLAG_METHOD = 0x400, GPR_FLAG_CAPI = 0x800,
  GPR_FLAG_STRESS = 0x1000, GPR_FLAG_IMMEDIATE_SWEEP = 0x2000, GPR_FLAG_HAVE_FINALIZE = 0x4000
}
enum  { BITS_SIZE = sizeof(bits_t), BITS_BITLENGTH = ( BITS_SIZE * CHAR_BIT ) }
enum  {
  HEAP_ALIGN = (1UL << HEAP_ALIGN_LOG), HEAP_ALIGN_MASK = (~(~0UL << HEAP_ALIGN_LOG)), REQUIRED_SIZE_BY_MALLOC = (sizeof(size_t) * 5), HEAP_SIZE = (HEAP_ALIGN - REQUIRED_SIZE_BY_MALLOC),
  HEAP_OBJ_LIMIT = (unsigned int)((HEAP_SIZE - sizeof(struct heap_page_header))/sizeof(struct RVALUE)), HEAP_BITMAP_LIMIT = CEILDIV(CEILDIV(HEAP_SIZE, sizeof(struct RVALUE)), BITS_BITLENGTH), HEAP_BITMAP_SIZE = ( BITS_SIZE * HEAP_BITMAP_LIMIT), HEAP_BITMAP_PLANES = USE_RGENGC ? 3 : 1
}
enum  memop_type { MEMOP_TYPE_MALLOC = 1, MEMOP_TYPE_FREE = 2, MEMOP_TYPE_REALLOC = 3 }

Functions

volatile VALUE * rb_gc_guarded_ptr (volatile VALUE *ptr)
void rb_gcdebug_print_obj_condition (VALUE obj)
static void rb_objspace_call_finalizer (rb_objspace_t *objspace)
static VALUE define_final0 (VALUE obj, VALUE block)
static void negative_size_allocation_error (const char *)
static void * aligned_malloc (size_t, size_t)
static void aligned_free (void *)
static void init_mark_stack (mark_stack_t *stack)
static VALUE lazy_sweep_enable (void)
static int ready_to_gc (rb_objspace_t *objspace)
static int heap_ready_to_gc (rb_objspace_t *objspace, rb_heap_t *heap)
static int garbage_collect (rb_objspace_t *, int full_mark, int immediate_sweep, int reason)
static int garbage_collect_body (rb_objspace_t *, int full_mark, int immediate_sweep, int reason)
static int gc_heap_lazy_sweep (rb_objspace_t *objspace, rb_heap_t *heap)
static void gc_rest_sweep (rb_objspace_t *objspace)
static void gc_heap_rest_sweep (rb_objspace_t *objspace, rb_heap_t *heap)
static void gc_mark_stacked_objects (rb_objspace_t *)
static void gc_mark (rb_objspace_t *objspace, VALUE ptr)
static void gc_mark_maybe (rb_objspace_t *objspace, VALUE ptr)
static void gc_mark_children (rb_objspace_t *objspace, VALUE ptr)
static size_t obj_memsize_of (VALUE obj, int use_tdata)
static double getrusage_time (void)
static void gc_prof_setup_new_record (rb_objspace_t *objspace, int reason)
static void gc_prof_timer_start (rb_objspace_t *)
static void gc_prof_timer_stop (rb_objspace_t *)
static void gc_prof_mark_timer_start (rb_objspace_t *)
static void gc_prof_mark_timer_stop (rb_objspace_t *)
static void gc_prof_sweep_timer_start (rb_objspace_t *)
static void gc_prof_sweep_timer_stop (rb_objspace_t *)
static void gc_prof_set_malloc_info (rb_objspace_t *)
static void gc_prof_set_heap_info (rb_objspace_t *)
static void rgengc_report_body (int level, rb_objspace_t *objspace, const char *fmt,...)
static const char * type_name (int type, VALUE obj)
static const char * obj_type_name (VALUE obj)
static int rgengc_remembered (rb_objspace_t *objspace, VALUE obj)
static int rgengc_remember (rb_objspace_t *objspace, VALUE obj)
static void rgengc_mark_and_rememberset_clear (rb_objspace_t *objspace, rb_heap_t *heap)
static void rgengc_rememberset_mark (rb_objspace_t *objspace, rb_heap_t *heap)
static int is_pointer_to_heap (rb_objspace_t *objspace, void *ptr)
static int gc_marked (rb_objspace_t *objspace, VALUE ptr)
static VALUE check_gen_consistency (VALUE obj)
static VALUE RVALUE_INFANT_P (VALUE obj)
static VALUE RVALUE_OLD_BITMAP_P (VALUE obj)
static VALUE RVALUE_OLD_P (VALUE obj)
static VALUE RVALUE_PROMOTED_P (VALUE obj)
static void RVALUE_PROMOTE_INFANT (VALUE obj)
static void RVALUE_DEMOTE_FROM_OLD (VALUE obj)
rb_objspace_trb_objspace_alloc (void)
static void free_stack_chunks (mark_stack_t *)
static void heap_page_free (rb_objspace_t *objspace, struct heap_page *page)
void rb_objspace_free (rb_objspace_t *objspace)
static void heap_pages_expand_sorted (rb_objspace_t *objspace)
static void heap_page_add_freeobj (rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
static void heap_add_freepage (rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
static void heap_unlink_page (rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
static void heap_pages_free_unused_pages (rb_objspace_t *objspace)
static struct heap_pageheap_page_allocate (rb_objspace_t *objspace)
static struct heap_pageheap_page_resurrect (rb_objspace_t *objspace)
static struct heap_pageheap_page_create (rb_objspace_t *objspace)
static void heap_add_page (rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
static void heap_assign_page (rb_objspace_t *objspace, rb_heap_t *heap)
static void heap_add_pages (rb_objspace_t *objspace, rb_heap_t *heap, size_t add)
static void heap_set_increment (rb_objspace_t *objspace, size_t minimum_limit)
static int heap_increment (rb_objspace_t *objspace, rb_heap_t *heap)
static struct heap_pageheap_prepare_freepage (rb_objspace_t *objspace, rb_heap_t *heap)
static RVALUEheap_get_freeobj_from_next_freepage (rb_objspace_t *objspace, rb_heap_t *heap)
static VALUE heap_get_freeobj (rb_objspace_t *objspace, rb_heap_t *heap)
void rb_objspace_set_event_hook (const rb_event_flag_t event)
static void gc_event_hook_body (rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data)
static VALUE newobj_of (VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3)
VALUE rb_newobj (void)
VALUE rb_newobj_of (VALUE klass, VALUE flags)
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)
static int free_method_entry_i (ID key, rb_method_entry_t *me, st_data_t data)
void rb_free_m_tbl (st_table *tbl)
void rb_free_m_tbl_wrapper (struct method_table_wrapper *wrapper)
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)
static void make_deferred (rb_objspace_t *objspace, RVALUE *p)
static void make_io_deferred (rb_objspace_t *objspace, RVALUE *p)
static int obj_free (rb_objspace_t *objspace, VALUE obj)
void Init_heap (void)
static VALUE objspace_each_objects (VALUE arg)
void rb_objspace_each_objects (each_obj_callback *callback, void *data)
static int internal_object_p (VALUE obj)
int rb_objspace_internal_object_p (VALUE obj)
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)
VALUE rb_undefine_finalizer (VALUE obj)
static void should_be_callable (VALUE block)
static void should_be_finalizable (VALUE obj)
static VALUE define_final (int argc, VALUE *argv, VALUE os)
VALUE rb_define_finalizer (VALUE obj, VALUE block)
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 table)
static void run_final (rb_objspace_t *objspace, VALUE obj)
static void finalize_list (rb_objspace_t *objspace, RVALUE *p)
static void finalize_deferred (rb_objspace_t *objspace)
static void gc_finalize_deferred (void *dmy)
void rb_gc_finalize_deferred (void)
static void gc_finalize_deferred_register (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)
static int is_id_value (rb_objspace_t *objspace, VALUE ptr)
static int heap_is_swept_object (rb_objspace_t *objspace, rb_heap_t *heap, VALUE ptr)
static int is_swept_object (rb_objspace_t *objspace, VALUE ptr)
static int is_dead_object (rb_objspace_t *objspace, VALUE ptr)
static int is_live_object (rb_objspace_t *objspace, VALUE ptr)
static int is_markable_object (rb_objspace_t *objspace, VALUE obj)
int rb_objspace_markable_object_p (VALUE obj)
static VALUE id2ref (VALUE obj, VALUE objid)
VALUE rb_obj_id (VALUE obj)
size_t rb_str_memsize (VALUE)
size_t rb_ary_memsize (VALUE)
size_t rb_io_memsize (const rb_io_t *)
size_t rb_generic_ivar_memsize (VALUE)
size_t rb_obj_memsize_of (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 size_t objspace_live_slot (rb_objspace_t *objspace)
static size_t objspace_total_slot (rb_objspace_t *objspace)
static size_t objspace_free_slot (rb_objspace_t *objspace)
static void gc_setup_mark_bits (struct heap_page *page)
static void gc_page_sweep (rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_page)
static void gc_heap_prepare_minimum_pages (rb_objspace_t *objspace, rb_heap_t *heap)
static void gc_before_heap_sweep (rb_objspace_t *objspace, rb_heap_t *heap)
static void gc_before_sweep (rb_objspace_t *objspace)
static void gc_after_sweep (rb_objspace_t *objspace)
static void gc_sweep (rb_objspace_t *objspace, int immediate_sweep)
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_stack_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)
int ruby_get_stack_grow_direction (volatile VALUE *addr)
size_t ruby_stack_length (VALUE **p)
static int stack_check (int water_mark)
int ruby_stack_check (void)
static ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
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 (st_data_t key, st_data_t value, st_data_t data)
static void mark_tbl (rb_objspace_t *objspace, st_table *tbl)
static int mark_key (st_data_t key, st_data_t 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 (st_data_t key, st_data_t 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_wrapper (rb_objspace_t *objspace, struct method_table_wrapper *wrapper)
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 void mark_current_machine_context (rb_objspace_t *objspace, rb_thread_t *th)
void rb_gc_mark_machine_stack (rb_thread_t *th)
void rb_mark_tbl (st_table *tbl)
void rb_gc_mark_maybe (VALUE obj)
static int gc_mark_ptr (rb_objspace_t *objspace, VALUE ptr)
static void rgengc_check_relation (rb_objspace_t *objspace, VALUE obj)
void rb_gc_mark (VALUE ptr)
void rb_gc_resurrect (VALUE obj)
static void gc_mark_roots (rb_objspace_t *objspace, int full_mark, const char **categoryp)
static void gc_marks_body (rb_objspace_t *objspace, int full_mark)
static void verify_internal_consistency_reachable_i (VALUE child, void *ptr)
static int verify_internal_consistency_i (void *page_start, void *page_end, size_t stride, void *ptr)
static VALUE gc_verify_internal_consistency (VALUE self)
static void gc_marks (rb_objspace_t *objspace, int full_mark)
static int rgengc_remembersetbits_get (rb_objspace_t *objspace, VALUE obj)
static int rgengc_remembersetbits_set (rb_objspace_t *objspace, VALUE obj)
void rb_gc_writebarrier (VALUE a, VALUE b)
void rb_gc_writebarrier_unprotect_promoted (VALUE obj)
void rb_gc_writebarrier_remember_promoted (VALUE obj)
static int rgengc_unprotect_logging_exit_func_i (st_data_t key, st_data_t val)
static void rgengc_unprotect_logging_exit_func (void)
void rb_gc_unprotect_logging (void *objptr, const char *filename, int line)
VALUE rb_obj_rgengc_writebarrier_protected_p (VALUE obj)
VALUE rb_obj_rgengc_promoted_p (VALUE obj)
size_t rb_obj_gc_flags (VALUE obj, ID *flags, size_t max)
void rb_gc_force_recycle (VALUE p)
void rb_gc_register_mark_object (VALUE obj)
void rb_gc_register_address (VALUE *addr)
void rb_gc_unregister_address (VALUE *addr)
void rb_global_variable (VALUE *var)
static void * gc_with_gvl (void *ptr)
static int garbage_collect_with_gvl (rb_objspace_t *objspace, int full_mark, int immediate_sweep, int reason)
int rb_garbage_collect (void)
void Init_stack (volatile VALUE *addr)
static VALUE gc_start_internal (int argc, VALUE *argv, VALUE self)
VALUE rb_gc_start (void)
void rb_gc (void)
int rb_during_gc (void)
size_t rb_gc_count (void)
static VALUE gc_count (VALUE self)
static VALUE gc_info_decode (int flags, VALUE hash_or_key)
VALUE rb_gc_latest_gc_info (VALUE key)
static VALUE gc_latest_gc_info (int argc, VALUE *argv, VALUE self)
static VALUE gc_stat_internal (VALUE hash_or_sym, size_t *out)
static VALUE gc_stat (int argc, VALUE *argv, VALUE self)
size_t rb_gc_stat (VALUE key)
static VALUE gc_stress_get (VALUE self)
static VALUE gc_stress_set (VALUE self, VALUE flag)
VALUE rb_gc_enable (void)
VALUE rb_gc_disable (void)
static int get_envparam_int (const char *name, unsigned int *default_value, int lower_bound)
static int get_envparam_double (const char *name, double *default_value, double lower_bound)
static void gc_set_initial_pages (void)
void ruby_gc_set_params (int safe_level)
void rb_gc_set_params (void)
void rb_objspace_reachable_objects_from (VALUE obj, void(func)(VALUE, void *), void *data)
static void root_objects_from (VALUE obj, void *ptr)
void rb_objspace_reachable_objects_from_root (void(func)(const char *category, VALUE, void *), void *passing_data)
static void objspace_xfree (rb_objspace_t *objspace, void *ptr, size_t size)
static void * negative_size_allocation_error_with_gvl (void *ptr)
static void * ruby_memerror_body (void *dummy)
static void ruby_memerror (void)
void rb_memerror (void)
static size_t objspace_malloc_size (rb_objspace_t *objspace, void *ptr, size_t hint)
static void atomic_sub_nounderflow (size_t *var, size_t sub)
static void objspace_malloc_increase (rb_objspace_t *objspace, void *mem, size_t new_size, size_t old_size, enum memop_type type)
static size_t objspace_malloc_prepare (rb_objspace_t *objspace, size_t size)
static void * objspace_malloc_fixup (rb_objspace_t *objspace, void *mem, size_t size)
static void * objspace_xmalloc (rb_objspace_t *objspace, size_t size)
static void * objspace_xrealloc (rb_objspace_t *objspace, void *ptr, size_t new_size, size_t old_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 * objspace_xcalloc (rb_objspace_t *objspace, size_t count, size_t elsize)
void * ruby_xcalloc (size_t n, size_t size)
void * ruby_sized_xrealloc (void *ptr, size_t new_size, size_t old_size)
void * ruby_xrealloc (void *ptr, size_t new_size)
void * ruby_sized_xrealloc2 (void *ptr, size_t n, size_t size, size_t old_n)
void * ruby_xrealloc2 (void *ptr, size_t n, size_t size)
void ruby_sized_xfree (void *x, size_t size)
void ruby_xfree (void *x)
void * ruby_mimmalloc (size_t size)
void ruby_mimfree (void *ptr)
static void wmap_mark (void *ptr)
static int wmap_free_map (st_data_t key, st_data_t val, st_data_t arg)
static void wmap_free (void *ptr)
static int wmap_memsize_map (st_data_t key, st_data_t val, st_data_t arg)
static size_t wmap_memsize (const void *ptr)
static VALUE wmap_allocate (VALUE klass)
static int wmap_final_func (st_data_t *key, st_data_t *value, st_data_t arg, int existing)
static VALUE wmap_finalize (VALUE self, VALUE objid)
static int wmap_inspect_i (st_data_t key, st_data_t val, st_data_t arg)
static VALUE wmap_inspect (VALUE self)
static int wmap_each_i (st_data_t key, st_data_t val, st_data_t arg)
static VALUE wmap_each (VALUE self)
static int wmap_each_key_i (st_data_t key, st_data_t val, st_data_t arg)
static VALUE wmap_each_key (VALUE self)
static int wmap_each_value_i (st_data_t key, st_data_t val, st_data_t arg)
static VALUE wmap_each_value (VALUE self)
static int wmap_keys_i (st_data_t key, st_data_t val, st_data_t arg)
static VALUE wmap_keys (VALUE self)
static int wmap_values_i (st_data_t key, st_data_t val, st_data_t arg)
static VALUE wmap_values (VALUE self)
static int wmap_aset_update (st_data_t *key, st_data_t *val, st_data_t arg, int existing)
static VALUE wmap_aset (VALUE self, VALUE wmap, VALUE orig)
static VALUE wmap_aref (VALUE self, VALUE wmap)
static VALUE wmap_has_key (VALUE self, VALUE key)
static VALUE wmap_size (VALUE self)
static double elapsed_time_from (double time)
static VALUE gc_profile_clear (void)
static VALUE gc_profile_record_get (void)
static void gc_profile_dump_on (VALUE out, VALUE(*append)(VALUE, VALUE))
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)
static VALUE gc_profile_enable_get (VALUE self)
static VALUE gc_profile_enable (void)
static VALUE gc_profile_disable (void)
void Init_GC (void)

Variables

static ruby_gc_params_t gc_params
VALUE * ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress
int ruby_gc_debug_indent = 0
VALUE rb_mGC
int ruby_disable_gc_stress = 0
int ruby_stack_grow_direction
static st_tablergengc_unprotect_logging_table
static const rb_data_type_t weakmap_type


Define Documentation

#define __has_feature (  )     0

Definition at line 35 of file gc.c.

#define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS

Definition at line 64 of file gc.c.

#define BITMAP_BIT (  )     ((bits_t)1 << BITMAP_OFFSET(p))

Definition at line 591 of file gc.c.

Referenced by gc_page_sweep().

#define BITMAP_INDEX (  )     (NUM_IN_PAGE(p) / BITS_BITLENGTH )

Definition at line 589 of file gc.c.

Referenced by gc_page_sweep().

#define BITMAP_OFFSET (  )     (NUM_IN_PAGE(p) & (BITS_BITLENGTH-1))

Definition at line 590 of file gc.c.

#define CALC_EXACT_MALLOC_SIZE   0

Definition at line 247 of file gc.c.

Referenced by gc_profile_dump_on(), and Init_GC().

#define CEILDIV ( i,
mod   )     (((i) + (mod) - 1)/(mod))

Definition at line 551 of file gc.c.

#define CLEAR_IN_BITMAP ( bits,
 )     ((bits)[BITMAP_INDEX(p)] = (bits)[BITMAP_INDEX(p)] & ~BITMAP_BIT(p))

Definition at line 595 of file gc.c.

Referenced by obj_free(), rb_gc_force_recycle(), rgengc_rememberset_mark(), and RVALUE_DEMOTE_FROM_OLD().

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

#define dont_gc   objspace->flags.dont_gc

Definition at line 623 of file gc.c.

Referenced by garbage_collect_with_gvl(), heap_ready_to_gc(), newobj_of(), rb_gc_disable(), and rb_gc_enable().

#define during_gc   objspace->flags.during_gc

Definition at line 624 of file gc.c.

Referenced by garbage_collect(), garbage_collect_body(), gc_heap_prepare_minimum_pages(), gc_heap_rest_sweep(), heap_page_allocate(), heap_pages_expand_sorted(), heap_prepare_freepage(), heap_ready_to_gc(), newobj_of(), rb_during_gc(), rb_objspace_call_finalizer(), and rgengc_report_body().

#define finalizer_table   objspace->finalizer_table

Definition at line 626 of file gc.c.

Referenced by define_final0(), gc_mark_roots(), Init_heap(), rb_gc_copy_finalizer(), rb_objspace_call_finalizer(), rb_undefine_finalizer(), and run_final().

#define finalizing   objspace->flags.finalizing

Definition at line 625 of file gc.c.

Referenced by gc_finalize_deferred(), gc_start_internal(), rb_gc(), and rb_objspace_call_finalizer().

#define FL_SET2 ( x,
 )     do {if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) rb_bug("FL_SET2: SPECIAL_CONST"); RBASIC(x)->flags |= (f);} while (0)

Definition at line 705 of file gc.c.

Referenced by RVALUE_PROMOTE_INFANT().

#define FL_TEST2 ( x,
 )     ((RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) ? (rb_bug("FL_TEST2: SPECIAL_CONST"), 0) : FL_TEST_RAW((x),(f)) != 0)

Definition at line 704 of file gc.c.

Referenced by check_gen_consistency(), RVALUE_INFANT_P(), RVALUE_OLD_P(), and RVALUE_PROMOTED_P().

#define FL_UNSET2 ( x,
 )     do {if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) rb_bug("FL_UNSET2: SPECIAL_CONST"); RBASIC(x)->flags &= ~(f);} while (0)

Definition at line 706 of file gc.c.

Referenced by RVALUE_DEMOTE_FROM_OLD().

#define GC_DEBUG   0

Definition at line 173 of file gc.c.

Referenced by Init_GC().

#define GC_ENABLE_LAZY_SWEEP   1

Definition at line 244 of file gc.c.

Referenced by garbage_collect_body(), heap_prepare_freepage(), and Init_GC().

#define gc_event_hook ( objspace,
event,
data   ) 

Value:

do { \
    if (UNLIKELY((objspace)->hook_events & (event))) { \
        gc_event_hook_body((objspace), (event), (data)); \
    } \
} while (0)

Definition at line 1278 of file gc.c.

Referenced by garbage_collect_body(), gc_after_sweep(), gc_marks_body(), newobj_of(), and obj_free().

#define GC_HEAP_FREE_SLOTS   4096

Definition at line 100 of file gc.c.

#define GC_HEAP_GROWTH_FACTOR   1.8

Definition at line 106 of file gc.c.

#define GC_HEAP_GROWTH_MAX_SLOTS   0

Definition at line 109 of file gc.c.

#define GC_HEAP_INIT_SLOTS   10000

Definition at line 103 of file gc.c.

#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR   2.0

Definition at line 112 of file gc.c.

#define GC_MALLOC_LIMIT_GROWTH_FACTOR   1.4

Definition at line 122 of file gc.c.

#define GC_MALLOC_LIMIT_MAX   (32 * 1024 * 1024 /* 32MB */)

Definition at line 119 of file gc.c.

#define GC_MALLOC_LIMIT_MIN   (16 * 1024 * 1024 /* 16MB */)

Definition at line 116 of file gc.c.

#define GC_NOTIFY   0

Definition at line 4967 of file gc.c.

Referenced by garbage_collect_body().

#define GC_OLDMALLOC_LIMIT_GROWTH_FACTOR   1.2

Definition at line 129 of file gc.c.

#define GC_OLDMALLOC_LIMIT_MAX   (128 * 1024 * 1024 /* 128MB */)

Definition at line 132 of file gc.c.

#define GC_OLDMALLOC_LIMIT_MIN   (16 * 1024 * 1024 /* 16MB */)

Definition at line 126 of file gc.c.

#define gc_prof_enabled ( objspace   )     ((objspace)->profile.run && (objspace)->profile.current_record)

Definition at line 691 of file gc.c.

Referenced by gc_prof_mark_timer_start(), gc_prof_mark_timer_stop(), gc_prof_set_heap_info(), gc_prof_set_malloc_info(), gc_prof_sweep_timer_start(), gc_prof_sweep_timer_stop(), gc_prof_timer_start(), and gc_prof_timer_stop().

#define gc_prof_record ( objspace   )     (objspace)->profile.current_record

Definition at line 690 of file gc.c.

Referenced by gc_marks(), gc_prof_mark_timer_start(), gc_prof_mark_timer_stop(), gc_prof_set_heap_info(), gc_prof_set_malloc_info(), gc_prof_sweep_timer_start(), gc_prof_sweep_timer_stop(), gc_prof_timer_start(), gc_prof_timer_stop(), and rgengc_rememberset_mark().

#define GC_PROFILE_DETAIL_MEMORY   0

Definition at line 241 of file gc.c.

Referenced by gc_profile_dump_on(), and Init_GC().

#define GC_PROFILE_MORE_DETAIL   0

Definition at line 238 of file gc.c.

Referenced by gc_prof_sweep_timer_start(), gc_prof_sweep_timer_stop(), and Init_GC().

#define GC_PROFILE_RECORD_DEFAULT_SIZE   100

Definition at line 6703 of file gc.c.

Referenced by gc_prof_setup_new_record(), and gc_profile_clear().

#define GET_HEAP_MARK_BITS (  )     (&GET_HEAP_PAGE(x)->mark_bits[0])

Definition at line 585 of file gc.c.

Referenced by gc_mark_ptr(), gc_marked(), is_dead_object(), rb_gc_force_recycle(), and rb_obj_gc_flags().

#define GET_HEAP_OLDGEN_BITS (  )     (&GET_HEAP_PAGE(x)->oldgen_bits[0])

Definition at line 587 of file gc.c.

Referenced by obj_free(), rb_gc_force_recycle(), RVALUE_DEMOTE_FROM_OLD(), and RVALUE_PROMOTE_INFANT().

#define GET_HEAP_PAGE (  )     (GET_PAGE_HEADER(x)->page)

Definition at line 584 of file gc.c.

Referenced by finalize_list(), heap_is_swept_object(), rb_gc_force_recycle(), and verify_internal_consistency_reachable_i().

#define GET_HEAP_REMEMBERSET_BITS (  )     (&GET_HEAP_PAGE(x)->rememberset_bits[0])

Definition at line 586 of file gc.c.

Referenced by rb_gc_force_recycle(), rb_obj_gc_flags(), rgengc_remembersetbits_get(), and rgengc_remembersetbits_set().

#define GET_PAGE_BODY (  )     ((struct heap_page_body *)((bits_t)(x) & ~(HEAP_ALIGN_MASK)))

Definition at line 582 of file gc.c.

#define GET_PAGE_HEADER (  )     (&GET_PAGE_BODY(x)->header)

Definition at line 583 of file gc.c.

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

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

#define HEAP_ALIGN_LOG   14

Definition at line 549 of file gc.c.

#define heap_eden   (&objspace->eden_heap)

Definition at line 621 of file gc.c.

Referenced by gc_after_sweep(), gc_before_sweep(), gc_marks_body(), gc_rest_sweep(), gc_set_initial_pages(), gc_stat_internal(), gc_sweep(), heap_pages_expand_sorted(), Init_heap(), is_dead_object(), is_swept_object(), newobj_of(), objspace_malloc_increase(), objspace_total_slot(), rb_gc_resurrect(), and ready_to_gc().

#define heap_pages_deferred_final   objspace->heap_pages.deferred_final

Definition at line 620 of file gc.c.

Referenced by finalize_deferred(), gc_prof_sweep_timer_stop(), make_deferred(), and rb_objspace_call_finalizer().

#define heap_pages_final_slots   objspace->heap_pages.final_slots

Definition at line 619 of file gc.c.

Referenced by gc_stat_internal(), objspace_free_slot(), and run_final().

#define heap_pages_himem   objspace->heap_pages.range[1]

Definition at line 614 of file gc.c.

Referenced by heap_page_allocate(), is_pointer_to_heap(), and rb_objspace_free().

#define heap_pages_increment   objspace->heap_pages.increment

Definition at line 616 of file gc.c.

Referenced by gc_after_sweep(), gc_stat_internal(), heap_add_pages(), heap_increment(), heap_pages_expand_sorted(), and heap_set_increment().

#define heap_pages_length   objspace->heap_pages.length

Definition at line 612 of file gc.c.

Referenced by gc_stat_internal(), heap_increment(), heap_page_allocate(), heap_page_create(), heap_pages_expand_sorted(), heap_set_increment(), and rb_objspace_free().

#define heap_pages_lomem   objspace->heap_pages.range[0]

Definition at line 613 of file gc.c.

Referenced by heap_page_allocate(), and rb_objspace_free().

#define heap_pages_max_free_slots   objspace->heap_pages.max_free_slots

Definition at line 618 of file gc.c.

Referenced by gc_before_sweep(), and heap_pages_free_unused_pages().

#define heap_pages_min_free_slots   objspace->heap_pages.min_free_slots

Definition at line 617 of file gc.c.

Referenced by gc_after_sweep(), and gc_before_sweep().

#define heap_pages_sorted   objspace->heap_pages.sorted

Definition at line 610 of file gc.c.

Referenced by count_objects(), heap_page_allocate(), heap_pages_expand_sorted(), heap_pages_free_unused_pages(), is_pointer_to_heap(), objspace_each_objects(), rb_objspace_call_finalizer(), and rb_objspace_free().

#define heap_pages_swept_slots   objspace->heap_pages.swept_slots

Definition at line 615 of file gc.c.

Referenced by finalize_list(), gc_after_sweep(), gc_before_sweep(), gc_stat_internal(), and heap_pages_free_unused_pages().

#define heap_pages_used   objspace->heap_pages.used

Definition at line 611 of file gc.c.

Referenced by count_objects(), garbage_collect(), garbage_collect_body(), gc_stat_internal(), heap_page_allocate(), heap_page_create(), heap_page_free(), heap_pages_free_unused_pages(), heap_set_increment(), is_pointer_to_heap(), objspace_each_objects(), rb_objspace_call_finalizer(), and rb_objspace_free().

#define heap_tomb   (&objspace->tomb_heap)

Definition at line 622 of file gc.c.

Referenced by gc_after_sweep(), gc_stat_internal(), heap_page_create(), heap_page_resurrect(), heap_pages_expand_sorted(), heap_pages_free_unused_pages(), heap_set_increment(), and objspace_total_slot().

#define I (  )     ID_##s = rb_intern(#s);

#define is_lazy_sweeping ( heap   )     ((heap)->sweep_pages != 0)

Definition at line 632 of file gc.c.

Referenced by gc_heap_rest_sweep(), heap_prepare_freepage(), is_dead_object(), objspace_malloc_increase(), and rb_gc_resurrect().

#define malloc_allocated_size   objspace->malloc_params.allocated_size

Definition at line 609 of file gc.c.

Referenced by gc_prof_setup_new_record().

#define MALLOC_ALLOCATED_SIZE   0

Definition at line 254 of file gc.c.

Referenced by Init_GC().

#define MALLOC_ALLOCATED_SIZE_CHECK   0

Definition at line 257 of file gc.c.

Referenced by Init_GC().

#define malloc_increase   objspace->malloc_params.increase

Definition at line 608 of file gc.c.

Referenced by gc_before_sweep(), gc_prof_set_malloc_info(), gc_stat_internal(), and objspace_malloc_increase().

#define malloc_limit   objspace->malloc_params.limit

Definition at line 607 of file gc.c.

Referenced by gc_before_sweep(), gc_prof_set_malloc_info(), gc_stat_internal(), objspace_malloc_increase(), and rb_objspace_alloc().

#define MARK_CHECKPOINT ( category   ) 

Value:

do { \
    if (categoryp) *categoryp = category; \
    MARK_CHECKPOINT_PRINT_TICK(category); \
} while (0)

Referenced by gc_mark_roots().

#define MARK_CHECKPOINT_PRINT_TICK ( category   ) 

#define MARK_IN_BITMAP ( bits,
 )     ((bits)[BITMAP_INDEX(p)] = (bits)[BITMAP_INDEX(p)] | BITMAP_BIT(p))

Definition at line 594 of file gc.c.

Referenced by gc_mark_ptr(), rgengc_remembersetbits_set(), and RVALUE_PROMOTE_INFANT().

#define MARKED_IN_BITMAP ( bits,
 )     ((bits)[BITMAP_INDEX(p)] & BITMAP_BIT(p))

Definition at line 593 of file gc.c.

Referenced by gc_marked(), is_dead_object(), obj_free(), rb_obj_gc_flags(), rgengc_remembersetbits_get(), rgengc_remembersetbits_set(), and verify_internal_consistency_reachable_i().

#define monitor_level   objspace->rgengc.monitor_level

Definition at line 629 of file gc.c.

#define monitored_object_table   objspace->rgengc.monitored_object_table

Definition at line 630 of file gc.c.

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

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

Referenced by rb_obj_id(), run_finalizer(), and wmap_aset().

#define NUM2PTR (  )     NUM2ULONG(x)

#define NUM_IN_PAGE (  )     (((bits_t)(p) & HEAP_ALIGN_MASK)/sizeof(RVALUE))

Definition at line 588 of file gc.c.

Referenced by gc_page_sweep(), and rgengc_rememberset_mark().

#define obj_id_to_ref ( objid   )     ((objid) ^ FIXNUM_FLAG)

Definition at line 635 of file gc.c.

Referenced by id2ref(), and wmap_finalize().

#define OPT (  )     if (o) rb_ary_push(opts, rb_str_new2(#o))

Referenced by Init_GC().

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

Definition at line 644 of file gc.c.

Referenced by gc_mark_children(), is_pointer_to_heap(), newobj_of(), obj_free(), and rb_objspace_call_finalizer().

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

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

Referenced by mark_current_machine_context().

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

Definition at line 599 of file gc.c.

Referenced by check_gen_consistency(), count_objects(), define_final0(), gc_finalize_deferred(), gc_latest_gc_info(), gc_profile_clear(), gc_profile_disable(), gc_profile_dump_on(), gc_profile_enable(), gc_profile_enable_get(), gc_profile_record_get(), gc_profile_total_time(), gc_set_initial_pages(), gc_start_internal(), gc_stat_internal(), gc_stress_get(), gc_stress_set(), gc_verify_internal_consistency(), id2ref(), Init_heap(), lazy_sweep_enable(), newobj_of(), objspace_each_objects(), rb_during_gc(), rb_garbage_collect(), rb_gc(), rb_gc_call_finalizer_at_exit(), rb_gc_copy_finalizer(), rb_gc_count(), rb_gc_disable(), rb_gc_enable(), rb_gc_force_recycle(), rb_gc_latest_gc_info(), rb_gc_mark(), rb_gc_mark_locations(), rb_gc_mark_machine_stack(), rb_gc_mark_maybe(), rb_gc_register_address(), rb_gc_resurrect(), rb_gc_unregister_address(), rb_gc_writebarrier(), rb_gc_writebarrier_remember_promoted(), rb_gc_writebarrier_unprotect_promoted(), rb_mark_hash(), rb_mark_method_entry(), rb_mark_set(), rb_mark_tbl(), rb_objspace_each_objects(), rb_objspace_markable_object_p(), rb_objspace_reachable_objects_from(), rb_objspace_reachable_objects_from_root(), rb_objspace_set_event_hook(), rb_undefine_finalizer(), ruby_gc_set_params(), ruby_sized_xfree(), ruby_sized_xrealloc(), ruby_sized_xrealloc2(), ruby_xcalloc(), ruby_xmalloc(), ruby_xmalloc2(), RVALUE_PROMOTE_INFANT(), wmap_aref(), wmap_each(), wmap_each_key(), wmap_each_value(), wmap_keys(), wmap_mark(), and wmap_values().

#define rb_setjmp ( env   )     RUBY_SETJMP(env)

Definition at line 88 of file gc.c.

Referenced by mark_current_machine_context().

#define RGENGC_CHECK_MODE   0

Definition at line 196 of file gc.c.

Referenced by check_gen_consistency(), gc_mark_stacked_objects(), Init_GC(), is_markable_object(), rb_gc_writebarrier(), rb_gc_writebarrier_unprotect_promoted(), RVALUE_DEMOTE_FROM_OLD(), and RVALUE_PROMOTE_INFANT().

#define RGENGC_DEBUG   0

Definition at line 185 of file gc.c.

Referenced by Init_GC(), and rgengc_report_body().

#define RGENGC_ESTIMATE_OLDMALLOC   1

Definition at line 224 of file gc.c.

Referenced by Init_GC().

#define RGENGC_PRINT_TICK   0

Definition at line 3984 of file gc.c.

#define RGENGC_PROFILE   0

Definition at line 205 of file gc.c.

Referenced by gc_profile_dump_on(), Init_GC(), and rgengc_remember().

#define rgengc_report   if (RGENGC_DEBUG) rgengc_report_body

Definition at line 693 of file gc.c.

Referenced by gc_after_sweep(), gc_before_sweep(), gc_mark_children(), gc_marks_body(), gc_page_sweep(), heap_increment(), heap_page_add_freeobj(), heap_page_allocate(), heap_pages_expand_sorted(), newobj_of(), rb_gc_writebarrier(), rb_gc_writebarrier_unprotect_promoted(), rgengc_remember(), rgengc_remembered(), and rgengc_rememberset_mark().

#define RGENGC_THREEGEN   0

Definition at line 214 of file gc.c.

Referenced by gc_after_sweep(), and Init_GC().

#define ruby_gc_stress   objspace->gc_stress

Definition at line 628 of file gc.c.

Referenced by garbage_collect_body(), gc_prof_setup_new_record(), gc_stress_get(), gc_stress_set(), newobj_of(), objspace_malloc_increase(), and rb_objspace_alloc().

#define ruby_initial_gc_stress   gc_params.gc_stress

Definition at line 600 of file gc.c.

Referenced by rb_objspace_alloc().

#define RVALUE_OLDGEN_BITMAP ( obj   )     MARKED_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), (obj))

Definition at line 711 of file gc.c.

Referenced by check_gen_consistency(), and RVALUE_OLD_BITMAP_P().

#define RVALUE_WB_PROTECTED ( obj   )     RVALUE_WB_PROTECTED_RAW(check_gen_consistency((VALUE)obj))

Definition at line 709 of file gc.c.

Referenced by gc_mark_children(), rb_gc_writebarrier_unprotect_promoted(), rgengc_check_relation(), rgengc_remember(), and rgengc_rememberset_mark().

#define RVALUE_WB_PROTECTED_RAW ( obj   )     FL_TEST2((obj), FL_WB_PROTECTED)

Definition at line 708 of file gc.c.

Referenced by check_gen_consistency().

#define S (  )     sym_##s = ID2SYM(rb_intern_const(#s))

#define S (  )     sym_##s = ID2SYM(rb_intern_const(#s))

Referenced by gc_info_decode(), gc_stat_internal(), init_des(), ruby_dtoa(), and vm_stat().

#define SET ( name,
attr   ) 

Value:

if (key == sym_##name) \
        return (*out = attr, Qnil); \
    else if (hash != Qnil) \
        rb_hash_aset(hash, sym_##name, SIZET2NUM(attr));

#define SET ( name,
attr   ) 

Value:

if (key == sym_##name) \
        return (attr); \
    else if (hash != Qnil) \
        rb_hash_aset(hash, sym_##name, (attr));

#define SET_STACK_END   SET_MACHINE_STACK_END(&th->machine.stack_end)

Definition at line 3221 of file gc.c.

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

#define STACK_CHUNK_SIZE   500

Definition at line 391 of file gc.c.

Referenced by init_mark_stack().

#define STACK_END   (th->machine.stack_end)

Definition at line 3225 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 3233 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 3226 of file gc.c.

Referenced by stack_check().

#define STACK_START   (th->machine.stack_start)

Definition at line 3224 of file gc.c.

Referenced by mark_current_machine_context(), and ruby_stack_length().

#define STACKFRAME_FOR_CALL_CFUNC   512

Definition at line 3276 of file gc.c.

Referenced by ruby_stack_check().

#define STR_ASSOC   FL_USER3

#define TRY_WITH_GC ( alloc   ) 

Value:

do { \
        if (!(alloc) && \
            (!garbage_collect_with_gvl(objspace, 1, 1, GPR_FLAG_MALLOC) || /* full mark && immediate sweep */ \
             !(alloc))) { \
            ruby_memerror(); \
        } \
    } while (0)

Definition at line 6080 of file gc.c.

Referenced by objspace_xcalloc(), objspace_xmalloc(), and objspace_xrealloc().

#define TYPE_NAME (  )     case (t): return #t;

Referenced by type_name().

#define WMAP_DELETE_DEAD_OBJECT_IN_MARK   0

Definition at line 6318 of file gc.c.


Typedef Documentation

typedef uintptr_t bits_t

Definition at line 370 of file gc.c.

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

Definition at line 1687 of file gc.c.

typedef struct mark_stack mark_stack_t

typedef struct rb_heap_struct rb_heap_t

typedef struct rb_objspace rb_objspace_t

typedef struct stack_chunk stack_chunk_t


Enumeration Type Documentation

anonymous enum

Enumerator:
HEAP_ALIGN 
HEAP_ALIGN_MASK 
REQUIRED_SIZE_BY_MALLOC 
HEAP_SIZE 
HEAP_OBJ_LIMIT 
HEAP_BITMAP_LIMIT 
HEAP_BITMAP_SIZE 
HEAP_BITMAP_PLANES 

Definition at line 552 of file gc.c.

anonymous enum

Enumerator:
BITS_SIZE 
BITS_BITLENGTH 

Definition at line 371 of file gc.c.

enum gc_profile_record_flag

Enumerator:
GPR_FLAG_NONE 
GPR_FLAG_MAJOR_BY_NOFREE 
GPR_FLAG_MAJOR_BY_OLDGEN 
GPR_FLAG_MAJOR_BY_SHADY 
GPR_FLAG_MAJOR_BY_RESCAN 
GPR_FLAG_MAJOR_BY_STRESS 
GPR_FLAG_MAJOR_BY_OLDMALLOC 
GPR_FLAG_MAJOR_MASK 
GPR_FLAG_NEWOBJ 
GPR_FLAG_MALLOC 
GPR_FLAG_METHOD 
GPR_FLAG_CAPI 
GPR_FLAG_STRESS 
GPR_FLAG_IMMEDIATE_SWEEP 
GPR_FLAG_HAVE_FINALIZE 

Definition at line 260 of file gc.c.

enum memop_type

Enumerator:
MEMOP_TYPE_MALLOC 
MEMOP_TYPE_FREE 
MEMOP_TYPE_REALLOC 

Definition at line 5959 of file gc.c.


Function Documentation

static void add_stack_chunk_cache ( mark_stack_t stack,
stack_chunk_t chunk 
) [static]

Definition at line 3108 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 aligned_free ( void *   )  [static]

Definition at line 5936 of file gc.c.

References free.

Referenced by heap_page_allocate(), and heap_page_free().

static void * aligned_malloc ( size_t  ,
size_t   
) [static]

Definition at line 5900 of file gc.c.

References assert, malloc, NULL, and VALUE.

Referenced by heap_page_allocate().

static void atomic_sub_nounderflow ( size_t *  var,
size_t  sub 
) [inline, static]

Definition at line 5966 of file gc.c.

References ATOMIC_SIZE_CAS, and val.

Referenced by objspace_malloc_increase().

static VALUE check_gen_consistency ( VALUE  obj  )  [inline, static]

Definition at line 717 of file gc.c.

References rb_objspace::during_minor_gc, FALSE, FL_PROMOTED, FL_TEST2, gc_marked(), is_pointer_to_heap(), obj_memsize_of(), obj_type_name(), rb_bug(), rb_objspace, rb_objspace::rgengc, RGENGC_CHECK_MODE, RVALUE_OLDGEN_BITMAP, RVALUE_WB_PROTECTED_RAW, type, and VALUE.

Referenced by gc_mark_children(), rgengc_remembered(), RVALUE_DEMOTE_FROM_OLD(), RVALUE_INFANT_P(), RVALUE_OLD_BITMAP_P(), RVALUE_OLD_P(), RVALUE_PROMOTE_INFANT(), and RVALUE_PROMOTED_P().

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

Definition at line 2588 of file gc.c.

References RVALUE::as, RVALUE::basic, BUILTIN_TYPE, RBasic::flags, hash(), heap_pages_sorted, heap_pages_used, rb_eTypeError, rb_objspace, rb_raise(), rb_scan_args(), RB_TYPE_P, T_HASH, T_MASK, and VALUE.

Referenced by Init_GC().

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

Definition at line 1949 of file gc.c.

References define_final0(), rb_block_proc(), rb_scan_args(), should_be_callable(), should_be_finalizable(), and VALUE.

Referenced by Init_GC().

static VALUE define_final0 ( VALUE  obj,
VALUE  block 
) [static]

Definition at line 1966 of file gc.c.

References finalizer_table, FL_FINALIZE, INT2FIX, OBJ_FREEZE, rb_ary_new3, rb_ary_push(), rb_objspace, rb_safe_level, RBASIC, RBASIC_CLEAR_CLASS, st_add_direct(), st_data_t, st_lookup(), and VALUE.

Referenced by define_final(), rb_define_finalizer(), and wmap_aset().

static double elapsed_time_from ( double  time  )  [static]

Definition at line 6817 of file gc.c.

References getrusage_time().

Referenced by gc_prof_mark_timer_stop(), gc_prof_sweep_timer_stop(), and gc_prof_timer_stop().

static void finalize_deferred ( rb_objspace_t objspace  )  [static]

Definition at line 2092 of file gc.c.

References ATOMIC_PTR_EXCHANGE, finalize_list(), and heap_pages_deferred_final.

Referenced by gc_finalize_deferred(), gc_start_internal(), rb_gc(), and rb_objspace_call_finalizer().

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

Definition at line 2074 of file gc.c.

References RVALUE::as, heap_page::final_slots, RVALUE::free, GET_HEAP_PAGE, heap_page_add_freeobj(), heap_pages_swept_slots, rb_objspace::profile, run_final(), rb_objspace::total_freed_object_num, and VALUE.

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

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

Referenced by rb_objspace_call_finalizer().

static int free_const_entry_i ( ID  key,
rb_const_entry_t ce,
st_data_t  data 
) [static]

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

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

Referenced by rb_free_m_tbl().

static void free_stack_chunks ( mark_stack_t  )  [static]

Definition at line 3164 of file gc.c.

References mark_stack::chunk, free, stack_chunk::next, heap_page::next, and NULL.

Referenced by rb_objspace_free().

static int garbage_collect ( rb_objspace_t ,
int  full_mark,
int  immediate_sweep,
int  reason 
) [static]

Definition at line 5053 of file gc.c.

References during_gc, FALSE, garbage_collect_body(), gc_rest_sweep(), getrusage_time(), heap_pages_used, rb_objspace::profile, ready_to_gc(), and TRUE.

Referenced by garbage_collect_with_gvl(), gc_start_internal(), gc_with_gvl(), heap_prepare_freepage(), newobj_of(), rb_garbage_collect(), and rb_gc().

static int garbage_collect_body ( rb_objspace_t ,
int  full_mark,
int  immediate_sweep,
int  reason 
) [static]

Definition at line 4970 of file gc.c.

References rb_objspace::count, rb_objspace::dont_lazy_sweep, during_gc, FALSE, FIX2INT, FIXNUM_P, rb_objspace::flags, GC_ENABLE_LAZY_SWEEP, gc_event_hook, gc_marks(), GC_NOTIFY, gc_prof_setup_new_record(), gc_prof_timer_start(), gc_prof_timer_stop(), gc_sweep(), GPR_FLAG_IMMEDIATE_SWEEP, GPR_FLAG_MAJOR_BY_NOFREE, GPR_FLAG_MAJOR_BY_OLDGEN, GPR_FLAG_MAJOR_BY_SHADY, GPR_FLAG_MAJOR_BY_STRESS, GPR_FLAG_MAJOR_MASK, GPR_FLAG_NONE, heap_pages_used, rb_objspace::heap_used_at_gc_start, rb_objspace::latest_gc_info, rb_objspace::need_major_gc, rb_objspace::old_object_count, rb_objspace::old_object_limit, rb_objspace::profile, rb_bug(), rb_objspace::remembered_shady_object_count, rb_objspace::remembered_shady_object_limit, rb_objspace::rgengc, ruby_gc_stress, RUBY_INTERNAL_EVENT_GC_START, rb_objspace::total_allocated_object_num, rb_objspace::total_allocated_object_num_at_gc_start, and TRUE.

Referenced by garbage_collect(), and heap_prepare_freepage().

static int garbage_collect_with_gvl ( rb_objspace_t objspace,
int  full_mark,
int  immediate_sweep,
int  reason 
) [static]

Definition at line 5092 of file gc.c.

References dont_gc, EXIT_FAILURE, objspace_and_reason::full_mark, garbage_collect(), gc_with_gvl(), objspace_and_reason::immediate_sweep, objspace_and_reason::objspace, rb_thread_call_with_gvl(), objspace_and_reason::reason, ruby_native_thread_p, ruby_thread_has_gvl_p(), TRUE, and VALUE.

Referenced by objspace_malloc_increase().

static void gc_after_sweep ( rb_objspace_t objspace  )  [static]

Definition at line 2952 of file gc.c.

References rb_objspace::count, rb_objspace::during_minor_gc, gc_event_hook, gc_prof_set_heap_info(), GPR_FLAG_MAJOR_BY_NOFREE, heap_eden, heap_increment(), HEAP_OBJ_LIMIT, heap_pages_free_unused_pages(), heap_pages_increment, heap_pages_min_free_slots, heap_pages_swept_slots, heap_set_increment(), heap_tomb, rb_objspace::last_major_gc, rb_objspace::major_gc_count, rb_objspace::minor_gc_count, rb_objspace::need_major_gc, rb_objspace::profile, rb_gc_count(), rb_objspace::remembered_shady_object_count, rb_objspace::rgengc, rgengc_report, RGENGC_THREEGEN, RUBY_INTERNAL_EVENT_GC_END_SWEEP, and rb_heap_struct::total_slots.

Referenced by gc_heap_lazy_sweep().

static void gc_before_heap_sweep ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 2830 of file gc.c.

References RVALUE::as, RVALUE::free, rb_heap_struct::free_pages, rb_heap_struct::freelist, heap_page::freelist, NULL, rb_heap_struct::pages, rb_heap_struct::sweep_pages, and rb_heap_struct::using_page.

Referenced by gc_before_sweep().

static void gc_before_sweep ( rb_objspace_t objspace  )  [static]

Definition at line 2850 of file gc.c.

References ATOMIC_SIZE_EXCHANGE, rb_objspace::during_minor_gc, gc_before_heap_sweep(), gc_params, gc_prof_set_malloc_info(), GET_VM, GPR_FLAG_MAJOR_BY_OLDMALLOC, heap_eden, ruby_gc_params_t::heap_free_slots, ruby_gc_params_t::heap_init_slots, heap_pages_max_free_slots, heap_pages_min_free_slots, heap_pages_swept_slots, rb_objspace::latest_gc_info, malloc_increase, malloc_limit, ruby_gc_params_t::malloc_limit_growth_factor, ruby_gc_params_t::malloc_limit_max, ruby_gc_params_t::malloc_limit_min, rb_objspace::need_major_gc, objspace_total_slot(), rb_objspace::oldmalloc_increase, rb_objspace::oldmalloc_increase_limit, ruby_gc_params_t::oldmalloc_limit_growth_factor, ruby_gc_params_t::oldmalloc_limit_max, ruby_gc_params_t::oldmalloc_limit_min, PRIuSIZE, rb_objspace::profile, rb_gc_count(), rb_sweep_method_entry(), rb_objspace::rgengc, and rgengc_report.

Referenced by gc_sweep().

static VALUE gc_count ( VALUE  self  )  [static]

Definition at line 5235 of file gc.c.

References rb_gc_count(), and SIZET2NUM.

Referenced by Init_GC().

static void gc_event_hook_body ( rb_objspace_t objspace,
const rb_event_flag_t  event,
VALUE  data 
) [static]

Definition at line 1272 of file gc.c.

References rb_thread_struct::cfp, EXEC_EVENT_HOOK, GET_THREAD(), and rb_control_frame_struct::self.

static void gc_finalize_deferred ( void *  dmy  )  [static]

Definition at line 2102 of file gc.c.

References ATOMIC_EXCHANGE, ATOMIC_SET, finalize_deferred(), finalizing, and rb_objspace.

Referenced by gc_finalize_deferred_register(), and rb_gc_finalize_deferred().

static void gc_finalize_deferred_register ( void   )  [static]

Definition at line 2118 of file gc.c.

References gc_finalize_deferred(), rb_bug(), and rb_postponed_job_register_one().

static int gc_heap_lazy_sweep ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 3004 of file gc.c.

References FALSE, rb_heap_struct::free_pages, gc_after_sweep(), gc_page_sweep(), gc_prof_sweep_timer_start(), gc_prof_sweep_timer_stop(), heap_page::heap, heap_page::next, NULL, result, rb_heap_struct::sweep_pages, and TRUE.

Referenced by gc_heap_rest_sweep(), gc_sweep(), and heap_prepare_freepage().

static void gc_heap_prepare_minimum_pages ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 2817 of file gc.c.

References during_gc, rb_heap_struct::free_pages, heap_increment(), heap_set_increment(), and rb_memerror().

Referenced by gc_sweep().

static void gc_heap_rest_sweep ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 3038 of file gc.c.

References during_gc, gc_heap_lazy_sweep(), heap_page::heap, and is_lazy_sweeping.

Referenced by gc_rest_sweep(), and gc_sweep().

static VALUE gc_info_decode ( int  flags,
VALUE  hash_or_key 
) [static]

Definition at line 5241 of file gc.c.

References GPR_FLAG_CAPI, GPR_FLAG_HAVE_FINALIZE, GPR_FLAG_IMMEDIATE_SWEEP, GPR_FLAG_MAJOR_BY_NOFREE, GPR_FLAG_MAJOR_BY_OLDGEN, GPR_FLAG_MAJOR_BY_OLDMALLOC, GPR_FLAG_MAJOR_BY_RESCAN, GPR_FLAG_MAJOR_BY_SHADY, GPR_FLAG_MAJOR_BY_STRESS, GPR_FLAG_MALLOC, GPR_FLAG_METHOD, GPR_FLAG_NEWOBJ, GPR_FLAG_STRESS, objspace_and_reason::immediate_sweep, key, malloc, Qfalse, Qnil, Qtrue, rb_eArgError, rb_eTypeError, rb_id2str(), rb_raise(), RB_TYPE_P, RSTRING_PTR, S, SET, SYM2ID, SYMBOL_P, T_HASH, and VALUE.

Referenced by gc_latest_gc_info(), gc_profile_record_get(), and rb_gc_latest_gc_info().

static VALUE gc_latest_gc_info ( int  argc,
VALUE *  argv,
VALUE  self 
) [static]

Definition at line 5334 of file gc.c.

References gc_info_decode(), rb_objspace::latest_gc_info, objspace_and_reason::objspace, rb_objspace::profile, Qnil, rb_eTypeError, rb_hash_new(), rb_objspace, rb_raise(), rb_scan_args(), RB_TYPE_P, SYMBOL_P, T_HASH, and VALUE.

Referenced by Init_GC().

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

Definition at line 3589 of file gc.c.

References rb_objspace::mark_func_data_struct::data, gc_mark_ptr(), is_markable_object(), LIKELY, rb_objspace::mark_func_data_struct::mark_func, rb_objspace::mark_func_data, rb_objspace::mark_stack, push_mark_stack(), and rgengc_check_relation().

Referenced by gc_mark_children(), gc_mark_maybe(), mark_const_entry_i(), mark_entry(), mark_key(), mark_keyvalue(), mark_method_entry(), and rb_gc_mark().

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

Definition at line 3624 of file gc.c.

References args, BUILTIN_TYPE, check_gen_consistency(), rb_objspace::during_minor_gc, FALSE, FL_EXIVAR, FL_TEST, gc_mark(), gc_mark_maybe(), gc_mark_ptr(), if(), is_markable_object(), LIKELY, rb_objspace::mark_func_data, mark_locations_array(), nd_type, 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_CREF, 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_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, obj_type_name(), rb_objspace::old_object_count, rb_objspace::parent_object_is_old, RANY, rb_bug(), rb_mark_generic_ivar(), rb_objspace::rgengc, rgengc_check_relation(), rgengc_report, RVALUE_INFANT_P(), RVALUE_PROMOTE_INFANT(), RVALUE_WB_PROTECTED, T_FIXNUM, T_NIL, T_NODE, TRUE, and VALUE.

Referenced by gc_mark_stacked_objects(), rb_objspace_reachable_objects_from(), and rgengc_rememberset_mark().

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

Definition at line 3301 of file gc.c.

References mark_locations_array().

Referenced by rb_gc_mark_locations().

static void gc_mark_maybe ( rb_objspace_t objspace,
VALUE  ptr 
) [static]

Definition at line 3525 of file gc.c.

References BUILTIN_TYPE, gc_mark(), is_pointer_to_heap(), T_NONE, T_ZOMBIE, type, and VALGRIND_MAKE_MEM_DEFINED.

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

static int gc_mark_ptr ( rb_objspace_t objspace,
VALUE  ptr 
) [inline, static]

Definition at line 3551 of file gc.c.

References gc_marked(), GET_HEAP_MARK_BITS, and MARK_IN_BITMAP.

Referenced by gc_mark(), gc_mark_children(), rb_gc_resurrect(), and rgengc_rememberset_mark().

static void gc_mark_roots ( rb_objspace_t objspace,
int  full_mark,
const char **  categoryp 
) [static]

Definition at line 4058 of file gc.c.

References FALSE, finalizer_table, GET_THREAD(), global_List, list, MARK_CHECKPOINT, mark_current_machine_context(), mark_tbl(), rb_objspace::parent_object_is_old, 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_unlinked_live_method_entries(), rb_mark_end_proc(), rb_mark_generic_ivar_tbl(), rb_vm_mark(), rb_objspace::rgengc, rb_vm_struct::self, SET_STACK_END, TRUE, and rb_thread_struct::vm.

Referenced by gc_marks_body(), and rb_objspace_reachable_objects_from_root().

static void gc_mark_stacked_objects ( rb_objspace_t  )  [static]

Definition at line 3968 of file gc.c.

References gc_mark_children(), gc_marked(), mark_stack::index, rb_objspace::mark_stack, obj_type_name(), pop_mark_stack(), rb_bug(), RGENGC_CHECK_MODE, shrink_stack_chunk_cache(), and VALUE.

Referenced by gc_marks_body().

static int gc_marked ( rb_objspace_t objspace,
VALUE  ptr 
) [inline, static]

Definition at line 3543 of file gc.c.

References GET_HEAP_MARK_BITS, and MARKED_IN_BITMAP.

Referenced by check_gen_consistency(), gc_mark_ptr(), gc_mark_stacked_objects(), rb_gc_resurrect(), and rgengc_check_relation().

static void gc_marks ( rb_objspace_t objspace,
int  full_mark 
) [static]

Definition at line 4492 of file gc.c.

References FALSE, gc_marks_body(), gc_params, gc_prof_mark_timer_start(), gc_prof_mark_timer_stop(), gc_prof_record, gc_verify_internal_consistency(), rb_objspace::mark_func_data, rb_objspace::old_object_count, rb_objspace::old_object_limit, ruby_gc_params_t::oldobject_limit_factor, Qnil, rb_objspace::remembered_shady_object_count, rb_objspace::remembered_shady_object_limit, rb_objspace::rgengc, and TRUE.

Referenced by garbage_collect_body().

static void gc_marks_body ( rb_objspace_t objspace,
int  full_mark 
) [static]

Definition at line 4143 of file gc.c.

References rb_objspace::during_minor_gc, FALSE, gc_event_hook, gc_mark_roots(), gc_mark_stacked_objects(), heap_eden, rb_objspace::major_gc_count, rb_objspace::minor_gc_count, rb_objspace::parent_object_is_old, rb_objspace::profile, rb_objspace::rgengc, rgengc_mark_and_rememberset_clear(), rgengc_rememberset_mark(), rgengc_report, RUBY_INTERNAL_EVENT_GC_END_MARK, and TRUE.

Referenced by gc_marks().

static void gc_page_sweep ( rb_objspace_t objspace,
rb_heap_t heap,
struct heap_page sweep_page 
) [inline, static]

Definition at line 2716 of file gc.c.

References RVALUE::as, RVALUE::basic, heap_page::before_sweep, BITMAP_BIT, BITMAP_INDEX, BITS_BITLENGTH, BUILTIN_TYPE, rb_objspace::during_minor_gc, FL_FINALIZE, FL_TEST, RBasic::flags, HEAP_BITMAP_LIMIT, heap_page_add_freeobj(), heap_page::limit, make_deferred(), heap_page::mark_bits, NUM_IN_PAGE, obj_free(), obj_type_name(), rb_bug(), RDATA, rb_objspace::rgengc, rgengc_remembered(), rgengc_report, RVALUE_OLD_P(), heap_page::start, T_ZOMBIE, VALGRIND_MAKE_MEM_UNDEFINED, and VALUE.

Referenced by gc_heap_lazy_sweep().

static void gc_prof_mark_timer_start ( rb_objspace_t  )  [inline, static]

Definition at line 6839 of file gc.c.

References gc_prof_enabled, gc_prof_record, getrusage_time(), RUBY_DTRACE_GC_MARK_BEGIN, and RUBY_DTRACE_GC_MARK_BEGIN_ENABLED.

Referenced by gc_marks().

static void gc_prof_mark_timer_stop ( rb_objspace_t  )  [inline, static]

Definition at line 6852 of file gc.c.

References elapsed_time_from(), gc_prof_enabled, gc_prof_record, RUBY_DTRACE_GC_MARK_END, and RUBY_DTRACE_GC_MARK_END_ENABLED.

Referenced by gc_marks().

static void gc_prof_set_heap_info ( rb_objspace_t  )  [inline, static]

Definition at line 6921 of file gc.c.

References gc_prof_enabled, gc_prof_record, HEAP_OBJ_LIMIT, gc_profile_record::heap_total_objects, gc_profile_record::heap_total_size, gc_profile_record::heap_use_size, rb_objspace::heap_used_at_gc_start, rb_objspace::profile, rb_objspace::total_allocated_object_num_at_gc_start, and rb_objspace::total_freed_object_num.

Referenced by gc_after_sweep().

static void gc_prof_set_malloc_info ( rb_objspace_t  )  [inline, static]

Definition at line 6909 of file gc.c.

References gc_prof_enabled, gc_prof_record, malloc_increase, and malloc_limit.

Referenced by gc_before_sweep().

static void gc_prof_setup_new_record ( rb_objspace_t objspace,
int  reason 
) [inline, static]

Definition at line 6760 of file gc.c.

References rb_objspace::current_record, gc_profile_record::flags, GC_PROFILE_RECORD_DEFAULT_SIZE, getrusage(), GPR_FLAG_STRESS, malloc, malloc_allocated_size, MEMZERO, rb_objspace::next_index, rb_objspace::profile, rb_bug(), realloc, rb_objspace::records, ruby_gc_stress, rb_objspace::run, and rb_objspace::size.

Referenced by garbage_collect_body().

static void gc_prof_sweep_timer_start ( rb_objspace_t  )  [inline, static]

Definition at line 6866 of file gc.c.

References gc_prof_enabled, gc_prof_record, GC_PROFILE_MORE_DETAIL, rb_objspace::gc_sweep_start_time, gc_profile_record::gc_time, getrusage_time(), rb_objspace::profile, RUBY_DTRACE_GC_SWEEP_BEGIN, and RUBY_DTRACE_GC_SWEEP_BEGIN_ENABLED.

Referenced by gc_heap_lazy_sweep(), and gc_sweep().

static void gc_prof_sweep_timer_stop ( rb_objspace_t  )  [inline, static]

Definition at line 6881 of file gc.c.

References elapsed_time_from(), gc_profile_record::flags, gc_prof_enabled, gc_prof_record, GC_PROFILE_MORE_DETAIL, rb_objspace::gc_sweep_start_time, gc_profile_record::gc_time, GPR_FLAG_HAVE_FINALIZE, heap_pages_deferred_final, rb_objspace::latest_gc_info, rb_objspace::profile, RUBY_DTRACE_GC_SWEEP_END, and RUBY_DTRACE_GC_SWEEP_END_ENABLED.

Referenced by gc_heap_lazy_sweep(), and gc_sweep().

static void gc_prof_timer_start ( rb_objspace_t  )  [inline, static]

Definition at line 6804 of file gc.c.

References gc_profile_record::gc_invoke_time, gc_prof_enabled, gc_prof_record, gc_profile_record::gc_time, getrusage_time(), and rb_objspace::profile.

Referenced by garbage_collect_body().

static void gc_prof_timer_stop ( rb_objspace_t  )  [inline, static]

Definition at line 6829 of file gc.c.

References elapsed_time_from(), gc_profile_record::gc_invoke_time, gc_prof_enabled, gc_prof_record, gc_profile_record::gc_time, rb_objspace::invoke_time, and rb_objspace::profile.

Referenced by garbage_collect_body().

static VALUE gc_profile_clear ( void   )  [static]

Definition at line 6949 of file gc.c.

References rb_objspace::current_record, GC_PROFILE_RECORD_DEFAULT_SIZE, MEMZERO, rb_objspace::next_index, rb_objspace::profile, Qnil, rb_memerror(), rb_objspace, realloc, rb_objspace::records, and rb_objspace::size.

Referenced by Init_GC().

static VALUE gc_profile_disable ( void   )  [static]

Definition at line 7301 of file gc.c.

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

Referenced by Init_GC().

static void gc_profile_dump_on ( VALUE  out,
VALUE(*)(VALUE, VALUE)  append 
) [static]

Definition at line 7099 of file gc.c.

References CALC_EXACT_MALLOC_SIZE, rb_objspace::count, count, gc_profile_record::flags, gc_profile_record::gc_invoke_time, GC_PROFILE_DETAIL_MEMORY, gc_profile_record::gc_time, GPR_FLAG_CAPI, GPR_FLAG_HAVE_FINALIZE, GPR_FLAG_MALLOC, GPR_FLAG_METHOD, GPR_FLAG_NEWOBJ, GPR_FLAG_STRESS, gc_profile_record::heap_total_objects, gc_profile_record::heap_total_size, gc_profile_record::heap_use_size, rb_objspace::next_index, PRIdSIZE, PRIuSIZE, rb_objspace::profile, rb_objspace, rb_sprintf(), rb_str_new_cstr(), rb_objspace::records, RGENGC_PROFILE, and rb_objspace::run.

Referenced by gc_profile_report(), and gc_profile_result().

static VALUE gc_profile_enable ( void   )  [static]

Definition at line 7284 of file gc.c.

References rb_objspace::current_record, 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 7269 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]

Definition at line 7016 of file gc.c.

References DBL2NUM, gc_info_decode(), GPR_FLAG_HAVE_FINALIZE, ID2SYM, rb_objspace::next_index, rb_objspace::profile, Qfalse, Qnil, Qtrue, rb_ary_new(), rb_ary_push(), rb_hash_aset(), rb_hash_new(), rb_intern, rb_objspace, rb_objspace::records, rb_objspace::run, SIZET2NUM, and VALUE.

Referenced by Init_GC().

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

Definition at line 7222 of file gc.c.

References gc_profile_dump_on(), Qnil, rb_io_write(), rb_scan_args(), rb_stdout, and VALUE.

Referenced by Init_GC().

static VALUE gc_profile_result ( void   )  [static]

Definition at line 7205 of file gc.c.

References gc_profile_dump_on(), rb_str_buf_append(), rb_str_buf_new(), and VALUE.

Referenced by Init_GC().

static VALUE gc_profile_total_time ( VALUE  self  )  [static]

Definition at line 7245 of file gc.c.

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

Referenced by Init_GC().

static void gc_rest_sweep ( rb_objspace_t objspace  )  [static]

Definition at line 3050 of file gc.c.

References gc_heap_rest_sweep(), heap_page::heap, and heap_eden.

Referenced by garbage_collect(), objspace_malloc_increase(), rb_gc_disable(), rb_objspace_call_finalizer(), rb_objspace_each_objects(), and rb_objspace_free().

static void gc_set_initial_pages ( void   )  [static]

Definition at line 5690 of file gc.c.

References gc_params, heap_add_pages(), heap_eden, ruby_gc_params_t::heap_init_slots, HEAP_OBJ_LIMIT, objspace_and_reason::objspace, and rb_objspace.

Referenced by ruby_gc_set_params().

static void gc_setup_mark_bits ( struct heap_page page  )  [static]

Definition at line 2704 of file gc.c.

References HEAP_BITMAP_SIZE, heap_page::mark_bits, and heap_page::oldgen_bits.

static VALUE gc_start_internal ( int  argc,
VALUE *  argv,
VALUE  self 
) [static]

Definition at line 5151 of file gc.c.

References finalize_deferred(), finalizing, objspace_and_reason::full_mark, garbage_collect(), GPR_FLAG_METHOD, objspace_and_reason::immediate_sweep, NIL_P, objspace_and_reason::objspace, Qnil, Qundef, rb_get_kwargs(), rb_intern, rb_objspace, rb_scan_args(), RTEST, TRUE, and VALUE.

Referenced by Init_GC().

static VALUE gc_stat ( int  argc,
VALUE *  argv,
VALUE  self 
) [static]

Definition at line 5533 of file gc.c.

References gc_stat_internal(), Qnil, rb_eTypeError, rb_hash_new(), rb_raise(), rb_scan_args(), RB_TYPE_P, SIZET2NUM, SYMBOL_P, T_HASH, and VALUE.

Referenced by Init_GC().

static VALUE gc_stat_internal ( VALUE  hash_or_sym,
size_t *  out 
) [static]

Definition at line 5352 of file gc.c.

References rb_objspace::count, count, heap_eden, heap_increment(), heap_pages_final_slots, heap_pages_increment, heap_pages_length, heap_pages_swept_slots, heap_pages_used, heap_tomb, key, rb_objspace::major_gc_count, malloc_increase, malloc_limit, rb_objspace::minor_gc_count, objspace_and_reason::objspace, objspace_free_slot(), objspace_live_slot(), rb_objspace::old_object_count, rb_objspace::old_object_limit, rb_objspace::oldmalloc_increase, rb_objspace::oldmalloc_increase_limit, rb_objspace::profile, Qnil, rb_eArgError, rb_eTypeError, rb_id2str(), rb_objspace, rb_raise(), RB_TYPE_P, rb_objspace::remembered_shady_object_count, rb_objspace::remembered_shady_object_limit, rb_objspace::rgengc, RSTRING_PTR, S, SET, SYM2ID, SYMBOL_P, T_HASH, rb_objspace::total_allocated_object_num, rb_objspace::total_freed_object_num, and VALUE.

Referenced by gc_stat(), and rb_gc_stat().

static VALUE gc_stress_get ( VALUE  self  )  [static]

Definition at line 5575 of file gc.c.

References objspace_and_reason::objspace, rb_objspace, and ruby_gc_stress.

Referenced by Init_GC().

static VALUE gc_stress_set ( VALUE  self,
VALUE  flag 
) [static]

Definition at line 5594 of file gc.c.

References FIXNUM_P, objspace_and_reason::objspace, Qfalse, Qtrue, rb_objspace, rb_secure(), RTEST, and ruby_gc_stress.

Referenced by Init_GC().

static void gc_sweep ( rb_objspace_t objspace,
int  immediate_sweep 
) [static]

Definition at line 3057 of file gc.c.

References heap_page::before_sweep, gc_before_sweep(), gc_heap_lazy_sweep(), gc_heap_prepare_minimum_pages(), gc_heap_rest_sweep(), gc_prof_sweep_timer_start(), gc_prof_sweep_timer_stop(), heap_eden, and heap_page::next.

Referenced by garbage_collect_body().

static VALUE gc_verify_internal_consistency ( VALUE  self  )  [static]

Definition at line 4224 of file gc.c.

References each_obj_args::callback, each_obj_args::data, verify_internal_consistency_struct::err_count, verify_internal_consistency_struct::objspace, objspace_each_objects(), Qnil, rb_bug(), rb_objspace, VALUE, and verify_internal_consistency_i().

Referenced by gc_marks(), and Init_GC().

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

Definition at line 5085 of file gc.c.

References objspace_and_reason::full_mark, garbage_collect(), objspace_and_reason::immediate_sweep, objspace_and_reason::objspace, objspace_and_reason::reason, and VALUE.

Referenced by garbage_collect_with_gvl().

static int get_envparam_double ( const char *  name,
double *  default_value,
double  lower_bound 
) [static]

Definition at line 5670 of file gc.c.

References getenv, NULL, RTEST, ruby_verbose, strtod, and val.

Referenced by ruby_gc_set_params().

static int get_envparam_int ( const char *  name,
unsigned int *  default_value,
int  lower_bound 
) [static]

Definition at line 5650 of file gc.c.

References getenv, NULL, RTEST, ruby_verbose, and val.

Referenced by ruby_gc_set_params().

static double getrusage_time ( void   )  [static]

Definition at line 6706 of file gc.c.

References clock_gettime(), getrusage(), timespec::tv_nsec, timeval::tv_sec, timespec::tv_sec, and timeval::tv_usec.

Referenced by elapsed_time_from(), garbage_collect(), gc_prof_mark_timer_start(), gc_prof_sweep_timer_start(), gc_prof_timer_start(), and Init_heap().

static void heap_add_freepage ( rb_objspace_t objspace,
rb_heap_t heap,
struct heap_page page 
) [inline, static]

Definition at line 967 of file gc.c.

References heap_page::free_next, rb_heap_struct::free_pages, heap_page::freelist, and heap_page::heap.

Referenced by heap_assign_page().

static void heap_add_page ( rb_objspace_t objspace,
rb_heap_t heap,
struct heap_page page 
) [static]

Definition at line 1130 of file gc.c.

References heap_page::heap, heap_page::limit, heap_page::next, rb_heap_struct::page_length, rb_heap_struct::pages, heap_page::prev, and rb_heap_struct::total_slots.

Referenced by heap_assign_page().

static void heap_add_pages ( rb_objspace_t objspace,
rb_heap_t heap,
size_t  add 
) [static]

Definition at line 1149 of file gc.c.

References heap_page::heap, heap_assign_page(), heap_pages_expand_sorted(), and heap_pages_increment.

Referenced by gc_set_initial_pages(), and Init_heap().

static void heap_assign_page ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 1141 of file gc.c.

References heap_page::heap, heap_add_freepage(), heap_add_page(), and heap_page_create().

Referenced by heap_add_pages(), and heap_increment().

static VALUE heap_get_freeobj ( rb_objspace_t objspace,
rb_heap_t heap 
) [inline, static]

Definition at line 1249 of file gc.c.

References RVALUE::as, RVALUE::free, rb_heap_struct::freelist, heap_page::heap, heap_get_freeobj_from_next_freepage(), and VALUE.

Referenced by newobj_of().

static RVALUE* heap_get_freeobj_from_next_freepage ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 1230 of file gc.c.

References heap_page::free_next, rb_heap_struct::free_pages, heap_page::freelist, heap_page::heap, heap_prepare_freepage(), NULL, and rb_heap_struct::using_page.

Referenced by heap_get_freeobj().

static int heap_increment ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 1184 of file gc.c.

References FALSE, heap_page::heap, heap_assign_page(), heap_pages_increment, heap_pages_length, rb_heap_struct::page_length, rgengc_report, and TRUE.

Referenced by gc_after_sweep(), gc_heap_prepare_minimum_pages(), gc_stat_internal(), heap_prepare_freepage(), and heap_ready_to_gc().

static int heap_is_swept_object ( rb_objspace_t objspace,
rb_heap_t heap,
VALUE  ptr 
) [inline, static]

Definition at line 2230 of file gc.c.

References heap_page::before_sweep, FALSE, GET_HEAP_PAGE, and TRUE.

Referenced by is_swept_object().

static void heap_page_add_freeobj ( rb_objspace_t objspace,
struct heap_page page,
VALUE  obj 
) [inline, static]

Definition at line 957 of file gc.c.

References RVALUE::as, RVALUE::free, heap_page::freelist, obj_type_name(), and rgengc_report.

Referenced by finalize_list(), gc_page_sweep(), heap_page_allocate(), and rb_gc_force_recycle().

static struct heap_page* heap_page_allocate ( rb_objspace_t objspace  )  [static]

Definition at line 1026 of file gc.c.

References aligned_free(), aligned_malloc(), assert, heap_page::body, during_gc, heap_page_body::header, HEAP_ALIGN, HEAP_OBJ_LIMIT, heap_page_add_freeobj(), heap_pages_himem, heap_pages_length, heap_pages_lomem, heap_pages_sorted, heap_pages_used, HEAP_SIZE, hi, lo, malloc, MEMMOVE, MEMZERO, heap_page_header::page, PRIuVALUE, rb_bug(), rb_memerror(), rgengc_report, heap_page::start, and VALUE.

Referenced by heap_page_create().

static struct heap_page* heap_page_create ( rb_objspace_t objspace  )  [static]

Definition at line 1116 of file gc.c.

References heap_page_allocate(), heap_page_resurrect(), heap_pages_length, heap_pages_used, heap_tomb, and NULL.

Referenced by heap_assign_page().

static void heap_page_free ( rb_objspace_t objspace,
struct heap_page page 
) [static]

Definition at line 989 of file gc.c.

References aligned_free(), heap_page::body, free, and heap_pages_used.

Referenced by heap_pages_free_unused_pages(), and rb_objspace_free().

static struct heap_page* heap_page_resurrect ( rb_objspace_t objspace  )  [static]

Definition at line 1104 of file gc.c.

References heap_tomb, heap_unlink_page(), and NULL.

Referenced by heap_page_create().

static void heap_pages_expand_sorted ( rb_objspace_t objspace  )  [static]

Definition at line 927 of file gc.c.

References during_gc, heap_eden, heap_pages_increment, heap_pages_length, heap_pages_sorted, heap_tomb, malloc, rb_memerror(), realloc, rgengc_report, and size.

Referenced by heap_add_pages(), and heap_set_increment().

static void heap_pages_free_unused_pages ( rb_objspace_t objspace  )  [static]

Definition at line 997 of file gc.c.

References heap_page_free(), heap_pages_max_free_slots, heap_pages_sorted, heap_pages_swept_slots, heap_pages_used, heap_tomb, heap_unlink_page(), and if().

Referenced by gc_after_sweep().

static struct heap_page* heap_prepare_freepage ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 1198 of file gc.c.

References rb_objspace::dont_lazy_sweep, during_gc, err, FALSE, rb_objspace::flags, rb_heap_struct::free_pages, garbage_collect(), garbage_collect_body(), GC_ENABLE_LAZY_SWEEP, gc_heap_lazy_sweep(), GPR_FLAG_NEWOBJ, heap_page::heap, heap_increment(), heap_ready_to_gc(), is_lazy_sweeping, rb_objspace::profile, rb_memerror(), and TRUE.

Referenced by heap_get_freeobj_from_next_freepage().

static int heap_ready_to_gc ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 5032 of file gc.c.

References dont_gc, during_gc, FALSE, rb_heap_struct::free_pages, rb_heap_struct::freelist, heap_increment(), heap_set_increment(), and TRUE.

Referenced by heap_prepare_freepage(), and ready_to_gc().

static void heap_set_increment ( rb_objspace_t objspace,
size_t  minimum_limit 
) [static]

Definition at line 1162 of file gc.c.

References gc_params, ruby_gc_params_t::growth_factor, ruby_gc_params_t::growth_max_slots, HEAP_OBJ_LIMIT, heap_pages_expand_sorted(), heap_pages_increment, heap_pages_length, heap_pages_used, and heap_tomb.

Referenced by gc_after_sweep(), gc_heap_prepare_minimum_pages(), and heap_ready_to_gc().

static void heap_unlink_page ( rb_objspace_t objspace,
rb_heap_t heap,
struct heap_page page 
) [static]

Definition at line 976 of file gc.c.

References heap_page::heap, heap_page::limit, heap_page::next, NULL, rb_heap_struct::page_length, rb_heap_struct::pages, heap_page::prev, and rb_heap_struct::total_slots.

Referenced by heap_page_resurrect(), and heap_pages_free_unused_pages().

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

Definition at line 2301 of file gc.c.

References FIXNUM_P, FLONUM_P, ID2SYM, is_id_value(), is_live_object(), NUM2PTR, obj_id_to_ref, Qfalse, Qnil, Qtrue, rb_eRangeError, rb_id2name(), rb_objspace, rb_raise(), and VALUE.

Referenced by Init_GC().

void Init_GC ( void   ) 

Definition at line 7472 of file gc.c.

References CALC_EXACT_MALLOC_SIZE, count_objects(), define_final(), gc_count(), GC_DEBUG, GC_ENABLE_LAZY_SWEEP, gc_latest_gc_info(), gc_profile_clear(), GC_PROFILE_DETAIL_MEMORY, gc_profile_disable(), gc_profile_enable(), gc_profile_enable_get(), GC_PROFILE_MORE_DETAIL, gc_profile_record_get(), gc_profile_report(), gc_profile_result(), gc_profile_total_time(), gc_start_internal(), gc_stat(), gc_stress_get(), gc_stress_set(), gc_verify_internal_consistency(), HEAP_BITMAP_PLANES, HEAP_BITMAP_SIZE, HEAP_OBJ_LIMIT, id2ref(), ID2SYM, MALLOC_ALLOCATED_SIZE, MALLOC_ALLOCATED_SIZE_CHECK, nomem_error, OBJ_FREEZE, OBJ_TAINT, OPT, os_each_obj(), rb_ary_new(), rb_cBasicObject, rb_cObject, rb_define_alloc_func(), rb_define_class_under(), rb_define_const(), rb_define_method(), rb_define_module(), rb_define_module_function(), rb_define_module_under(), rb_define_private_method(), rb_define_singleton_method(), rb_eNoMemError, rb_exc_new3, rb_gc_disable(), rb_gc_enable(), rb_hash_aset(), rb_hash_new(), rb_include_module(), rb_intern, rb_mEnumerable, rb_mKernel, rb_obj_freeze(), rb_obj_id(), rb_str_new2, RGENGC_CHECK_MODE, RGENGC_DEBUG, RGENGC_ESTIMATE_OLDMALLOC, RGENGC_PROFILE, RGENGC_THREEGEN, SIZET2NUM, undefine_final(), USE_RGENGC, VALUE, wmap_allocate(), wmap_aref(), wmap_aset(), wmap_each(), wmap_each_key(), wmap_each_value(), wmap_finalize(), wmap_has_key(), wmap_inspect(), wmap_keys(), wmap_size(), and wmap_values().

void Init_heap ( void   ) 

Definition at line 1661 of file gc.c.

References finalizer_table, free, gc_params, GET_THREAD(), getrusage_time(), heap_add_pages(), heap_eden, ruby_gc_params_t::heap_init_slots, HEAP_OBJ_LIMIT, init_mark_stack(), rb_objspace::invoke_time, malloc, rb_objspace::mark_stack, rb_objspace::oldmalloc_increase_limit, ruby_gc_params_t::oldmalloc_limit_min, rb_objspace::profile, rb_objspace, rb_sigaltstack_size(), rb_objspace::rgengc, and st_init_numtable().

Referenced by ruby_setup().

static void init_mark_stack ( mark_stack_t stack  )  [static]

Definition at line 3203 of file gc.c.

References add_stack_chunk_cache(), mark_stack::cache_size, mark_stack::index, mark_stack::limit, push_mark_stack_chunk(), stack_chunk_alloc(), STACK_CHUNK_SIZE, and mark_stack::unused_cache_size.

Referenced by Init_heap().

void Init_stack ( volatile VALUE *  addr  ) 

Definition at line 5124 of file gc.c.

References ruby_init_stack().

static int internal_object_p ( VALUE  obj  )  [static]

Definition at line 1787 of file gc.c.

References RVALUE::as, RVALUE::basic, BUILTIN_TYPE, FL_SINGLETON, FL_TEST, RBasic::flags, T_CLASS, T_ICLASS, T_NODE, T_NONE, and T_ZOMBIE.

Referenced by os_obj_of_i(), and rb_objspace_internal_object_p().

static int is_dead_object ( rb_objspace_t objspace,
VALUE  ptr 
) [inline, static]

Definition at line 2248 of file gc.c.

References FALSE, GET_HEAP_MARK_BITS, heap_eden, is_lazy_sweeping, is_swept_object(), MARKED_IN_BITMAP, and TRUE.

Referenced by is_live_object().

static int is_id_value ( rb_objspace_t objspace,
VALUE  ptr 
) [inline, static]

Definition at line 2221 of file gc.c.

References BUILTIN_TYPE, FALSE, is_pointer_to_heap(), T_FIXNUM, T_ICLASS, and TRUE.

Referenced by id2ref(), wmap_aref(), wmap_each_i(), wmap_each_key_i(), wmap_each_value_i(), wmap_keys_i(), and wmap_values_i().

static int is_live_object ( rb_objspace_t objspace,
VALUE  ptr 
) [inline, static]

Definition at line 2256 of file gc.c.

References BUILTIN_TYPE, FALSE, is_dead_object(), T_ZOMBIE, and TRUE.

Referenced by id2ref(), rb_objspace_markable_object_p(), verify_internal_consistency_i(), wmap_aref(), wmap_each_i(), wmap_each_key_i(), wmap_each_value_i(), wmap_keys_i(), and wmap_values_i().

static int is_mark_stack_empty ( mark_stack_t stack  )  [inline, static]

Definition at line 3102 of file gc.c.

References mark_stack::chunk, and NULL.

Referenced by pop_mark_stack().

static int is_markable_object ( rb_objspace_t objspace,
VALUE  obj 
) [inline, static]

Definition at line 2267 of file gc.c.

References BUILTIN_TYPE, is_pointer_to_heap(), rb_bug(), rb_special_const_p(), RGENGC_CHECK_MODE, T_NONE, and T_ZOMBIE.

Referenced by gc_mark(), gc_mark_children(), rb_objspace_markable_object_p(), and rb_objspace_reachable_objects_from().

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

Definition at line 1405 of file gc.c.

References FALSE, heap_pages_himem, heap_pages_sorted, heap_pages_used, hi, heap_page::limit, lo, RANY, heap_page::start, TRUE, and VALUE.

Referenced by check_gen_consistency(), gc_mark_maybe(), is_id_value(), and is_markable_object().

static int is_swept_object ( rb_objspace_t objspace,
VALUE  ptr 
) [inline, static]

Definition at line 2237 of file gc.c.

References FALSE, heap_eden, heap_is_swept_object(), and TRUE.

Referenced by is_dead_object(), and rb_gc_resurrect().

static VALUE lazy_sweep_enable ( void   )  [static]

Definition at line 2677 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 ( rb_objspace_t objspace,
RVALUE p 
) [inline, static]

Definition at line 1473 of file gc.c.

References RVALUE::as, RVALUE::basic, RBasic::flags, RVALUE::free, heap_pages_deferred_final, and T_ZOMBIE.

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

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

Definition at line 1481 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(), and rb_objspace_call_finalizer().

static int mark_const_entry_i ( ID  key,
const rb_const_entry_t ce,
st_data_t  data 
) [static]

Definition at line 3447 of file gc.c.

References rb_const_entry_struct::file, 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 3456 of file gc.c.

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

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

Definition at line 3475 of file gc.c.

References FLUSH_REGISTER_WINDOWS, GET_STACK_BOUNDS, rb_thread_struct::machine, mark_locations_array(), numberof, rb_gc_mark_locations, rb_jmp_buf, rb_setjmp, SET_STACK_END, STACK_END, STACK_START, and VALUE.

Referenced by gc_mark_roots().

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

Definition at line 3323 of file gc.c.

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

Referenced by mark_tbl().

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

Definition at line 3372 of file gc.c.

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

Referenced by rb_mark_hash().

static int mark_key ( st_data_t  key,
st_data_t  value,
st_data_t  data 
) [static]

Definition at line 3340 of file gc.c.

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

Referenced by mark_set().

static int mark_keyvalue ( st_data_t  key,
st_data_t  value,
st_data_t  data 
) [static]

Definition at line 3363 of file gc.c.

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

Referenced by mark_hash().

static ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS void mark_locations_array ( rb_objspace_t objspace,
register VALUE *  x,
register long  n 
) [static]

Definition at line 3290 of file gc.c.

References gc_mark_maybe(), and VALUE.

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

static void mark_m_tbl_wrapper ( rb_objspace_t objspace,
struct method_table_wrapper wrapper 
) [static]

Definition at line 3431 of file gc.c.

References LIKELY, rb_objspace::mark_func_data, mark_method_entry_i(), mark_tbl_arg::objspace, rb_gc_count(), method_table_wrapper::serial, st_data_t, st_foreach(), and method_table_wrapper::tbl.

static void mark_method_entry ( rb_objspace_t objspace,
const rb_method_entry_t me 
) [static]

Definition at line 3387 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::orig_me, 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, VM_METHOD_TYPE_IVAR, and VM_METHOD_TYPE_REFINED.

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

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

Referenced by mark_m_tbl_wrapper().

static void mark_set ( rb_objspace_t objspace,
st_table tbl 
) [static]

Definition at line 3348 of file gc.c.

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

Referenced by rb_mark_set().

static void mark_tbl ( rb_objspace_t objspace,
st_table tbl 
) [static]

Definition at line 3331 of file gc.c.

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

Referenced by gc_mark_roots(), and rb_mark_tbl().

static void negative_size_allocation_error ( const char *   )  [static]

Definition at line 5840 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 objspace_malloc_prepare(), and objspace_xrealloc().

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

Definition at line 5833 of file gc.c.

References rb_eNoMemError, and rb_raise().

Referenced by negative_size_allocation_error().

static VALUE newobj_of ( VALUE  klass,
VALUE  flags,
VALUE  v1,
VALUE  v2,
VALUE  v3 
) [static]

Definition at line 1285 of file gc.c.

References assert, BUILTIN_TYPE, dont_gc, during_gc, FALSE, FL_SET, FL_TAINT, FL_WB_PROTECTED, garbage_collect(), gc_event_hook, GPR_FLAG_NEWOBJ, heap_eden, heap_get_freeobj(), obj_type_name(), rb_objspace::profile, RANY, rb_bug(), rb_memerror(), rb_objspace, rb_safe_level, rb_sourcefile, rb_sourceline(), RBASIC, RBASIC_SET_CLASS_RAW, rgengc_remembered(), rgengc_report, ruby_gc_stress, RUBY_INTERNAL_EVENT_NEWOBJ, RVALUE_PROMOTED_P(), SPECIAL_CONST_P, rb_objspace::total_allocated_object_num, UNLIKELY, and VALUE.

Referenced by rb_data_object_alloc(), rb_data_typed_object_alloc(), rb_newobj(), rb_newobj_of(), and rb_node_newnode().

static int obj_free ( rb_objspace_t objspace,
VALUE  obj 
) [static]

Definition at line 1490 of file gc.c.

References BUILTIN_TYPE, rmatch::char_offset, CLEAR_IN_BITMAP, DATA_PTR, FALSE, FL_EXIVAR, FL_TEST, FL_UNSET, gc_event_hook, GET_HEAP_OLDGEN_BITS, make_deferred(), make_io_deferred(), MARKED_IN_BITMAP, nd_type, NODE_ALLOCA, NODE_ARGS, NODE_SCOPE, NULL, onig_free(), onig_region_free(), PRIxVALUE, RANY, rb_ary_free(), rb_bug(), rb_class_detach_module_subclasses(), rb_class_detach_subclasses(), rb_class_remove_from_module_subclasses(), rb_class_remove_from_super_subclasses(), rb_free_const_table(), rb_free_generic_ivar(), rb_free_m_tbl_wrapper(), rb_str_free(), RBASIC, RBIGNUM_DIGITS, RBIGNUM_EMBED_FLAG, RCLASS_CONST_TBL, RCLASS_EXT, RCLASS_IV_INDEX_TBL, RCLASS_IV_TBL, RCLASS_M_TBL_WRAPPER, RDATA, rmatch::regs, ROBJECT_EMBED, RSTRUCT_EMBED_LEN_MASK, RTYPEDDATA_P, RUBY_DEFAULT_FREE, RUBY_INTERNAL_EVENT_FREEOBJ, RUBY_TYPED_FREE_IMMEDIATELY, 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, VALUE, and xfree.

Referenced by gc_page_sweep().

static size_t obj_memsize_of ( VALUE  obj,
int  use_tdata 
) [static]

Definition at line 2426 of file gc.c.

References BDIGIT, BUILTIN_TYPE, rmatch::char_offset_num_allocated, FL_EXIVAR, FL_TEST, nd_type, NODE_ALLOCA, NODE_SCOPE, onig_memsize(), onig_region_memsize(), rb_ary_memsize(), rb_bug(), rb_generic_ivar_memsize(), rb_io_memsize(), rb_objspace_data_type_memsize(), rb_str_memsize(), RBASIC, RBIGNUM_DIGITS, RBIGNUM_EMBED_FLAG, RBIGNUM_LEN, RCLASS, RCLASS_EXT, RCLASS_IV_INDEX_TBL, RCLASS_IV_TBL, RCLASS_M_TBL, RCLASS_M_TBL_WRAPPER, rmatch::regs, RFILE, RHASH, RMATCH, RNODE, ROBJECT, ROBJECT_EMBED, RREGEXP, RSTRUCT, RSTRUCT_EMBED_LEN_MASK, RSTRUCT_LEN, size, SPECIAL_CONST_P, st_memsize(), T_ARRAY, T_BIGNUM, T_CLASS, T_COMPLEX, T_DATA, T_FILE, T_FLOAT, T_HASH, T_ICLASS, T_MATCH, T_MODULE, T_NODE, T_OBJECT, T_RATIONAL, T_REGEXP, T_STRING, T_STRUCT, T_ZOMBIE, and VALUE.

Referenced by check_gen_consistency(), and rb_obj_memsize_of().

static const char * obj_type_name ( VALUE  obj  )  [static]

Definition at line 7354 of file gc.c.

References TYPE, and type_name().

Referenced by check_gen_consistency(), gc_mark_children(), gc_mark_stacked_objects(), gc_page_sweep(), heap_page_add_freeobj(), newobj_of(), rb_gc_unprotect_logging(), rb_gc_writebarrier(), rb_gc_writebarrier_unprotect_promoted(), rgengc_remember(), rgengc_remembered(), rgengc_rememberset_mark(), RVALUE_DEMOTE_FROM_OLD(), RVALUE_PROMOTE_INFANT(), and verify_internal_consistency_reachable_i().

static VALUE objspace_each_objects ( VALUE  arg  )  [static]

Definition at line 1695 of file gc.c.

References args, heap_page::body, heap_pages_sorted, heap_pages_used, heap_page::limit, Qnil, rb_objspace, and heap_page::start.

Referenced by gc_verify_internal_consistency(), and rb_objspace_each_objects().

static size_t objspace_free_slot ( rb_objspace_t objspace  )  [static]

Definition at line 2698 of file gc.c.

References heap_pages_final_slots, objspace_live_slot(), and objspace_total_slot().

Referenced by gc_stat_internal().

static size_t objspace_live_slot ( rb_objspace_t objspace  )  [static]

Definition at line 2686 of file gc.c.

References rb_objspace::profile, rb_objspace::total_allocated_object_num, and rb_objspace::total_freed_object_num.

Referenced by gc_stat_internal(), and objspace_free_slot().

static void* objspace_malloc_fixup ( rb_objspace_t objspace,
void *  mem,
size_t  size 
) [inline, static]

Definition at line 6070 of file gc.c.

Referenced by objspace_xcalloc(), and objspace_xmalloc().

static void objspace_malloc_increase ( rb_objspace_t objspace,
void *  mem,
size_t  new_size,
size_t  old_size,
enum memop_type  type 
) [static]

Definition at line 5978 of file gc.c.

References assert, ATOMIC_SIZE_ADD, ATOMIC_SIZE_INC, atomic_sub_nounderflow(), FALSE, garbage_collect_with_gvl(), gc_rest_sweep(), GPR_FLAG_MALLOC, heap_eden, is_lazy_sweeping, malloc_increase, malloc_limit, rb_objspace::malloc_params, MEMOP_TYPE_FREE, MEMOP_TYPE_MALLOC, MEMOP_TYPE_REALLOC, rb_objspace::oldmalloc_increase, rb_bug(), rb_objspace::rgengc, ruby_gc_stress, ruby_thread_has_gvl_p(), and TRUE.

Referenced by objspace_xfree(), objspace_xmalloc(), and objspace_xrealloc().

static size_t objspace_malloc_prepare ( rb_objspace_t objspace,
size_t  size 
) [inline, static]

Definition at line 6055 of file gc.c.

References negative_size_allocation_error().

Referenced by objspace_xcalloc(), and objspace_xmalloc().

static size_t objspace_malloc_size ( rb_objspace_t objspace,
void *  ptr,
size_t  hint 
) [inline, static]

Definition at line 5950 of file gc.c.

Referenced by objspace_xfree(), objspace_xmalloc(), and objspace_xrealloc().

static size_t objspace_total_slot ( rb_objspace_t objspace  )  [static]

Definition at line 2692 of file gc.c.

References heap_eden, and heap_tomb.

Referenced by gc_before_sweep(), and objspace_free_slot().

static void* objspace_xcalloc ( rb_objspace_t objspace,
size_t  count,
size_t  elsize 
) [static]

Definition at line 6178 of file gc.c.

References calloc, objspace_malloc_fixup(), objspace_malloc_prepare(), size, TRY_WITH_GC, and xmalloc2_size().

Referenced by ruby_xcalloc().

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

Definition at line 6142 of file gc.c.

References free, MEMOP_TYPE_FREE, objspace_malloc_increase(), and objspace_malloc_size().

Referenced by objspace_xrealloc(), and ruby_sized_xfree().

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

Definition at line 6089 of file gc.c.

References malloc, MEMOP_TYPE_MALLOC, objspace_malloc_fixup(), objspace_malloc_increase(), objspace_malloc_prepare(), objspace_malloc_size(), and TRY_WITH_GC.

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

static void* objspace_xrealloc ( rb_objspace_t objspace,
void *  ptr,
size_t  new_size,
size_t  old_size 
) [static]

Definition at line 6101 of file gc.c.

References MEMOP_TYPE_REALLOC, negative_size_allocation_error(), objspace_malloc_increase(), objspace_malloc_size(), objspace_xfree(), objspace_xmalloc(), realloc, and TRY_WITH_GC.

Referenced by ruby_sized_xrealloc(), and ruby_sized_xrealloc2().

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

Definition at line 1882 of file gc.c.

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

Referenced by Init_GC().

static VALUE os_obj_of ( VALUE  of  )  [static]

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

References internal_object_p(), os_each_struct::num, os_each_struct::of, rb_obj_is_kind_of(), rb_yield(), and VALUE.

Referenced by os_obj_of().

static int pop_mark_stack ( mark_stack_t ,
VALUE *   
) [static]

Definition at line 3187 of file gc.c.

References mark_stack::chunk, stack_chunk::data, FALSE, mark_stack::index, is_mark_stack_empty(), pop_mark_stack_chunk(), and TRUE.

Referenced by gc_mark_stacked_objects().

static void pop_mark_stack_chunk ( mark_stack_t stack  )  [static]

Definition at line 3151 of file gc.c.

References add_stack_chunk_cache(), assert, mark_stack::chunk, mark_stack::index, mark_stack::limit, stack_chunk::next, and prev.

Referenced by pop_mark_stack().

static void push_mark_stack ( mark_stack_t ,
VALUE   
) [static]

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

Definition at line 3130 of file gc.c.

References assert, mark_stack::cache, mark_stack::cache_size, mark_stack::chunk, mark_stack::index, mark_stack::limit, stack_chunk::next, heap_page::next, stack_chunk_alloc(), and mark_stack::unused_cache_size.

Referenced by init_mark_stack(), and push_mark_stack().

size_t rb_ary_memsize ( VALUE   ) 

Definition at line 548 of file array.c.

References ARY_OWNS_HEAP_P, RARRAY, and VALUE.

Referenced by obj_memsize_of().

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

Definition at line 1369 of file gc.c.

References Check_Type, newobj_of(), T_CLASS, T_DATA, and VALUE.

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

Definition at line 1376 of file gc.c.

References Check_Type, newobj_of(), T_CLASS, T_DATA, T_MASK, type, and VALUE.

Referenced by iow_newobj().

VALUE rb_define_finalizer ( VALUE  obj,
VALUE  block 
)

Definition at line 1990 of file gc.c.

References define_final0(), should_be_callable(), and should_be_finalizable().

int rb_during_gc ( void   ) 

Definition at line 5198 of file gc.c.

References during_gc, objspace_and_reason::objspace, and rb_objspace.

void rb_free_const_table ( st_table tbl  ) 

Definition at line 1466 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_tbl ( st_table tbl  ) 

Definition at line 1443 of file gc.c.

References free_method_entry_i(), st_foreach(), and st_free_table().

Referenced by rb_free_m_tbl_wrapper().

void rb_free_m_tbl_wrapper ( struct method_table_wrapper wrapper  ) 

Definition at line 1450 of file gc.c.

References rb_free_m_tbl(), method_table_wrapper::tbl, and xfree.

Referenced by obj_free(), and rb_mod_init_copy().

int rb_garbage_collect ( void   ) 

Definition at line 5116 of file gc.c.

References garbage_collect(), GPR_FLAG_CAPI, rb_objspace, and TRUE.

void rb_gc ( void   ) 

Definition at line 5190 of file gc.c.

References finalize_deferred(), finalizing, garbage_collect(), GPR_FLAG_CAPI, objspace_and_reason::objspace, rb_objspace, and TRUE.

Referenced by dir_initialize(), getDevice(), 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 2144 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 1998 of file gc.c.

References finalizer_table, FL_FINALIZE, FL_SET, FL_TEST, rb_objspace, st_data_t, st_insert(), st_lookup(), and VALUE.

Referenced by init_copy().

size_t rb_gc_count ( void   ) 

Definition at line 5219 of file gc.c.

References rb_objspace.

Referenced by gc_after_sweep(), gc_before_sweep(), gc_count(), mark_m_tbl_wrapper(), and newobj_i().

VALUE rb_gc_disable ( void   ) 

Definition at line 5638 of file gc.c.

References dont_gc, gc_rest_sweep(), objspace_and_reason::objspace, 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 5616 of file gc.c.

References dont_gc, FALSE, objspace_and_reason::objspace, 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 2112 of file gc.c.

References gc_finalize_deferred().

void rb_gc_force_recycle ( VALUE  p  ) 

Definition at line 4897 of file gc.c.

References heap_page::before_sweep, CLEAR_IN_BITMAP, GET_HEAP_MARK_BITS, GET_HEAP_OLDGEN_BITS, GET_HEAP_PAGE, GET_HEAP_REMEMBERSET_BITS, heap_page_add_freeobj(), rb_objspace::profile, rb_objspace, and rb_objspace::total_freed_object_num.

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

volatile VALUE* rb_gc_guarded_ptr ( volatile VALUE *  ptr  ) 

Definition at line 93 of file gc.c.

VALUE rb_gc_latest_gc_info ( VALUE  key  ) 

Definition at line 5318 of file gc.c.

References gc_info_decode(), rb_objspace::latest_gc_info, objspace_and_reason::objspace, rb_objspace::profile, and rb_objspace.

void rb_gc_mark ( VALUE  ptr  ) 

Definition at line 3604 of file gc.c.

References gc_mark(), and rb_objspace.

Referenced by _thread_call_proc_arg_mark(), addrinfo_mark(), argf_mark(), autoload_i_mark(), backtrace_mark(), bm_mark(), call_queue_mark(), cont_mark(), cparse_params_mark(), dir_mark(), dlcfunc_mark(), dlptr_mark(), enumerator_mark(), eval_queue_mark(), fiber_mark(), fiddle_ptr_mark(), gc_mark_roots(), generator_mark(), givar_mark_i(), gzfile_mark(), invoke_queue_mark(), iow_mark(), location_mark(), location_mark_entry(), mark_dump_arg(), mark_exec_arg(), mark_marshal_compat_i(), parser_mark(), random_mark(), rb_mark_end_proc(), rb_thread_mark(), rb_vm_mark(), rb_vm_trace_mark_event_hooks(), strio_mark(), strscan_mark(), subst_mark(), thread_shield_mark(), time_mark(), tp_mark(), vm_mark_each_thread_func(), wmap_mark(), yielder_mark(), and zstream_mark().

void rb_gc_mark_locations ( VALUE *  start,
VALUE *  end 
)

Definition at line 3311 of file gc.c.

References gc_mark_locations(), and rb_objspace.

void rb_gc_mark_machine_stack ( rb_thread_t th  ) 

Definition at line 3506 of file gc.c.

References GET_STACK_BOUNDS, rb_thread_struct::machine, rb_gc_mark_locations, rb_objspace, and VALUE.

Referenced by rb_thread_mark().

void rb_gc_mark_maybe ( VALUE  obj  ) 

Definition at line 3537 of file gc.c.

References gc_mark_maybe(), and rb_objspace.

Referenced by gc_mark_roots(), JSON_mark(), mark_global_entry(), val_marker(), and var_marker().

void rb_gc_register_address ( VALUE *  addr  ) 

Definition at line 4927 of file gc.c.

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

Referenced by Init_coverage(), Init_readline(), and rb_global_variable().

void rb_gc_register_mark_object ( VALUE  obj  ) 

Definition at line 4920 of file gc.c.

References GET_THREAD(), rb_vm_struct::mark_object_ary, rb_ary_push(), VALUE, and rb_thread_struct::vm.

Referenced by date__strptime_internal(), Init_Encoding(), Init_IO(), Init_load(), Init_marshal(), Init_Random(), Init_VM(), Init_win32ole(), power_cache_get_power(), pruby_init(), rb_define_class_id_under(), rb_define_module_id_under(), rt_complete_frags(), ruby_process_options(), and sym_to_proc().

void rb_gc_resurrect ( VALUE  obj  ) 

Definition at line 3612 of file gc.c.

References gc_mark_ptr(), gc_marked(), heap_eden, is_lazy_sweeping, is_swept_object(), and rb_objspace.

Referenced by fstr_update_callback().

void rb_gc_set_params ( void   ) 

Definition at line 5773 of file gc.c.

References rb_safe_level, and ruby_gc_set_params().

VALUE rb_gc_start ( void   ) 

Definition at line 5183 of file gc.c.

References Qnil, and rb_gc().

size_t rb_gc_stat ( VALUE  key  ) 

Definition at line 5555 of file gc.c.

References gc_stat_internal(), and SYMBOL_P.

void rb_gc_unprotect_logging ( void *  objptr,
const char *  filename,
int  line 
)

Definition at line 4804 of file gc.c.

References cnt, malloc, obj_type_name(), OBJ_WB_PROTECTED, rgengc_unprotect_logging_exit_func(), rgengc_unprotect_logging_table, snprintf, st_data_t, st_init_strtable(), st_insert(), st_lookup(), strlen(), and VALUE.

void rb_gc_unregister_address ( VALUE *  addr  ) 

Definition at line 4939 of file gc.c.

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

void rb_gc_writebarrier ( VALUE  a,
VALUE  b 
)

Definition at line 4731 of file gc.c.

References obj_type_name(), rb_bug(), rb_objspace, RGENGC_CHECK_MODE, rgengc_remember(), rgengc_remembered(), rgengc_report, RVALUE_OLD_BITMAP_P(), RVALUE_OLD_P(), and RVALUE_PROMOTED_P().

Referenced by rb_obj_written().

void rb_gc_writebarrier_remember_promoted ( VALUE  obj  ) 

Definition at line 4782 of file gc.c.

References rb_objspace, and rgengc_remember().

Referenced by ary_memcpy(), rb_ary_modify(), rb_hash_keys(), and rb_hash_values().

void rb_gc_writebarrier_unprotect_promoted ( VALUE  obj  ) 

Definition at line 4749 of file gc.c.

References BUILTIN_TYPE, obj_type_name(), rb_objspace::profile, rb_bug(), rb_objspace, rb_objspace::remembered_shady_object_count, rb_objspace::rgengc, RGENGC_CHECK_MODE, rgengc_remember(), rgengc_remembered(), rgengc_report, RVALUE_DEMOTE_FROM_OLD(), RVALUE_OLD_P(), RVALUE_PROMOTED_P(), and RVALUE_WB_PROTECTED.

Referenced by rb_obj_wb_unprotect().

void rb_gcdebug_print_obj_condition ( VALUE  obj  ) 

size_t rb_generic_ivar_memsize ( VALUE   ) 

Definition at line 1040 of file variable.c.

References generic_iv_tbl, st_data_t, st_lookup(), and st_memsize().

Referenced by obj_memsize_of().

void rb_global_variable ( VALUE *  var  ) 

Definition at line 4962 of file gc.c.

References rb_gc_register_address().

Referenced by Init_openssl(), Init_ossl_asn1(), Init_RandomSeed(), Init_Regexp(), Init_tcltklib(), and Init_tkutil().

size_t rb_io_memsize ( const rb_io_t  ) 

Definition at line 4280 of file io.c.

References rb_io_buffer_t::capa, rb_io_t::cbuf, finish_writeconv_arg::fptr, rb_econv_memsize(), rb_io_t::rbuf, rb_io_t::readconv, size, rb_io_t::wbuf, and rb_io_t::writeconv.

Referenced by obj_memsize_of().

void rb_mark_hash ( st_table tbl  ) 

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

References mark_method_entry(), and rb_objspace.

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 3357 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 3519 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 5882 of file gc.c.

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

Referenced by gc_heap_prepare_minimum_pages(), gc_profile_clear(), heap_page_allocate(), heap_pages_expand_sorted(), heap_prepare_freepage(), newobj_of(), nsdr(), readline_attempted_completion_function(), ruby_memerror(), ruby_memerror_body(), and stack_chunk_alloc().

VALUE rb_newobj ( void   ) 

Definition at line 1348 of file gc.c.

References newobj_of(), and T_NONE.

VALUE rb_newobj_of ( VALUE  klass,
VALUE  flags 
)

Definition at line 1354 of file gc.c.

References newobj_of().

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

Definition at line 1360 of file gc.c.

References FL_WB_PROTECTED, nd_set_type, newobj_of(), NODE_CREF, RGENGC_WB_PROTECTED_NODE_CREF, T_NODE, and VALUE.

size_t rb_obj_gc_flags ( VALUE  obj,
ID flags,
size_t  max 
)

Definition at line 4848 of file gc.c.

References GET_HEAP_MARK_BITS, GET_HEAP_REMEMBERSET_BITS, I, MARKED_IN_BITMAP, OBJ_WB_PROTECTED, RVALUE_INFANT_P(), and RVALUE_OLD_P().

Referenced by dump_object(), and Init_objspace_dump().

VALUE rb_obj_id ( VALUE  obj  ) 

Definition at line 2373 of file gc.c.

References FIXNUM_FLAG, FLONUM_P, LONG2NUM, nonspecial_obj_id, SIGNED_VALUE, SPECIAL_CONST_P, SYM2ID, and SYMBOL_P.

Referenced by exec_recursive(), Init_GC(), iow_internal_object_id(), rb_exec_recursive_paired(), rb_exec_recursive_paired_outer(), and rb_obj_hash().

size_t rb_obj_memsize_of ( VALUE  obj  ) 

Definition at line 2548 of file gc.c.

References obj_memsize_of(), and TRUE.

Referenced by cos_i(), dump_object(), iow_size(), memsize_of_m(), and total_i().

VALUE rb_obj_rgengc_promoted_p ( VALUE  obj  ) 

Definition at line 4842 of file gc.c.

References OBJ_PROMOTED, Qfalse, and Qtrue.

VALUE rb_obj_rgengc_writebarrier_protected_p ( VALUE  obj  ) 

Definition at line 4836 of file gc.c.

References OBJ_WB_PROTECTED, Qfalse, and Qtrue.

rb_objspace_t* rb_objspace_alloc ( void   ) 

Definition at line 873 of file gc.c.

References gc_params, malloc, malloc_limit, ruby_gc_params_t::malloc_limit_min, ruby_gc_stress, and ruby_initial_gc_stress.

Referenced by Init_BareVM().

static void rb_objspace_call_finalizer ( rb_objspace_t objspace  )  [static]

Definition at line 2150 of file gc.c.

References assert, ATOMIC_EXCHANGE, BUILTIN_TYPE, DATA_PTR, during_gc, finalize_deferred(), finalizer_table, finalizing, force_chain_object(), gc_rest_sweep(), heap_pages_deferred_final, heap_pages_sorted, heap_pages_used, if(), list, make_deferred(), make_io_deferred(), force_finalize_list::next, force_finalize_list::obj, RANY, rb_obj_is_fiber(), rb_obj_is_mutex(), rb_obj_is_thread(), RDATA, RTYPEDDATA_P, run_finalizer(), st_data_t, st_delete(), st_foreach(), T_DATA, T_FILE, force_finalize_list::table, VALUE, and xfree.

Referenced by rb_gc_call_finalizer_at_exit().

size_t rb_objspace_data_type_memsize ( VALUE  obj  ) 

Definition at line 1383 of file gc.c.

References RTYPEDDATA_DATA, RTYPEDDATA_P, and RTYPEDDATA_TYPE.

Referenced by obj_memsize_of().

const char* rb_objspace_data_type_name ( VALUE  obj  ) 

Definition at line 1394 of file gc.c.

References RTYPEDDATA_P, and RTYPEDDATA_TYPE.

Referenced by cto_i(), and type_name().

void rb_objspace_each_objects ( each_obj_callback callback,
void *  data 
)

Definition at line 1761 of file gc.c.

References args, gc_rest_sweep(), lazy_sweep_enable(), objspace_each_objects(), Qnil, rb_ensure(), rb_objspace, TRUE, and VALUE.

Referenced by count_nodes(), count_objects_size(), count_tdata_objects(), memsize_of_all_m(), objspace_dump_all(), and os_obj_of().

void rb_objspace_free ( rb_objspace_t objspace  ) 

Definition at line 890 of file gc.c.

References rb_objspace::eden_heap, free, free_stack_chunks(), gc_rest_sweep(), global_List, heap_page_free(), heap_pages_himem, heap_pages_length, heap_pages_lomem, heap_pages_sorted, heap_pages_used, list, rb_objspace::mark_stack, gc_list::next, NULL, rb_heap_struct::page_length, rb_heap_struct::pages, rb_objspace::profile, rb_objspace::records, rb_heap_struct::total_slots, and xfree.

Referenced by ruby_vm_destruct().

int rb_objspace_internal_object_p ( VALUE  obj  ) 

Definition at line 1810 of file gc.c.

References internal_object_p().

Referenced by reachable_object_from_i(), and reachable_object_from_root_i().

int rb_objspace_markable_object_p ( VALUE  obj  ) 

Definition at line 2281 of file gc.c.

References is_live_object(), is_markable_object(), and rb_objspace.

Referenced by reachable_object_from_i(), reachable_object_from_root_i(), and reachable_objects_from().

void rb_objspace_reachable_objects_from ( VALUE  obj,
void(func)(VALUE, void *)  ,
void *  data 
)

Definition at line 5779 of file gc.c.

References gc_mark_children(), is_markable_object(), rb_objspace::mark_func_data, objspace_and_reason::objspace, and rb_objspace.

Referenced by dump_object(), reachable_objects_from(), and verify_internal_consistency_i().

void rb_objspace_reachable_objects_from_root ( void(func)(const char *category, VALUE, void *)  ,
void *  passing_data 
)

Definition at line 5807 of file gc.c.

References root_objects_data::category, root_objects_data::data, root_objects_data::func, gc_mark_roots(), rb_objspace::mark_func_data, rb_objspace, root_objects_from(), and TRUE.

Referenced by objspace_dump_all(), and reachable_objects_from_root().

void rb_objspace_set_event_hook ( const rb_event_flag_t  event  ) 

Definition at line 1265 of file gc.c.

References rb_objspace::hook_events, rb_objspace, and RUBY_INTERNAL_EVENT_OBJSPACE_MASK.

Referenced by recalc_add_ruby_vm_event_flags(), and recalc_remove_ruby_vm_event_flags().

size_t rb_str_memsize ( VALUE   ) 

Definition at line 953 of file string.c.

References ELTS_SHARED, FL_TEST, STR_HEAP_SIZE, and STR_NOEMBED.

Referenced by obj_memsize_of().

VALUE rb_undefine_finalizer ( VALUE  obj  ) 

Definition at line 1911 of file gc.c.

References finalizer_table, FL_FINALIZE, FL_UNSET, rb_check_frozen, rb_objspace, st_data_t, and st_delete().

Referenced by undefine_final().

static int ready_to_gc ( rb_objspace_t objspace  )  [static]

Definition at line 5047 of file gc.c.

References heap_eden, and heap_ready_to_gc().

Referenced by garbage_collect().

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

Definition at line 3560 of file gc.c.

References gc_marked(), rb_objspace::parent_object_is_old, rb_objspace::rgengc, rgengc_remember(), RVALUE_INFANT_P(), RVALUE_OLD_P(), RVALUE_PROMOTE_INFANT(), and RVALUE_WB_PROTECTED.

Referenced by gc_mark(), and gc_mark_children().

static void rgengc_mark_and_rememberset_clear ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 4717 of file gc.c.

References heap_page::heap, HEAP_BITMAP_SIZE, heap_page::mark_bits, heap_page::next, rb_heap_struct::pages, and heap_page::rememberset_bits.

Referenced by gc_marks_body().

static int rgengc_remember ( rb_objspace_t objspace,
VALUE  obj 
) [static]

Definition at line 4600 of file gc.c.

References BUILTIN_TYPE, obj_type_name(), rb_objspace::profile, rb_bug(), rb_objspace::remembered_shady_object_count, RGENGC_PROFILE, rgengc_remembered(), rgengc_remembersetbits_get(), rgengc_remembersetbits_set(), rgengc_report, RVALUE_WB_PROTECTED, T_NONE, and T_ZOMBIE.

Referenced by rb_gc_writebarrier(), rb_gc_writebarrier_remember_promoted(), rb_gc_writebarrier_unprotect_promoted(), and rgengc_check_relation().

static int rgengc_remembered ( rb_objspace_t objspace,
VALUE  obj 
) [static]

Definition at line 4642 of file gc.c.

References check_gen_consistency(), obj_type_name(), result, rgengc_remembersetbits_get(), and rgengc_report.

Referenced by gc_page_sweep(), newobj_of(), rb_gc_writebarrier(), rb_gc_writebarrier_unprotect_promoted(), and rgengc_remember().

static void rgengc_rememberset_mark ( rb_objspace_t objspace,
rb_heap_t heap 
) [static]

Definition at line 4651 of file gc.c.

References BITS_BITLENGTH, CLEAR_IN_BITMAP, gc_mark_children(), gc_mark_ptr(), gc_prof_record, heap_page::heap, HEAP_BITMAP_LIMIT, heap_page::next, NUM_IN_PAGE, obj_type_name(), rb_heap_struct::pages, PRIdSIZE, heap_page::rememberset_bits, rgengc_report, RVALUE_INFANT_P(), RVALUE_PROMOTE_INFANT(), RVALUE_WB_PROTECTED, heap_page::start, and VALUE.

Referenced by gc_marks_body().

static int rgengc_remembersetbits_get ( rb_objspace_t objspace,
VALUE  obj 
) [static]

Definition at line 4577 of file gc.c.

References GET_HEAP_REMEMBERSET_BITS, and MARKED_IN_BITMAP.

Referenced by rgengc_remember(), and rgengc_remembered().

static int rgengc_remembersetbits_set ( rb_objspace_t objspace,
VALUE  obj 
) [static]

Definition at line 4584 of file gc.c.

References FALSE, GET_HEAP_REMEMBERSET_BITS, MARK_IN_BITMAP, MARKED_IN_BITMAP, and TRUE.

Referenced by rgengc_remember().

static void rgengc_report_body ( int  level,
rb_objspace_t objspace,
const char *  fmt,
  ... 
) [static]

Definition at line 4549 of file gc.c.

References args, buf, during_gc, rb_objspace::during_minor_gc, rb_objspace::rgengc, RGENGC_DEBUG, and vsnprintf.

static void rgengc_unprotect_logging_exit_func ( void   )  [static]

Definition at line 4798 of file gc.c.

References rgengc_unprotect_logging_exit_func_i(), rgengc_unprotect_logging_table, and st_foreach().

Referenced by rb_gc_unprotect_logging().

static int rgengc_unprotect_logging_exit_func_i ( st_data_t  key,
st_data_t  val 
) [static]

Definition at line 4791 of file gc.c.

References ST_CONTINUE.

Referenced by rgengc_unprotect_logging_exit_func().

static void root_objects_from ( VALUE  obj,
void *  ptr 
) [static]

Definition at line 5800 of file gc.c.

References root_objects_data::data.

Referenced by rb_objspace_reachable_objects_from_root().

void ruby_gc_set_params ( int  safe_level  ) 

Definition at line 5733 of file gc.c.

References gc_params, gc_set_initial_pages(), get_envparam_double(), get_envparam_int(), ruby_gc_params_t::growth_factor, ruby_gc_params_t::growth_max_slots, ruby_gc_params_t::heap_free_slots, ruby_gc_params_t::heap_init_slots, ruby_gc_params_t::malloc_limit_growth_factor, ruby_gc_params_t::malloc_limit_max, ruby_gc_params_t::malloc_limit_min, objspace_and_reason::objspace, rb_objspace::oldmalloc_increase_limit, ruby_gc_params_t::oldmalloc_limit_growth_factor, ruby_gc_params_t::oldmalloc_limit_max, ruby_gc_params_t::oldmalloc_limit_min, ruby_gc_params_t::oldobject_limit_factor, rb_objspace, rb_warn(), and rb_objspace::rgengc.

Referenced by process_options(), and rb_gc_set_params().

int ruby_get_stack_grow_direction ( volatile VALUE *  addr  ) 

Definition at line 3239 of file gc.c.

References SET_MACHINE_STACK_END, and VALUE.

static void ruby_memerror ( void   )  [static]

Definition at line 5864 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().

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

Definition at line 5857 of file gc.c.

References rb_memerror().

Referenced by ruby_memerror().

void ruby_mimfree ( void *  ptr  ) 

Definition at line 6267 of file gc.c.

References free.

Referenced by ruby_vm_destruct().

void* ruby_mimmalloc ( size_t  size  ) 

Definition at line 6251 of file gc.c.

References malloc.

Referenced by Init_BareVM().

void ruby_sized_xfree ( void *  x,
size_t  size 
)

Definition at line 6234 of file gc.c.

References objspace_xfree(), and rb_objspace.

Referenced by rb_ary_free(), rb_ary_initialize(), rb_ary_replace(), rb_ary_sort_bang(), rb_str_free(), ruby_xfree(), str_discard(), tr_trans(), wmap_final_func(), wmap_finalize(), and wmap_free_map().

void* ruby_sized_xrealloc ( void *  ptr,
size_t  new_size,
size_t  old_size 
)

Definition at line 6200 of file gc.c.

References objspace_xrealloc(), and rb_objspace.

Referenced by ruby_xrealloc().

void* ruby_sized_xrealloc2 ( void *  ptr,
size_t  n,
size_t  size,
size_t  old_n 
)

Definition at line 6215 of file gc.c.

References objspace_xrealloc(), rb_eArgError, rb_objspace, and rb_raise().

Referenced by ruby_xrealloc2(), wmap_aset_update(), and wmap_final_func().

void* ruby_xcalloc ( size_t  n,
size_t  size 
)

Definition at line 6191 of file gc.c.

References objspace_xcalloc(), and rb_objspace.

Referenced by getifaddrs(), and rb_iseq_defined_string().

void ruby_xfree ( void *  x  ) 

Definition at line 6242 of file gc.c.

References ruby_sized_xfree().

Referenced by ary_resize_capa(), backtrace_free(), 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(), delete_unique_str(), env_free(), fbuffer_free(), free_keys_i(), free_sdbm(), free_values_i(), freeifaddrs(), freeobj_i(), getifaddrs(), Init_dl(), Init_fiddle(), inst_free(), iseq_free(), JSON_free(), location_free(), mutex_free(), ossl_cipher_free(), ossl_hmac_free(), proc_free(), rb_dl_free(), rb_fiddle_free(), rb_str_resize(), rb_thread_recycle_stack_release(), State_free(), strscan_free(), and thread_free().

void* ruby_xmalloc ( size_t  size  ) 

Definition at line 6156 of file gc.c.

References objspace_xmalloc(), and rb_objspace.

Referenced by bt_init(), getifaddrs(), make_unique_str(), newobj_i(), rb_dl_malloc(), rb_dlptr_malloc(), rb_fiddle_malloc(), and rb_fiddle_ptr_malloc().

void* ruby_xmalloc2 ( size_t  n,
size_t  size 
)

Definition at line 6172 of file gc.c.

References objspace_xmalloc(), rb_objspace, and xmalloc2_size().

Referenced by wmap_aset_update().

void* ruby_xrealloc ( void *  ptr,
size_t  new_size 
)

Definition at line 6206 of file gc.c.

References ruby_sized_xrealloc().

Referenced by rb_dl_realloc(), rb_fiddle_realloc(), and zstream_expand_buffer_without_gvl().

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

Definition at line 6225 of file gc.c.

References ruby_sized_xrealloc2().

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

Definition at line 2048 of file gc.c.

References DATA_PTR, finalizer_table, heap_pages_final_slots, key, RBASIC_CLEAR_CLASS, RDATA, RTYPEDDATA_P, RTYPEDDATA_TYPE, run_finalizer(), st_data_t, st_delete(), and VALUE.

Referenced by finalize_list().

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

Definition at line 2021 of file gc.c.

References args, FIX2INT, nonspecial_obj_id, Qnil, RARRAY_AREF, RARRAY_LEN, rb_ary_new3, rb_obj_freeze(), rb_protect(), rb_safe_level, rb_set_errinfo(), run_single_final(), and VALUE.

Referenced by rb_objspace_call_finalizer(), and run_final().

static VALUE run_single_final ( VALUE  arg  )  [static]

Definition at line 2013 of file gc.c.

References args, Qnil, rb_eval_cmd(), and VALUE.

Referenced by run_finalizer().

static void RVALUE_DEMOTE_FROM_OLD ( VALUE  obj  )  [inline, static]

Definition at line 854 of file gc.c.

References check_gen_consistency(), CLEAR_IN_BITMAP, FL_PROMOTED, FL_UNSET2, GET_HEAP_OLDGEN_BITS, obj_type_name(), rb_bug(), RGENGC_CHECK_MODE, and RVALUE_OLD_P().

Referenced by rb_gc_writebarrier_unprotect_promoted().

static VALUE RVALUE_INFANT_P ( VALUE  obj  )  [inline, static]

Definition at line 756 of file gc.c.

References check_gen_consistency(), FL_PROMOTED, and FL_TEST2.

Referenced by gc_mark_children(), rb_obj_gc_flags(), rgengc_check_relation(), rgengc_rememberset_mark(), and RVALUE_PROMOTE_INFANT().

static VALUE RVALUE_OLD_BITMAP_P ( VALUE  obj  )  [inline, static]

Definition at line 763 of file gc.c.

References check_gen_consistency(), and RVALUE_OLDGEN_BITMAP.

Referenced by rb_gc_writebarrier(), and RVALUE_OLD_P().

static VALUE RVALUE_OLD_P ( VALUE  obj  )  [inline, static]

Definition at line 770 of file gc.c.

References check_gen_consistency(), FL_PROMOTED, FL_TEST2, and RVALUE_OLD_BITMAP_P().

Referenced by gc_page_sweep(), rb_gc_writebarrier(), rb_gc_writebarrier_unprotect_promoted(), rb_obj_gc_flags(), rgengc_check_relation(), RVALUE_DEMOTE_FROM_OLD(), verify_internal_consistency_i(), and verify_internal_consistency_reachable_i().

static void RVALUE_PROMOTE_INFANT ( VALUE  obj  )  [inline, static]

Definition at line 788 of file gc.c.

References BUILTIN_TYPE, check_gen_consistency(), FL_PROMOTED, FL_SET2, GET_HEAP_OLDGEN_BITS, MARK_IN_BITMAP, obj_type_name(), rb_objspace::profile, rb_bug(), rb_objspace, RGENGC_CHECK_MODE, and RVALUE_INFANT_P().

Referenced by gc_mark_children(), rgengc_check_relation(), and rgengc_rememberset_mark().

static VALUE RVALUE_PROMOTED_P ( VALUE  obj  )  [inline, static]

Definition at line 781 of file gc.c.

References check_gen_consistency(), FL_PROMOTED, and FL_TEST2.

Referenced by newobj_of(), rb_gc_writebarrier(), and rb_gc_writebarrier_unprotect_promoted().

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

Definition at line 2554 of file gc.c.

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

static void should_be_callable ( VALUE  block  )  [static]

Definition at line 1922 of file gc.c.

References rb_eArgError, rb_intern, rb_obj_classname(), rb_obj_respond_to(), rb_raise(), and TRUE.

Referenced by define_final(), and rb_define_finalizer().

static void should_be_finalizable ( VALUE  obj  )  [static]

Definition at line 1930 of file gc.c.

References FL_ABLE, rb_check_frozen, rb_eArgError, rb_obj_classname(), and rb_raise().

Referenced by define_final(), rb_define_finalizer(), and wmap_aset().

static void shrink_stack_chunk_cache ( mark_stack_t stack  )  [static]

Definition at line 3116 of file gc.c.

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

Referenced by gc_mark_stacked_objects().

static int stack_check ( int  water_mark  )  [static]

Definition at line 3260 of file gc.c.

References GET_THREAD(), rb_thread_struct::machine, SET_STACK_END, STACK_LENGTH, STACK_LEVEL_MAX, and VALUE.

Referenced by raise_method_missing(), rb_call0(), rb_check_funcall(), rb_check_funcall_with_hook(), and ruby_stack_check().

static stack_chunk_t* stack_chunk_alloc ( void   )  [static]

Definition at line 3090 of file gc.c.

References malloc, and rb_memerror().

Referenced by init_mark_stack(), and push_mark_stack_chunk().

static const char * type_name ( int  type,
VALUE  obj 
) [static]

Definition at line 7315 of file gc.c.

References rb_objspace_data_type_name(), 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_NONE, T_OBJECT, T_RATIONAL, T_REGEXP, T_STRING, T_STRUCT, T_SYMBOL, T_TRUE, T_UNDEF, T_ZOMBIE, and TYPE_NAME.

Referenced by obj_type_name().

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

Definition at line 1905 of file gc.c.

References rb_undefine_finalizer().

Referenced by Init_GC().

static int verify_internal_consistency_i ( void *  page_start,
void *  page_end,
size_t  stride,
void *  ptr 
) [static]

Definition at line 4194 of file gc.c.

References if(), is_live_object(), verify_internal_consistency_struct::objspace, verify_internal_consistency_struct::parent, rb_objspace_reachable_objects_from(), RVALUE_OLD_P(), VALUE, and verify_internal_consistency_reachable_i().

Referenced by gc_verify_internal_consistency().

static void verify_internal_consistency_reachable_i ( VALUE  child,
void *  ptr 
) [static]

Definition at line 4176 of file gc.c.

References assert, verify_internal_consistency_struct::err_count, GET_HEAP_PAGE, MARKED_IN_BITMAP, obj_type_name(), verify_internal_consistency_struct::parent, and RVALUE_OLD_P().

Referenced by verify_internal_consistency_i().

static VALUE wmap_allocate ( VALUE  klass  )  [static]

Definition at line 6390 of file gc.c.

References weakmap::final, ID2SYM, weakmap::obj2wmap, rb_intern, rb_obj_method(), st_init_numtable(), TypedData_Make_Struct, VALUE, weakmap_type, and weakmap::wmap2obj.

Referenced by Init_GC().

static VALUE wmap_aref ( VALUE  self,
VALUE  wmap 
) [static]

Definition at line 6662 of file gc.c.

References is_id_value(), is_live_object(), Qnil, rb_objspace, st_data_t, st_lookup(), TypedData_Get_Struct, VALUE, weakmap_type, and weakmap::wmap2obj.

Referenced by Init_GC(), and wmap_has_key().

static VALUE wmap_aset ( VALUE  self,
VALUE  wmap,
VALUE  orig 
) [static]

Definition at line 6646 of file gc.c.

References define_final0(), weakmap::final, nonspecial_obj_id, weakmap::obj2wmap, should_be_finalizable(), st_data_t, st_insert(), st_update(), TypedData_Get_Struct, weakmap_type, weakmap::wmap2obj, and wmap_aset_update().

Referenced by Init_GC().

static int wmap_aset_update ( st_data_t key,
st_data_t val,
st_data_t  arg,
int  existing 
) [static]

Definition at line 6624 of file gc.c.

References ruby_sized_xrealloc2(), ruby_xmalloc2(), size, ST_CONTINUE, st_data_t, ST_STOP, and VALUE.

Referenced by wmap_aset().

static VALUE wmap_each ( VALUE  self  )  [static]

Definition at line 6513 of file gc.c.

References rb_objspace, st_data_t, st_foreach(), TypedData_Get_Struct, weakmap_type, weakmap::wmap2obj, and wmap_each_i().

Referenced by Init_GC().

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

Definition at line 6501 of file gc.c.

References is_id_value(), is_live_object(), rb_yield_values(), ST_CONTINUE, and VALUE.

Referenced by wmap_each().

static VALUE wmap_each_key ( VALUE  self  )  [static]

Definition at line 6536 of file gc.c.

References rb_objspace, st_data_t, st_foreach(), TypedData_Get_Struct, weakmap_type, weakmap::wmap2obj, and wmap_each_key_i().

Referenced by Init_GC().

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

Definition at line 6524 of file gc.c.

References is_id_value(), is_live_object(), rb_yield(), ST_CONTINUE, and VALUE.

Referenced by wmap_each_key().

static VALUE wmap_each_value ( VALUE  self  )  [static]

Definition at line 6559 of file gc.c.

References rb_objspace, st_data_t, st_foreach(), TypedData_Get_Struct, weakmap_type, weakmap::wmap2obj, and wmap_each_value_i().

Referenced by Init_GC().

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

Definition at line 6547 of file gc.c.

References is_id_value(), is_live_object(), rb_yield(), ST_CONTINUE, and VALUE.

Referenced by wmap_each_value().

static int wmap_final_func ( st_data_t key,
st_data_t value,
st_data_t  arg,
int  existing 
) [static]

Definition at line 6401 of file gc.c.

References ruby_sized_xfree(), ruby_sized_xrealloc2(), size, ST_CONTINUE, st_data_t, ST_DELETE, ST_STOP, and VALUE.

Referenced by wmap_finalize().

static VALUE wmap_finalize ( VALUE  self,
VALUE  objid 
) [static]

Definition at line 6424 of file gc.c.

References NULL, weakmap::obj2wmap, obj_id_to_ref, ruby_sized_xfree(), size, st_data_t, st_delete(), st_update(), TypedData_Get_Struct, VALUE, weakmap_type, weakmap::wmap2obj, and wmap_final_func().

Referenced by Init_GC().

static void wmap_free ( void *  ptr  )  [static]

Definition at line 6350 of file gc.c.

References weakmap::obj2wmap, st_foreach(), st_free_table(), weakmap::wmap2obj, and wmap_free_map().

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

Definition at line 6342 of file gc.c.

References ruby_sized_xfree(), ST_CONTINUE, and VALUE.

Referenced by wmap_free().

static VALUE wmap_has_key ( VALUE  self,
VALUE  key 
) [static]

Definition at line 6679 of file gc.c.

References NIL_P, Qfalse, Qtrue, and wmap_aref().

Referenced by Init_GC().

static VALUE wmap_inspect ( VALUE  self  )  [static]

Definition at line 6484 of file gc.c.

References CLASS_OF, PRIsVALUE, rb_class_name(), rb_sprintf(), rb_str_cat2(), RSTRING_PTR, st_foreach(), TypedData_Get_Struct, VALUE, weakmap_type, weakmap::wmap2obj, and wmap_inspect_i().

Referenced by Init_GC().

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

Definition at line 6460 of file gc.c.

References OBJ_INFECT, rb_any_to_s(), rb_inspect(), rb_str_append(), rb_str_cat2(), RSTRING_PTR, SPECIAL_CONST_P, ST_CONTINUE, and VALUE.

Referenced by wmap_inspect().

static VALUE wmap_keys ( VALUE  self  )  [static]

Definition at line 6584 of file gc.c.

References args, rb_ary_new(), rb_objspace, st_data_t, st_foreach(), TypedData_Get_Struct, weakmap_type, weakmap::wmap2obj, and wmap_keys_i().

Referenced by Init_GC().

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

Definition at line 6570 of file gc.c.

References is_id_value(), is_live_object(), wmap_iter_arg::objspace, rb_ary_push(), ST_CONTINUE, wmap_iter_arg::value, and VALUE.

Referenced by wmap_keys().

static void wmap_mark ( void *  ptr  )  [static]

Definition at line 6332 of file gc.c.

References weakmap::final, weakmap::obj2wmap, rb_gc_mark(), rb_objspace, st_data_t, and st_foreach().

static size_t wmap_memsize ( const void *  ptr  )  [static]

Definition at line 6367 of file gc.c.

References weakmap::obj2wmap, size, st_data_t, st_foreach(), st_memsize(), weakmap::wmap2obj, and wmap_memsize_map().

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

Definition at line 6359 of file gc.c.

References ST_CONTINUE, and VALUE.

Referenced by wmap_memsize().

static VALUE wmap_size ( VALUE  self  )  [static]

Definition at line 6685 of file gc.c.

References st_table::num_entries, TypedData_Get_Struct, ULONG2NUM, weakmap_type, and weakmap::wmap2obj.

Referenced by Init_GC().

static VALUE wmap_values ( VALUE  self  )  [static]

Definition at line 6611 of file gc.c.

References args, rb_ary_new(), rb_objspace, st_data_t, st_foreach(), TypedData_Get_Struct, weakmap_type, weakmap::wmap2obj, and wmap_values_i().

Referenced by Init_GC().

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

Definition at line 6597 of file gc.c.

References is_id_value(), is_live_object(), wmap_iter_arg::objspace, rb_ary_push(), ST_CONTINUE, wmap_iter_arg::value, and VALUE.

Referenced by wmap_values().

static size_t xmalloc2_size ( size_t  n,
size_t  size 
) [inline, static]

Definition at line 6162 of file gc.c.

References rb_eArgError, and rb_raise().

Referenced by objspace_xcalloc(), and ruby_xmalloc2().


Variable Documentation

ruby_gc_params_t gc_params [static]

Initial value:

Definition at line 152 of file gc.c.

Referenced by gc_before_sweep(), gc_marks(), gc_set_initial_pages(), heap_set_increment(), Init_heap(), rb_objspace_alloc(), and ruby_gc_set_params().

VALUE rb_mGC

Definition at line 649 of file gc.c.

st_table* rgengc_unprotect_logging_table [static]

Definition at line 4788 of file gc.c.

Referenced by rb_gc_unprotect_logging(), and rgengc_unprotect_logging_exit_func().

int ruby_disable_gc_stress = 0

Definition at line 650 of file gc.c.

int ruby_gc_debug_indent = 0

Definition at line 648 of file gc.c.

VALUE* ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress

Definition at line 601 of file gc.c.

Referenced by set_debug_option().

int ruby_stack_grow_direction

Definition at line 3237 of file gc.c.

const rb_data_type_t weakmap_type [static]

Initial value:

Definition at line 6379 of file gc.c.

Referenced by wmap_allocate(), wmap_aref(), wmap_aset(), wmap_each(), wmap_each_key(), wmap_each_value(), wmap_finalize(), wmap_inspect(), wmap_keys(), wmap_size(), and wmap_values().


Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7