Ruby: Write barrier (WB) interfaces:

Ruby 3.4.3p32 (2025-04-14 revision d0b7e5b6a04bde21ca483d20a1546b28b401c2d4)

Macros
Write barrier (WB) interfaces:

## Macros
#define | RB_OBJ_WRITE(old, slot, young)
| Declaration of a "back" pointer.
#define | RB_OBJ_WRITTEN(old, oldv, young)
| Identical to RB_OBJ_WRITE(), except it doesn't write any values, but only a WB declaration.

## Detailed Description

Note
  The following core interfaces can be changed in the future. Please catch up if you want to insert WB into C-extensions correctly.

## Macro Definition Documentation

## ◆ RB_OBJ_WRITE

#define RB_OBJ_WRITE | ( |  | old,
|  |  | slot,
|  |  | young )

Value:
RBIMPL_CAST(rb_obj_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young), __FILE__, __LINE__))
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40

Declaration of a "back" pointer.

This is a write barrier for new reference from "old" generation to "young" generation. It writes `young` into `*slot`, which is a pointer inside of `old`.

Parameters

  [in] | old | An old object.
  [in] | slot | A pointer inside of `old`.
  [out] | young | A young object.

Definition at line 603 of file gc.h.

Referenced by class_alloc(), RARRAY_ASET(), rb_alias(), rb_ary_push(), rb_copy_generic_ivar(), rb_enc_reg_new(), rb_hash_set_ifnone(), rb_ractor_stderr_set(), rb_ractor_stdin_set(), rb_ractor_stdout_set(), and rb_tracepoint_disable().

## ◆ RB_OBJ_WRITTEN

#define RB_OBJ_WRITTEN | ( |  | old,
|  |  | oldv,
|  |  | young )

Value:
RBIMPL_CAST(rb_obj_written((VALUE)(old), (VALUE)(oldv), (VALUE)(young), __FILE__, __LINE__))

Identical to RB_OBJ_WRITE(), except it doesn't write any values, but only a WB declaration.

`oldv` is replaced value with `b` (not used in current Ruby).

Parameters

  [in] | old | An old object.
  [in] | oldv | An object previously stored inside of `old`.
  [out] | young | A young object.

Definition at line 615 of file gc.h.