23#include "ruby/internal/config.h"
29#ifdef HAVE_SYS_TYPES_H
30# include <sys/types.h>
47#define RUBY_REF_EDGE(s, p) offsetof(s, p)
48#define RUBY_REFS_LIST_PTR(l) (RUBY_DATA_FUNC)(l)
49#define RUBY_REF_END SIZE_MAX
50#define RUBY_REFERENCES(t) static const size_t t[]
51#define RUBY_REFERENCES_START(t) RUBY_REFERENCES(t) = {
52#define RUBY_REFERENCES_END RUBY_REF_END, };
169void rb_gc_mark(
VALUE obj);
432void rb_gc_register_mark_object(
VALUE object);
450#ifndef USE_RGENGC_LOGGING_WB_UNPROTECT
451# define USE_RGENGC_LOGGING_WB_UNPROTECT 0
461#ifndef RGENGC_WB_PROTECTED_ARRAY
462# define RGENGC_WB_PROTECTED_ARRAY 1
472#ifndef RGENGC_WB_PROTECTED_HASH
473# define RGENGC_WB_PROTECTED_HASH 1
483#ifndef RGENGC_WB_PROTECTED_STRUCT
484# define RGENGC_WB_PROTECTED_STRUCT 1
494#ifndef RGENGC_WB_PROTECTED_STRING
495# define RGENGC_WB_PROTECTED_STRING 1
505#ifndef RGENGC_WB_PROTECTED_OBJECT
506# define RGENGC_WB_PROTECTED_OBJECT 1
516#ifndef RGENGC_WB_PROTECTED_REGEXP
517# define RGENGC_WB_PROTECTED_REGEXP 1
527#ifndef RGENGC_WB_PROTECTED_MATCH
528# define RGENGC_WB_PROTECTED_MATCH 1
538#ifndef RGENGC_WB_PROTECTED_CLASS
539# define RGENGC_WB_PROTECTED_CLASS 1
549#ifndef RGENGC_WB_PROTECTED_FLOAT
550# define RGENGC_WB_PROTECTED_FLOAT 1
560#ifndef RGENGC_WB_PROTECTED_COMPLEX
561# define RGENGC_WB_PROTECTED_COMPLEX 1
571#ifndef RGENGC_WB_PROTECTED_RATIONAL
572# define RGENGC_WB_PROTECTED_RATIONAL 1
582#ifndef RGENGC_WB_PROTECTED_BIGNUM
583# define RGENGC_WB_PROTECTED_BIGNUM 1
597#ifndef RGENGC_WB_PROTECTED_NODE_CREF
598# define RGENGC_WB_PROTECTED_NODE_CREF 1
619#define RB_OBJ_WRITE(old, slot, young) \
620 RBIMPL_CAST(rb_obj_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young), __FILE__, __LINE__))
631#define RB_OBJ_WRITTEN(old, oldv, young) \
632 RBIMPL_CAST(rb_obj_written((VALUE)(old), (VALUE)(oldv), (VALUE)(young), __FILE__, __LINE__))
635#define OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW
636#define OBJ_PROMOTED RB_OBJ_PROMOTED
637#define OBJ_WB_UNPROTECT RB_OBJ_WB_UNPROTECT
646#define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
659#define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
660 (RGENGC_WB_PROTECTED_##type ? OBJ_WB_UNPROTECT(obj) : obj)
668#define RGENGC_LOGGING_WB_UNPROTECT rb_gc_unprotect_logging
671#define RB_OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW
672#define RB_OBJ_PROMOTED RB_OBJ_PROMOTED
693#if USE_RGENGC_LOGGING_WB_UNPROTECT
706void rb_gc_unprotect_logging(
void *objptr,
const char *filename,
int line);
765 const char *filename,
769#if USE_RGENGC_LOGGING_WB_UNPROTECT
796 const char *filename,
800#if USE_RGENGC_LOGGING_WB_UNPROTECT
801 RGENGC_LOGGING_OBJ_WRITTEN(a, oldv, b, filename, line);
828 const char *filename,
832#ifdef RGENGC_LOGGING_WRITE
833 RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
838 rb_obj_written(a,
RUBY_Qundef , b, filename, line);
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
#define RBIMPL_ASSERT_OR_ASSUME(expr)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Defines RBIMPL_ATTR_COLD.
#define RBIMPL_ATTR_COLD()
Wraps (or simulates) __attribute__((cold))
#define RBIMPL_ATTR_DEPRECATED(msg)
Wraps (or simulates) [[deprecated]]
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
static bool RB_FL_ABLE(VALUE obj)
Checks if the object is flaggable.
static bool RB_FL_ANY_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_ANY().
@ RUBY_FL_PROMOTED
Ruby objects are "generational".
void rb_mark_tbl_no_pin(struct st_table *tbl)
Identical to rb_mark_tbl(), except it marks objects using rb_gc_mark_movable().
void rb_memerror(void)
Triggers out-of-memory error.
size_t rb_gc_stat(VALUE key_or_buf)
Obtains various GC related profiles.
void rb_gc_mark_movable(VALUE obj)
Maybe this is the only function provided for C extensions to control the pinning of objects,...
VALUE rb_gc_disable(void)
Disables GC.
VALUE rb_gc_start(void)
Identical to rb_gc(), except the return value.
static VALUE rb_obj_wb_unprotect(VALUE x, const char *filename, int line)
This is the implementation of RB_OBJ_WB_UNPROTECT().
VALUE rb_gc_latest_gc_info(VALUE key_or_buf)
Obtains various info regarding the most recent GC run.
void rb_mark_tbl(struct st_table *tbl)
Identical to rb_mark_hash(), except it marks only values of the table and leave their associated keys...
VALUE rb_gc_enable(void)
(Re-) enables GC.
void rb_mark_hash(struct st_table *tbl)
Marks keys and values associated inside of the given table.
VALUE rb_undefine_finalizer(VALUE obj)
Modifies the object so that it has no finalisers at all.
int rb_during_gc(void)
Queries if the GC is busy.
void rb_gc_register_address(VALUE *valptr)
Inform the garbage collector that the global or static variable pointed by valptr stores a live Ruby ...
void rb_gc_unregister_address(VALUE *valptr)
Inform the garbage collector that a pointer previously passed to rb_gc_register_address() no longer p...
void rb_gc_mark_maybe(VALUE obj)
Identical to rb_gc_mark(), except it allows the passed value be a non-object.
void rb_gc_writebarrier(VALUE old, VALUE young)
This is the implementation of RB_OBJ_WRITE().
VALUE rb_gc_location(VALUE obj)
Finds a new "location" of an object.
void rb_gc_writebarrier_unprotect(VALUE obj)
This is the implementation of RB_OBJ_WB_UNPROTECT().
void rb_gc_mark_locations(const VALUE *start, const VALUE *end)
Marks objects between the two pointers.
void rb_gc(void)
Triggers a GC process.
void rb_gc_force_recycle(VALUE obj)
Asserts that the passed object is no longer needed.
void rb_gc_update_tbl_refs(st_table *ptr)
Updates references inside of tables.
#define RGENGC_LOGGING_WB_UNPROTECT
This is an implementation detail of rb_obj_wb_unprotect().
void rb_mark_set(struct st_table *tbl)
Identical to rb_mark_hash(), except it marks only keys of the table and leave their associated values...
VALUE rb_define_finalizer(VALUE obj, VALUE block)
Assigns a finaliser for an object.
void rb_gc_copy_finalizer(VALUE dst, VALUE src)
Copy&paste an object's finaliser to another.
static bool RB_OBJ_PROMOTED(VALUE obj)
Tests if the object is "promoted" – that is, whether the object experienced one or more GC marks.
static bool RB_OBJ_PROMOTED_RAW(VALUE obj)
This is the implementation of RB_OBJ_PROMOTED().
void rb_gc_adjust_memory_usage(ssize_t diff)
Informs that there are external memory usages.
size_t rb_gc_count(void)
Identical to rb_gc_stat(), with "count" parameter.
Defines RBIMPL_ATTR_MAYBE_UNUSED.
#define RBIMPL_ATTR_MAYBE_UNUSED()
Wraps (or simulates) [[maybe_unused]]
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Defines RBIMPL_ATTR_NORETURN.
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
Defines enum ruby_special_consts.
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
@ RUBY_Qundef
Represents so-called undef.
uintptr_t VALUE
Type that represents a Ruby object.