ruby-changes:69094
From: Aaron <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:48 +0900 (JST)
Subject: [ruby-changes:69094] e8617d0e7e (master): Make sure we can still compile with the JIT disabled
https://git.ruby-lang.org/ruby.git/commit/?id=e8617d0e7e From e8617d0e7ea8039f3757896f547107f51566256b Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Thu, 15 Jul 2021 15:43:39 -0700 Subject: Make sure we can still compile with the JIT disabled If `--disable-jit-support` is passed to configure, then `jit_func` is removed from the iseq body and we can't compile YJIT. This commit detects when the JIT function pointer is gone and disables YJIT in that case. --- yjit.h | 2 ++ yjit_core.c | 3 +++ yjit_iface.c | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/yjit.h b/yjit.h index 0e7a7b6c9b..5d27d4f4a7 100644 --- a/yjit.h +++ b/yjit.h @@ -14,6 +14,8 @@ https://github.com/ruby/ruby/blob/trunk/yjit.h#L14 #define PLATFORM_SUPPORTED_P 1 #endif +#define JIT_ENABLED USE_MJIT + #ifndef YJIT_CHECK_MODE #define YJIT_CHECK_MODE 0 #endif diff --git a/yjit_core.c b/yjit_core.c index 8af35258b2..6e1659ca23 100644 --- a/yjit_core.c +++ b/yjit_core.c @@ -945,7 +945,10 @@ invalidate_block_version(block_t* block) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L945 // Clear out the JIT func so that we can recompile later and so the // interpreter will run the iseq + +#if JIT_ENABLED iseq->body->jit_func = 0; +#endif // TODO: // May want to recompile a new entry point (for interpreter entry blocks) diff --git a/yjit_iface.c b/yjit_iface.c index 0985dd8d53..b6283a26f8 100644 --- a/yjit_iface.c +++ b/yjit_iface.c @@ -453,8 +453,8 @@ typedef VALUE (*yjit_func_t)(rb_execution_context_t *, rb_control_frame_t *); https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L453 bool rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec) { +#if (OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE) && JIT_ENABLED bool success = true; -#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE RB_VM_LOCK_ENTER(); // TODO: I think we need to stop all other ractors here @@ -471,8 +471,10 @@ rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L471 } RB_VM_LOCK_LEAVE(); -#endif return success; +#else + return false; +#endif } struct yjit_block_itr { @@ -1004,7 +1006,7 @@ outgoing_ids(VALUE self) https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L1006 void rb_yjit_init(struct rb_yjit_options *options) { - if (!PLATFORM_SUPPORTED_P) { + if (!PLATFORM_SUPPORTED_P || !JIT_ENABLED) { return; } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/