Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Macros | Functions
rgengc.h File Reference

RGENGC write-barrier APIs. More...

#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/special_consts.h"
#include "ruby/internal/stdbool.h"
#include "ruby/internal/value.h"
#include "ruby/assert.h"
#include "ruby/backward/2/attributes.h"

Go to the source code of this file.

Macros

#define USE_RGENGC   1
 
#define USE_RINCGC   1
 
#define USE_RGENGC_LOGGING_WB_UNPROTECT   0
 
#define RGENGC_WB_PROTECTED_ARRAY   1
 
#define RGENGC_WB_PROTECTED_HASH   1
 
#define RGENGC_WB_PROTECTED_STRUCT   1
 
#define RGENGC_WB_PROTECTED_STRING   1
 
#define RGENGC_WB_PROTECTED_OBJECT   1
 
#define RGENGC_WB_PROTECTED_REGEXP   1
 
#define RGENGC_WB_PROTECTED_CLASS   1
 
#define RGENGC_WB_PROTECTED_FLOAT   1
 
#define RGENGC_WB_PROTECTED_COMPLEX   1
 
#define RGENGC_WB_PROTECTED_RATIONAL   1
 
#define RGENGC_WB_PROTECTED_BIGNUM   1
 
#define RGENGC_WB_PROTECTED_NODE_CREF   1
 
#define OBJ_PROMOTED_RAW   RB_OBJ_PROMOTED_RAW
 
#define OBJ_PROMOTED   RB_OBJ_PROMOTED
 
#define OBJ_WB_UNPROTECT   RB_OBJ_WB_UNPROTECT
 
#define RB_OBJ_WB_UNPROTECT(x)   rb_obj_wb_unprotect(x, __FILE__, __LINE__)
 
#define RB_OBJ_WB_UNPROTECT_FOR(type, obj)    (RGENGC_WB_PROTECTED_##type ? OBJ_WB_UNPROTECT(obj) : obj)
 
#define RGENGC_LOGGING_WB_UNPROTECT   rb_gc_unprotect_logging
 
Write barrier (WB) interfaces:
Note
The following core interfaces can be changed in the future. Please catch up if you want to insert WB into C-extensions correctly.
#define RB_OBJ_WRITE(a, slot, b)    RBIMPL_CAST(rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__))
 WB for new reference from ‘a’ to ‘b’. More...
 
#define RB_OBJ_WRITTEN(a, oldv, b)    RBIMPL_CAST(rb_obj_written((VALUE)(a), (VALUE)(oldv), (VALUE)(b), __FILE__, __LINE__))
 WB for new reference from ‘a’ to ‘b’. More...
 

Functions

void rb_gc_writebarrier (VALUE a, VALUE b)
 
void rb_gc_writebarrier_unprotect (VALUE obj)
 

Detailed Description

RGENGC write-barrier APIs.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
Warning
Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
Note
To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.
See also
Sasada, K., "Gradual write-barrier insertion into a Ruby interpreter", in proceedings of the 2019 ACM SIGPLAN International Symposium on Memory Management (ISMM 2019), pp 115-121, 2019. https://doi.org/10.1145/3315573.3329986

Definition in file rgengc.h.

Macro Definition Documentation

◆ OBJ_PROMOTED

#define OBJ_PROMOTED   RB_OBJ_PROMOTED

Definition at line 119 of file rgengc.h.

◆ OBJ_PROMOTED_RAW

#define OBJ_PROMOTED_RAW   RB_OBJ_PROMOTED_RAW

Definition at line 118 of file rgengc.h.

◆ OBJ_WB_UNPROTECT

#define OBJ_WB_UNPROTECT   RB_OBJ_WB_UNPROTECT

Definition at line 120 of file rgengc.h.

◆ RB_OBJ_WB_UNPROTECT

#define RB_OBJ_WB_UNPROTECT (   x)    rb_obj_wb_unprotect(x, __FILE__, __LINE__)

Definition at line 122 of file rgengc.h.

◆ RB_OBJ_WB_UNPROTECT_FOR

#define RB_OBJ_WB_UNPROTECT_FOR (   type,
  obj 
)     (RGENGC_WB_PROTECTED_##type ? OBJ_WB_UNPROTECT(obj) : obj)

Definition at line 123 of file rgengc.h.

◆ RB_OBJ_WRITE

#define RB_OBJ_WRITE (   a,
  slot,
 
)     RBIMPL_CAST(rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__))

WB for new reference from ‘a’ to ‘b’.

Write ‘b’ into ‘*slot’. ‘slot’ is a pointer in ‘a’.

Definition at line 107 of file rgengc.h.

◆ RB_OBJ_WRITTEN

#define RB_OBJ_WRITTEN (   a,
  oldv,
 
)     RBIMPL_CAST(rb_obj_written((VALUE)(a), (VALUE)(oldv), (VALUE)(b), __FILE__, __LINE__))

WB for new reference from ‘a’ to ‘b’.

This doesn't write any values, but only a WB declaration. ‘oldv’ is replaced value with ‘b’ (not used in current Ruby).

Definition at line 114 of file rgengc.h.

◆ RGENGC_LOGGING_WB_UNPROTECT

#define RGENGC_LOGGING_WB_UNPROTECT   rb_gc_unprotect_logging

Definition at line 125 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_ARRAY

#define RGENGC_WB_PROTECTED_ARRAY   1

Definition at line 48 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_BIGNUM

#define RGENGC_WB_PROTECTED_BIGNUM   1

Definition at line 88 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_CLASS

#define RGENGC_WB_PROTECTED_CLASS   1

Definition at line 72 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_COMPLEX

#define RGENGC_WB_PROTECTED_COMPLEX   1

Definition at line 80 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_FLOAT

#define RGENGC_WB_PROTECTED_FLOAT   1

Definition at line 76 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_HASH

#define RGENGC_WB_PROTECTED_HASH   1

Definition at line 52 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_NODE_CREF

#define RGENGC_WB_PROTECTED_NODE_CREF   1

Definition at line 92 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_OBJECT

#define RGENGC_WB_PROTECTED_OBJECT   1

Definition at line 64 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_RATIONAL

#define RGENGC_WB_PROTECTED_RATIONAL   1

Definition at line 84 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_REGEXP

#define RGENGC_WB_PROTECTED_REGEXP   1

Definition at line 68 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_STRING

#define RGENGC_WB_PROTECTED_STRING   1

Definition at line 60 of file rgengc.h.

◆ RGENGC_WB_PROTECTED_STRUCT

#define RGENGC_WB_PROTECTED_STRUCT   1

Definition at line 56 of file rgengc.h.

◆ USE_RGENGC

#define USE_RGENGC   1

Definition at line 37 of file rgengc.h.

◆ USE_RGENGC_LOGGING_WB_UNPROTECT

#define USE_RGENGC_LOGGING_WB_UNPROTECT   0

Definition at line 44 of file rgengc.h.

◆ USE_RINCGC

#define USE_RINCGC   1

Definition at line 40 of file rgengc.h.

Function Documentation

◆ rb_gc_writebarrier()

void rb_gc_writebarrier ( VALUE  a,
VALUE  b 
)

◆ rb_gc_writebarrier_unprotect()

void rb_gc_writebarrier_unprotect ( VALUE  obj)