10#include "gc/mmtk/mmtk.h"
12#include "ccan/list/list.h"
16#include <sys/sysctl.h>
25 size_t total_allocated_objects;
31 struct ccan_list_head ractor_caches;
32 unsigned long live_ractor_cache_count;
34 pthread_mutex_t mutex;
37 pthread_cond_t cond_world_stopped;
38 pthread_cond_t cond_world_started;
39 size_t start_the_world_count;
41 struct rb_gc_vm_context vm_context;
43 unsigned int fork_hook_vm_lock_lev;
47 struct ccan_list_node list_node;
49 MMTk_Mutator *mutator;
57 MMTK_FINAL_JOB_FINALIZE,
66 VALUE finalizer_array;
71#ifdef RB_THREAD_LOCAL_SPECIFIER
74# error We currently need language-supported TLS
82 rb_mmtk_gc_thread_tls = gc_thread_tls;
86rb_mmtk_is_mutator(
void)
92rb_mmtk_stop_the_world(
void)
97 if ((err = pthread_mutex_lock(&
objspace->mutex)) != 0) {
98 rb_bug(
"ERROR: cannot lock objspace->mutex: %s", strerror(err));
105 if ((err = pthread_mutex_unlock(&
objspace->mutex)) != 0) {
106 rb_bug(
"ERROR: cannot release objspace->mutex: %s", strerror(err));
111rb_mmtk_resume_mutators(
void)
116 if ((err = pthread_mutex_lock(&
objspace->mutex)) != 0) {
117 rb_bug(
"ERROR: cannot lock objspace->mutex: %s", strerror(err));
122 pthread_cond_broadcast(&
objspace->cond_world_started);
124 if ((err = pthread_mutex_unlock(&
objspace->mutex)) != 0) {
125 rb_bug(
"ERROR: cannot release objspace->mutex: %s", strerror(err));
134 size_t starting_gc_count =
objspace->gc_count;
136 int lock_lev = RB_GC_VM_LOCK();
139 if ((err = pthread_mutex_lock(&
objspace->mutex)) != 0) {
140 rb_bug(
"ERROR: cannot lock objspace->mutex: %s", strerror(err));
143 if (
objspace->gc_count == starting_gc_count) {
146 rb_gc_initialize_vm_context(&
objspace->vm_context);
148 mutator->gc_mutator_p =
true;
152 clock_gettime(CLOCK_MONOTONIC, &gc_start_time);
155 rb_gc_save_machine_context();
161 pthread_cond_broadcast(&
objspace->cond_world_stopped);
170 clock_gettime(CLOCK_MONOTONIC, &gc_end_time);
173 (gc_end_time.tv_sec - gc_start_time.tv_sec) * (1000 * 1000 * 1000) +
174 (gc_end_time.tv_nsec - gc_start_time.tv_nsec);
178 if ((err = pthread_mutex_unlock(&
objspace->mutex)) != 0) {
179 rb_bug(
"ERROR: cannot release objspace->mutex: %s", strerror(err));
181 RB_GC_VM_UNLOCK(lock_lev);
185rb_mmtk_number_of_mutators(
void)
188 return objspace->live_ractor_cache_count;
192rb_mmtk_get_mutators(
void (*visit_mutator)(MMTk_Mutator *mutator,
void *data),
void *data)
197 ccan_list_for_each(&
objspace->ractor_caches, ractor_cache, list_node) {
198 visit_mutator(ractor_cache->mutator, data);
203rb_mmtk_scan_gc_roots(
void)
209 rb_gc_worker_thread_set_vm_context(&
objspace->vm_context);
211 rb_gc_worker_thread_unset_vm_context(&
objspace->vm_context);
215pin_value(st_data_t key, st_data_t value, st_data_t data)
217 rb_gc_impl_mark_and_pin((
void *)data, (
VALUE)value);
223rb_mmtk_scan_objspace(
void)
227 if (
objspace->finalizer_table != NULL) {
232 while (job != NULL) {
234 case MMTK_FINAL_JOB_DFREE:
236 case MMTK_FINAL_JOB_FINALIZE:
237 rb_gc_impl_mark(
objspace, job->as.finalize.finalizer_array);
240 rb_bug(
"rb_mmtk_scan_objspace: unknown final job type %d", job->kind);
248rb_mmtk_scan_object_ruby_style(MMTk_ObjectReference
object)
250 rb_gc_mark_children(rb_gc_get_objspace(), (
VALUE)
object);
254rb_mmtk_call_gc_mark_children(MMTk_ObjectReference
object)
256 rb_gc_mark_children(rb_gc_get_objspace(), (
VALUE)
object);
260rb_mmtk_call_obj_free(MMTk_ObjectReference
object)
266 rb_gc_worker_thread_set_vm_context(&
objspace->vm_context);
268 rb_gc_worker_thread_unset_vm_context(&
objspace->vm_context);
275rb_mmtk_vm_live_bytes(
void)
284 RUBY_ASSERT(mmtk_is_reachable((MMTk_ObjectReference)table));
290 job->next =
objspace->finalizer_jobs;
291 job->kind = MMTK_FINAL_JOB_FINALIZE;
292 job->as.finalize.finalizer_array = table;
298rb_mmtk_update_finalizer_table_i(st_data_t key, st_data_t value, st_data_t data)
301 RUBY_ASSERT(mmtk_is_reachable((MMTk_ObjectReference)value));
306 if (!mmtk_is_reachable((MMTk_ObjectReference)key)) {
318rb_mmtk_update_finalizer_table(
void)
323 st_foreach(
objspace->finalizer_table, rb_mmtk_update_finalizer_table_i, (st_data_t)
objspace);
327rb_mmtk_update_table_i(
VALUE val,
void *data)
329 if (!mmtk_is_reachable((MMTk_ObjectReference)val)) {
337rb_mmtk_global_tables_count(
void)
339 return RB_GC_VM_WEAK_TABLE_COUNT;
343rb_mmtk_update_global_tables(
int table)
347 rb_gc_vm_weak_table_foreach(rb_mmtk_update_table_i, NULL, NULL,
true, (
enum rb_gc_vm_weak_tables)table);
351rb_mmtk_special_const_p(MMTk_ObjectReference
object)
360 rb_mmtk_init_gc_worker_thread,
362 rb_mmtk_stop_the_world,
363 rb_mmtk_resume_mutators,
364 rb_mmtk_block_for_gc,
365 rb_mmtk_number_of_mutators,
366 rb_mmtk_get_mutators,
367 rb_mmtk_scan_gc_roots,
368 rb_mmtk_scan_objspace,
369 rb_mmtk_scan_object_ruby_style,
370 rb_mmtk_call_gc_mark_children,
371 rb_mmtk_call_obj_free,
372 rb_mmtk_vm_live_bytes,
373 rb_mmtk_update_global_tables,
374 rb_mmtk_global_tables_count,
375 rb_mmtk_update_finalizer_table,
376 rb_mmtk_special_const_p,
380#define RB_MMTK_HEAP_LIMIT_PERC 80
381#define RB_MMTK_DEFAULT_HEAP_MIN (1024 * 1024)
382#define RB_MMTK_DEFAULT_HEAP_MAX (rb_mmtk_system_physical_memory() / 100 * RB_MMTK_HEAP_LIMIT_PERC)
385 RB_MMTK_DYNAMIC_HEAP,
390rb_mmtk_builder_init(
void)
392 MMTk_Builder *builder = mmtk_builder_default();
397rb_gc_impl_objspace_alloc(
void)
399 MMTk_Builder *builder = rb_mmtk_builder_init();
400 mmtk_init_binding(builder, NULL, &ruby_upcalls, (MMTk_ObjectReference)
Qundef);
402 return calloc(1,
sizeof(
struct objspace));
405static void gc_run_finalizers(
void *data);
408rb_gc_impl_objspace_init(
void *objspace_ptr)
414 objspace->finalizer_table = st_init_numtable();
417 ccan_list_head_init(&
objspace->ractor_caches);
419 objspace->mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
420 objspace->cond_world_stopped = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
421 objspace->cond_world_started = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
425rb_gc_impl_objspace_free(
void *objspace_ptr)
431rb_gc_impl_ractor_cache_alloc(
void *objspace_ptr,
void *ractor)
434 if (
objspace->live_ractor_cache_count == 0) {
435 mmtk_initialize_collection(ractor);
437 objspace->live_ractor_cache_count++;
440 ccan_list_add(&
objspace->ractor_caches, &cache->list_node);
442 cache->mutator = mmtk_bind_mutator(cache);
448rb_gc_impl_ractor_cache_free(
void *objspace_ptr,
void *cache_ptr)
453 ccan_list_del(&cache->list_node);
456 objspace->live_ractor_cache_count--;
458 mmtk_destroy_mutator(cache->mutator);
461void rb_gc_impl_set_params(
void *objspace_ptr) { }
463static VALUE gc_verify_internal_consistency(
VALUE self) {
return Qnil; }
468 VALUE gc_constants = rb_hash_new();
471 rb_hash_aset(gc_constants,
ID2SYM(rb_intern(
"RVALUE_OVERHEAD")),
INT2NUM(0));
472 rb_hash_aset(gc_constants,
ID2SYM(rb_intern(
"RVARGC_MAX_ALLOCATE_SIZE")),
LONG2FIX(640));
474 rb_hash_aset(gc_constants,
ID2SYM(rb_intern(
"SIZE_POOL_COUNT")),
LONG2FIX(5));
476 rb_define_const(
rb_mGC,
"INTERNAL_CONSTANTS", gc_constants);
488static size_t heap_sizes[6] = {
489 40, 80, 160, 320, 640, 0
493rb_gc_impl_heap_sizes(
void *objspace_ptr)
499rb_mmtk_obj_free_iter_wrapper(
VALUE obj,
void *data)
504 rb_gc_obj_free_vm_weak_references(obj);
515rb_gc_impl_shutdown_free_objects(
void *objspace_ptr)
517 mmtk_set_gc_enabled(
false);
518 each_object(objspace_ptr, rb_mmtk_obj_free_iter_wrapper, objspace_ptr);
519 mmtk_set_gc_enabled(
true);
524rb_gc_impl_start(
void *objspace_ptr,
bool full_mark,
bool immediate_mark,
bool immediate_sweep,
bool compact)
526 mmtk_handle_user_collection_request(rb_gc_get_ractor_newobj_cache(),
true, full_mark);
530rb_gc_impl_during_gc_p(
void *objspace_ptr)
537rb_gc_impl_prepare_heap_i(MMTk_ObjectReference obj,
void *d)
539 rb_gc_prepare_heap_process_object((
VALUE)obj);
543rb_gc_impl_prepare_heap(
void *objspace_ptr)
545 mmtk_enumerate_objects(rb_gc_impl_prepare_heap_i, NULL);
549rb_gc_impl_gc_enable(
void *objspace_ptr)
551 mmtk_set_gc_enabled(
true);
555rb_gc_impl_gc_disable(
void *objspace_ptr,
bool finish_current_gc)
557 mmtk_set_gc_enabled(
false);
561rb_gc_impl_gc_enabled_p(
void *objspace_ptr)
563 return mmtk_gc_enabled_p();
567rb_gc_impl_stress_set(
void *objspace_ptr,
VALUE flag)
575rb_gc_impl_stress_get(
void *objspace_ptr)
583rb_gc_impl_config_get(
void *objspace_ptr)
585 VALUE hash = rb_hash_new();
590 size_t heap_min = mmtk_heap_min();
598rb_gc_impl_config_set(
void *objspace_ptr,
VALUE hash)
606rb_gc_impl_new_obj(
void *objspace_ptr,
void *cache_ptr,
VALUE klass,
VALUE flags,
bool wb_protected,
size_t alloc_size)
608#define MMTK_ALLOCATION_SEMANTICS_DEFAULT 0
612 if (alloc_size > 640) rb_bug(
"too big");
613 for (
int i = 0; i < 5; i++) {
614 if (alloc_size == heap_sizes[i])
break;
615 if (alloc_size < heap_sizes[i]) {
616 alloc_size = heap_sizes[i];
622 mmtk_handle_user_collection_request(ractor_cache,
false,
false);
625 VALUE *alloc_obj = mmtk_alloc(ractor_cache->mutator, alloc_size + 8, MMTk_MIN_OBJ_ALIGN, 0, MMTK_ALLOCATION_SEMANTICS_DEFAULT);
627 alloc_obj[-1] = alloc_size;
628 alloc_obj[0] = flags;
629 alloc_obj[1] = klass;
631 mmtk_post_alloc(ractor_cache->mutator, (
void*)alloc_obj, alloc_size + 8, MMTK_ALLOCATION_SEMANTICS_DEFAULT);
634 mmtk_add_obj_free_candidate(alloc_obj);
636 objspace->total_allocated_objects++;
638 return (
VALUE)alloc_obj;
642rb_gc_impl_obj_slot_size(
VALUE obj)
644 return ((
VALUE *)obj)[-1];
648rb_gc_impl_heap_id_for_size(
void *objspace_ptr,
size_t size)
650 for (
int i = 0; i < 5; i++) {
651 if (size == heap_sizes[i])
return i;
652 if (size < heap_sizes[i])
return i;
655 rb_bug(
"size too big");
659rb_gc_impl_size_allocatable_p(
size_t size)
666rb_gc_impl_malloc(
void *objspace_ptr,
size_t size,
bool gc_allowed)
673rb_gc_impl_calloc(
void *objspace_ptr,
size_t size,
bool gc_allowed)
676 return calloc(1, size);
680rb_gc_impl_realloc(
void *objspace_ptr,
void *ptr,
size_t new_size,
size_t old_size,
bool gc_allowed)
683 return realloc(ptr, new_size);
687rb_gc_impl_free(
void *objspace_ptr,
void *ptr,
size_t old_size)
693void rb_gc_impl_adjust_memory_usage(
void *objspace_ptr, ssize_t diff) { }
697rb_gc_impl_mark(
void *objspace_ptr,
VALUE obj)
702 rb_mmtk_gc_thread_tls->gc_context,
703 (MMTk_ObjectReference)obj,
708rb_gc_impl_mark_and_move(
void *objspace_ptr,
VALUE *ptr)
713 rb_gc_impl_mark(objspace_ptr, *ptr);
717rb_gc_impl_mark_and_pin(
void *objspace_ptr,
VALUE obj)
722 rb_gc_impl_mark(objspace_ptr, obj);
726rb_gc_impl_mark_maybe(
void *objspace_ptr,
VALUE obj)
728 if (rb_gc_impl_pointer_to_heap_p(objspace_ptr, (
const void *)obj)) {
729 rb_gc_impl_mark_and_pin(objspace_ptr, obj);
734rb_gc_impl_mark_weak(
void *objspace_ptr,
VALUE *ptr)
736 mmtk_mark_weak((MMTk_ObjectReference *)ptr);
740rb_gc_impl_remove_weak(
void *objspace_ptr,
VALUE parent_obj,
VALUE *ptr)
742 mmtk_remove_weak((MMTk_ObjectReference *)ptr);
747rb_gc_impl_object_moved_p(
void *objspace_ptr,
VALUE obj)
749 rb_bug(
"unimplemented");
753rb_gc_impl_location(
void *objspace_ptr,
VALUE value)
755 rb_bug(
"unimplemented");
760rb_gc_impl_writebarrier(
void *objspace_ptr,
VALUE a,
VALUE b)
766 mmtk_object_reference_write_post(cache->mutator, (MMTk_ObjectReference)a);
770rb_gc_impl_writebarrier_unprotect(
void *objspace_ptr,
VALUE obj)
772 mmtk_register_wb_unprotected_object((MMTk_ObjectReference)obj);
776rb_gc_impl_writebarrier_remember(
void *objspace_ptr,
VALUE obj)
780 mmtk_object_reference_write_post(cache->mutator, (MMTk_ObjectReference)obj);
785each_objects_i(MMTk_ObjectReference obj,
void *d)
787 rb_darray(
VALUE) *objs = d;
789 rb_darray_append(objs, (
VALUE)obj);
795 rb_darray(
VALUE) objs;
796 rb_darray_make(&objs, 0);
798 mmtk_enumerate_objects(each_objects_i, &objs);
801 rb_darray_foreach(objs, i, obj_ptr) {
802 if (!mmtk_is_mmtk_object((MMTk_ObjectReference)*obj_ptr))
continue;
804 if (func(*obj_ptr, data) != 0) {
809 rb_darray_free(objs);
813 int (*func)(
void *,
void *, size_t,
void *);
818rb_gc_impl_each_objects_i(
VALUE obj,
void *d)
822 size_t slot_size = rb_gc_impl_obj_slot_size(obj);
824 return data->func((
void *)obj, (
void *)(obj + slot_size), slot_size, data->data);
828rb_gc_impl_each_objects(
void *objspace_ptr,
int (*func)(
void *,
void *,
size_t,
void *),
void *data)
835 each_object(objspace_ptr, rb_gc_impl_each_objects_i, &each_objects_data);
839 void (*func)(
VALUE,
void *);
844rb_gc_impl_each_object_i(
VALUE obj,
void *d)
848 data->func(obj, data->data);
854rb_gc_impl_each_object(
void *objspace_ptr,
void (*func)(
VALUE,
void *),
void *data)
861 each_object(objspace_ptr, rb_gc_impl_each_object_i, &each_object_data);
866gc_run_finalizers_get_final(
long i,
void *data)
874gc_run_finalizers(
void *data)
878 rb_gc_set_pending_interrupt();
880 while (
objspace->finalizer_jobs != NULL) {
882 objspace->finalizer_jobs = job->next;
885 case MMTK_FINAL_JOB_DFREE:
886 job->as.dfree.func(job->as.dfree.data);
888 case MMTK_FINAL_JOB_FINALIZE: {
889 VALUE finalizer_array = job->as.finalize.finalizer_array;
891 rb_gc_run_obj_finalizer(
894 gc_run_finalizers_get_final,
895 (
void *)finalizer_array
906 rb_gc_unset_pending_interrupt();
910rb_gc_impl_make_zombie(
void *objspace_ptr,
VALUE obj,
void (*dfree)(
void *),
void *data)
912 if (dfree == NULL)
return;
917 job->kind = MMTK_FINAL_JOB_DFREE;
918 job->as.dfree.func = dfree;
919 job->as.dfree.data = data;
923 job->next =
objspace->finalizer_jobs;
925 }
while (prev != job->next);
927 if (!ruby_free_at_exit_p()) {
933rb_gc_impl_define_finalizer(
void *objspace_ptr,
VALUE obj,
VALUE block)
941 int lev = RB_GC_VM_LOCK();
943 if (st_lookup(
objspace->finalizer_table, obj, &data)) {
951 for (i = 0; i <
len; i++) {
954 RB_GC_VM_UNLOCK(lev);
965 st_add_direct(
objspace->finalizer_table, obj, table);
968 RB_GC_VM_UNLOCK(lev);
974rb_gc_impl_undefine_finalizer(
void *objspace_ptr,
VALUE obj)
978 st_data_t data = obj;
980 int lev = RB_GC_VM_LOCK();
981 st_delete(
objspace->finalizer_table, &data, 0);
982 RB_GC_VM_UNLOCK(lev);
988rb_gc_impl_copy_finalizer(
void *objspace_ptr,
VALUE dest,
VALUE obj)
996 int lev = RB_GC_VM_LOCK();
997 if (RB_LIKELY(st_lookup(
objspace->finalizer_table, obj, &data))) {
1000 st_insert(
objspace->finalizer_table, dest, table);
1004 rb_bug(
"rb_gc_copy_finalizer: FL_FINALIZE set but not found in finalizer_table: %s", rb_obj_info(obj));
1006 RB_GC_VM_UNLOCK(lev);
1010move_finalizer_from_table_i(st_data_t key, st_data_t val, st_data_t arg)
1020rb_gc_impl_shutdown_call_finalizer(
void *objspace_ptr)
1024 while (
objspace->finalizer_table->num_entries) {
1025 st_foreach(
objspace->finalizer_table, move_finalizer_from_table_i, (st_data_t)
objspace);
1030 unsigned int lev = RB_GC_VM_LOCK();
1033 for (
size_t i = 0; i < registered_candidates.len; i++) {
1034 VALUE obj = (
VALUE)registered_candidates.ptr[i];
1036 if (rb_gc_shutdown_call_finalizer_p(obj)) {
1037 rb_gc_obj_free(objspace_ptr, obj);
1041 mmtk_free_raw_vec_of_obj_ref(registered_candidates);
1043 RB_GC_VM_UNLOCK(lev);
1051rb_gc_impl_before_fork(
void *objspace_ptr)
1056 objspace->fork_hook_vm_lock_lev = RB_GC_VM_LOCK();
1070 if (mutator_blocking_count != 0) {
1071 RB_GC_VM_UNLOCK(
objspace->fork_hook_vm_lock_lev);
1079rb_gc_impl_after_fork(
void *objspace_ptr, rb_pid_t pid)
1083 mmtk_after_fork(rb_gc_get_ractor_newobj_cache());
1085 RB_GC_VM_UNLOCK(
objspace->fork_hook_vm_lock_lev);
1091rb_gc_impl_set_measure_total_time(
void *objspace_ptr,
VALUE flag)
1099rb_gc_impl_get_measure_total_time(
void *objspace_ptr)
1107rb_gc_impl_get_total_time(
void *objspace_ptr)
1115rb_gc_impl_gc_count(
void *objspace_ptr)
1123rb_gc_impl_latest_gc_info(
void *objspace_ptr,
VALUE hash_or_key)
1134 rb_bug(
"gc_info_decode: non-hash or symbol given");
1137#define SET(name, attr) \
1138 if (key == ID2SYM(rb_intern_const(#name))) \
1140 else if (hash != Qnil) \
1141 rb_hash_aset(hash, ID2SYM(rb_intern_const(#name)), (attr));
1159 gc_stat_sym_total_allocated_objects,
1160 gc_stat_sym_total_bytes,
1161 gc_stat_sym_used_bytes,
1162 gc_stat_sym_free_bytes,
1163 gc_stat_sym_starting_heap_address,
1164 gc_stat_sym_last_heap_address,
1168static VALUE gc_stat_symbols[gc_stat_sym_last];
1171setup_gc_stat_symbols(
void)
1173 if (gc_stat_symbols[0] == 0) {
1174#define S(s) gc_stat_symbols[gc_stat_sym_##s] = ID2SYM(rb_intern_const(#s))
1177 S(total_allocated_objects);
1181 S(starting_heap_address);
1182 S(last_heap_address);
1187rb_gc_impl_stat(
void *objspace_ptr,
VALUE hash_or_sym)
1192 setup_gc_stat_symbols();
1201 rb_bug(
"non-hash or symbol given");
1204#define SET(name, attr) \
1205 if (key == gc_stat_symbols[gc_stat_sym_##name]) \
1206 return SIZET2NUM(attr); \
1207 else if (hash != Qnil) \
1208 rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
1211 SET(time,
objspace->total_gc_time / (1000 * 1000));
1212 SET(total_allocated_objects,
objspace->total_allocated_objects);
1213 SET(total_bytes, mmtk_total_bytes());
1214 SET(used_bytes, mmtk_used_bytes());
1215 SET(free_bytes, mmtk_free_bytes());
1216 SET(starting_heap_address, (
size_t)mmtk_starting_heap_address());
1217 SET(last_heap_address, (
size_t)mmtk_last_heap_address());
1229rb_gc_impl_stat_heap(
void *objspace_ptr,
VALUE heap_name,
VALUE hash_or_sym)
1241#define RB_GC_OBJECT_METADATA_ENTRY_COUNT 1
1245rb_gc_impl_object_metadata(
void *objspace_ptr,
VALUE obj)
1247 static ID ID_object_id;
1249 if (!ID_object_id) {
1250#define I(s) ID_##s = rb_intern(#s);
1257#define SET_ENTRY(na, v) do { \
1258 RUBY_ASSERT(n <= RB_GC_OBJECT_METADATA_ENTRY_COUNT); \
1259 object_metadata_entries[n].name = ID_##na; \
1260 object_metadata_entries[n].val = v; \
1264 if (rb_obj_id_p(obj)) SET_ENTRY(object_id, rb_obj_id(obj));
1266 object_metadata_entries[n].name = 0;
1267 object_metadata_entries[n].val = 0;
1269 return object_metadata_entries;
1273rb_gc_impl_pointer_to_heap_p(
void *objspace_ptr,
const void *ptr)
1275 if (ptr == NULL)
return false;
1276 if ((uintptr_t)ptr %
sizeof(
void*) != 0)
return false;
1277 return mmtk_is_mmtk_object((MMTk_Address)ptr);
1281rb_gc_impl_garbage_object_p(
void *objspace_ptr,
VALUE obj)
1286void rb_gc_impl_set_event_hook(
void *objspace_ptr,
const rb_event_flag_t event) { }
1289rb_gc_impl_copy_attributes(
void *objspace_ptr,
VALUE dest,
VALUE obj)
1291 if (mmtk_object_wb_unprotected_p((MMTk_ObjectReference)obj)) {
1292 rb_gc_impl_writebarrier_unprotect(objspace_ptr, dest);
1295 rb_gc_impl_copy_finalizer(objspace_ptr, dest, obj);
1301rb_gc_impl_active_gc_name(
void)
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
#define RUBY_ATOMIC_INC(var)
Atomically increments the value pointed by var.
#define RUBY_ATOMIC_PTR_CAS(var, oldval, newval)
Identical to RUBY_ATOMIC_CAS, except it expects its arguments are void*.
std::atomic< unsigned > rb_atomic_t
Type that is eligible for atomic operations.
#define RUBY_ATOMIC_DEC(var)
Atomically decrements the value pointed by var.
#define RUBY_ATOMIC_LOAD(var)
Atomic load.
#define rb_define_singleton_method(klass, mid, func, arity)
Defines klass.mid.
unsigned int rb_postponed_job_handle_t
The type of a handle returned from rb_postponed_job_preregister and passed to rb_postponed_job_trigge...
void rb_postponed_job_trigger(rb_postponed_job_handle_t h)
Triggers a pre-registered job registered with rb_postponed_job_preregister, scheduling it for executi...
rb_postponed_job_handle_t rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, void *data)
Pre-registers a func in Ruby's postponed job preregistration table, returning an opaque handle which ...
#define RUBY_INTERNAL_EVENT_FREEOBJ
Object swept.
#define RUBY_INTERNAL_EVENT_GC_START
GC started.
uint32_t rb_event_flag_t
Represents event(s).
static VALUE RB_FL_TEST(VALUE obj, VALUE flags)
Tests if the given flag(s) are set or not.
static void RB_FL_UNSET(VALUE obj, VALUE flags)
Clears the given flag(s).
@ RUBY_FL_FINALIZE
This flag has something to do with finalisers.
#define xfree
Old name of ruby_xfree.
#define Qundef
Old name of RUBY_Qundef.
#define ID2SYM
Old name of RB_ID2SYM.
#define SPECIAL_CONST_P
Old name of RB_SPECIAL_CONST_P.
#define OBJ_FREEZE
Old name of RB_OBJ_FREEZE.
#define T_NONE
Old name of RUBY_T_NONE.
#define SIZET2NUM
Old name of RB_SIZE2NUM.
#define xmalloc
Old name of ruby_xmalloc.
#define LONG2FIX
Old name of RB_INT2FIX.
#define FL_FINALIZE
Old name of RUBY_FL_FINALIZE.
#define T_HASH
Old name of RUBY_T_HASH.
#define FL_SET
Old name of RB_FL_SET.
#define rb_ary_new3
Old name of rb_ary_new_from_args.
#define Qtrue
Old name of RUBY_Qtrue.
#define INT2NUM
Old name of RB_INT2NUM.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
#define NIL_P
Old name of RB_NIL_P.
#define FL_TEST
Old name of RB_FL_TEST.
#define FL_UNSET
Old name of RB_FL_UNSET.
#define SYMBOL_P
Old name of RB_SYMBOL_P.
VALUE rb_obj_hide(VALUE obj)
Make the object invisible from Ruby code.
VALUE rb_equal(VALUE lhs, VALUE rhs)
This function is an optimised version of calling #==.
VALUE rb_ary_dup(VALUE ary)
Duplicates an array.
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
#define rb_str_new_cstr(str)
Identical to rb_str_new, except it assumes the passed pointer is a pointer to a C string.
VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker)
Raises rb_eNotImpError.
static ID rb_intern_const(const char *str)
This is a "tiny optimisation" over rb_intern().
int len
Length of the buffer.
#define RB_ULONG2NUM
Just another name of rb_ulong2num_inline.
#define RB_GC_GUARD(v)
Prevents premature destruction of local objects.
#define RARRAY_LEN
Just another name of rb_array_len.
static void RARRAY_ASET(VALUE ary, long i, VALUE v)
Assigns an object in an array.
#define RARRAY_AREF(a, i)
#define RBASIC(obj)
Convenient casting macro.
int ruby_native_thread_p(void)
Queries if the thread which calls this function is a ruby's thread.
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
#define RTEST
This is an old name of RB_TEST.
void * rust_closure
The pointer to the Rust-level closure object.
MMTk_ObjectClosureFunction c_function
The function to be called from C.
Ruby object's base components.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.
static enum ruby_value_type RB_BUILTIN_TYPE(VALUE obj)
Queries the type of the object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.