зеркало из https://github.com/github/ruby.git
Make sure RUBY_YJIT_ENABLE only enables YJIT for truthy values (#7208)
* Make sure RUBY_YJIT_ENABLE only enables YJIT for truthy values Addresses bug reported in: https://github.com/Shopify/yjit/issues/309 * Update ruby.c Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
This commit is contained in:
Родитель
74e52c2a17
Коммит
4ce642620f
20
ruby.c
20
ruby.c
|
@ -1798,6 +1798,24 @@ copy_str(VALUE str, rb_encoding *enc, bool intern)
|
|||
return rb_enc_interned_str(RSTRING_PTR(str), RSTRING_LEN(str), enc);
|
||||
}
|
||||
|
||||
// Check that an environment variable is set to a truthy value
|
||||
static bool
|
||||
env_var_truthy(const char *name)
|
||||
{
|
||||
const char *value = getenv(name);
|
||||
|
||||
if (!value)
|
||||
return false;
|
||||
if (strcmp(value, "1") == 0)
|
||||
return true;
|
||||
if (strcmp(value, "true") == 0)
|
||||
return true;
|
||||
if (strcmp(value, "yes") == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
||||
{
|
||||
|
@ -1907,7 +1925,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||
|
||||
if (!(FEATURE_SET_BITS(opt->features) & feature_jit_mask)) {
|
||||
#if USE_YJIT
|
||||
if (!FEATURE_USED_P(opt->features, yjit) && getenv("RUBY_YJIT_ENABLE")) {
|
||||
if (!FEATURE_USED_P(opt->features, yjit) && env_var_truthy("RUBY_YJIT_ENABLE")) {
|
||||
FEATURE_SET(opt->features, FEATURE_BIT(yjit));
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче