Don't add +YJIT
to RUBY_DESCRIPTION
until it's actually enabled
If you start Ruby with `--yjit-disable`, the `+YJIT` shouldn't be added until `RubyVM::YJIT.enable` is actually called. Otherwise it's confusing in crash reports etc.
This commit is contained in:
parent
fa038f838f
commit
33f92b3c88
3
ruby.c
3
ruby.c
@ -2302,7 +2302,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||||||
#endif
|
#endif
|
||||||
#if USE_YJIT
|
#if USE_YJIT
|
||||||
if (FEATURE_SET_P(opt->features, yjit)) {
|
if (FEATURE_SET_P(opt->features, yjit)) {
|
||||||
opt->yjit = true; // set opt->yjit for Init_ruby_description() and calling rb_yjit_init()
|
bool rb_yjit_option_disable(void);
|
||||||
|
opt->yjit = !rb_yjit_option_disable(); // set opt->yjit for Init_ruby_description() and calling rb_yjit_init()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,14 +56,26 @@ class TestYJIT < Test::Unit::TestCase
|
|||||||
def test_yjit_enable
|
def test_yjit_enable
|
||||||
args = []
|
args = []
|
||||||
args << "--disable=yjit" if RubyVM::YJIT.enabled?
|
args << "--disable=yjit" if RubyVM::YJIT.enabled?
|
||||||
assert_separately(args, <<~RUBY)
|
assert_separately(args, <<~'RUBY')
|
||||||
assert_false RubyVM::YJIT.enabled?
|
refute_predicate RubyVM::YJIT, :enabled?
|
||||||
assert_false RUBY_DESCRIPTION.include?("+YJIT")
|
refute_includes RUBY_DESCRIPTION, "+YJIT"
|
||||||
|
|
||||||
RubyVM::YJIT.enable
|
RubyVM::YJIT.enable
|
||||||
|
|
||||||
assert_true RubyVM::YJIT.enabled?
|
assert_predicate RubyVM::YJIT, :enabled?
|
||||||
assert_true RUBY_DESCRIPTION.include?("+YJIT")
|
assert_includes RUBY_DESCRIPTION, "+YJIT"
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_yjit_disable
|
||||||
|
assert_separately(["--yjit", "--yjit-disable"], <<~'RUBY')
|
||||||
|
refute_predicate RubyVM::YJIT, :enabled?
|
||||||
|
refute_includes RUBY_DESCRIPTION, "+YJIT"
|
||||||
|
|
||||||
|
RubyVM::YJIT.enable
|
||||||
|
|
||||||
|
assert_predicate RubyVM::YJIT, :enabled?
|
||||||
|
assert_includes RUBY_DESCRIPTION, "+YJIT"
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ pub extern "C" fn rb_yjit_parse_option(str_ptr: *const raw::c_char) -> bool {
|
|||||||
return parse_option(str_ptr).is_some();
|
return parse_option(str_ptr).is_some();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn rb_yjit_option_disable() -> bool {
|
||||||
|
return get_option!(disable);
|
||||||
|
}
|
||||||
|
|
||||||
/// Like rb_yjit_enabled_p, but for Rust code.
|
/// Like rb_yjit_enabled_p, but for Rust code.
|
||||||
pub fn yjit_enabled_p() -> bool {
|
pub fn yjit_enabled_p() -> bool {
|
||||||
unsafe { rb_yjit_enabled_p }
|
unsafe { rb_yjit_enabled_p }
|
||||||
@ -34,7 +39,7 @@ pub extern "C" fn rb_yjit_init(yjit_enabled: bool) {
|
|||||||
yjit_reg_method_codegen_fns();
|
yjit_reg_method_codegen_fns();
|
||||||
|
|
||||||
// If --yjit-disable, yjit_init() will not be called until RubyVM::YJIT.enable.
|
// If --yjit-disable, yjit_init() will not be called until RubyVM::YJIT.enable.
|
||||||
if yjit_enabled && !get_option!(disable) {
|
if yjit_enabled {
|
||||||
yjit_init();
|
yjit_init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user