Ruby: gc/mmtk/mmtk.h Source File

Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)

mmtk.h
1#ifndef MMTK_H
2#define MMTK_H
3
4/* Warning, this file is autogenerated by cbindgen from the mmtk-ruby repository. Don't modify this manually. */
5
6#include <stdarg.h>
7#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10#include <stdlib.h>
11
12typedef struct MMTk_Builder MMTk_Builder;
13typedef struct MMTk_Mutator MMTk_Mutator;
14
15typedef struct MMTk_ractor_cache *MMTk_VMThread;
16typedef struct MMTk_ractor_cache *MMTk_VMMutatorThread;
17typedef struct MMTk_GCThreadTLS *MMTk_VMWorkerThread;
18typedef void *MMTk_Address;
19typedef void *MMTk_ObjectReference;
20typedef void *MMTk_NullableObjectReference;
21typedef uint32_t MMTk_AllocationSemantics;
22
23 typedef struct MMTk_BumpPointer {
24 uintptr_t cursor;
25 uintptr_t limit;
26} MMTk_BumpPointer;
27
28
29#define MMTk_OBJREF_OFFSET 8
30
31#define MMTk_MIN_OBJ_ALIGN 8
32
33#define MMTk_GC_THREAD_KIND_WORKER 1
34
35 typedef struct MMTk_RubyBindingOptions {
36 bool ractor_check_mode;
37 size_t suffix_size;
38} MMTk_RubyBindingOptions;
39
40typedef MMTk_ObjectReference (*MMTk_ObjectClosureFunction)(void*, void*, MMTk_ObjectReference, bool);
41
42 typedef struct MMTk_ObjectClosure {
46 MMTk_ObjectClosureFunction c_function;
50 void *rust_closure;
51} MMTk_ObjectClosure;
52
53 typedef struct MMTk_GCThreadTLS {
54 int kind;
55 void *gc_context;
56 struct MMTk_ObjectClosure object_closure;
57} MMTk_GCThreadTLS;
58
59 typedef struct MMTk_RubyUpcalls {
60 void (*init_gc_worker_thread)(struct MMTk_GCThreadTLS *gc_worker_tls);
61 bool (*is_mutator)(void);
62 void (*stop_the_world)(void);
63 void (*resume_mutators)(void);
64 void (*block_for_gc)(MMTk_VMMutatorThread tls);
65 size_t (*number_of_mutators)(void);
66 void (*get_mutators)(void (*visit_mutator)(MMTk_Mutator*, void*), void *data);
67 void (*scan_gc_roots)(void);
68 void (*scan_objspace)(void);
69 void (*scan_object_ruby_style)(MMTk_ObjectReference object);
70 void (*call_gc_mark_children)(MMTk_ObjectReference object);
71 void (*call_obj_free)(MMTk_ObjectReference object);
72 size_t (*vm_live_bytes)(void);
73 void (*update_global_tables)(int tbl_idx);
74 int (*global_tables_count)(void);
75 void (*update_finalizer_table)(void);
76 bool (*special_const_p)(MMTk_ObjectReference object);
77 void (*mutator_thread_panic_handler)(void);
78} MMTk_RubyUpcalls;
79
80 typedef struct MMTk_RawVecOfObjRef {
81 MMTk_ObjectReference *ptr;
82 size_t len;
83 size_t capa;
84} MMTk_RawVecOfObjRef;
85
86bool mmtk_is_live_object(MMTk_ObjectReference object);
87
88bool mmtk_is_reachable(MMTk_ObjectReference object);
89
90MMTk_Builder *mmtk_builder_default(void);
91
92void mmtk_init_binding(MMTk_Builder *builder,
93 const struct MMTk_RubyBindingOptions *_binding_options,
94 const struct MMTk_RubyUpcalls *upcalls,
95 MMTk_ObjectReference weak_reference_dead_value);
96
97void mmtk_initialize_collection(MMTk_VMThread tls);
98
99MMTk_Mutator *mmtk_bind_mutator(MMTk_VMMutatorThread tls);
100
101 MMTk_BumpPointer *mmtk_get_bump_pointer_allocator(MMTk_Mutator *m);
102
103void mmtk_destroy_mutator(MMTk_Mutator *mutator);
104
105void mmtk_handle_user_collection_request(MMTk_VMMutatorThread tls, bool force, bool exhaustive);
106
107void mmtk_set_gc_enabled(bool enable);
108
109bool mmtk_gc_enabled_p(void);
110
111MMTk_Address mmtk_alloc(MMTk_Mutator *mutator,
112 size_t size,
113 size_t align,
114 size_t offset,
115 MMTk_AllocationSemantics semantics);
116
117void mmtk_post_alloc(MMTk_Mutator *mutator,
118 MMTk_ObjectReference refer,
119 size_t bytes,
120 MMTk_AllocationSemantics semantics);
121
122void mmtk_add_obj_free_candidate(MMTk_ObjectReference object);
123
124void mmtk_mark_weak(MMTk_ObjectReference *ptr);
125
126void mmtk_remove_weak(const MMTk_ObjectReference *ptr);
127
128void mmtk_object_reference_write_post(MMTk_Mutator *mutator, MMTk_ObjectReference object);
129
130void mmtk_register_wb_unprotected_object(MMTk_ObjectReference object);
131
132bool mmtk_object_wb_unprotected_p(MMTk_ObjectReference object);
133
134void mmtk_enumerate_objects(void (*callback)(MMTk_ObjectReference, void*), void *data);
135
136struct MMTk_RawVecOfObjRef mmtk_get_all_obj_free_candidates(void);
137
138void mmtk_free_raw_vec_of_obj_ref(struct MMTk_RawVecOfObjRef raw_vec);
139
140void mmtk_before_fork(void);
141
142void mmtk_after_fork(MMTk_VMThread tls);
143
144size_t mmtk_total_bytes(void);
145
146size_t mmtk_used_bytes(void);
147
148size_t mmtk_free_bytes(void);
149
150MMTk_Address mmtk_starting_heap_address(void);
151
152MMTk_Address mmtk_last_heap_address(void);
153
154size_t mmtk_worker_count(void);
155
156const uint8_t *mmtk_plan(void);
157
158const uint8_t *mmtk_heap_mode(void);
159
160size_t mmtk_heap_min(void);
161
162size_t mmtk_heap_max(void);
163
164bool mmtk_is_mmtk_object(MMTk_Address addr);
165
166#endif /* MMTK_H */
stdarg.h
Defines old _.
stdbool.h
C99 shim for <stdbool.h>.
MMTk_BumpPointer
Definition mmtk.h:23
MMTk_GCThreadTLS
Definition mmtk.h:53
MMTk_ObjectClosure
Definition mmtk.h:42
MMTk_ObjectClosure::rust_closure
void * rust_closure
The pointer to the Rust-level closure object.
Definition mmtk.h:50
MMTk_ObjectClosure::c_function
MMTk_ObjectClosureFunction c_function
The function to be called from C.
Definition mmtk.h:46
MMTk_RawVecOfObjRef
Definition mmtk.h:80
MMTk_RubyBindingOptions
Definition mmtk.h:35
MMTk_RubyUpcalls
Definition mmtk.h:59
MMTk_ractor_cache
Definition mmtk.c:46