diff options
-rw-r--r-- | common.mk | 1 | ||||
-rw-r--r-- | gc.c | 18 | ||||
-rw-r--r-- | yjit.c | 27 | ||||
-rw-r--r-- | yjit/src/invariants.rs | 4 | ||||
-rw-r--r-- | yjit/src/yjit.rs | 6 |
5 files changed, 21 insertions, 35 deletions
@@ -7503,6 +7503,7 @@ gc.$(OBJEXT): {$(VPATH)}vm_core.h gc.$(OBJEXT): {$(VPATH)}vm_debug.h gc.$(OBJEXT): {$(VPATH)}vm_opts.h gc.$(OBJEXT): {$(VPATH)}vm_sync.h +gc.$(OBJEXT): {$(VPATH)}yjit.h goruby.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h goruby.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h goruby.$(OBJEXT): $(CCAN_DIR)/list/list.h @@ -122,6 +122,7 @@ #include "vm_sync.h" #include "vm_callinfo.h" #include "ractor_core.h" +#include "yjit.h" #include "builtin.h" #include "shape.h" @@ -2474,6 +2475,15 @@ rb_gc_mark_roots(void *objspace, const char **categoryp) MARK_CHECKPOINT("global_tbl"); rb_gc_mark_global_tbl(); +#if USE_YJIT + void rb_yjit_root_mark(void); // in Rust + + if (rb_yjit_enabled_p) { + MARK_CHECKPOINT("YJIT"); + rb_yjit_root_mark(); + } +#endif + MARK_CHECKPOINT("finish"); #undef MARK_CHECKPOINT } @@ -3152,6 +3162,14 @@ rb_gc_update_vm_references(void *objspace) global_symbols.ids = rb_gc_impl_location(objspace, global_symbols.ids); global_symbols.dsymbol_fstr_hash = rb_gc_impl_location(objspace, global_symbols.dsymbol_fstr_hash); gc_update_table_refs(objspace, global_symbols.str_sym); + +#if USE_YJIT + void rb_yjit_root_update_references(void); // in Rust + + if (rb_yjit_enabled_p) { + rb_yjit_root_update_references(); + } +#endif } void @@ -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); -} diff --git a/yjit/src/invariants.rs b/yjit/src/invariants.rs index b1da603b27..98516aa400 100644 --- a/yjit/src/invariants.rs +++ b/yjit/src/invariants.rs @@ -345,7 +345,7 @@ pub extern "C" fn rb_yjit_constant_state_changed(id: ID) { /// Callback for marking GC objects inside [Invariants]. /// See `struct yjijt_root_struct` in C. #[no_mangle] -pub extern "C" fn rb_yjit_root_mark(_: *mut c_void) { +pub extern "C" fn rb_yjit_root_mark() { // Call rb_gc_mark on exit location's raw_samples to // wrap frames in a GC allocated object. This needs to be called // at the same time as root mark. @@ -374,7 +374,7 @@ pub extern "C" fn rb_yjit_root_mark(_: *mut c_void) { } #[no_mangle] -pub extern "C" fn rb_yjit_root_update_references(_: *mut c_void) { +pub extern "C" fn rb_yjit_root_update_references() { if unsafe { INVARIANTS.is_none() } { return; } diff --git a/yjit/src/yjit.rs b/yjit/src/yjit.rs index 5de9d17624..c2647d55f7 100644 --- a/yjit/src/yjit.rs +++ b/yjit/src/yjit.rs @@ -75,12 +75,6 @@ fn yjit_init() { let _ = std::fs::remove_file(&perf_map); println!("YJIT perf map: {perf_map}"); } - - // Initialize the GC hooks. Do this at last as some code depend on Rust initialization. - extern "C" { - fn rb_yjit_init_gc_hooks(); - } - unsafe { rb_yjit_init_gc_hooks() } } /// At the moment, we abort in all cases we panic. |