Ruby  3.4.0dev (2024-11-26 revision 6b4f8945d600168bf530d21395da8293fbd5e8ba)
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 
12 typedef struct MMTk_Builder MMTk_Builder;
13 typedef struct MMTk_Mutator MMTk_Mutator;
14 
15 typedef struct MMTk_ractor_cache *MMTk_VMThread;
18 typedef void *MMTk_Address;
19 typedef void *MMTk_ObjectReference;
20 typedef void *MMTk_NullableObjectReference;
21 typedef 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;
34 
35 typedef MMTk_ObjectReference (*MMTk_ObjectClosureFunction)(void*, void*, MMTk_ObjectReference, bool);
36 
37 typedef struct MMTk_ObjectClosure {
41  MMTk_ObjectClosureFunction c_function;
45  void *rust_closure;
47 
48 typedef struct MMTk_GCThreadTLS {
49  int kind;
50  void *gc_context;
51  struct MMTk_ObjectClosure object_closure;
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);
75 
76 typedef struct MMTk_RawVecOfObjRef {
77  MMTk_ObjectReference *ptr;
78  size_t len;
79  size_t capa;
81 
82 bool mmtk_is_live_object(MMTk_ObjectReference object);
83 
84 bool mmtk_is_reachable(MMTk_ObjectReference object);
85 
86 MMTk_Builder *mmtk_builder_default(void);
87 
88 void 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 
93 void mmtk_initialize_collection(MMTk_VMThread tls);
94 
95 MMTk_Mutator *mmtk_bind_mutator(MMTk_VMMutatorThread tls);
96 
97 void mmtk_destroy_mutator(MMTk_Mutator *mutator);
98 
99 void mmtk_handle_user_collection_request(MMTk_VMMutatorThread tls);
100 
101 void mmtk_set_gc_enabled(bool enable);
102 
103 bool mmtk_gc_enabled_p(void);
104 
105 MMTk_Address mmtk_alloc(MMTk_Mutator *mutator,
106  size_t size,
107  size_t align,
108  size_t offset,
109  MMTk_AllocationSemantics semantics);
110 
111 void mmtk_post_alloc(MMTk_Mutator *mutator,
112  MMTk_ObjectReference refer,
113  size_t bytes,
114  MMTk_AllocationSemantics semantics);
115 
116 void mmtk_add_obj_free_candidate(MMTk_ObjectReference object);
117 
118 void mmtk_mark_weak(MMTk_ObjectReference *ptr);
119 
120 void mmtk_remove_weak(const MMTk_ObjectReference *ptr);
121 
122 void mmtk_object_reference_write_post(MMTk_Mutator *mutator, MMTk_ObjectReference object);
123 
124 void mmtk_register_wb_unprotected_object(MMTk_ObjectReference object);
125 
126 bool mmtk_object_wb_unprotected_p(MMTk_ObjectReference object);
127 
128 void mmtk_enumerate_objects(void (*callback)(MMTk_ObjectReference, void*), void *data);
129 
130 struct MMTk_RawVecOfObjRef mmtk_get_all_obj_free_candidates(void);
131 
132 void mmtk_free_raw_vec_of_obj_ref(struct MMTk_RawVecOfObjRef raw_vec);
133 
134 void mmtk_before_fork(void);
135 
136 void mmtk_after_fork(MMTk_VMThread tls);
137 
138 size_t mmtk_total_bytes(void);
139 
140 size_t mmtk_used_bytes(void);
141 
142 size_t mmtk_free_bytes(void);
143 
144 MMTk_Address mmtk_starting_heap_address(void);
145 
146 MMTk_Address mmtk_last_heap_address(void);
147 
148 bool mmtk_is_mmtk_object(MMTk_Address addr);
149 
150 #endif /* MMTK_H */
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
Definition: io.h:2
Defines old _.
C99 shim for <stdbool.h>
void * rust_closure
The pointer to the Rust-level closure object.
Definition: mmtk.h:45
MMTk_ObjectClosureFunction c_function
The function to be called from C.
Definition: mmtk.h:41