Ruby: transient_heap.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

transient_heap.h
1#ifndef RUBY_TRANSIENT_HEAP_H
2#define RUBY_TRANSIENT_HEAP_H
3/**********************************************************************
4
5 transient_heap.h - declarations of transient_heap related APIs.
6
7 Copyright (C) 2018 Koichi Sasada
8
9**********************************************************************/
10
11#include "internal.h"
12
13#if USE_TRANSIENT_HEAP
14
15/* public API */
16
17/* Allocate req_size bytes from transient_heap.
18 Allocated memories are free-ed when next GC
19 if this memory is not marked by `rb_transient_heap_mark()`.
20 */
21void *rb_transient_heap_alloc(VALUE obj, size_t req_size);
22
23/* If `obj` uses a memory pointed by `ptr` from transient_heap,
24 you need to call `rb_transient_heap_mark(obj, ptr)`
25 to assert liveness of `obj` (and ptr). */
26void rb_transient_heap_mark(VALUE obj, const void *ptr);
27
28/* used by gc.c */
29void rb_transient_heap_promote(VALUE obj);
30void rb_transient_heap_start_marking(int full_marking);
31void rb_transient_heap_finish_marking(void);
32void rb_transient_heap_update_references(void);
33
34/* used by ractor.c */
35void rb_transient_heap_evacuate(void);
36
37/* for debug API */
38void rb_transient_heap_dump(void);
39void rb_transient_heap_verify(void);
40int rb_transient_heap_managed_ptr_p(const void *ptr);
41
42/* evacuate functions for each type */
43void rb_ary_transient_heap_evacuate(VALUE ary, int promote);
44void rb_obj_transient_heap_evacuate(VALUE obj, int promote);
45void rb_hash_transient_heap_evacuate(VALUE hash, int promote);
46void rb_struct_transient_heap_evacuate(VALUE st, int promote);
47
48#else /* USE_TRANSIENT_HEAP */
49
50#define rb_transient_heap_alloc(o, s) NULL
51#define rb_transient_heap_verify() ((void)0)
52#define rb_transient_heap_promote(obj) ((void)0)
53#define rb_transient_heap_start_marking(full_marking) ((void)0)
54#define rb_transient_heap_update_references() ((void)0)
55#define rb_transient_heap_evacuate() ((void)0)
56#define rb_transient_heap_finish_marking() ((void)0)
57#define rb_transient_heap_mark(obj, ptr) ((void)0)
58
59#define rb_ary_transient_heap_evacuate(x, y) ((void)0)
60#define rb_obj_transient_heap_evacuate(x, y) ((void)0)
61#define rb_hash_transient_heap_evacuate(x, y) ((void)0)
62#define rb_struct_transient_heap_evacuate(x, y) ((void)0)
63
64#endif /* USE_TRANSIENT_HEAP */
65#endif
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40