summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-12-06 21:27:46 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2022-12-06 21:36:58 -0800
commite6b63b382c30cb665d24853f745586a157ae58f3 (patch)
treeb5e32f5aac0760b86c9cdf3a2fbb5a9ca42814b2 /vm.c
parent8684904cb418df3f6d15ea0b0ad5c7c357d7ef06 (diff)
downloadruby-e6b63b382c30cb665d24853f745586a157ae58f3.tar.gz
MJIT: Refactor the jit_func enum for MJIT
All values should have a MJIT_ prefix. We could address the warning for the end mark if we just define the macro for the check next to the enum. It even simplifies some code for checking the enum.
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/vm.c b/vm.c
index b2fca12b74..3181f97123 100644
--- a/vm.c
+++ b/vm.c
@@ -388,19 +388,18 @@ static VALUE
mjit_check_iseq(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body)
{
uintptr_t func_i = (uintptr_t)(body->jit_func);
- ASSUME(func_i <= LAST_JIT_ISEQ_FUNC);
- switch ((enum rb_mjit_iseq_func)func_i) {
- case NOT_ADDED_JIT_ISEQ_FUNC:
+ ASSUME(MJIT_FUNC_STATE_P(func_i));
+ switch ((enum rb_mjit_func_state)func_i) {
+ case MJIT_FUNC_NOT_QUEUED:
if (body->total_calls == mjit_opts.call_threshold) {
rb_mjit_add_iseq_to_process(iseq);
- if (UNLIKELY(mjit_opts.wait && (uintptr_t)body->jit_func > LAST_JIT_ISEQ_FUNC)) {
+ if (UNLIKELY(mjit_opts.wait && !MJIT_FUNC_STATE_P(body->jit_func))) {
return body->jit_func(ec, ec->cfp);
}
}
break;
- case NOT_READY_JIT_ISEQ_FUNC:
- case NOT_COMPILED_JIT_ISEQ_FUNC:
- default: // to avoid warning with LAST_JIT_ISEQ_FUNC
+ case MJIT_FUNC_COMPILING:
+ case MJIT_FUNC_FAILED:
break;
}
return Qundef;
@@ -439,7 +438,7 @@ jit_exec(rb_execution_context_t *ec)
return Qundef;
}
}
- else if (UNLIKELY((uintptr_t)(func = body->jit_func) <= LAST_JIT_ISEQ_FUNC)) {
+ else if (UNLIKELY(MJIT_FUNC_STATE_P(func = body->jit_func))) {
return mjit_check_iseq(ec, iseq, body);
}