ruby.c: accept --disable-jit option
by promoting jit to feature flag. mjit.h: update comment about mjit_opts.on test_rubyoptions.rb: add test for switching JIT enablement "--jit" flag usage may be deprecated later, but not discussed yet. [Feature #14878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4bc1669127
commit
053cdaf7ee
4
mjit.h
4
mjit.h
@ -27,7 +27,9 @@ enum rb_mjit_iseq_func {
|
|||||||
|
|
||||||
/* MJIT options which can be defined on the MRI command line. */
|
/* MJIT options which can be defined on the MRI command line. */
|
||||||
struct mjit_options {
|
struct mjit_options {
|
||||||
char on; /* flag of MJIT usage */
|
/* Converted from "jit" feature flag to tell the enablement
|
||||||
|
information to ruby_show_version(). */
|
||||||
|
char on;
|
||||||
/* Save temporary files after MRI finish. The temporary files
|
/* Save temporary files after MRI finish. The temporary files
|
||||||
include the pre-compiled header, C code file generated for ISEQ,
|
include the pre-compiled header, C code file generated for ISEQ,
|
||||||
and the corresponding object file. */
|
and the corresponding object file. */
|
||||||
|
13
ruby.c
13
ruby.c
@ -77,6 +77,8 @@ char *getenv();
|
|||||||
X(rubyopt) \
|
X(rubyopt) \
|
||||||
SEP \
|
SEP \
|
||||||
X(frozen_string_literal) \
|
X(frozen_string_literal) \
|
||||||
|
SEP \
|
||||||
|
X(jit) \
|
||||||
/* END OF FEATURES */
|
/* END OF FEATURES */
|
||||||
#define EACH_DEBUG_FEATURES(X, SEP) \
|
#define EACH_DEBUG_FEATURES(X, SEP) \
|
||||||
X(frozen_string_literal) \
|
X(frozen_string_literal) \
|
||||||
@ -167,6 +169,7 @@ enum {
|
|||||||
& ~FEATURE_BIT(gems)
|
& ~FEATURE_BIT(gems)
|
||||||
#endif
|
#endif
|
||||||
& ~FEATURE_BIT(frozen_string_literal)
|
& ~FEATURE_BIT(frozen_string_literal)
|
||||||
|
& ~FEATURE_BIT(jit)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -180,7 +183,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
|
|||||||
opt->intern.enc.index = -1;
|
opt->intern.enc.index = -1;
|
||||||
opt->features = DEFAULT_FEATURES;
|
opt->features = DEFAULT_FEATURES;
|
||||||
#ifdef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */
|
#ifdef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */
|
||||||
opt->mjit.on = MJIT_FORCE_ENABLE;
|
opt->features |= FEATURE_BIT(jit);
|
||||||
#endif
|
#endif
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
@ -272,6 +275,7 @@ usage(const char *name, int help)
|
|||||||
M("did_you_mean", "", "did_you_mean (default: "DEFAULT_RUBYGEMS_ENABLED")"),
|
M("did_you_mean", "", "did_you_mean (default: "DEFAULT_RUBYGEMS_ENABLED")"),
|
||||||
M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"),
|
M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"),
|
||||||
M("frozen-string-literal", "", "freeze all string literals (default: disabled)"),
|
M("frozen-string-literal", "", "freeze all string literals (default: disabled)"),
|
||||||
|
M("jit", "", "MJIT (default: disabled)"),
|
||||||
};
|
};
|
||||||
static const struct message mjit_options[] = {
|
static const struct message mjit_options[] = {
|
||||||
M("--jit-warnings", "", "Enable printing MJIT warnings"),
|
M("--jit-warnings", "", "Enable printing MJIT warnings"),
|
||||||
@ -945,7 +949,6 @@ set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen
|
|||||||
static void
|
static void
|
||||||
setup_mjit_options(const char *s, struct mjit_options *mjit_opt)
|
setup_mjit_options(const char *s, struct mjit_options *mjit_opt)
|
||||||
{
|
{
|
||||||
mjit_opt->on = 1;
|
|
||||||
if (*s == 0) return;
|
if (*s == 0) return;
|
||||||
else if (strcmp(s, "-warnings") == 0) {
|
else if (strcmp(s, "-warnings") == 0) {
|
||||||
mjit_opt->warnings = 1;
|
mjit_opt->warnings = 1;
|
||||||
@ -1327,6 +1330,7 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
|
|||||||
ruby_verbose = Qtrue;
|
ruby_verbose = Qtrue;
|
||||||
}
|
}
|
||||||
else if (strncmp("jit", s, 3) == 0) {
|
else if (strncmp("jit", s, 3) == 0) {
|
||||||
|
opt->features |= FEATURE_BIT(jit);
|
||||||
setup_mjit_options(s + 3, &opt->mjit);
|
setup_mjit_options(s + 3, &opt->mjit);
|
||||||
}
|
}
|
||||||
else if (strcmp("yydebug", s) == 0) {
|
else if (strcmp("yydebug", s) == 0) {
|
||||||
@ -1568,8 +1572,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||||||
if (opt->src.enc.name)
|
if (opt->src.enc.name)
|
||||||
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 & FEATURE_BIT(jit)) {
|
||||||
|
opt->mjit.on = TRUE; /* set mjit.on for ruby_show_version() API and check to call mjit_init() */
|
||||||
|
}
|
||||||
if (opt->dump & (DUMP_BIT(version) | DUMP_BIT(version_v))) {
|
if (opt->dump & (DUMP_BIT(version) | DUMP_BIT(version_v))) {
|
||||||
mjit_opts.on = opt->mjit.on; /* used by ruby_show_version(). mjit_init() is still not called here. */
|
mjit_opts.on = opt->mjit.on; /* used by ruby_show_version(). mjit_init() still can't be called here. */
|
||||||
ruby_show_version();
|
ruby_show_version();
|
||||||
if (opt->dump & DUMP_BIT(version)) return Qtrue;
|
if (opt->dump & DUMP_BIT(version)) return Qtrue;
|
||||||
}
|
}
|
||||||
|
@ -181,17 +181,36 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
assert_equal([], e)
|
assert_equal([], e)
|
||||||
end
|
end
|
||||||
if JITSupport.supported?
|
|
||||||
assert_in_out_err(%w(--version --jit)) do |r, e|
|
[
|
||||||
assert_match(VERSION_PATTERN_WITH_JIT, r[0])
|
%w(--version --jit --disable=jit),
|
||||||
if RubyVM::MJIT.enabled?
|
%w(--version --enable=jit --disable=jit),
|
||||||
assert_equal(RUBY_DESCRIPTION, r[0])
|
%w(--version --enable-jit --disable-jit),
|
||||||
else
|
].each do |args|
|
||||||
assert_equal(EnvUtil.invoke_ruby(['--jit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
|
assert_in_out_err(args) do |r, e|
|
||||||
end
|
assert_match(VERSION_PATTERN, r[0])
|
||||||
|
assert_match(NO_JIT_DESCRIPTION, r[0])
|
||||||
assert_equal([], e)
|
assert_equal([], e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if JITSupport.supported?
|
||||||
|
[
|
||||||
|
%w(--version --jit),
|
||||||
|
%w(--version --enable=jit),
|
||||||
|
%w(--version --enable-jit),
|
||||||
|
].each do |args|
|
||||||
|
assert_in_out_err(args) do |r, e|
|
||||||
|
assert_match(VERSION_PATTERN_WITH_JIT, r[0])
|
||||||
|
if RubyVM::MJIT.enabled?
|
||||||
|
assert_equal(RUBY_DESCRIPTION, r[0])
|
||||||
|
else
|
||||||
|
assert_equal(EnvUtil.invoke_ruby(['--jit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
|
||||||
|
end
|
||||||
|
assert_equal([], e)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eval
|
def test_eval
|
||||||
|
Loading…
x
Reference in New Issue
Block a user