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)(uintptr_t)(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, };
434 #ifndef USE_RGENGC_LOGGING_WB_UNPROTECT
435 # define USE_RGENGC_LOGGING_WB_UNPROTECT 0
445 #ifndef RGENGC_WB_PROTECTED_ARRAY
446 # define RGENGC_WB_PROTECTED_ARRAY 1
456 #ifndef RGENGC_WB_PROTECTED_HASH
457 # define RGENGC_WB_PROTECTED_HASH 1
467 #ifndef RGENGC_WB_PROTECTED_STRUCT
468 # define RGENGC_WB_PROTECTED_STRUCT 1
478 #ifndef RGENGC_WB_PROTECTED_STRING
479 # define RGENGC_WB_PROTECTED_STRING 1
489 #ifndef RGENGC_WB_PROTECTED_OBJECT
490 # define RGENGC_WB_PROTECTED_OBJECT 1
500 #ifndef RGENGC_WB_PROTECTED_REGEXP
501 # define RGENGC_WB_PROTECTED_REGEXP 1
511 #ifndef RGENGC_WB_PROTECTED_MATCH
512 # define RGENGC_WB_PROTECTED_MATCH 1
522 #ifndef RGENGC_WB_PROTECTED_CLASS
523 # define RGENGC_WB_PROTECTED_CLASS 1
533 #ifndef RGENGC_WB_PROTECTED_FLOAT
534 # define RGENGC_WB_PROTECTED_FLOAT 1
544 #ifndef RGENGC_WB_PROTECTED_COMPLEX
545 # define RGENGC_WB_PROTECTED_COMPLEX 1
555 #ifndef RGENGC_WB_PROTECTED_RATIONAL
556 # define RGENGC_WB_PROTECTED_RATIONAL 1
566 #ifndef RGENGC_WB_PROTECTED_BIGNUM
567 # define RGENGC_WB_PROTECTED_BIGNUM 1
581 #ifndef RGENGC_WB_PROTECTED_NODE_CREF
582 # define RGENGC_WB_PROTECTED_NODE_CREF 1
603 #define RB_OBJ_WRITE(old, slot, young) \
604 RBIMPL_CAST(rb_obj_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young), __FILE__, __LINE__))
615 #define RB_OBJ_WRITTEN(old, oldv, young) \
616 RBIMPL_CAST(rb_obj_written((VALUE)(old), (VALUE)(oldv), (VALUE)(young), __FILE__, __LINE__))
619 #define OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW
620 #define OBJ_PROMOTED RB_OBJ_PROMOTED
621 #define OBJ_WB_UNPROTECT RB_OBJ_WB_UNPROTECT
630 #define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
643 #define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
644 (RGENGC_WB_PROTECTED_##type ? OBJ_WB_UNPROTECT(obj) : obj)
652 #define RGENGC_LOGGING_WB_UNPROTECT rb_gc_unprotect_logging
655 #define RB_OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW
656 #define RB_OBJ_PROMOTED RB_OBJ_PROMOTED
677 #if USE_RGENGC_LOGGING_WB_UNPROTECT
690 void rb_gc_unprotect_logging(
void *objptr,
const char *filename,
int line);
749 const char *filename,
753 #if USE_RGENGC_LOGGING_WB_UNPROTECT
780 const char *filename,
784 #if USE_RGENGC_LOGGING_WB_UNPROTECT
785 RGENGC_LOGGING_OBJ_WRITTEN(a, oldv, b, filename, line);
812 const char *filename,
816 #ifdef RGENGC_LOGGING_WRITE
817 RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
822 rb_obj_written(a,
RUBY_Qundef , b, filename, line);
827 static
inline void rb_gc_force_recycle(
VALUE obj){}
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
#define RBIMPL_ASSERT_OR_ASSUME(...)
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_gc_mark(VALUE obj)
Marks an object.
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_register_mark_object(VALUE object)
Inform the garbage collector that object is a live Ruby object that should not be moved.
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.
RBIMPL_ATTR_NORETURN() void rb_eof_error(void)
Utility function to raise rb_eEOFError.
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
RBIMPL_ATTR_PURE() int rb_io_read_pending(rb_io_t *fptr)
Queries if the passed IO has any pending reads.
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 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_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.