Ruby  3.3.0dev (2023-07-13 revision 76ef28186f5c470ef18c7a661f9c7a5d4dc696ea)
transient_heap.h (76ef28186f5c470ef18c7a661f9c7a5d4dc696ea)
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  */
21 void *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). */
26 void rb_transient_heap_mark(VALUE obj, const void *ptr);
27 
28 /* used by gc.c */
29 void rb_transient_heap_promote(VALUE obj);
30 void rb_transient_heap_start_marking(int full_marking);
31 void rb_transient_heap_finish_marking(void);
32 void rb_transient_heap_update_references(void);
33 
34 /* used by ractor.c */
35 void rb_transient_heap_evacuate(void);
36 
37 /* for debug API */
38 void rb_transient_heap_dump(void);
39 void rb_transient_heap_verify(void);
40 int rb_transient_heap_managed_ptr_p(const void *ptr);
41 
42 /* evacuate functions for each type */
43 void rb_ary_transient_heap_evacuate(VALUE ary, int promote);
44 void rb_obj_transient_heap_evacuate(VALUE obj, int promote);
45 void rb_struct_transient_heap_evacuate(VALUE st, int promote);
46 
47 #else /* USE_TRANSIENT_HEAP */
48 
49 #define rb_transient_heap_alloc(o, s) NULL
50 #define rb_transient_heap_verify() ((void)0)
51 #define rb_transient_heap_promote(obj) ((void)0)
52 #define rb_transient_heap_start_marking(full_marking) ((void)0)
53 #define rb_transient_heap_update_references() ((void)0)
54 #define rb_transient_heap_evacuate() ((void)0)
55 #define rb_transient_heap_finish_marking() ((void)0)
56 #define rb_transient_heap_mark(obj, ptr) ((void)0)
57 
58 #define rb_ary_transient_heap_evacuate(x, y) ((void)0)
59 #define rb_obj_transient_heap_evacuate(x, y) ((void)0)
60 #define rb_struct_transient_heap_evacuate(x, y) ((void)0)
61 
62 #endif /* USE_TRANSIENT_HEAP */
63 #endif
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
Definition: io.h:2
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40