Ruby: gc/mmtk/mmtk.h Source File

Ruby 3.4.4p34 (2025-05-14 revision a38531fd3f617bf734ef7d6c595325f69985ea1d)

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
24#define MMTk_OBJREF_OFFSET 8
25
26#define MMTk_MIN_OBJ_ALIGN 8
27
28#define MMTk_GC_THREAD_KIND_WORKER 1
29
30 typedef struct MMTk_RubyBindingOptions {
31 bool ractor_check_mode;
32 size_t suffix_size;
33} MMTk_RubyBindingOptions;
34
35typedef MMTk_ObjectReference (*MMTk_ObjectClosureFunction)(void*, void*, MMTk_ObjectReference, bool);
36
37 typedef struct MMTk_ObjectClosure {
41 MMTk_ObjectClosureFunction c_function;
45 void *rust_closure;
46} MMTk_ObjectClosure;
47
48 typedef struct MMTk_GCThreadTLS {
49 int kind;
50 void *gc_context;
51 struct MMTk_ObjectClosure object_closure;
52} MMTk_GCThreadTLS;
53
54 typedef struct MMTk_RubyUpcalls {
55 void (*init_gc_worker_thread)(struct MMTk_GCThreadTLS *gc_worker_tls);
56 bool (*is_mutator)(void);
57 void (*stop_the_world)(void);
58 void (*resume_mutators)(void);
59 void (*block_for_gc)(MMTk_VMMutatorThread tls);
60 size_t (*number_of_mutators)(void);
61 void (*get_mutators)(void (*visit_mutator)(MMTk_Mutator*, void*), void *data);
62 void (*scan_gc_roots)(void);
63 void (*scan_objspace)(void);
64 void (*scan_roots_in_mutator_thread)(MMTk_VMMutatorThread mutator_tls,
65 MMTk_VMWorkerThread worker_tls);
66 void (*scan_object_ruby_style)(MMTk_ObjectReference object);
67 void (*call_gc_mark_children)(MMTk_ObjectReference object);
68 void (*call_obj_free)(MMTk_ObjectReference object);
69 size_t (*vm_live_bytes)(void);
70 void (*update_global_tables)(int tbl_idx);
71 int (*global_tables_count)(void);
72 void (*update_finalizer_table)(void);
73 void (*update_obj_id_tables)(void);
74} MMTk_RubyUpcalls;
75
76 typedef struct MMTk_RawVecOfObjRef {
77 MMTk_ObjectReference *ptr;
78 size_t len;
79 size_t capa;
80} MMTk_RawVecOfObjRef;
81
82bool mmtk_is_live_object(MMTk_ObjectReference object);
83
84bool mmtk_is_reachable(MMTk_ObjectReference object);
85
86MMTk_Builder *mmtk_builder_default(void);
87
88void mmtk_init_binding(MMTk_Builder *builder,
89 const struct MMTk_RubyBindingOptions *_binding_options,
90 const struct MMTk_RubyUpcalls *upcalls,
91 MMTk_ObjectReference weak_reference_dead_value);
92
93void mmtk_initialize_collection(MMTk_VMThread tls);
94
95MMTk_Mutator *mmtk_bind_mutator(MMTk_VMMutatorThread tls);
96
97void mmtk_destroy_mutator(MMTk_Mutator *mutator);
98
99void mmtk_handle_user_collection_request(MMTk_VMMutatorThread tls);
100
101void mmtk_set_gc_enabled(bool enable);
102
103bool mmtk_gc_enabled_p(void);
104
105MMTk_Address mmtk_alloc(MMTk_Mutator *mutator,
106 size_t size,
107 size_t align,
108 size_t offset,
109 MMTk_AllocationSemantics semantics);
110
111void mmtk_post_alloc(MMTk_Mutator *mutator,
112 MMTk_ObjectReference refer,
113 size_t bytes,
114 MMTk_AllocationSemantics semantics);
115
116void mmtk_add_obj_free_candidate(MMTk_ObjectReference object);
117
118void mmtk_mark_weak(MMTk_ObjectReference *ptr);
119
120void mmtk_remove_weak(const MMTk_ObjectReference *ptr);
121
122void mmtk_object_reference_write_post(MMTk_Mutator *mutator, MMTk_ObjectReference object);
123
124void mmtk_register_wb_unprotected_object(MMTk_ObjectReference object);
125
126bool mmtk_object_wb_unprotected_p(MMTk_ObjectReference object);
127
128void mmtk_enumerate_objects(void (*callback)(MMTk_ObjectReference, void*), void *data);
129
130struct MMTk_RawVecOfObjRef mmtk_get_all_obj_free_candidates(void);
131
132void mmtk_free_raw_vec_of_obj_ref(struct MMTk_RawVecOfObjRef raw_vec);
133
134void mmtk_before_fork(void);
135
136void mmtk_after_fork(MMTk_VMThread tls);
137
138size_t mmtk_total_bytes(void);
139
140size_t mmtk_used_bytes(void);
141
142size_t mmtk_free_bytes(void);
143
144MMTk_Address mmtk_starting_heap_address(void);
145
146MMTk_Address mmtk_last_heap_address(void);
147
148bool mmtk_is_mmtk_object(MMTk_Address addr);
149
150#endif /* MMTK_H */
stdarg.h
Defines old _.
stdbool.h
C99 shim for <stdbool.h>
MMTk_GCThreadTLS
Definition mmtk.h:48
MMTk_ObjectClosure
Definition mmtk.h:37
MMTk_ObjectClosure::rust_closure
void * rust_closure
The pointer to the Rust-level closure object.
Definition mmtk.h:45
MMTk_ObjectClosure::c_function
MMTk_ObjectClosureFunction c_function
The function to be called from C.
Definition mmtk.h:41
MMTk_RawVecOfObjRef
Definition mmtk.h:76
MMTk_RubyBindingOptions
Definition mmtk.h:30
MMTk_RubyUpcalls
Definition mmtk.h:54
MMTk_ractor_cache
Definition mmtk.c:47