Ruby: gc.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions | Variables
gc.h File Reference
`#include "ruby/ruby.h"`

Go to the source code of this file.

## Macros
#define | SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
#define | USE_CONSERVATIVE_STACK_END
#define | RB_GC_SAVE_MACHINE_CONTEXT(th)
#define | RUBY_MARK_FREE_DEBUG 0
#define | RUBY_MARK_ENTER(msg)
#define | RUBY_MARK_LEAVE(msg)
#define | RUBY_FREE_ENTER(msg)
#define | RUBY_FREE_LEAVE(msg)
#define | RUBY_GC_INFO if(0)printf
#define | RUBY_MARK_MOVABLE_UNLESS_NULL(ptr)
#define | RUBY_MARK_UNLESS_NULL(ptr)
#define | RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
#define | stack_growup_p(x)
#define | STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
#define | STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
#define | STACK_DIR_UPPER(a, b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
#define | IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)

## Functions
void | rb_gc_set_stack_end (VALUE **stack_end_p)
int | ruby_get_stack_grow_direction (volatile VALUE *addr)
const char * | rb_obj_info (VALUE obj)
const char * | rb_raw_obj_info (char *buff, const int buff_size, VALUE obj)
VALUE | rb_gc_disable_no_rest (void)
size_t | rb_objspace_data_type_memsize (VALUE obj)
void | rb_objspace_reachable_objects_from (VALUE obj, void(func)(VALUE, void *), void *data)
void | rb_objspace_reachable_objects_from_root (void(func)(const char *category, VALUE, void *), void *data)
int | rb_objspace_markable_object_p (VALUE obj)
int | rb_objspace_internal_object_p (VALUE obj)
int | rb_objspace_marked_object_p (VALUE obj)
int | rb_objspace_garbage_object_p (VALUE obj)
void | rb_objspace_each_objects (int(*callback)(void *start, void *end, size_t stride, void *data), void *data)
void | rb_objspace_each_objects_without_setup (int(*callback)(void *, void *, size_t, void *), void *data)

## Variables
int | ruby_stack_grow_direction

## Macro Definition Documentation

## ◆ IS_STACK_DIR_UPPER

#define IS_STACK_DIR_UPPER | ( |  | ) | STACK_DIR_UPPER(1,0)

Definition at line 110 of file gc.h.

## ◆ RB_GC_SAVE_MACHINE_CONTEXT

#define RB_GC_SAVE_MACHINE_CONTEXT | ( |  | th | ) |

Value:
do { \
FLUSH_REGISTER_WINDOWS; \
setjmp((th)->ec->machine.regs); \
SET_MACHINE_STACK_END(&(th)->ec->machine.stack_end); \
} while (0)
FLUSH_REGISTER_WINDOWS
#define FLUSH_REGISTER_WINDOWS
Definition: defines.h:106

Definition at line 19 of file gc.h.

## ◆ RUBY_FREE_ENTER

#define RUBY_FREE_ENTER | ( |  | msg | ) |

Definition at line 66 of file gc.h.

## ◆ RUBY_FREE_LEAVE

#define RUBY_FREE_LEAVE | ( |  | msg | ) |

Definition at line 67 of file gc.h.

## ◆ RUBY_FREE_UNLESS_NULL

#define RUBY_FREE_UNLESS_NULL | ( |  | ptr | ) | if(ptr){ruby_xfree(ptr);(ptr)=NULL;}

Definition at line 79 of file gc.h.

## ◆ RUBY_GC_INFO

#define RUBY_GC_INFO if(0)printf

Definition at line 68 of file gc.h.

## ◆ RUBY_MARK_ENTER

#define RUBY_MARK_ENTER | ( |  | msg | ) |

Definition at line 64 of file gc.h.

## ◆ RUBY_MARK_FREE_DEBUG

#define RUBY_MARK_FREE_DEBUG 0

Definition at line 29 of file gc.h.

## ◆ RUBY_MARK_LEAVE

#define RUBY_MARK_LEAVE | ( |  | msg | ) |

Definition at line 65 of file gc.h.

## ◆ RUBY_MARK_MOVABLE_UNLESS_NULL

#define RUBY_MARK_MOVABLE_UNLESS_NULL | ( |  | ptr | ) |

Value:
do { \
VALUE markobj = (ptr); \
if (RTEST(markobj)) {rb_gc_mark_movable(markobj);} \
} while (0)
ptr
struct RIMemo * ptr
Definition: debug.c:88
rb_gc_mark_movable
void rb_gc_mark_movable(VALUE ptr)
Definition: gc.c:6106
RTEST
#define RTEST
Definition: special_consts.h:42
VALUE
unsigned long VALUE
Definition: value.h:38

Definition at line 71 of file gc.h.

## ◆ RUBY_MARK_UNLESS_NULL

#define RUBY_MARK_UNLESS_NULL | ( |  | ptr | ) |

Value:
do { \
VALUE markobj = (ptr); \
if (RTEST(markobj)) {rb_gc_mark(markobj);} \
} while (0)
rb_gc_mark
void rb_gc_mark(VALUE ptr)
Definition: gc.c:6112

Definition at line 75 of file gc.h.

## ◆ SET_MACHINE_STACK_END

#define SET_MACHINE_STACK_END | ( |  | p | ) | rb_gc_set_stack_end(p)

Definition at line 15 of file gc.h.

## ◆ STACK_DIR_UPPER

#define STACK_DIR_UPPER | ( |  | a,
|  |  | b
| ) |  | STACK_UPPER(&stack_grow_dir_detection, (a), (b))

Definition at line 108 of file gc.h.

## ◆ STACK_GROW_DIR_DETECTION

#define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection

Definition at line 107 of file gc.h.

## ◆ stack_growup_p

#define stack_growup_p | ( |  | x | ) |

Value:
( \
(ruby_stack_grow_direction ? \
ruby_stack_grow_direction : \
ruby_get_stack_grow_direction(x)) > 0)
ruby_stack_grow_direction
int ruby_stack_grow_direction
Definition: gc.c:5499

Definition at line 88 of file gc.h.

## ◆ STACK_UPPER

#define STACK_UPPER | ( |  | x,
|  |  | a,
|  |  | b
| ) |  | (stack_growup_p(x) ? (a) : (b))

Definition at line 92 of file gc.h.

## ◆ USE_CONSERVATIVE_STACK_END

#define USE_CONSERVATIVE_STACK_END

Definition at line 16 of file gc.h.

## Function Documentation

## ◆ rb_gc_disable_no_rest()

VALUE rb_gc_disable_no_rest | ( | void |  | ) |

Definition at line 9910 of file gc.c.

References rb_objspace.

## ◆ rb_gc_set_stack_end()

void rb_gc_set_stack_end | ( | VALUE ** | stack_end_p | ) |

Definition at line 4586 of file thread.c.

## ◆ rb_obj_info()

const char * rb_obj_info | ( | VALUE | obj | ) |

Definition at line 12499 of file gc.c.

## ◆ rb_objspace_data_type_memsize()

size_t rb_objspace_data_type_memsize | ( | VALUE | obj | ) |

Definition at line 2521 of file gc.c.

References ptr, and RTYPEDDATA_DATA.

## ◆ rb_objspace_each_objects()

void rb_objspace_each_objects | ( | int(*)(void *start, void *end, size_t stride, void *data) | callback,
|  | void * | data
| ) |  |

## ◆ rb_objspace_each_objects_without_setup()

void rb_objspace_each_objects_without_setup | ( | int(*)(void *, void *, size_t, void *) | callback,
|  | void * | data
| ) |  |

## ◆ rb_objspace_garbage_object_p()

int rb_objspace_garbage_object_p | ( | VALUE | obj | ) |

Definition at line 3933 of file gc.c.

References rb_objspace.

Referenced by rb_include_module(), and rb_prepend_module().

## ◆ rb_objspace_internal_object_p()

int rb_objspace_internal_object_p | ( | VALUE | obj | ) |

Definition at line 3355 of file gc.c.

## ◆ rb_objspace_markable_object_p()

int rb_objspace_markable_object_p | ( | VALUE | obj | ) |

Definition at line 3926 of file gc.c.

References rb_objspace.

## ◆ rb_objspace_marked_object_p()

int rb_objspace_marked_object_p | ( | VALUE | obj | ) |

Definition at line 6122 of file gc.c.

References FALSE, and TRUE.

## ◆ rb_objspace_reachable_objects_from()

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

Definition at line 10169 of file gc.c.

References during_gc, rb_ractor_struct::mfd, rb_bug(), and rb_objspace.

## ◆ rb_objspace_reachable_objects_from_root()

void rb_objspace_reachable_objects_from_root | ( | void(func)(const char *category, VALUE, void *) | ,
|  | void * | data
| ) |  |

Definition at line 10202 of file gc.c.

References root_objects_data::func, and rb_objspace.

## ◆ rb_raw_obj_info()

const char * rb_raw_obj_info | ( | char * | buff,
|  | const int | buff_size,
|  | VALUE | obj
| ) |  |

Definition at line 12229 of file gc.c.

References rb_method_definition_struct::alias_count, APPENDF, ARY_EMBED_P, ARY_SHARED_P, block_type_iseq, rb_method_definition_struct::body, BUFF_ARGS, BUILTIN_TYPE, C, rb_method_entry_struct::called_id, DATA_PTR, rb_method_entry_struct::def, rb_method_entry_struct::defined_class, ELTS_SHARED, FIX2LONG, FIXNUM_P, FL_TEST, rb_ractor_pub::id, imemo_callcache, imemo_callinfo, imemo_iseq, imemo_ment, rb_method_definition_struct::iseq, rb_method_iseq_struct::iseqptr, rb_callcache::klass, len, METHOD_ENTRY_CACHED, METHOD_ENTRY_COMPLEMENTED, METHOD_ENTRY_INVALIDATED, METHOD_ENTRY_VISI, METHOD_VISI_PRIVATE, METHOD_VISI_PUBLIC, NIL_P, NULL, rb_method_entry_struct::owner, PRIdSIZE, ptr, rb_ractor_struct::pub, Qnil, RANY, RARRAY, RARRAY_CONST_PTR_TRANSIENT, RARRAY_EMBED_FLAG, RARRAY_LEN, rb_class_path_cached(), rb_gc_location(), rb_id2name(), rb_imemo_name(), rb_method_type_name(), rb_obj_info(), rb_obj_is_proc(), rb_objspace_data_type_name(), rb_ractor_p(), rb_raw_obj_info(), RBASIC, RBASIC_CLASS, RHASH_SIZE, ROBJECT_EMBED, RSTRING_PTR, RSYMBOL, RTEST, RVALUE_MARK_BITMAP, RVALUE_MARKING_BITMAP, RVALUE_PIN_BITMAP, RVALUE_UNCOLLECTIBLE_BITMAP, RVALUE_WB_UNPROTECTED_BITMAP, SPECIAL_CONST_P, SYM2ID, SYMBOL_P, T_ARRAY, T_CLASS, T_DATA, T_HASH, T_ICLASS, T_IMEMO, T_MODULE, T_MOVED, T_NODE, T_OBJECT, T_STRING, T_SYMBOL, UNEXPECTED_NODE, and VM_METHOD_TYPE_ISEQ.

Referenced by rb_obj_info_dump(), rb_obj_info_dump_loc(), rb_raw_obj_info(), and ruby_debug_print_value().

## ◆ ruby_get_stack_grow_direction()

int ruby_get_stack_grow_direction | ( | volatile VALUE * | addr | ) |

Definition at line 5501 of file gc.c.

References ruby_stack_grow_direction, and SET_MACHINE_STACK_END.

## Variable Documentation

## ◆ ruby_stack_grow_direction

int ruby_stack_grow_direction
| extern

Definition at line 5499 of file gc.c.

Referenced by ruby_get_stack_grow_direction().