Ruby  2.1.10p492(2016-04-01revision54464)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
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
 

Macros

#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 /* 0 is disable */
 
#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) /* unset 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 /* copied from string.c */
 
#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 struct gc_profile_record gc_profile_record
 
typedef struct RVALUE RVALUE
 
typedef uintptr_t bits_t
 
typedef struct stack_chunk stack_chunk_t
 
typedef struct mark_stack mark_stack_t
 
typedef struct rb_heap_struct rb_heap_t
 
typedef struct 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 VALUErb_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
 
VALUEruby_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
 

Macro Definition Documentation

◆ __has_feature

#define __has_feature (   x)    0

Definition at line 35 of file gc.c.

◆ ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS

#define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS

Definition at line 64 of file gc.c.

◆ BITMAP_BIT

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

Definition at line 591 of file gc.c.

Referenced by gc_page_sweep().

◆ BITMAP_INDEX

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

Definition at line 589 of file gc.c.

Referenced by gc_page_sweep().

◆ BITMAP_OFFSET

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

Definition at line 590 of file gc.c.

◆ CALC_EXACT_MALLOC_SIZE

#define CALC_EXACT_MALLOC_SIZE   0

Definition at line 247 of file gc.c.

Referenced by gc_profile_dump_on(), and Init_GC().

◆ CEILDIV

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

Definition at line 551 of file gc.c.

◆ CLEAR_IN_BITMAP

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

◆ COUNT_TYPE

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

Referenced by count_objects().

◆ dont_gc

#define dont_gc   objspace->flags.dont_gc

◆ during_gc

#define during_gc   objspace->flags.during_gc

◆ finalizer_table

#define finalizer_table   objspace->finalizer_table

◆ finalizing

#define finalizing   objspace->flags.finalizing

◆ FL_SET2

#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)

Definition at line 705 of file gc.c.

Referenced by RVALUE_PROMOTE_INFANT().

◆ FL_TEST2

#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)

Definition at line 704 of file gc.c.

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

◆ FL_UNSET2

#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)

Definition at line 706 of file gc.c.

Referenced by RVALUE_DEMOTE_FROM_OLD().

◆ GC_DEBUG

#define GC_DEBUG   0

Definition at line 173 of file gc.c.

Referenced by Init_GC().

◆ GC_ENABLE_LAZY_SWEEP

#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().

◆ gc_event_hook

#define gc_event_hook (   objspace,
  event,
  data 
)
Value:
do { \
if (UNLIKELY((objspace)->hook_events & (event))) { \
gc_event_hook_body((objspace), (event), (data)); \
} \
} while (0)
#define UNLIKELY(x)
Definition: vm_core.h:109

Definition at line 1278 of file gc.c.

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

◆ GC_HEAP_FREE_SLOTS

#define GC_HEAP_FREE_SLOTS   4096

Definition at line 100 of file gc.c.

◆ GC_HEAP_GROWTH_FACTOR

#define GC_HEAP_GROWTH_FACTOR   1.8

Definition at line 106 of file gc.c.

◆ GC_HEAP_GROWTH_MAX_SLOTS

#define GC_HEAP_GROWTH_MAX_SLOTS   0 /* 0 is disable */

Definition at line 109 of file gc.c.

◆ GC_HEAP_INIT_SLOTS

#define GC_HEAP_INIT_SLOTS   10000

Definition at line 103 of file gc.c.

◆ GC_HEAP_OLDOBJECT_LIMIT_FACTOR

#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR   2.0

Definition at line 112 of file gc.c.

◆ GC_MALLOC_LIMIT_GROWTH_FACTOR

#define GC_MALLOC_LIMIT_GROWTH_FACTOR   1.4

Definition at line 122 of file gc.c.

◆ GC_MALLOC_LIMIT_MAX

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

Definition at line 119 of file gc.c.

◆ GC_MALLOC_LIMIT_MIN

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

Definition at line 116 of file gc.c.

◆ GC_NOTIFY

#define GC_NOTIFY   0

Definition at line 4970 of file gc.c.

Referenced by garbage_collect_body().

◆ GC_OLDMALLOC_LIMIT_GROWTH_FACTOR

#define GC_OLDMALLOC_LIMIT_GROWTH_FACTOR   1.2

Definition at line 129 of file gc.c.

◆ GC_OLDMALLOC_LIMIT_MAX

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

Definition at line 132 of file gc.c.

◆ GC_OLDMALLOC_LIMIT_MIN

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

Definition at line 126 of file gc.c.

◆ gc_prof_enabled

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

◆ gc_prof_record

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

◆ GC_PROFILE_DETAIL_MEMORY

#define GC_PROFILE_DETAIL_MEMORY   0

Definition at line 241 of file gc.c.

Referenced by gc_profile_dump_on(), and Init_GC().

◆ GC_PROFILE_MORE_DETAIL

#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().

◆ GC_PROFILE_RECORD_DEFAULT_SIZE

#define GC_PROFILE_RECORD_DEFAULT_SIZE   100

Definition at line 6706 of file gc.c.

Referenced by gc_prof_setup_new_record(), and gc_profile_clear().

◆ GET_HEAP_MARK_BITS

#define GET_HEAP_MARK_BITS (   x)    (&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().

◆ GET_HEAP_OLDGEN_BITS

#define GET_HEAP_OLDGEN_BITS (   x)    (&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().

◆ GET_HEAP_PAGE

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

◆ GET_HEAP_REMEMBERSET_BITS

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

◆ GET_PAGE_BODY

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

Definition at line 582 of file gc.c.

◆ GET_PAGE_HEADER

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

Definition at line 583 of file gc.c.

◆ GET_STACK_BOUNDS

#define GET_STACK_BOUNDS (   start,
  end,
  appendix 
)
Value:
((start) = STACK_END, (end) = STACK_START) : ((start) = STACK_START, (end) = STACK_END+(appendix)))
#define STACK_START
Definition: gc.c:3227
#define STACK_END
Definition: gc.c:3228

Definition at line 3472 of file gc.c.

Referenced by mark_current_machine_context(), and rb_gc_mark_machine_stack().

◆ global_List

#define global_List   objspace->global_list

◆ HEAP_ALIGN_LOG

#define HEAP_ALIGN_LOG   14

Definition at line 549 of file gc.c.

◆ heap_eden

#define heap_eden   (&objspace->eden_heap)

◆ heap_pages_deferred_final

#define heap_pages_deferred_final   objspace->heap_pages.deferred_final

◆ heap_pages_final_slots

#define heap_pages_final_slots   objspace->heap_pages.final_slots

Definition at line 619 of file gc.c.

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

◆ heap_pages_himem

#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().

◆ heap_pages_increment

#define heap_pages_increment   objspace->heap_pages.increment

◆ heap_pages_length

#define heap_pages_length   objspace->heap_pages.length

◆ heap_pages_lomem

#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().

◆ heap_pages_max_free_slots

#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().

◆ heap_pages_min_free_slots

#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().

◆ heap_pages_sorted

#define heap_pages_sorted   objspace->heap_pages.sorted

◆ heap_pages_swept_slots

#define heap_pages_swept_slots   objspace->heap_pages.swept_slots

◆ heap_pages_used

#define heap_pages_used   objspace->heap_pages.used

◆ heap_tomb

#define heap_tomb   (&objspace->tomb_heap)

◆ I

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

Referenced by rb_obj_gc_flags().

◆ is_lazy_sweeping

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

◆ MALLOC_ALLOCATED_SIZE

#define MALLOC_ALLOCATED_SIZE   0

Definition at line 254 of file gc.c.

Referenced by Init_GC().

◆ malloc_allocated_size

#define malloc_allocated_size   objspace->malloc_params.allocated_size

Definition at line 609 of file gc.c.

Referenced by gc_prof_setup_new_record().

◆ MALLOC_ALLOCATED_SIZE_CHECK

#define MALLOC_ALLOCATED_SIZE_CHECK   0

Definition at line 257 of file gc.c.

Referenced by Init_GC().

◆ malloc_increase

#define malloc_increase   objspace->malloc_params.increase

◆ malloc_limit

#define malloc_limit   objspace->malloc_params.limit

◆ MARK_CHECKPOINT

#define MARK_CHECKPOINT (   category)
Value:
do { \
if (categoryp) *categoryp = category; \
MARK_CHECKPOINT_PRINT_TICK(category); \
} while (0)

Referenced by gc_mark_roots().

◆ MARK_CHECKPOINT_PRINT_TICK

#define MARK_CHECKPOINT_PRINT_TICK (   category)

◆ MARK_IN_BITMAP

#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().

◆ MARKED_IN_BITMAP

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

◆ monitor_level

#define monitor_level   objspace->rgengc.monitor_level

Definition at line 629 of file gc.c.

◆ monitored_object_table

#define monitored_object_table   objspace->rgengc.monitored_object_table

Definition at line 630 of file gc.c.

◆ nomem_error

#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().

◆ nonspecial_obj_id

#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().

◆ NUM2PTR

#define NUM2PTR (   x)    NUM2ULONG(x)

Referenced by id2ref().

◆ NUM_IN_PAGE

#define NUM_IN_PAGE (   p)    (((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().

◆ obj_id_to_ref

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

Definition at line 635 of file gc.c.

Referenced by id2ref(), and wmap_finalize().

◆ OPT

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

Referenced by Init_GC().

◆ RANY

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

◆ rb_gc_mark_locations

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

◆ rb_jmp_buf

#define rb_jmp_buf   rb_jmpbuf_t

Definition at line 89 of file gc.c.

Referenced by mark_current_machine_context().

◆ rb_objspace

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

◆ rb_setjmp

#define rb_setjmp (   env)    RUBY_SETJMP(env)

Definition at line 88 of file gc.c.

Referenced by mark_current_machine_context().

◆ RGENGC_CHECK_MODE

#define RGENGC_CHECK_MODE   0

◆ RGENGC_DEBUG

#define RGENGC_DEBUG   0

Definition at line 185 of file gc.c.

Referenced by Init_GC(), and rgengc_report_body().

◆ RGENGC_ESTIMATE_OLDMALLOC

#define RGENGC_ESTIMATE_OLDMALLOC   1

Definition at line 224 of file gc.c.

Referenced by Init_GC().

◆ RGENGC_PRINT_TICK

#define RGENGC_PRINT_TICK   0

Definition at line 3987 of file gc.c.

◆ RGENGC_PROFILE

#define RGENGC_PROFILE   0

Definition at line 205 of file gc.c.

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

◆ rgengc_report

#define rgengc_report   if (RGENGC_DEBUG) rgengc_report_body

◆ RGENGC_THREEGEN

#define RGENGC_THREEGEN   0

Definition at line 214 of file gc.c.

Referenced by gc_after_sweep(), and Init_GC().

◆ ruby_gc_stress

#define ruby_gc_stress   objspace->gc_stress

◆ ruby_initial_gc_stress

#define ruby_initial_gc_stress   gc_params.gc_stress

Definition at line 600 of file gc.c.

Referenced by rb_objspace_alloc().

◆ RVALUE_OLDGEN_BITMAP

#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().

◆ RVALUE_WB_PROTECTED

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

◆ RVALUE_WB_PROTECTED_RAW

#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().

◆ S [1/2]

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

◆ S [2/2]

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

◆ SET [1/2]

#define SET (   name,
  attr 
)
Value:
if (key == sym_##name) \
return (attr); \
else if (hash != Qnil) \
rb_hash_aset(hash, sym_##name, (attr));
#define Qnil
Definition: ruby.h:427
uint8_t key[16]
Definition: random.c:1250
static unsigned int hash(const char *str, unsigned int len)
Definition: lex.c:56
const char * name
Definition: nkf.c:208

Referenced by gc_info_decode(), and gc_stat_internal().

◆ SET [2/2]

#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 Qnil
Definition: ruby.h:427
uint8_t key[16]
Definition: random.c:1250
static unsigned int hash(const char *str, unsigned int len)
Definition: lex.c:56
const char * name
Definition: nkf.c:208
#define SIZET2NUM(v)
Definition: ruby.h:262

◆ SET_STACK_END

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

Definition at line 3224 of file gc.c.

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

◆ STACK_CHUNK_SIZE

#define STACK_CHUNK_SIZE   500

Definition at line 391 of file gc.c.

Referenced by init_mark_stack().

◆ STACK_END

#define STACK_END   (th->machine.stack_end)

Definition at line 3228 of file gc.c.

Referenced by mark_current_machine_context(), and ruby_stack_length().

◆ STACK_LENGTH

#define STACK_LENGTH
Value:
: (size_t)(STACK_END - STACK_START + 1))
#define STACK_START
Definition: gc.c:3227
#define STACK_END
Definition: gc.c:3228

Definition at line 3236 of file gc.c.

Referenced by ruby_stack_length(), and stack_check().

◆ STACK_LEVEL_MAX

#define STACK_LEVEL_MAX   (th->machine.stack_maxsize/sizeof(VALUE))

Definition at line 3229 of file gc.c.

Referenced by stack_check().

◆ STACK_START

#define STACK_START   (th->machine.stack_start)

Definition at line 3227 of file gc.c.

Referenced by mark_current_machine_context(), and ruby_stack_length().

◆ STACKFRAME_FOR_CALL_CFUNC

#define STACKFRAME_FOR_CALL_CFUNC   512

Definition at line 3279 of file gc.c.

Referenced by ruby_stack_check().

◆ STR_ASSOC

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

◆ TRY_WITH_GC

#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)
static int garbage_collect_with_gvl(rb_objspace_t *objspace, int full_mark, int immediate_sweep, int reason)
Definition: gc.c:5095

Definition at line 6083 of file gc.c.

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

◆ TYPE_NAME

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

Referenced by type_name().

◆ WMAP_DELETE_DEAD_OBJECT_IN_MARK

#define WMAP_DELETE_DEAD_OBJECT_IN_MARK   0

Definition at line 6321 of file gc.c.

Typedef Documentation

◆ bits_t

typedef uintptr_t bits_t

Definition at line 370 of file gc.c.

◆ each_obj_callback

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

Definition at line 1687 of file gc.c.

◆ gc_profile_record

◆ mark_stack_t

typedef struct mark_stack mark_stack_t

◆ rb_heap_t

typedef struct rb_heap_struct rb_heap_t

◆ rb_objspace_t

typedef struct rb_objspace rb_objspace_t

◆ RVALUE

typedef struct RVALUE RVALUE

◆ stack_chunk_t

typedef struct stack_chunk stack_chunk_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BITS_SIZE 
BITS_BITLENGTH 

Definition at line 371 of file gc.c.

◆ anonymous enum

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.

◆ 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.

◆ memop_type

enum memop_type
Enumerator
MEMOP_TYPE_MALLOC 
MEMOP_TYPE_FREE 
MEMOP_TYPE_REALLOC 

Definition at line 5962 of file gc.c.

Function Documentation

◆ add_stack_chunk_cache()

static void add_stack_chunk_cache ( mark_stack_t stack,
stack_chunk_t chunk 
)
static

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

◆ aligned_free()

static void aligned_free ( void *  ptr)
static

Definition at line 5939 of file gc.c.

References free().

Referenced by heap_page_allocate(), and heap_page_free().

◆ aligned_malloc()

static void * aligned_malloc ( size_t  alignment,
size_t  size 
)
static

Definition at line 5903 of file gc.c.

References assert, malloc, NULL, and size.

Referenced by heap_page_allocate().

◆ atomic_sub_nounderflow()

static void atomic_sub_nounderflow ( size_t *  var,
size_t  sub 
)
inlinestatic

Definition at line 5969 of file gc.c.

References ATOMIC_SIZE_CAS, sub, and val.

Referenced by objspace_malloc_increase().

◆ check_gen_consistency()

static VALUE check_gen_consistency ( VALUE  obj)
inlinestatic

◆ count_objects()

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

◆ define_final()

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

Definition at line 1949 of file gc.c.

References argc, argv, define_final0(), rb_block_proc(), rb_scan_args(), should_be_callable(), and should_be_finalizable().

Referenced by Init_GC().

◆ define_final0()

static VALUE define_final0 ( VALUE  obj,
VALUE  block 
)
static

◆ elapsed_time_from()

static double elapsed_time_from ( double  time)
static

Definition at line 6820 of file gc.c.

References getrusage_time().

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

◆ finalize_deferred()

static void finalize_deferred ( rb_objspace_t objspace)
static

◆ finalize_list()

static void finalize_list ( rb_objspace_t objspace,
RVALUE p 
)
static

◆ force_chain_object()

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

◆ free_const_entry_i()

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().

◆ free_method_entry_i()

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().

◆ free_stack_chunks()

static void free_stack_chunks ( mark_stack_t stack)
static

Definition at line 3167 of file gc.c.

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

Referenced by rb_objspace_free().

◆ garbage_collect()

static int garbage_collect ( rb_objspace_t objspace,
int  full_mark,
int  immediate_sweep,
int  reason 
)
static

◆ garbage_collect_body()

static int garbage_collect_body ( rb_objspace_t objspace,
int  full_mark,
int  immediate_sweep,
int  reason 
)
static

◆ garbage_collect_with_gvl()

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

◆ gc_after_sweep()

static void gc_after_sweep ( rb_objspace_t objspace)
static

◆ gc_before_heap_sweep()

static void gc_before_heap_sweep ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

◆ gc_before_sweep()

static void gc_before_sweep ( rb_objspace_t objspace)
static

◆ gc_count()

static VALUE gc_count ( VALUE  self)
static

Definition at line 5238 of file gc.c.

References rb_gc_count(), and SIZET2NUM.

Referenced by Init_GC().

◆ gc_event_hook_body()

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

◆ gc_finalize_deferred()

static void gc_finalize_deferred ( void *  dmy)
static

◆ gc_finalize_deferred_register()

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().

Referenced by gc_page_sweep().

◆ gc_heap_lazy_sweep()

static int gc_heap_lazy_sweep ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

◆ gc_heap_prepare_minimum_pages()

static void gc_heap_prepare_minimum_pages ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

◆ gc_heap_rest_sweep()

static void gc_heap_rest_sweep ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

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

◆ gc_info_decode()

static VALUE gc_info_decode ( int  flags,
VALUE  hash_or_key 
)
static

◆ gc_latest_gc_info()

static VALUE gc_latest_gc_info ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ gc_mark()

static void gc_mark ( rb_objspace_t objspace,
VALUE  ptr 
)
static

◆ gc_mark_children()

static void gc_mark_children ( rb_objspace_t objspace,
VALUE  ptr 
)
static

Definition at line 3627 of file gc.c.

References 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, and TRUE.

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

◆ gc_mark_locations()

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

Definition at line 3304 of file gc.c.

References mark_locations_array(), and heap_page::start.

Referenced by rb_gc_mark_locations().

◆ gc_mark_maybe()

static void gc_mark_maybe ( rb_objspace_t objspace,
VALUE  ptr 
)
static

◆ gc_mark_ptr()

static int gc_mark_ptr ( rb_objspace_t objspace,
VALUE  ptr 
)
inlinestatic

◆ gc_mark_roots()

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

◆ gc_mark_stacked_objects()

static void gc_mark_stacked_objects ( rb_objspace_t objspace)
static

◆ gc_marked()

static int gc_marked ( rb_objspace_t objspace,
VALUE  ptr 
)
inlinestatic

◆ gc_marks()

static void gc_marks ( rb_objspace_t objspace,
int  full_mark 
)
static

◆ gc_marks_body()

static void gc_marks_body ( rb_objspace_t objspace,
int  full_mark 
)
static

◆ gc_page_sweep()

static void gc_page_sweep ( rb_objspace_t objspace,
rb_heap_t heap,
struct heap_page sweep_page 
)
inlinestatic

◆ gc_prof_mark_timer_start()

static void gc_prof_mark_timer_start ( rb_objspace_t objspace)
inlinestatic

◆ gc_prof_mark_timer_stop()

static void gc_prof_mark_timer_stop ( rb_objspace_t objspace)
inlinestatic

◆ gc_prof_set_heap_info()

static void gc_prof_set_heap_info ( rb_objspace_t objspace)
inlinestatic

◆ gc_prof_set_malloc_info()

static void gc_prof_set_malloc_info ( rb_objspace_t objspace)
inlinestatic

Definition at line 6912 of file gc.c.

References gc_prof_enabled, gc_prof_record, malloc_increase, and malloc_limit.

Referenced by gc_before_sweep().

◆ gc_prof_setup_new_record()

static void gc_prof_setup_new_record ( rb_objspace_t objspace,
int  reason 
)
inlinestatic

◆ gc_prof_sweep_timer_start()

static void gc_prof_sweep_timer_start ( rb_objspace_t objspace)
inlinestatic

◆ gc_prof_sweep_timer_stop()

static void gc_prof_sweep_timer_stop ( rb_objspace_t objspace)
inlinestatic

◆ gc_prof_timer_start()

static void gc_prof_timer_start ( rb_objspace_t objspace)
inlinestatic

◆ gc_prof_timer_stop()

static void gc_prof_timer_stop ( rb_objspace_t objspace)
inlinestatic

◆ gc_profile_clear()

static VALUE gc_profile_clear ( void  )
static

◆ gc_profile_disable()

static VALUE gc_profile_disable ( void  )
static

Definition at line 7304 of file gc.c.

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

Referenced by Init_GC().

◆ gc_profile_dump_on()

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

◆ gc_profile_enable()

static VALUE gc_profile_enable ( void  )
static

Definition at line 7287 of file gc.c.

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

Referenced by Init_GC().

◆ gc_profile_enable_get()

static VALUE gc_profile_enable_get ( VALUE  self)
static

Definition at line 7272 of file gc.c.

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

Referenced by Init_GC().

◆ gc_profile_record_get()

static VALUE gc_profile_record_get ( void  )
static

◆ gc_profile_report()

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

Definition at line 7225 of file gc.c.

References argc, argv, gc_profile_dump_on(), Qnil, rb_io_write(), rb_scan_args(), and rb_stdout.

Referenced by Init_GC().

◆ gc_profile_result()

static VALUE gc_profile_result ( void  )
static

Definition at line 7208 of file gc.c.

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

Referenced by Init_GC().

◆ gc_profile_total_time()

static VALUE gc_profile_total_time ( VALUE  self)
static

◆ gc_rest_sweep()

static void gc_rest_sweep ( rb_objspace_t objspace)
static

◆ gc_set_initial_pages()

static void gc_set_initial_pages ( void  )
static

◆ gc_setup_mark_bits()

static void gc_setup_mark_bits ( struct heap_page page)
static

Definition at line 2707 of file gc.c.

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

Referenced by gc_page_sweep().

◆ gc_start_internal()

static VALUE gc_start_internal ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ gc_stat()

static VALUE gc_stat ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 5536 of file gc.c.

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

Referenced by Init_GC().

◆ gc_stat_internal()

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

◆ gc_stress_get()

static VALUE gc_stress_get ( VALUE  self)
static

Definition at line 5578 of file gc.c.

References objspace_and_reason::objspace, rb_objspace, and ruby_gc_stress.

Referenced by Init_GC().

◆ gc_stress_set()

static VALUE gc_stress_set ( VALUE  self,
VALUE  flag 
)
static

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

◆ gc_sweep()

static void gc_sweep ( rb_objspace_t objspace,
int  immediate_sweep 
)
static

◆ gc_verify_internal_consistency()

static VALUE gc_verify_internal_consistency ( VALUE  self)
static

◆ gc_with_gvl()

static void* gc_with_gvl ( void *  ptr)
static

◆ get_envparam_double()

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

Definition at line 5673 of file gc.c.

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

Referenced by ruby_gc_set_params().

◆ get_envparam_int()

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

Definition at line 5653 of file gc.c.

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

Referenced by ruby_gc_set_params().

◆ getrusage_time()

static double getrusage_time ( void  )
static

◆ heap_add_freepage()

static void heap_add_freepage ( rb_objspace_t objspace,
rb_heap_t heap,
struct heap_page page 
)
inlinestatic

◆ heap_add_page()

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

◆ heap_add_pages()

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

◆ heap_assign_page()

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().

◆ heap_get_freeobj()

static VALUE heap_get_freeobj ( rb_objspace_t objspace,
rb_heap_t heap 
)
inlinestatic

◆ heap_get_freeobj_from_next_freepage()

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

◆ heap_increment()

static int heap_increment ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

◆ heap_is_swept_object()

static int heap_is_swept_object ( rb_objspace_t objspace,
rb_heap_t heap,
VALUE  ptr 
)
inlinestatic

Definition at line 2230 of file gc.c.

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

Referenced by is_swept_object().

◆ heap_page_add_freeobj()

static void heap_page_add_freeobj ( rb_objspace_t objspace,
struct heap_page page,
VALUE  obj 
)
inlinestatic

◆ heap_page_allocate()

static struct heap_page* heap_page_allocate ( rb_objspace_t objspace)
static

◆ heap_page_create()

static struct heap_page* heap_page_create ( rb_objspace_t objspace)
static

◆ heap_page_free()

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().

◆ heap_page_resurrect()

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().

◆ heap_pages_expand_sorted()

static void heap_pages_expand_sorted ( rb_objspace_t objspace)
static

◆ heap_pages_free_unused_pages()

static void heap_pages_free_unused_pages ( rb_objspace_t objspace)
static

◆ heap_prepare_freepage()

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

◆ heap_ready_to_gc()

static int heap_ready_to_gc ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

◆ heap_set_increment()

static void heap_set_increment ( rb_objspace_t objspace,
size_t  minimum_limit 
)
static

◆ heap_unlink_page()

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

◆ id2ref()

static VALUE id2ref ( VALUE  obj,
VALUE  objid 
)
static

◆ Init_GC()

void Init_GC ( void  )

◆ Init_heap()

void Init_heap ( void  )

◆ init_mark_stack()

static void init_mark_stack ( mark_stack_t stack)
static

◆ Init_stack()

void Init_stack ( volatile VALUE addr)

Definition at line 5127 of file gc.c.

References ruby_init_stack().

◆ internal_object_p()

static int internal_object_p ( VALUE  obj)
static

◆ is_dead_object()

static int is_dead_object ( rb_objspace_t objspace,
VALUE  ptr 
)
inlinestatic

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().

◆ is_id_value()

static int is_id_value ( rb_objspace_t objspace,
VALUE  ptr 
)
inlinestatic

◆ is_live_object()

static int is_live_object ( rb_objspace_t objspace,
VALUE  ptr 
)
inlinestatic

◆ is_mark_stack_empty()

static int is_mark_stack_empty ( mark_stack_t stack)
inlinestatic

Definition at line 3105 of file gc.c.

References mark_stack::chunk, and NULL.

Referenced by pop_mark_stack().

◆ is_markable_object()

static int is_markable_object ( rb_objspace_t objspace,
VALUE  obj 
)
inlinestatic

◆ is_pointer_to_heap()

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

◆ is_swept_object()

static int is_swept_object ( rb_objspace_t objspace,
VALUE  ptr 
)
inlinestatic

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().

◆ lazy_sweep_enable()

static VALUE lazy_sweep_enable ( void  )
static

Definition at line 2680 of file gc.c.

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

Referenced by rb_objspace_each_objects().

◆ make_deferred()

static void make_deferred ( rb_objspace_t objspace,
RVALUE p 
)
inlinestatic

◆ make_io_deferred()

static void make_io_deferred ( rb_objspace_t objspace,
RVALUE p 
)
inlinestatic

◆ mark_const_entry_i()

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

◆ mark_const_tbl()

static void mark_const_tbl ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 3459 of file gc.c.

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

◆ mark_current_machine_context()

static void mark_current_machine_context ( rb_objspace_t objspace,
rb_thread_t th 
)
static

◆ mark_entry()

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

Definition at line 3326 of file gc.c.

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

Referenced by mark_tbl().

◆ mark_hash()

static void mark_hash ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 3375 of file gc.c.

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

Referenced by rb_mark_hash().

◆ mark_key()

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

Definition at line 3343 of file gc.c.

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

Referenced by mark_set().

◆ mark_keyvalue()

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

Definition at line 3366 of file gc.c.

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

Referenced by mark_hash().

◆ mark_locations_array()

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

Definition at line 3293 of file gc.c.

References gc_mark_maybe().

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

◆ mark_m_tbl_wrapper()

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

◆ mark_method_entry()

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

◆ mark_method_entry_i()

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

Definition at line 3426 of file gc.c.

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

Referenced by mark_m_tbl_wrapper().

◆ mark_set()

static void mark_set ( rb_objspace_t objspace,
st_table tbl 
)
static

Definition at line 3351 of file gc.c.

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

Referenced by rb_mark_set().

◆ mark_tbl()

static void mark_tbl ( rb_objspace_t objspace,
st_table tbl 
)
static

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

◆ negative_size_allocation_error()

static void negative_size_allocation_error ( const char *  msg)
static

◆ negative_size_allocation_error_with_gvl()

static void* negative_size_allocation_error_with_gvl ( void *  ptr)
static

Definition at line 5836 of file gc.c.

References rb_eNoMemError, and rb_raise().

Referenced by negative_size_allocation_error().

◆ newobj_of()

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

◆ obj_free()

static int obj_free ( rb_objspace_t objspace,
VALUE  obj 
)
static

◆ obj_memsize_of()

static size_t obj_memsize_of ( VALUE  obj,
int  use_tdata 
)
static

◆ obj_type_name()

static const char * obj_type_name ( VALUE  obj)
static

◆ objspace_each_objects()

static VALUE objspace_each_objects ( VALUE  arg)
static

◆ objspace_free_slot()

static size_t objspace_free_slot ( rb_objspace_t objspace)
static

Definition at line 2701 of file gc.c.

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

Referenced by gc_stat_internal().

◆ objspace_live_slot()

static size_t objspace_live_slot ( rb_objspace_t objspace)
static

◆ objspace_malloc_fixup()

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

Definition at line 6073 of file gc.c.

References size.

Referenced by objspace_xcalloc(), and objspace_xmalloc().

◆ objspace_malloc_increase()

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

◆ objspace_malloc_prepare()

static size_t objspace_malloc_prepare ( rb_objspace_t objspace,
size_t  size 
)
inlinestatic

Definition at line 6058 of file gc.c.

References negative_size_allocation_error(), and size.

Referenced by objspace_xcalloc(), and objspace_xmalloc().

◆ objspace_malloc_size()

static size_t objspace_malloc_size ( rb_objspace_t objspace,
void *  ptr,
size_t  hint 
)
inlinestatic

Definition at line 5953 of file gc.c.

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

◆ objspace_total_slot()

static size_t objspace_total_slot ( rb_objspace_t objspace)
static

Definition at line 2695 of file gc.c.

References heap_eden, and heap_tomb.

Referenced by gc_before_sweep(), and objspace_free_slot().

◆ objspace_xcalloc()

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

Definition at line 6181 of file gc.c.

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

Referenced by ruby_xcalloc().

◆ objspace_xfree()

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

Definition at line 6145 of file gc.c.

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

Referenced by objspace_xrealloc(), and ruby_sized_xfree().

◆ objspace_xmalloc()

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

◆ objspace_xrealloc()

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

◆ os_each_obj()

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

Definition at line 1882 of file gc.c.

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

Referenced by Init_GC().

◆ os_obj_of()

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().

◆ os_obj_of_i()

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(), and rb_yield().

Referenced by os_obj_of().

◆ pop_mark_stack()

static int pop_mark_stack ( mark_stack_t stack,
VALUE data 
)
static

◆ pop_mark_stack_chunk()

static void pop_mark_stack_chunk ( mark_stack_t stack)
static

◆ push_mark_stack()

static void push_mark_stack ( mark_stack_t stack,
VALUE  data 
)
static

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

◆ push_mark_stack_chunk()

static void push_mark_stack_chunk ( mark_stack_t stack)
static

◆ rb_ary_memsize()

size_t rb_ary_memsize ( VALUE  )

Definition at line 552 of file array.c.

References ARY_OWNS_HEAP_P, and RARRAY.

Referenced by obj_memsize_of().

◆ rb_data_object_alloc()

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, and T_DATA.

◆ rb_data_typed_object_alloc()

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, and type.

Referenced by iow_newobj().

◆ rb_define_finalizer()

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().

◆ rb_during_gc()

int rb_during_gc ( void  )

Definition at line 5201 of file gc.c.

References during_gc, objspace_and_reason::objspace, and rb_objspace.

◆ rb_free_const_table()

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().

◆ rb_free_m_tbl()

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().

◆ 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().

◆ rb_garbage_collect()

int rb_garbage_collect ( void  )

Definition at line 5119 of file gc.c.

References garbage_collect(), GPR_FLAG_CAPI, and TRUE.

◆ rb_gc()

void rb_gc ( void  )

◆ rb_gc_call_finalizer_at_exit()

void rb_gc_call_finalizer_at_exit ( void  )

Definition at line 2144 of file gc.c.

References rb_objspace_call_finalizer().

Referenced by ruby_finalize_1().

◆ rb_gc_copy_finalizer()

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(), and st_lookup().

Referenced by init_copy().

◆ rb_gc_count()

size_t rb_gc_count ( void  )

◆ rb_gc_disable()

VALUE rb_gc_disable ( void  )

◆ rb_gc_enable()

VALUE rb_gc_enable ( void  )

◆ rb_gc_finalize_deferred()

void rb_gc_finalize_deferred ( void  )

Definition at line 2112 of file gc.c.

References gc_finalize_deferred().

◆ rb_gc_force_recycle()

void rb_gc_force_recycle ( VALUE  p)

◆ rb_gc_guarded_ptr()

volatile VALUE* rb_gc_guarded_ptr ( volatile VALUE ptr)

Definition at line 93 of file gc.c.

◆ rb_gc_latest_gc_info()

VALUE rb_gc_latest_gc_info ( VALUE  key)

◆ rb_gc_mark()

void rb_gc_mark ( VALUE  ptr)

◆ rb_gc_mark_locations()

void rb_gc_mark_locations ( VALUE start,
VALUE end 
)

Definition at line 3314 of file gc.c.

References gc_mark_locations(), and heap_page::start.

◆ rb_gc_mark_machine_stack()

void rb_gc_mark_machine_stack ( rb_thread_t th)

Definition at line 3509 of file gc.c.

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

Referenced by rb_thread_mark().

◆ rb_gc_mark_maybe()

void rb_gc_mark_maybe ( VALUE  obj)

Definition at line 3540 of file gc.c.

References gc_mark_maybe().

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

◆ rb_gc_register_address()

void rb_gc_register_address ( VALUE addr)

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

◆ rb_gc_register_mark_object()

void rb_gc_register_mark_object ( VALUE  obj)

◆ rb_gc_resurrect()

void rb_gc_resurrect ( VALUE  obj)

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

◆ rb_gc_set_params()

void rb_gc_set_params ( void  )

Definition at line 5776 of file gc.c.

References rb_safe_level, and ruby_gc_set_params().

◆ rb_gc_start()

VALUE rb_gc_start ( void  )

Definition at line 5186 of file gc.c.

References Qnil, and rb_gc().

◆ rb_gc_stat()

size_t rb_gc_stat ( VALUE  key)

Definition at line 5558 of file gc.c.

References gc_stat_internal(), key, and SYMBOL_P.

◆ rb_gc_unprotect_logging()

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

◆ rb_gc_unregister_address()

void rb_gc_unregister_address ( VALUE addr)

Definition at line 4942 of file gc.c.

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

◆ rb_gc_writebarrier()

void rb_gc_writebarrier ( VALUE  a,
VALUE  b 
)

◆ rb_gc_writebarrier_remember_promoted()

void rb_gc_writebarrier_remember_promoted ( VALUE  obj)

Definition at line 4785 of file gc.c.

References rb_objspace, and rgengc_remember().

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

◆ rb_gc_writebarrier_unprotect_promoted()

void rb_gc_writebarrier_unprotect_promoted ( VALUE  obj)

◆ rb_gcdebug_print_obj_condition()

void rb_gcdebug_print_obj_condition ( VALUE  obj)

◆ rb_generic_ivar_memsize()

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().

◆ rb_global_variable()

void rb_global_variable ( VALUE var)

◆ rb_io_memsize()

size_t rb_io_memsize ( const rb_io_t )

◆ rb_mark_hash()

void rb_mark_hash ( st_table tbl)

Definition at line 3384 of file gc.c.

References mark_hash().

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

◆ rb_mark_method_entry()

void rb_mark_method_entry ( const rb_method_entry_t me)

Definition at line 3420 of file gc.c.

References mark_method_entry().

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

◆ rb_mark_set()

void rb_mark_set ( st_table tbl)

Definition at line 3360 of file gc.c.

References mark_set().

Referenced by mark_dump_arg().

◆ rb_mark_tbl()

void rb_mark_tbl ( st_table tbl)

◆ rb_memerror()

void rb_memerror ( void  )

◆ rb_newobj()

VALUE rb_newobj ( void  )

Definition at line 1348 of file gc.c.

References newobj_of(), and T_NONE.

◆ rb_newobj_of()

VALUE rb_newobj_of ( VALUE  klass,
VALUE  flags 
)

Definition at line 1354 of file gc.c.

References newobj_of().

◆ rb_node_newnode()

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

◆ rb_obj_gc_flags()

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

◆ rb_obj_id()

VALUE rb_obj_id ( VALUE  obj)

◆ rb_obj_memsize_of()

size_t rb_obj_memsize_of ( VALUE  obj)

Definition at line 2551 of file gc.c.

References obj_memsize_of(), and TRUE.

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

◆ rb_obj_rgengc_promoted_p()

VALUE rb_obj_rgengc_promoted_p ( VALUE  obj)

Definition at line 4845 of file gc.c.

References OBJ_PROMOTED, Qfalse, and Qtrue.

◆ rb_obj_rgengc_writebarrier_protected_p()

VALUE rb_obj_rgengc_writebarrier_protected_p ( VALUE  obj)

Definition at line 4839 of file gc.c.

References OBJ_WB_PROTECTED, Qfalse, and Qtrue.

◆ rb_objspace_alloc()

rb_objspace_t* rb_objspace_alloc ( void  )

◆ rb_objspace_call_finalizer()

static void rb_objspace_call_finalizer ( rb_objspace_t objspace)
static

◆ rb_objspace_data_type_memsize()

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().

◆ rb_objspace_data_type_name()

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().

◆ rb_objspace_each_objects()

void rb_objspace_each_objects ( each_obj_callback callback,
void *  data 
)

◆ rb_objspace_free()

void rb_objspace_free ( rb_objspace_t objspace)

◆ rb_objspace_internal_object_p()

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().

◆ rb_objspace_markable_object_p()

int rb_objspace_markable_object_p ( VALUE  obj)

◆ rb_objspace_reachable_objects_from()

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

◆ rb_objspace_reachable_objects_from_root()

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

◆ rb_objspace_set_event_hook()

void rb_objspace_set_event_hook ( const rb_event_flag_t  event)

◆ rb_str_memsize()

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().

◆ rb_undefine_finalizer()

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().

◆ ready_to_gc()

static int ready_to_gc ( rb_objspace_t objspace)
static

Definition at line 5050 of file gc.c.

References heap_eden, and heap_ready_to_gc().

Referenced by garbage_collect().

◆ rgengc_check_relation()

static void rgengc_check_relation ( rb_objspace_t objspace,
VALUE  obj 
)
static

◆ rgengc_mark_and_rememberset_clear()

static void rgengc_mark_and_rememberset_clear ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

◆ rgengc_remember()

static int rgengc_remember ( rb_objspace_t objspace,
VALUE  obj 
)
static

◆ rgengc_remembered()

static int rgengc_remembered ( rb_objspace_t objspace,
VALUE  obj 
)
static

◆ rgengc_rememberset_mark()

static void rgengc_rememberset_mark ( rb_objspace_t objspace,
rb_heap_t heap 
)
static

◆ rgengc_remembersetbits_get()

static int rgengc_remembersetbits_get ( rb_objspace_t objspace,
VALUE  obj 
)
static

Definition at line 4580 of file gc.c.

References GET_HEAP_REMEMBERSET_BITS, and MARKED_IN_BITMAP.

Referenced by rgengc_remember(), and rgengc_remembered().

◆ rgengc_remembersetbits_set()

static int rgengc_remembersetbits_set ( rb_objspace_t objspace,
VALUE  obj 
)
static

Definition at line 4587 of file gc.c.

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

Referenced by rgengc_remember().

◆ rgengc_report_body()

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

◆ rgengc_unprotect_logging_exit_func()

static void rgengc_unprotect_logging_exit_func ( void  )
static

◆ rgengc_unprotect_logging_exit_func_i()

static int rgengc_unprotect_logging_exit_func_i ( st_data_t  key,
st_data_t  val 
)
static

Definition at line 4794 of file gc.c.

References key, ST_CONTINUE, and val.

Referenced by rgengc_unprotect_logging_exit_func().

◆ root_objects_from()

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

Definition at line 5803 of file gc.c.

References root_objects_data::data.

Referenced by rb_objspace_reachable_objects_from_root().

◆ ruby_gc_set_params()

void ruby_gc_set_params ( int  safe_level)

◆ ruby_get_stack_grow_direction()

int ruby_get_stack_grow_direction ( volatile VALUE addr)

Definition at line 3242 of file gc.c.

References ruby_stack_grow_direction, and SET_MACHINE_STACK_END.

◆ ruby_memerror()

static void ruby_memerror ( void  )
static

◆ ruby_memerror_body()

static void* ruby_memerror_body ( void *  dummy)
static

Definition at line 5860 of file gc.c.

References rb_memerror().

Referenced by ruby_memerror().

◆ ruby_mimfree()

void ruby_mimfree ( void *  ptr)

Definition at line 6270 of file gc.c.

References free().

Referenced by ruby_vm_destruct().

◆ ruby_mimmalloc()

void* ruby_mimmalloc ( size_t  size)

Definition at line 6254 of file gc.c.

References malloc, and size.

Referenced by Init_BareVM().

◆ ruby_sized_xfree()

void ruby_sized_xfree ( void *  x,
size_t  size 
)

◆ ruby_sized_xrealloc()

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

Definition at line 6203 of file gc.c.

References new_size(), and objspace_xrealloc().

Referenced by ruby_xrealloc().

◆ ruby_sized_xrealloc2()

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

Definition at line 6218 of file gc.c.

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

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

◆ ruby_xcalloc()

void* ruby_xcalloc ( size_t  n,
size_t  size 
)

Definition at line 6194 of file gc.c.

References objspace_xcalloc(), and size.

Referenced by getifaddrs(), and rb_iseq_defined_string().

◆ ruby_xfree()

void ruby_xfree ( void *  x)

◆ ruby_xmalloc()

void* ruby_xmalloc ( size_t  size)

◆ ruby_xmalloc2()

void* ruby_xmalloc2 ( size_t  n,
size_t  size 
)

Definition at line 6175 of file gc.c.

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

Referenced by wmap_aset_update().

◆ ruby_xrealloc()

void* ruby_xrealloc ( void *  ptr,
size_t  new_size 
)

◆ ruby_xrealloc2()

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

Definition at line 6228 of file gc.c.

References ruby_sized_xrealloc2(), and size.

◆ run_final()

static void run_final ( rb_objspace_t objspace,
VALUE  obj 
)
static

◆ run_finalizer()

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

◆ run_single_final()

static VALUE run_single_final ( VALUE  arg)
static

Definition at line 2013 of file gc.c.

References Qnil, and rb_eval_cmd().

Referenced by run_finalizer().

◆ RVALUE_DEMOTE_FROM_OLD()

static void RVALUE_DEMOTE_FROM_OLD ( VALUE  obj)
inlinestatic

◆ RVALUE_INFANT_P()

static VALUE RVALUE_INFANT_P ( VALUE  obj)
inlinestatic

◆ RVALUE_OLD_BITMAP_P()

static VALUE RVALUE_OLD_BITMAP_P ( VALUE  obj)
inlinestatic

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().

◆ RVALUE_OLD_P()

static VALUE RVALUE_OLD_P ( VALUE  obj)
inlinestatic

◆ RVALUE_PROMOTE_INFANT()

static void RVALUE_PROMOTE_INFANT ( VALUE  obj)
inlinestatic

◆ RVALUE_PROMOTED_P()

static VALUE RVALUE_PROMOTED_P ( VALUE  obj)
inlinestatic

◆ set_zero()

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

Definition at line 2557 of file gc.c.

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

Referenced by count_objects().

◆ should_be_callable()

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().

◆ should_be_finalizable()

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().

◆ shrink_stack_chunk_cache()

static void shrink_stack_chunk_cache ( mark_stack_t stack)
static

◆ stack_check()

static int stack_check ( int  water_mark)
static

Definition at line 3263 of file gc.c.

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

Referenced by ruby_stack_check().

◆ stack_chunk_alloc()

static stack_chunk_t* stack_chunk_alloc ( void  )
static

Definition at line 3093 of file gc.c.

References malloc, and rb_memerror().

Referenced by init_mark_stack(), and push_mark_stack_chunk().

◆ type_name()

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

◆ undefine_final()

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().

◆ verify_internal_consistency_i()

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

◆ verify_internal_consistency_reachable_i()

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

◆ wmap_allocate()

static VALUE wmap_allocate ( VALUE  klass)
static

◆ wmap_aref()

static VALUE wmap_aref ( VALUE  self,
VALUE  wmap 
)
static

◆ wmap_aset()

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

◆ wmap_aset_update()

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

Definition at line 6627 of file gc.c.

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

Referenced by wmap_aset().

◆ wmap_each()

static VALUE wmap_each ( VALUE  self)
static

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

◆ wmap_each_i()

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

Definition at line 6504 of file gc.c.

References is_id_value(), is_live_object(), key, rb_yield_values(), ST_CONTINUE, and val.

Referenced by wmap_each().

◆ wmap_each_key()

static VALUE wmap_each_key ( VALUE  self)
static

◆ wmap_each_key_i()

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

Definition at line 6527 of file gc.c.

References is_id_value(), is_live_object(), key, rb_yield(), ST_CONTINUE, and val.

Referenced by wmap_each_key().

◆ wmap_each_value()

static VALUE wmap_each_value ( VALUE  self)
static

◆ wmap_each_value_i()

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

Definition at line 6550 of file gc.c.

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

Referenced by wmap_each_value().

◆ wmap_final_func()

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

Definition at line 6404 of file gc.c.

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

Referenced by wmap_finalize().

◆ wmap_finalize()

static VALUE wmap_finalize ( VALUE  self,
VALUE  objid 
)
static

◆ wmap_free()

static void wmap_free ( void *  ptr)
static

Definition at line 6353 of file gc.c.

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

◆ wmap_free_map()

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

Definition at line 6345 of file gc.c.

References ruby_sized_xfree(), ST_CONTINUE, and val.

Referenced by wmap_free().

◆ wmap_has_key()

static VALUE wmap_has_key ( VALUE  self,
VALUE  key 
)
static

Definition at line 6682 of file gc.c.

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

Referenced by Init_GC().

◆ wmap_inspect()

static VALUE wmap_inspect ( VALUE  self)
static

◆ wmap_inspect_i()

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

◆ wmap_keys()

static VALUE wmap_keys ( VALUE  self)
static

◆ wmap_keys_i()

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

◆ wmap_mark()

static void wmap_mark ( void *  ptr)
static

Definition at line 6335 of file gc.c.

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

◆ wmap_memsize()

static size_t wmap_memsize ( const void *  ptr)
static

◆ wmap_memsize_map()

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

Definition at line 6362 of file gc.c.

References ST_CONTINUE, and val.

Referenced by wmap_memsize().

◆ wmap_size()

static VALUE wmap_size ( VALUE  self)
static

Definition at line 6688 of file gc.c.

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

Referenced by Init_GC().

◆ wmap_values()

static VALUE wmap_values ( VALUE  self)
static

◆ wmap_values_i()

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

◆ xmalloc2_size()

static size_t xmalloc2_size ( size_t  n,
size_t  size 
)
inlinestatic

Definition at line 6165 of file gc.c.

References rb_eArgError, rb_raise(), and size.

Referenced by objspace_xcalloc(), and ruby_xmalloc2().

Variable Documentation

◆ gc_params

ruby_gc_params_t gc_params
static
Initial value:
= {
}
#define FALSE
Definition: nkf.h:174
#define GC_HEAP_GROWTH_FACTOR
Definition: gc.c:106
#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR
Definition: gc.c:112
#define GC_MALLOC_LIMIT_MAX
Definition: gc.c:119
#define GC_OLDMALLOC_LIMIT_GROWTH_FACTOR
Definition: gc.c:129
#define GC_HEAP_GROWTH_MAX_SLOTS
Definition: gc.c:109
#define GC_MALLOC_LIMIT_GROWTH_FACTOR
Definition: gc.c:122
#define GC_HEAP_FREE_SLOTS
Definition: gc.c:100
#define GC_HEAP_INIT_SLOTS
Definition: gc.c:103
#define GC_OLDMALLOC_LIMIT_MIN
Definition: gc.c:126
#define GC_MALLOC_LIMIT_MIN
Definition: gc.c:116
#define GC_OLDMALLOC_LIMIT_MAX
Definition: gc.c:132

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().

◆ rb_mGC

VALUE rb_mGC

Definition at line 649 of file gc.c.

Referenced by Init_GC().

◆ rgengc_unprotect_logging_table

st_table* rgengc_unprotect_logging_table
static

Definition at line 4791 of file gc.c.

Referenced by rb_gc_unprotect_logging(), and rgengc_unprotect_logging_exit_func().

◆ ruby_disable_gc_stress

int ruby_disable_gc_stress = 0

◆ ruby_gc_debug_indent

int ruby_gc_debug_indent = 0

Definition at line 648 of file gc.c.

◆ ruby_initial_gc_stress_ptr

VALUE* ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress

Definition at line 601 of file gc.c.

Referenced by set_debug_option().

◆ ruby_stack_grow_direction

int ruby_stack_grow_direction

Definition at line 3240 of file gc.c.

Referenced by ruby_get_stack_grow_direction().

◆ weakmap_type

const rb_data_type_t weakmap_type
static
Initial value:
= {
"weakmap",
{
},
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1015
static void wmap_mark(void *ptr)
Definition: gc.c:6335
static size_t wmap_memsize(const void *ptr)
Definition: gc.c:6370
static void wmap_free(void *ptr)
Definition: gc.c:6353
#define NULL
Definition: _sdbm.c:102

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