From 0bff07644ba5aff9c844b6cf75a0e1365c35c6a3 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 8 Aug 2024 12:19:35 -0400 Subject: Make YJIT a GC root rather than an object (#11343) YJIT currently uses the YJIT root object to mark objects during GC and update references during compaction. This object otherwise serves no purpose. This commit changes it YJIT to be step when marking the GC root. This saves some memory from being allocated from the system and the GC. --- yjit.c | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'yjit.c') diff --git a/yjit.c b/yjit.c index 89387875c9..a0af72b3ca 100644 --- a/yjit.c +++ b/yjit.c @@ -1156,24 +1156,6 @@ struct yjit_root_struct { bool unused; // empty structs are not legal in C99 }; -static size_t -yjit_root_memsize(const void *ptr) -{ - // Count off-gc-heap allocation size of the dependency table - return 0; // TODO: more accurate accounting -} - -void rb_yjit_root_mark(void *ptr); // in Rust -void rb_yjit_root_update_references(void *ptr); // in Rust - -// Custom type for interacting with the GC -// TODO: make this write barrier protected -static const rb_data_type_t yjit_root_type = { - "yjit_root", - {rb_yjit_root_mark, RUBY_DEFAULT_FREE, yjit_root_memsize, rb_yjit_root_update_references}, - 0, 0, RUBY_TYPED_FREE_IMMEDIATELY -}; - // For dealing with refinements void rb_yjit_invalidate_all_method_lookup_assumptions(void) @@ -1256,12 +1238,3 @@ VALUE rb_yjit_enable(rb_execution_context_t *ec, VALUE self, VALUE gen_stats, VA // Preprocessed yjit.rb generated during build #include "yjit.rbinc" - -// Initialize the GC hooks -void -rb_yjit_init_gc_hooks(void) -{ - struct yjit_root_struct *root; - VALUE yjit_root = TypedData_Make_Struct(0, struct yjit_root_struct, &yjit_root_type, root); - rb_vm_register_global_object(yjit_root); -} -- cgit v1.2.3