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:
parent
359dd59db2
commit
06f54f0303
4
cont.c
4
cont.c
@ -378,7 +378,7 @@ cont_free(void *ptr)
|
|||||||
#endif
|
#endif
|
||||||
RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr);
|
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);
|
mjit_cont_free(cont->mjit_cont);
|
||||||
}
|
}
|
||||||
/* free rb_cont_t or rb_fiber_t */
|
/* 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 = NULL;
|
||||||
cont->saved_ec.local_storage_recursive_hash = Qnil;
|
cont->saved_ec.local_storage_recursive_hash = Qnil;
|
||||||
cont->saved_ec.local_storage_recursive_hash_for_trace = 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);
|
cont->mjit_cont = mjit_cont_new(&cont->saved_ec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
mjit.c
36
mjit.c
@ -169,8 +169,8 @@ struct rb_mjit_unit_list {
|
|||||||
int length; /* the list length */
|
int length; /* the list length */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TRUE if MJIT is initialized and will be used. */
|
/* TRUE if MJIT is enabled. */
|
||||||
int mjit_init_p = FALSE;
|
int mjit_enabled = FALSE;
|
||||||
|
|
||||||
/* Priority queue of iseqs waiting for JIT compilation.
|
/* Priority queue of iseqs waiting for JIT compilation.
|
||||||
This variable is a pointer to head unit of the queue. */
|
This variable is a pointer to head unit of the queue. */
|
||||||
@ -422,7 +422,7 @@ CRITICAL_SECTION_FINISH(int level, const char *msg)
|
|||||||
void
|
void
|
||||||
mjit_gc_start_hook(void)
|
mjit_gc_start_hook(void)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return;
|
return;
|
||||||
CRITICAL_SECTION_START(4, "mjit_gc_start_hook");
|
CRITICAL_SECTION_START(4, "mjit_gc_start_hook");
|
||||||
while (in_jit) {
|
while (in_jit) {
|
||||||
@ -439,7 +439,7 @@ mjit_gc_start_hook(void)
|
|||||||
void
|
void
|
||||||
mjit_gc_finish_hook(void)
|
mjit_gc_finish_hook(void)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return;
|
return;
|
||||||
CRITICAL_SECTION_START(4, "mjit_gc_finish_hook");
|
CRITICAL_SECTION_START(4, "mjit_gc_finish_hook");
|
||||||
in_gc = FALSE;
|
in_gc = FALSE;
|
||||||
@ -453,7 +453,7 @@ mjit_gc_finish_hook(void)
|
|||||||
void
|
void
|
||||||
mjit_free_iseq(const rb_iseq_t *iseq)
|
mjit_free_iseq(const rb_iseq_t *iseq)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return;
|
return;
|
||||||
CRITICAL_SECTION_START(4, "mjit_free_iseq");
|
CRITICAL_SECTION_START(4, "mjit_free_iseq");
|
||||||
if (iseq->body->jit_unit) {
|
if (iseq->body->jit_unit) {
|
||||||
@ -947,7 +947,7 @@ worker(void)
|
|||||||
make_pch();
|
make_pch();
|
||||||
}
|
}
|
||||||
if (pch_status == PCH_FAILED) {
|
if (pch_status == PCH_FAILED) {
|
||||||
mjit_init_p = FALSE;
|
mjit_enabled = FALSE;
|
||||||
CRITICAL_SECTION_START(3, "in worker to update worker_stopped");
|
CRITICAL_SECTION_START(3, "in worker to update worker_stopped");
|
||||||
worker_stopped = TRUE;
|
worker_stopped = TRUE;
|
||||||
verbose(3, "Sending wakeup signal to client in a mjit-worker");
|
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;
|
struct rb_mjit_unit_node *node;
|
||||||
|
|
||||||
if (!mjit_init_p || pch_status == PCH_FAILED)
|
if (!mjit_enabled || pch_status == PCH_FAILED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
|
iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
|
||||||
@ -1274,7 +1274,7 @@ static void
|
|||||||
child_after_fork(void)
|
child_after_fork(void)
|
||||||
{
|
{
|
||||||
verbose(3, "Switching off MJIT in a forked child");
|
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. */
|
/* TODO: Should we initiate MJIT in the forked Ruby. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1388,7 +1388,7 @@ start_worker(void)
|
|||||||
worker_stopped = FALSE;
|
worker_stopped = FALSE;
|
||||||
|
|
||||||
if (!rb_thread_create_mjit_thread(child_after_fork, worker)) {
|
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_mutex_destroy(&mjit_engine_mutex);
|
||||||
rb_native_cond_destroy(&mjit_pch_wakeup);
|
rb_native_cond_destroy(&mjit_pch_wakeup);
|
||||||
rb_native_cond_destroy(&mjit_client_wakeup);
|
rb_native_cond_destroy(&mjit_client_wakeup);
|
||||||
@ -1409,7 +1409,7 @@ mjit_init(struct mjit_options *opts)
|
|||||||
VALUE rb_description;
|
VALUE rb_description;
|
||||||
|
|
||||||
mjit_opts = *opts;
|
mjit_opts = *opts;
|
||||||
mjit_init_p = TRUE;
|
mjit_enabled = TRUE;
|
||||||
|
|
||||||
/* Normalize options */
|
/* Normalize options */
|
||||||
if (mjit_opts.min_calls == 0)
|
if (mjit_opts.min_calls == 0)
|
||||||
@ -1431,7 +1431,7 @@ mjit_init(struct mjit_options *opts)
|
|||||||
init_header_filename();
|
init_header_filename();
|
||||||
pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
|
pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
|
||||||
if (header_file == NULL || pch_file == NULL) {
|
if (header_file == NULL || pch_file == NULL) {
|
||||||
mjit_init_p = FALSE;
|
mjit_enabled = FALSE;
|
||||||
verbose(1, "Failure in MJIT header file name initialization\n");
|
verbose(1, "Failure in MJIT header file name initialization\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1481,7 +1481,7 @@ stop_worker(void)
|
|||||||
VALUE
|
VALUE
|
||||||
mjit_pause(void)
|
mjit_pause(void)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p) {
|
if (!mjit_enabled) {
|
||||||
rb_raise(rb_eRuntimeError, "MJIT is not enabled");
|
rb_raise(rb_eRuntimeError, "MJIT is not enabled");
|
||||||
}
|
}
|
||||||
if (worker_stopped) {
|
if (worker_stopped) {
|
||||||
@ -1496,7 +1496,7 @@ mjit_pause(void)
|
|||||||
VALUE
|
VALUE
|
||||||
mjit_resume(void)
|
mjit_resume(void)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p) {
|
if (!mjit_enabled) {
|
||||||
rb_raise(rb_eRuntimeError, "MJIT is not enabled");
|
rb_raise(rb_eRuntimeError, "MJIT is not enabled");
|
||||||
}
|
}
|
||||||
if (!worker_stopped) {
|
if (!worker_stopped) {
|
||||||
@ -1515,7 +1515,7 @@ mjit_resume(void)
|
|||||||
void
|
void
|
||||||
mjit_finish(void)
|
mjit_finish(void)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Wait for pch finish */
|
/* Wait for pch finish */
|
||||||
@ -1553,7 +1553,7 @@ mjit_finish(void)
|
|||||||
free_list(&active_units);
|
free_list(&active_units);
|
||||||
finish_conts();
|
finish_conts();
|
||||||
|
|
||||||
mjit_init_p = FALSE;
|
mjit_enabled = FALSE;
|
||||||
verbose(1, "Successful MJIT finish");
|
verbose(1, "Successful MJIT finish");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1561,7 +1561,7 @@ void
|
|||||||
mjit_mark(void)
|
mjit_mark(void)
|
||||||
{
|
{
|
||||||
struct rb_mjit_unit_node *node;
|
struct rb_mjit_unit_node *node;
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return;
|
return;
|
||||||
RUBY_MARK_ENTER("mjit");
|
RUBY_MARK_ENTER("mjit");
|
||||||
CRITICAL_SECTION_START(4, "mjit_mark");
|
CRITICAL_SECTION_START(4, "mjit_mark");
|
||||||
@ -1585,7 +1585,7 @@ mjit_mark(void)
|
|||||||
void
|
void
|
||||||
mjit_add_class_serial(rb_serial_t class_serial)
|
mjit_add_class_serial(rb_serial_t class_serial)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Do not wrap CRITICAL_SECTION here. This function is only called in main thread
|
/* 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
|
void
|
||||||
mjit_remove_class_serial(rb_serial_t class_serial)
|
mjit_remove_class_serial(rb_serial_t class_serial)
|
||||||
{
|
{
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CRITICAL_SECTION_START(3, "in mjit_remove_class_serial");
|
CRITICAL_SECTION_START(3, "in mjit_remove_class_serial");
|
||||||
|
4
mjit.h
4
mjit.h
@ -53,7 +53,7 @@ typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
|
|||||||
|
|
||||||
RUBY_SYMBOL_EXPORT_BEGIN
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
extern struct mjit_options mjit_opts;
|
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 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);
|
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;
|
long unsigned total_calls;
|
||||||
mjit_func_t func;
|
mjit_func_t func;
|
||||||
|
|
||||||
if (!mjit_init_p)
|
if (!mjit_enabled)
|
||||||
return Qundef;
|
return Qundef;
|
||||||
|
|
||||||
iseq = ec->cfp->iseq;
|
iseq = ec->cfp->iseq;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user