Ruby  3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
Data Structures | Macros | Typedefs | Functions | Variables
gc.h File Reference

(b76ad15ed0da636161de0243c547ee1e6fc95681)

Internal header for GC. More...

#include "ruby/internal/config.h"
#include <stddef.h>
#include "internal/compilers.h"
#include "ruby/ruby.h"
Include dependency graph for gc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ractor_newobj_cache
 

Macros

#define USE_RVARGC   0
 
#define RB_NEWOBJ_OF(var, T, c, f)
 
#define RB_EC_NEWOBJ_OF(ec, var, T, c, f)
 
#define RB_RVARGC_NEWOBJ_OF(var, T, c, f, s)
 
#define NEWOBJ_OF(var, T, c, f)   RB_NEWOBJ_OF((var), T, (c), (f))
 
#define RVARGC_NEWOBJ_OF(var, T, c, f, s)   RB_RVARGC_NEWOBJ_OF((var), T, (c), (f), (s))
 
#define RB_OBJ_GC_FLAGS_MAX   6 /* used in ext/objspace */
 
#define UNALIGNED_MEMBER_ACCESS(expr)   (expr)
 
#define UNALIGNED_MEMBER_PTR(ptr, mem)   UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
 
#define RB_OBJ_WRITE(a, slot, b)
 
#define SIZED_REALLOC_N(v, T, m, n)   ((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))
 
#define ruby_sized_xrealloc   ruby_sized_xrealloc_inlined
 
#define ruby_sized_xrealloc2   ruby_sized_xrealloc2_inlined
 
#define ruby_sized_xfree   ruby_sized_xfree_inlined
 

Typedefs

typedef struct ractor_newobj_cache rb_ractor_newobj_cache_t
 

Functions

RUBY_ATTR_MALLOC void * ruby_mimmalloc (size_t size)
 
void ruby_mimfree (void *ptr)
 
void rb_objspace_set_event_hook (const rb_event_flag_t event)
 
VALUE rb_objspace_gc_enable (struct rb_objspace *)
 
VALUE rb_objspace_gc_disable (struct rb_objspace *)
 
void ruby_gc_set_params (void)
 
void rb_copy_wb_protected_attribute (VALUE dest, VALUE obj)
 
 __attribute__ ((__alloc_align__(1))) RUBY_ATTR_MALLOC void *rb_aligned_malloc(size_t
 
size_t RUBY_ATTR_ALLOC_SIZE ((2))
 
size_t rb_size_mul_or_raise (size_t, size_t, VALUE)
 
size_t rb_size_mul_add_or_raise (size_t, size_t, size_t, VALUE)
 
RUBY_ATTR_MALLOC void * rb_xmalloc_mul_add (size_t, size_t, size_t)
 
void * rb_xrealloc_mul_add (const void *, size_t, size_t, size_t)
 
RUBY_ATTR_MALLOC void * rb_xmalloc_mul_add_mul (size_t, size_t, size_t, size_t)
 
RUBY_ATTR_MALLOC void * rb_xcalloc_mul_add_mul (size_t, size_t, size_t, size_t)
 
VALUE rb_class_allocate_instance (VALUE klass)
 
void rb_gc_ractor_newobj_cache_clear (rb_ractor_newobj_cache_t *newobj_cache)
 
void * rb_gc_rvargc_object_data (VALUE obj)
 
const char * rb_objspace_data_type_name (VALUE obj)
 
VALUE rb_wb_protected_newobj_of (VALUE, VALUE, size_t)
 
VALUE rb_wb_unprotected_newobj_of (VALUE, VALUE, size_t)
 
VALUE rb_ec_wb_protected_newobj_of (struct rb_execution_context_struct *ec, VALUE klass, VALUE flags, size_t)
 
size_t rb_obj_memsize_of (VALUE)
 
void rb_gc_verify_internal_consistency (void)
 
size_t rb_obj_gc_flags (VALUE, ID[], size_t)
 
void rb_gc_mark_values (long n, const VALUE *values)
 
void rb_gc_mark_vm_stack_values (long n, const VALUE *values)
 
void * ruby_sized_xrealloc (void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2))
 
void * ruby_sized_xrealloc2 (void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2
 
void void ruby_sized_xfree (void *x, size_t size)
 
int rb_ec_stack_check (struct rb_execution_context_struct *ec)
 
void rb_gc_writebarrier_remember (VALUE obj)
 
const char * rb_obj_info (VALUE obj)
 

Variables

VALUEruby_initial_gc_stress_ptr
 
int ruby_disable_gc
 

Detailed Description

Internal header for GC.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Definition in file gc.h.

Macro Definition Documentation

◆ NEWOBJ_OF

#define NEWOBJ_OF (   var,
  T,
  c,
  f 
)    RB_NEWOBJ_OF((var), T, (c), (f))

Definition at line 48 of file gc.h.

◆ RB_EC_NEWOBJ_OF

#define RB_EC_NEWOBJ_OF (   ec,
  var,
  T,
  c,
  f 
)
Value:
T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
rb_ec_wb_protected_newobj_of((ec), (c), (f) & ~FL_WB_PROTECTED, 0) : \

Definition at line 38 of file gc.h.

◆ RB_NEWOBJ_OF

#define RB_NEWOBJ_OF (   var,
  T,
  c,
  f 
)
Value:
T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
rb_wb_protected_newobj_of((c), (f) & ~FL_WB_PROTECTED, 0) : \

Definition at line 33 of file gc.h.

◆ RB_OBJ_GC_FLAGS_MAX

#define RB_OBJ_GC_FLAGS_MAX   6 /* used in ext/objspace */

Definition at line 50 of file gc.h.

◆ RB_OBJ_WRITE

#define RB_OBJ_WRITE (   a,
  slot,
 
)
Value:
rb_obj_write((VALUE)(a), UNALIGNED_MEMBER_ACCESS((VALUE *)(slot)), \
(VALUE)(b), __FILE__, __LINE__)

Definition at line 70 of file gc.h.

◆ RB_RVARGC_NEWOBJ_OF

#define RB_RVARGC_NEWOBJ_OF (   var,
  T,
  c,
  f,
 
)
Value:
T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
rb_wb_protected_newobj_of((c), (f) & ~FL_WB_PROTECTED, s) : \

Definition at line 43 of file gc.h.

◆ ruby_sized_xfree

#define ruby_sized_xfree   ruby_sized_xfree_inlined

Definition at line 177 of file gc.h.

◆ ruby_sized_xrealloc

#define ruby_sized_xrealloc   ruby_sized_xrealloc_inlined

Definition at line 175 of file gc.h.

◆ ruby_sized_xrealloc2

#define ruby_sized_xrealloc2   ruby_sized_xrealloc2_inlined

Definition at line 176 of file gc.h.

◆ RVARGC_NEWOBJ_OF

#define RVARGC_NEWOBJ_OF (   var,
  T,
  c,
  f,
 
)    RB_RVARGC_NEWOBJ_OF((var), T, (c), (f), (s))

Definition at line 49 of file gc.h.

◆ SIZED_REALLOC_N

#define SIZED_REALLOC_N (   v,
  T,
  m,
 
)    ((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))

Definition at line 170 of file gc.h.

◆ UNALIGNED_MEMBER_ACCESS

#define UNALIGNED_MEMBER_ACCESS (   expr)    (expr)

Definition at line 53 of file gc.h.

◆ UNALIGNED_MEMBER_PTR

#define UNALIGNED_MEMBER_PTR (   ptr,
  mem 
)    UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)

Definition at line 69 of file gc.h.

◆ USE_RVARGC

#define USE_RVARGC   0

Definition at line 23 of file gc.h.

Typedef Documentation

◆ rb_ractor_newobj_cache_t

Function Documentation

◆ __attribute__()

__attribute__ ( (__alloc_align__(1))  )

◆ rb_class_allocate_instance()

VALUE rb_class_allocate_instance ( VALUE  klass)

Definition at line 2727 of file gc.c.

References heap_page::flags, RCLASS_IV_INDEX_TBL, ROBJECT_EMBED, and T_OBJECT.

◆ rb_copy_wb_protected_attribute()

void rb_copy_wb_protected_attribute ( VALUE  dest,
VALUE  obj 
)

Definition at line 8660 of file gc.c.

References rb_objspace.

◆ rb_ec_stack_check()

int rb_ec_stack_check ( struct rb_execution_context_struct ec)

Definition at line 6242 of file gc.c.

◆ rb_ec_wb_protected_newobj_of()

VALUE rb_ec_wb_protected_newobj_of ( struct rb_execution_context_struct ec,
VALUE  klass,
VALUE  flags,
size_t   
)

Definition at line 2590 of file gc.c.

References FL_WB_PROTECTED, heap_page::flags, GC_ASSERT, and size.

◆ rb_gc_mark_values()

void rb_gc_mark_values ( long  n,
const VALUE values 
)

Definition at line 6292 of file gc.c.

References rb_objspace.

◆ rb_gc_mark_vm_stack_values()

void rb_gc_mark_vm_stack_values ( long  n,
const VALUE values 
)

Definition at line 6315 of file gc.c.

References rb_objspace.

Referenced by rb_execution_context_mark().

◆ rb_gc_ractor_newobj_cache_clear()

void rb_gc_ractor_newobj_cache_clear ( rb_ractor_newobj_cache_t newobj_cache)

Definition at line 8721 of file gc.c.

References ractor_newobj_cache::using_page.

◆ rb_gc_rvargc_object_data()

void* rb_gc_rvargc_object_data ( VALUE  obj)

◆ rb_gc_verify_internal_consistency()

void rb_gc_verify_internal_consistency ( void  )

Definition at line 7876 of file gc.c.

◆ rb_gc_writebarrier_remember()

void rb_gc_writebarrier_remember ( VALUE  obj)

Definition at line 8598 of file gc.c.

References gc_report, and rb_objspace.

◆ rb_obj_gc_flags()

size_t rb_obj_gc_flags ( VALUE  ,
ID  [],
size_t   
)

◆ rb_obj_info()

const char* rb_obj_info ( VALUE  obj)

Definition at line 13368 of file gc.c.

◆ rb_obj_memsize_of()

size_t rb_obj_memsize_of ( VALUE  )

Definition at line 4673 of file gc.c.

◆ rb_objspace_data_type_name()

const char* rb_objspace_data_type_name ( VALUE  obj)

Definition at line 2800 of file gc.c.

◆ rb_objspace_gc_disable()

VALUE rb_objspace_gc_disable ( struct rb_objspace )

Definition at line 10763 of file gc.c.

Referenced by rb_gc_disable().

◆ rb_objspace_gc_enable()

VALUE rb_objspace_gc_enable ( struct rb_objspace )

Definition at line 10726 of file gc.c.

References dont_gc_off, dont_gc_val, and RBOOL.

Referenced by rb_gc_enable().

◆ rb_objspace_set_event_hook()

void rb_objspace_set_event_hook ( const rb_event_flag_t  event)

◆ rb_size_mul_add_or_raise()

size_t rb_size_mul_add_or_raise ( size_t  ,
size_t  ,
size_t  ,
VALUE   
)

Definition at line 228 of file gc.c.

◆ rb_size_mul_or_raise()

size_t rb_size_mul_or_raise ( size_t  ,
size_t  ,
VALUE   
)

Definition at line 201 of file gc.c.

◆ rb_wb_protected_newobj_of()

VALUE rb_wb_protected_newobj_of ( VALUE  ,
VALUE  ,
size_t   
)

Definition at line 2582 of file gc.c.

References FL_WB_PROTECTED, heap_page::flags, GC_ASSERT, and size.

◆ rb_wb_unprotected_newobj_of()

VALUE rb_wb_unprotected_newobj_of ( VALUE  ,
VALUE  ,
size_t   
)

Definition at line 2574 of file gc.c.

References FL_WB_PROTECTED, heap_page::flags, GC_ASSERT, and size.

◆ rb_xcalloc_mul_add_mul()

RUBY_ATTR_MALLOC void* rb_xcalloc_mul_add_mul ( size_t  ,
size_t  ,
size_t  ,
size_t   
)

Definition at line 11832 of file gc.c.

◆ rb_xmalloc_mul_add()

RUBY_ATTR_MALLOC void* rb_xmalloc_mul_add ( size_t  ,
size_t  ,
size_t   
)

Definition at line 11811 of file gc.c.

◆ rb_xmalloc_mul_add_mul()

RUBY_ATTR_MALLOC void* rb_xmalloc_mul_add_mul ( size_t  ,
size_t  ,
size_t  ,
size_t   
)

Definition at line 11825 of file gc.c.

◆ rb_xrealloc_mul_add()

void* rb_xrealloc_mul_add ( const void *  ,
size_t  ,
size_t  ,
size_t   
)

Definition at line 11818 of file gc.c.

◆ RUBY_ATTR_ALLOC_SIZE()

size_t RUBY_ATTR_ALLOC_SIZE ( (2)  )

◆ ruby_gc_set_params()

void ruby_gc_set_params ( void  )

Definition at line 10971 of file gc.c.

◆ ruby_mimfree()

void ruby_mimfree ( void *  ptr)

Definition at line 11870 of file gc.c.

References free(), and ptr.

◆ ruby_mimmalloc()

RUBY_ATTR_MALLOC void* ruby_mimmalloc ( size_t  size)

Definition at line 11842 of file gc.c.

References malloc, NULL, size, and malloc_obj_info::size.

Referenced by Init_BareVM(), rb_ractor_main_alloc(), and rb_threadptr_root_fiber_setup().

◆ ruby_sized_xfree()

void void ruby_sized_xfree ( void *  x,
size_t  size 
)

Definition at line 11797 of file gc.c.

Referenced by ruby_xfree().

◆ ruby_sized_xrealloc()

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

Definition at line 11762 of file gc.c.

Referenced by ruby_xrealloc_body().

◆ ruby_sized_xrealloc2()

void* ruby_sized_xrealloc2 ( void *  ptr,
size_t  new_count,
size_t  element_size,
size_t  old_count 
)

Variable Documentation

◆ ruby_disable_gc

int ruby_disable_gc

Definition at line 1109 of file gc.c.

◆ ruby_initial_gc_stress_ptr

VALUE* ruby_initial_gc_stress_ptr

Definition at line 946 of file gc.c.

Referenced by ruby_env_debug_option().

UNALIGNED_MEMBER_ACCESS
#define UNALIGNED_MEMBER_ACCESS(expr)
Definition: gc.h:53
FL_WB_PROTECTED
#define FL_WB_PROTECTED
Definition: fl_type.h:59
VALUE
unsigned long VALUE
Definition: value.h:38
f
#define f
rb_wb_unprotected_newobj_of
VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE, size_t)
Definition: gc.c:2574