1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Exit if YJIT and MJIT are both enabled

YJIT and MJIT can't be running in the same process otherwise they'll
clobber each other.  We should show an error and exit if they're both
enabled.
This commit is contained in:
Aaron Patterson 2021-09-07 12:57:33 -07:00 committed by Alan Wu
parent 013a4a31d6
commit 234ab816ba

9
ruby.c
View file

@ -1834,13 +1834,18 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
*/ */
rb_warning("-K is specified; it is for 1.8 compatibility and may cause odd behavior"); rb_warning("-K is specified; it is for 1.8 compatibility and may cause odd behavior");
if (opt->features.set & FEATURE_BIT(yjit))
rb_yjit_init(&opt->yjit);
#if USE_MJIT #if USE_MJIT
if (opt->features.set & FEATURE_BIT(jit)) { if (opt->features.set & FEATURE_BIT(jit)) {
opt->mjit.on = TRUE; /* set mjit.on for ruby_show_version() API and check to call mjit_init() */ opt->mjit.on = TRUE; /* set mjit.on for ruby_show_version() API and check to call mjit_init() */
} }
#endif #endif
if (opt->features.set & FEATURE_BIT(yjit)) {
if (opt->mjit.on) {
rb_warn("MJIT and YJIT are both enabled at the same time. Exiting");
exit(1);
}
rb_yjit_init(&opt->yjit);
}
if (opt->dump & (DUMP_BIT(version) | DUMP_BIT(version_v))) { if (opt->dump & (DUMP_BIT(version) | DUMP_BIT(version_v))) {
#if USE_MJIT #if USE_MJIT
mjit_opts.on = opt->mjit.on; /* used by ruby_show_version(). mjit_init() still can't be called here. */ mjit_opts.on = opt->mjit.on; /* used by ruby_show_version(). mjit_init() still can't be called here. */