summaryrefslogtreecommitdiff
path: root/yjit.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-10-25 10:45:22 -0400
committerGitHub <noreply@github.com>2021-10-25 10:45:22 -0400
commit244c98e635a01cc7cfde9e24ed4b44413e6c3e75 (patch)
treef9e8a1fe841d1e4222d36bb42e58c06c5022aa2f /yjit.c
parente943511455acfd70dc3bd085038969a11802d688 (diff)
Strip out YJIT at build time when unsupported or disabled (#5003)
In an effort to minimize build issues on non x64 platforms, we can decide at build time to not build the bulk of YJIT. This should fix obscure build errors like this one on riscv64: yjit_asm.c:137:(.text+0x3fa): relocation truncated to fit: R_RISCV_PCREL_HI20 against `alloc_exec_mem' We also don't need to bulid YJIT on `--disable-jit-support` builds. One wrinkle to this is that the YJIT Ruby module will not be defined when YJIT is stripped from the build. I think that's a fair change as it's only meant to be used for YJIT development.
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'yjit.c')
-rw-r--r--yjit.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/yjit.c b/yjit.c
index bfe79822f0..a0ac959d4f 100644
--- a/yjit.c
+++ b/yjit.c
@@ -10,8 +10,6 @@
#include "vm_sync.h"
#include "yjit.h"
-#include "yjit_asm.c"
-
#ifndef YJIT_CHECK_MODE
# define YJIT_CHECK_MODE 0
#endif
@@ -31,6 +29,11 @@
// USE_MJIT comes from configure options
#define JIT_ENABLED USE_MJIT
+// Check if we need to include YJIT in the build
+#if JIT_ENABLED && PLATFORM_SUPPORTED_P
+
+#include "yjit_asm.c"
+
// Code block into which we write machine code
static codeblock_t block;
static codeblock_t *cb = NULL;
@@ -154,3 +157,31 @@ static uint32_t yjit_codepage_frozen_bytes = 0;
#include "yjit_core.c"
#include "yjit_iface.c"
#include "yjit_codegen.c"
+
+#else
+// !JIT_ENABLED || !PLATFORM_SUPPORTED_P
+// In these builds, YJIT could never be turned on. Provide dummy
+// implementations for YJIT functions exposed to the rest of the code base.
+// See yjit.h.
+
+void Init_builtin_yjit(void) {}
+bool rb_yjit_enabled_p(void) { return false; }
+unsigned rb_yjit_call_threshold(void) { return UINT_MAX; }
+void rb_yjit_invalidate_all_method_lookup_assumptions(void) {};
+void rb_yjit_method_lookup_change(VALUE klass, ID mid) {};
+void rb_yjit_cme_invalidate(VALUE cme) {}
+void rb_yjit_collect_vm_usage_insn(int insn) {}
+void rb_yjit_collect_binding_alloc(void) {}
+void rb_yjit_collect_binding_set(void) {}
+bool rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec) { return false; }
+void rb_yjit_init(struct rb_yjit_options *options) {}
+void rb_yjit_bop_redefined(VALUE klass, const rb_method_entry_t *me, enum ruby_basic_operators bop) {}
+void rb_yjit_constant_state_changed(void) {}
+void rb_yjit_iseq_mark(const struct rb_iseq_constant_body *body) {}
+void rb_yjit_iseq_update_references(const struct rb_iseq_constant_body *body) {}
+void rb_yjit_iseq_free(const struct rb_iseq_constant_body *body) {}
+void rb_yjit_before_ractor_spawn(void) {}
+void rb_yjit_constant_ic_update(const rb_iseq_t *iseq, IC ic) {}
+void rb_yjit_tracing_invalidate_all(void) {}
+
+#endif // if JIT_ENABLED && PLATFORM_SUPPORTED_P