Stop managing valid class serials

`mjit_valid_class_serial_p` has no longer been used since b9007b6c54.
This commit is contained in:
Takashi Kokubun 2020-12-29 23:01:10 -08:00
Родитель 11b8bb99e6
Коммит ac2df89113
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 6FFC433B12EE23DD
5 изменённых файлов: 1 добавлений и 67 удалений

1
gc.c
Просмотреть файл

@ -2820,7 +2820,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
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)) {

49
mjit.c
Просмотреть файл

@ -521,19 +521,6 @@ init_header_filename(void)
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)
// 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)
}
}
// 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

4
mjit.h
Просмотреть файл

@ -101,8 +101,6 @@ extern void mjit_update_references(const rb_iseq_t *iseq);
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){}
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){}

Просмотреть файл

@ -240,9 +240,6 @@ static bool worker_stopped;
// 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)
}
#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.

1
vm.c
Просмотреть файл

@ -366,7 +366,6 @@ rb_serial_t
rb_next_class_serial(void)
{
rb_serial_t class_serial = NEXT_CLASS_SERIAL();
mjit_add_class_serial(class_serial);
return class_serial;
}