1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

mjit.c: unify the variable name with method name

`RubyVM::MJIT.enabled?`.

It's set to be TRUE even before initialization is finished.
So it was actually not "mjit initialized predicate".

This flag is also used to check whether JIT-ed code should be called
or not, but I'm going to split the responsibility to another flag.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-06-23 13:41:06 +00:00
parent 359dd59db2
commit 06f54f0303
4 changed files with 23 additions and 23 deletions

4
cont.c
View file

@ -378,7 +378,7 @@ cont_free(void *ptr)
#endif
RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr);
if (mjit_init_p && cont->mjit_cont != NULL) {
if (mjit_enabled && cont->mjit_cont != NULL) {
mjit_cont_free(cont->mjit_cont);
}
/* free rb_cont_t or rb_fiber_t */
@ -565,7 +565,7 @@ cont_init(rb_context_t *cont, rb_thread_t *th)
cont->saved_ec.local_storage = NULL;
cont->saved_ec.local_storage_recursive_hash = Qnil;
cont->saved_ec.local_storage_recursive_hash_for_trace = Qnil;
if (mjit_init_p) {
if (mjit_enabled) {
cont->mjit_cont = mjit_cont_new(&cont->saved_ec);
}
}

36
mjit.c
View file

@ -169,8 +169,8 @@ struct rb_mjit_unit_list {
int length; /* the list length */
};
/* TRUE if MJIT is initialized and will be used. */
int mjit_init_p = FALSE;
/* TRUE if MJIT is enabled. */
int mjit_enabled = FALSE;
/* Priority queue of iseqs waiting for JIT compilation.
This variable is a pointer to head unit of the queue. */
@ -422,7 +422,7 @@ CRITICAL_SECTION_FINISH(int level, const char *msg)
void
mjit_gc_start_hook(void)
{
if (!mjit_init_p)
if (!mjit_enabled)
return;
CRITICAL_SECTION_START(4, "mjit_gc_start_hook");
while (in_jit) {
@ -439,7 +439,7 @@ mjit_gc_start_hook(void)
void
mjit_gc_finish_hook(void)
{
if (!mjit_init_p)
if (!mjit_enabled)
return;
CRITICAL_SECTION_START(4, "mjit_gc_finish_hook");
in_gc = FALSE;
@ -453,7 +453,7 @@ mjit_gc_finish_hook(void)
void
mjit_free_iseq(const rb_iseq_t *iseq)
{
if (!mjit_init_p)
if (!mjit_enabled)
return;
CRITICAL_SECTION_START(4, "mjit_free_iseq");
if (iseq->body->jit_unit) {
@ -947,7 +947,7 @@ worker(void)
make_pch();
}
if (pch_status == PCH_FAILED) {
mjit_init_p = FALSE;
mjit_enabled = FALSE;
CRITICAL_SECTION_START(3, "in worker to update worker_stopped");
worker_stopped = TRUE;
verbose(3, "Sending wakeup signal to client in a mjit-worker");
@ -1162,7 +1162,7 @@ mjit_add_iseq_to_process(const rb_iseq_t *iseq)
{
struct rb_mjit_unit_node *node;
if (!mjit_init_p || pch_status == PCH_FAILED)
if (!mjit_enabled || pch_status == PCH_FAILED)
return;
iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
@ -1274,7 +1274,7 @@ static void
child_after_fork(void)
{
verbose(3, "Switching off MJIT in a forked child");
mjit_init_p = FALSE;
mjit_enabled = FALSE;
/* TODO: Should we initiate MJIT in the forked Ruby. */
}
@ -1388,7 +1388,7 @@ start_worker(void)
worker_stopped = FALSE;
if (!rb_thread_create_mjit_thread(child_after_fork, worker)) {
mjit_init_p = FALSE;
mjit_enabled = FALSE;
rb_native_mutex_destroy(&mjit_engine_mutex);
rb_native_cond_destroy(&mjit_pch_wakeup);
rb_native_cond_destroy(&mjit_client_wakeup);
@ -1409,7 +1409,7 @@ mjit_init(struct mjit_options *opts)
VALUE rb_description;
mjit_opts = *opts;
mjit_init_p = TRUE;
mjit_enabled = TRUE;
/* Normalize options */
if (mjit_opts.min_calls == 0)
@ -1431,7 +1431,7 @@ mjit_init(struct mjit_options *opts)
init_header_filename();
pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
if (header_file == NULL || pch_file == NULL) {
mjit_init_p = FALSE;
mjit_enabled = FALSE;
verbose(1, "Failure in MJIT header file name initialization\n");
return;
}
@ -1481,7 +1481,7 @@ stop_worker(void)
VALUE
mjit_pause(void)
{
if (!mjit_init_p) {
if (!mjit_enabled) {
rb_raise(rb_eRuntimeError, "MJIT is not enabled");
}
if (worker_stopped) {
@ -1496,7 +1496,7 @@ mjit_pause(void)
VALUE
mjit_resume(void)
{
if (!mjit_init_p) {
if (!mjit_enabled) {
rb_raise(rb_eRuntimeError, "MJIT is not enabled");
}
if (!worker_stopped) {
@ -1515,7 +1515,7 @@ mjit_resume(void)
void
mjit_finish(void)
{
if (!mjit_init_p)
if (!mjit_enabled)
return;
/* Wait for pch finish */
@ -1553,7 +1553,7 @@ mjit_finish(void)
free_list(&active_units);
finish_conts();
mjit_init_p = FALSE;
mjit_enabled = FALSE;
verbose(1, "Successful MJIT finish");
}
@ -1561,7 +1561,7 @@ void
mjit_mark(void)
{
struct rb_mjit_unit_node *node;
if (!mjit_init_p)
if (!mjit_enabled)
return;
RUBY_MARK_ENTER("mjit");
CRITICAL_SECTION_START(4, "mjit_mark");
@ -1585,7 +1585,7 @@ mjit_mark(void)
void
mjit_add_class_serial(rb_serial_t class_serial)
{
if (!mjit_init_p)
if (!mjit_enabled)
return;
/* Do not wrap CRITICAL_SECTION here. This function is only called in main thread
@ -1597,7 +1597,7 @@ mjit_add_class_serial(rb_serial_t class_serial)
void
mjit_remove_class_serial(rb_serial_t class_serial)
{
if (!mjit_init_p)
if (!mjit_enabled)
return;
CRITICAL_SECTION_START(3, "in mjit_remove_class_serial");

4
mjit.h
View file

@ -53,7 +53,7 @@ typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
RUBY_SYMBOL_EXPORT_BEGIN
extern struct mjit_options mjit_opts;
extern int mjit_init_p;
extern int mjit_enabled;
extern void mjit_add_iseq_to_process(const rb_iseq_t *iseq);
extern mjit_func_t mjit_get_iseq_func(struct rb_iseq_constant_body *body);
@ -94,7 +94,7 @@ mjit_exec(rb_execution_context_t *ec)
long unsigned total_calls;
mjit_func_t func;
if (!mjit_init_p)
if (!mjit_enabled)
return Qundef;
iseq = ec->cfp->iseq;

2
vm.c
View file

@ -2777,7 +2777,7 @@ core_hash_merge_kwd(int argc, VALUE *argv)
static VALUE
mjit_enabled_p(void)
{
return mjit_init_p ? Qtrue : Qfalse;
return mjit_enabled ? Qtrue : Qfalse;
}
extern VALUE mjit_pause(void);