ruby-changes:64673
From: Takashi <ko1@a...>
Date: Wed, 30 Dec 2020 16:05:57 +0900 (JST)
Subject: [ruby-changes:64673] ac2df89113 (master): Stop managing valid class serials
https://git.ruby-lang.org/ruby.git/commit/?id=ac2df89113 From ac2df89113d6ead77032aaa21cf2b0253c8975db Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Tue, 29 Dec 2020 23:01:10 -0800 Subject: Stop managing valid class serials `mjit_valid_class_serial_p` has no longer been used since b9007b6c548. diff --git a/gc.c b/gc.c index 3989a80..f8810d1 100644 --- a/gc.c +++ b/gc.c @@ -2820,7 +2820,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L2820 break; case T_MODULE: case T_CLASS: - mjit_remove_class_serial(RCLASS_SERIAL(obj)); rb_id_table_free(RCLASS_M_TBL(obj)); cc_table_free(objspace, obj, FALSE); if (RCLASS_IV_TBL(obj)) { diff --git a/mjit.c b/mjit.c index d87961d..b98f742 100644 --- a/mjit.c +++ b/mjit.c @@ -521,19 +521,6 @@ init_header_filename(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L521 return true; } -static enum rb_id_table_iterator_result -valid_class_serials_add_i(ID key, VALUE v, void *unused) -{ - rb_const_entry_t *ce = (rb_const_entry_t *)v; - VALUE value = ce->value; - - if (!rb_is_const_id(key)) return ID_TABLE_CONTINUE; - if (RB_TYPE_P(value, T_MODULE) || RB_TYPE_P(value, T_CLASS)) { - mjit_add_class_serial(RCLASS_SERIAL(value)); - } - return ID_TABLE_CONTINUE; -} - #ifdef _WIN32 UINT rb_w32_system_tmpdir(WCHAR *path, UINT len); #endif @@ -738,16 +725,6 @@ mjit_init(const struct mjit_options *opts) https://github.com/ruby/ruby/blob/trunk/mjit.c#L725 // rb_fiber_init_mjit_cont again with mjit_enabled=true to set the root_fiber's mjit_cont. rb_fiber_init_mjit_cont(GET_EC()->fiber_ptr); - // Initialize class_serials cache for compilation - valid_class_serials = rb_hash_new(); - rb_obj_hide(valid_class_serials); - rb_gc_register_mark_object(valid_class_serials); - mjit_add_class_serial(RCLASS_SERIAL(rb_cObject)); - mjit_add_class_serial(RCLASS_SERIAL(CLASS_OF(rb_vm_top_self()))); - if (RCLASS_CONST_TBL(rb_cObject)) { - rb_id_table_foreach(RCLASS_CONST_TBL(rb_cObject), valid_class_serials_add_i, NULL); - } - // Initialize worker thread start_worker(); } @@ -996,28 +973,4 @@ mjit_mark_cc_entries(const struct rb_iseq_constant_body *const body) https://github.com/ruby/ruby/blob/trunk/mjit.c#L973 } } -// A hook to update valid_class_serials. -void -mjit_add_class_serial(rb_serial_t class_serial) -{ - if (!mjit_enabled) - return; - - // Do not wrap CRITICAL_SECTION here. This function is only called in main thread - // and guarded by GVL, and `rb_hash_aset` may cause GC and deadlock in it. - rb_hash_aset(valid_class_serials, LONG2FIX(class_serial), Qtrue); -} - -// A hook to update valid_class_serials. -void -mjit_remove_class_serial(rb_serial_t class_serial) -{ - if (!mjit_enabled) - return; - - CRITICAL_SECTION_START(3, "in mjit_remove_class_serial"); - rb_hash_delete_entry(valid_class_serials, LONG2FIX(class_serial)); - CRITICAL_SECTION_FINISH(3, "in mjit_remove_class_serial"); -} - -#endif +#endif // USE_MJIT diff --git a/mjit.h b/mjit.h index dd23cf7..80138f7 100644 --- a/mjit.h +++ b/mjit.h @@ -101,8 +101,6 @@ extern void mjit_update_references(const rb_iseq_t *iseq); https://github.com/ruby/ruby/blob/trunk/mjit.h#L101 extern void mjit_mark(void); extern struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec); extern void mjit_cont_free(struct mjit_cont *cont); -extern void mjit_add_class_serial(rb_serial_t class_serial); -extern void mjit_remove_class_serial(rb_serial_t class_serial); extern void mjit_mark_cc_entries(const struct rb_iseq_constant_body *const body); // A threshold used to reject long iseqs from JITting as such iseqs @@ -206,8 +204,6 @@ static inline void mjit_gc_start_hook(void){} https://github.com/ruby/ruby/blob/trunk/mjit.h#L204 static inline void mjit_gc_exit_hook(void){} static inline void mjit_free_iseq(const rb_iseq_t *iseq){} static inline void mjit_mark(void){} -static inline void mjit_add_class_serial(rb_serial_t class_serial){} -static inline void mjit_remove_class_serial(rb_serial_t class_serial){} static inline VALUE mjit_exec(rb_execution_context_t *ec) { return Qundef; /* unreachable */ } static inline void mjit_child_after_fork(void){} diff --git a/mjit_worker.c b/mjit_worker.c index ba90cca..ea6b896 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -240,9 +240,6 @@ static bool worker_stopped; https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L240 // Path of "/tmp", which can be changed to $TMP in MinGW. static char *tmp_dir; -// Hash like { 1 => true, 2 => true, ... } whose keys are valid `class_serial`s. -// This is used to invalidate obsoleted CALL_CACHE. -static VALUE valid_class_serials; // Used C compiler path. static const char *cc_path; @@ -488,16 +485,6 @@ real_ms_time(void) https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L485 } #endif -// Return true if class_serial is not obsoleted. This is used by mjit_compile.c. -bool -mjit_valid_class_serial_p(rb_serial_t class_serial) -{ - CRITICAL_SECTION_START(3, "in valid_class_serial_p"); - bool found_p = rb_hash_stlike_lookup(valid_class_serials, LONG2FIX(class_serial), NULL); - CRITICAL_SECTION_FINISH(3, "in valid_class_serial_p"); - return found_p; -} - // Return the best unit from list. The best is the first // high priority unit or the unit whose iseq has the biggest number // of calls so far. diff --git a/vm.c b/vm.c index 696cffb..faea688 100644 --- a/vm.c +++ b/vm.c @@ -366,7 +366,6 @@ rb_serial_t https://github.com/ruby/ruby/blob/trunk/vm.c#L366 rb_next_class_serial(void) { rb_serial_t class_serial = NEXT_CLASS_SERIAL(); - mjit_add_class_serial(class_serial); return class_serial; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/