summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2025-04-29 09:50:05 -0700
committerGitHub <[email protected]>2025-04-29 09:50:05 -0700
commit608fe6ee535e10b0203516b9d8c8039703aea3c5 (patch)
tree8f3e6e5818981bcac7f9bc387e4204d7fe465952 /ruby.c
parent10fd5a6357aceed4778bedf389e6a4cbf3ea294a (diff)
ZJIT: Handle ZJIT options properly (#13197)
Notes
Notes: Merged-By: k0kubun <[email protected]>
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/ruby.c b/ruby.c
index a675698643..3eab16af21 100644
--- a/ruby.c
+++ b/ruby.c
@@ -307,7 +307,9 @@ usage(const char *name, int help, int highlight, int columns)
#define M(shortopt, longopt, desc) RUBY_OPT_MESSAGE(shortopt, longopt, desc)
#if USE_YJIT
-# define PLATFORM_JIT_OPTION "--yjit"
+# define DEFAULT_JIT_OPTION "--yjit"
+#elif USE_ZJIT
+# define DEFAULT_JIT_OPTION "--zjit"
#endif
/* This message really ought to be max 23 lines.
@@ -338,13 +340,15 @@ usage(const char *name, int help, int highlight, int columns)
M("-W[level=2|:category]", "", "Set warning flag ($-W):\n"
"0 for silent; 1 for moderate; 2 for verbose."),
M("-x[dirpath]", "", "Execute Ruby code starting from a #!ruby line."),
-#if USE_YJIT
- M("--jit", "", "Enable JIT for the platform; same as " PLATFORM_JIT_OPTION "."),
+#if USE_YJIT || USE_ZJIT
+ M("--jit", "", "Enable the default JIT for the build; same as " DEFAULT_JIT_OPTION "."),
#endif
#if USE_YJIT
M("--yjit", "", "Enable in-process JIT compiler."),
#endif
- M("--zjit", "", "Enable in-process JIT compiler."),
+#if USE_ZJIT
+ M("--zjit", "", "Enable method-based JIT compiler."),
+#endif
M("-h", "", "Print this help message; use --help for longer message."),
};
STATIC_ASSERT(usage_msg_size, numberof(usage_msg) < 26);
@@ -382,6 +386,9 @@ usage(const char *name, int help, int highlight, int columns)
#if USE_YJIT
M("yjit", "", "In-process JIT compiler (default: disabled)."),
#endif
+#if USE_ZJIT
+ M("zjit", "", "Method-based JIT compiler (default: disabled)."),
+#endif
};
static const struct ruby_opt_message warn_categories[] = {
M("deprecated", "", "Deprecated features."),
@@ -419,6 +426,11 @@ usage(const char *name, int help, int highlight, int columns)
printf("%s""YJIT options:%s\n", sb, se);
rb_yjit_show_usage(help, highlight, w, columns);
#endif
+#if USE_ZJIT
+ printf("%s""ZJIT options:%s\n", sb, se);
+ extern void rb_zjit_show_usage(int help, int highlight, unsigned int width, int columns);
+ rb_zjit_show_usage(help, highlight, w, columns);
+#endif
}
#define rubylib_path_new rb_str_new
@@ -1993,7 +2005,7 @@ copy_str(VALUE str, rb_encoding *enc, bool intern)
return rb_enc_interned_str(RSTRING_PTR(str), RSTRING_LEN(str), enc);
}
-#if USE_YJIT
+#if USE_YJIT || USE_ZJIT
// Check that an environment variable is set to a truthy value
static bool
env_var_truthy(const char *name)
@@ -2345,6 +2357,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
if (!FEATURE_USED_P(opt->features, yjit) && env_var_truthy("RUBY_YJIT_ENABLE")) {
FEATURE_SET(opt->features, FEATURE_BIT(yjit));
}
+#elif USE_ZJIT
+ if (!FEATURE_USED_P(opt->features, zjit) && env_var_truthy("RUBY_ZJIT_ENABLE")) {
+ FEATURE_SET(opt->features, FEATURE_BIT(zjit));
+ }
#endif
}
if (MULTI_BITS_P(FEATURE_SET_BITS(opt->features) & feature_jit_mask)) {