Ruby: transient_heap.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

transient_heap.h
Go to the documentation of this file.
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
ptr
struct RIMemo * ptr
Definition: debug.c:88
internal.h
rb_transient_heap_finish_marking
#define rb_transient_heap_finish_marking()
Definition: transient_heap.h:56
rb_obj_transient_heap_evacuate
#define rb_obj_transient_heap_evacuate(x, y)
Definition: transient_heap.h:60
rb_transient_heap_promote
#define rb_transient_heap_promote(obj)
Definition: transient_heap.h:52
rb_transient_heap_verify
#define rb_transient_heap_verify()
Definition: transient_heap.h:51
rb_ary_transient_heap_evacuate
#define rb_ary_transient_heap_evacuate(x, y)
Definition: transient_heap.h:59
rb_hash_transient_heap_evacuate
#define rb_hash_transient_heap_evacuate(x, y)
Definition: transient_heap.h:61
rb_struct_transient_heap_evacuate
#define rb_struct_transient_heap_evacuate(x, y)
Definition: transient_heap.h:62
rb_transient_heap_evacuate
#define rb_transient_heap_evacuate()
Definition: transient_heap.h:55
rb_transient_heap_alloc
#define rb_transient_heap_alloc(o, s)
Definition: transient_heap.h:50
rb_transient_heap_mark
#define rb_transient_heap_mark(obj, ptr)
Definition: transient_heap.h:57
rb_transient_heap_update_references
#define rb_transient_heap_update_references()
Definition: transient_heap.h:54
rb_transient_heap_start_marking
#define rb_transient_heap_start_marking(full_marking)
Definition: transient_heap.h:53
VALUE
unsigned long VALUE
Definition: value.h:38