mjit.h: call compiled code immediately
after the first compilation on --jit-wait. Previously the assignment to `func` didn't have meaning for the behavior, and the compiled code wasn't called immediately after the synchronous compilation. It wasn't intentional. Fixing this issue without impacting performance without --jit-wait is not so obvious. Adding branch or goto to call func in mjit_exec spoiled the performance without --jit-wait. Instead of that, I called the func inside mjit_wait_call() (former mjit_get_iseq_func()) which is never inlined to mjit_exec(). Thanks to that, this commit has no impact for normal performance. mjit.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b50955fdb8
commit
e889fad86c
18
mjit.c
18
mjit.c
|
@ -306,8 +306,8 @@ mjit_add_iseq_to_process(const rb_iseq_t *iseq)
|
||||||
|
|
||||||
/* Wait for JIT compilation finish for --jit-wait. This should only return a function pointer
|
/* Wait for JIT compilation finish for --jit-wait. This should only return a function pointer
|
||||||
or NOT_COMPILED_JIT_ISEQ_FUNC. */
|
or NOT_COMPILED_JIT_ISEQ_FUNC. */
|
||||||
mjit_func_t
|
VALUE
|
||||||
mjit_get_iseq_func(struct rb_iseq_constant_body *body)
|
mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
|
@ -316,19 +316,23 @@ mjit_get_iseq_func(struct rb_iseq_constant_body *body)
|
||||||
while (body->jit_func == (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC) {
|
while (body->jit_func == (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC) {
|
||||||
tries++;
|
tries++;
|
||||||
if (tries / 1000 > MJIT_WAIT_TIMEOUT_SECONDS || pch_status == PCH_FAILED) {
|
if (tries / 1000 > MJIT_WAIT_TIMEOUT_SECONDS || pch_status == PCH_FAILED) {
|
||||||
CRITICAL_SECTION_START(3, "in mjit_get_iseq_func to set jit_func");
|
CRITICAL_SECTION_START(3, "in mjit_wait_call to set jit_func");
|
||||||
body->jit_func = (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; /* JIT worker seems dead. Give up. */
|
body->jit_func = (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; /* JIT worker seems dead. Give up. */
|
||||||
CRITICAL_SECTION_FINISH(3, "in mjit_get_iseq_func to set jit_func");
|
CRITICAL_SECTION_FINISH(3, "in mjit_wait_call to set jit_func");
|
||||||
mjit_warning("timed out to wait for JIT finish");
|
mjit_warning("timed out to wait for JIT finish");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRITICAL_SECTION_START(3, "in mjit_get_iseq_func for a client wakeup");
|
CRITICAL_SECTION_START(3, "in mjit_wait_call for a client wakeup");
|
||||||
rb_native_cond_broadcast(&mjit_worker_wakeup);
|
rb_native_cond_broadcast(&mjit_worker_wakeup);
|
||||||
CRITICAL_SECTION_FINISH(3, "in mjit_get_iseq_func for a client wakeup");
|
CRITICAL_SECTION_FINISH(3, "in mjit_wait_call for a client wakeup");
|
||||||
rb_thread_wait_for(tv);
|
rb_thread_wait_for(tv);
|
||||||
}
|
}
|
||||||
return body->jit_func;
|
|
||||||
|
if ((uintptr_t)body->jit_func <= (uintptr_t)LAST_JIT_ISEQ_FUNC) {
|
||||||
|
return Qundef;
|
||||||
|
}
|
||||||
|
return body->jit_func(ec, ec->cfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern VALUE ruby_archlibdir_path, ruby_prefix_path;
|
extern VALUE ruby_archlibdir_path, ruby_prefix_path;
|
||||||
|
|
4
mjit.h
4
mjit.h
|
@ -59,7 +59,7 @@ RUBY_EXTERN struct mjit_options mjit_opts;
|
||||||
RUBY_EXTERN int mjit_call_p;
|
RUBY_EXTERN int mjit_call_p;
|
||||||
|
|
||||||
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 VALUE mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body);
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
||||||
extern int mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *funcname);
|
extern int mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *funcname);
|
||||||
|
@ -110,7 +110,7 @@ mjit_exec(rb_execution_context_t *ec)
|
||||||
if (total_calls == mjit_opts.min_calls && mjit_target_iseq_p(body)) {
|
if (total_calls == mjit_opts.min_calls && mjit_target_iseq_p(body)) {
|
||||||
mjit_add_iseq_to_process(iseq);
|
mjit_add_iseq_to_process(iseq);
|
||||||
if (UNLIKELY(mjit_opts.wait)) {
|
if (UNLIKELY(mjit_opts.wait)) {
|
||||||
func = mjit_get_iseq_func(body);
|
return mjit_wait_call(ec, body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Qundef;
|
return Qundef;
|
||||||
|
|
Loading…
Reference in New Issue