version.c: show +JIT when --jit is passed
in version output. version.h: ditto ruby.c: propagate option for it common.mk: updated dependency for version.c mjit.c: overwrites the RUBY_DESCRIPTION to have +JIT when --jit is passed test/ruby/test_rubyoptions.rb: add test for them Only `ruby --jit -v` will have "+JIT", but this is intentional. This may not be convenient for debugging by ticket with `ruby -v`, but it's convenient for benchmark tools that pass options (--jit) when showing it. At least such behavior is planned for benchmark_driver.gem and this behavior is designed for it. Other benchmark tools are recommended to follow the behavior too if they show version. RUBY_DESCRIPTION might be useful for it too. The position of "+JIT" is changed from original proposal because other platforms like JRuby and TruffleRuby end it with archtecture. It's made similar to JRuby, but it's upper-cased because Matz made approval for "+JIT" in the ticket. Example: $ ruby -v ruby 2.6.0dev (2018-02-22 trunk 62529) [x86_64-linux] $ ruby --jit -v ruby 2.6.0dev (2018-02-22 trunk 62529) +JIT [x86_64-linux] After --jit is made default in the future, this output may be removed. So do not rely on this output if possible. [Feature #14462] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cc777d09f4
commit
171c496e50
@ -2847,9 +2847,11 @@ version.$(OBJEXT): {$(VPATH)}config.h
|
||||
version.$(OBJEXT): {$(VPATH)}defines.h
|
||||
version.$(OBJEXT): {$(VPATH)}intern.h
|
||||
version.$(OBJEXT): {$(VPATH)}missing.h
|
||||
version.$(OBJEXT): {$(VPATH)}mjit.h
|
||||
version.$(OBJEXT): {$(VPATH)}st.h
|
||||
version.$(OBJEXT): {$(VPATH)}subst.h
|
||||
version.$(OBJEXT): {$(VPATH)}version.c
|
||||
version.$(OBJEXT): {$(VPATH)}vm_core.h
|
||||
vm.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
|
||||
vm.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
|
||||
vm.$(OBJEXT): $(CCAN_DIR)/list/list.h
|
||||
|
9
mjit.c
9
mjit.c
@ -1314,12 +1314,16 @@ system_tmpdir(void)
|
||||
/* Minimum value for JIT cache size. */
|
||||
#define MIN_CACHE_SIZE 10
|
||||
|
||||
extern const char ruby_description_with_jit[];
|
||||
|
||||
/* Initialize MJIT. Start a thread creating the precompiled header and
|
||||
processing ISeqs. The function should be called first for using MJIT.
|
||||
If everything is successfull, MJIT_INIT_P will be TRUE. */
|
||||
void
|
||||
mjit_init(struct mjit_options *opts)
|
||||
{
|
||||
VALUE rb_description;
|
||||
|
||||
mjit_opts = *opts;
|
||||
mjit_init_p = TRUE;
|
||||
|
||||
@ -1366,6 +1370,11 @@ mjit_init(struct mjit_options *opts)
|
||||
rb_id_table_foreach(RCLASS_CONST_TBL(rb_cObject), valid_class_serials_add_i, NULL);
|
||||
}
|
||||
|
||||
/* Overwrites RUBY_DESCRIPTION constant */
|
||||
rb_const_remove(rb_cObject, rb_intern("RUBY_DESCRIPTION"));
|
||||
rb_description = rb_usascii_str_new_static(ruby_description_with_jit, strlen(ruby_description_with_jit));
|
||||
rb_define_global_const("RUBY_DESCRIPTION", rb_obj_freeze(rb_description));
|
||||
|
||||
/* Initialize worker thread */
|
||||
finish_worker_p = FALSE;
|
||||
worker_finished = FALSE;
|
||||
|
7
ruby.c
7
ruby.c
@ -1506,6 +1506,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
||||
const struct rb_block *base_block;
|
||||
unsigned int dump = opt->dump & dump_exit_bits;
|
||||
|
||||
#ifndef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */
|
||||
opt->mjit.on = 1;
|
||||
#endif
|
||||
|
||||
if (opt->dump & (DUMP_BIT(usage)|DUMP_BIT(help))) {
|
||||
const char *const progname =
|
||||
(argc > 0 && argv && argv[0] ? argv[0] :
|
||||
@ -1538,6 +1542,7 @@ 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");
|
||||
|
||||
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. */
|
||||
ruby_show_version();
|
||||
if (opt->dump & DUMP_BIT(version)) return Qtrue;
|
||||
}
|
||||
@ -1590,9 +1595,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
||||
ruby_gc_set_params(opt->safe_level);
|
||||
ruby_init_loadpath_safe(opt->safe_level);
|
||||
|
||||
#ifndef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */
|
||||
if (opt->mjit.on)
|
||||
#endif
|
||||
/* Using TMP_RUBY_PREFIX created by ruby_init_loadpath_safe(). */
|
||||
mjit_init(&opt->mjit);
|
||||
|
||||
|
@ -96,6 +96,15 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||
end
|
||||
private_constant :VERSION_PATTERN
|
||||
|
||||
VERSION_PATTERN_WITH_JIT =
|
||||
case RUBY_ENGINE
|
||||
when 'jruby'
|
||||
VERSIN_PATTERN
|
||||
else
|
||||
/^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+JIT \[#{q[RUBY_PLATFORM]}\]$/
|
||||
end
|
||||
private_constant :VERSION_PATTERN_WITH_JIT
|
||||
|
||||
def test_verbose
|
||||
assert_in_out_err(["-vve", ""]) do |r, e|
|
||||
assert_match(VERSION_PATTERN, r[0])
|
||||
@ -155,7 +164,20 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||
def test_version
|
||||
assert_in_out_err(%w(--version)) do |r, e|
|
||||
assert_match(VERSION_PATTERN, r[0])
|
||||
assert_equal(RUBY_DESCRIPTION, r[0])
|
||||
if RubyVM::MJIT.enabled?
|
||||
assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
|
||||
else
|
||||
assert_equal(RUBY_DESCRIPTION, r[0])
|
||||
end
|
||||
assert_equal([], e)
|
||||
end
|
||||
assert_in_out_err(%w(--version --jit)) 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
|
||||
|
11
version.c
11
version.c
@ -11,6 +11,8 @@
|
||||
|
||||
#include "ruby/ruby.h"
|
||||
#include "version.h"
|
||||
#include "vm_core.h"
|
||||
#include "mjit.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
@ -31,6 +33,7 @@ const char ruby_release_date[] = RUBY_RELEASE_DATE;
|
||||
const char ruby_platform[] = RUBY_PLATFORM;
|
||||
const int ruby_patchlevel = RUBY_PATCHLEVEL;
|
||||
const char ruby_description[] = RUBY_DESCRIPTION;
|
||||
const char ruby_description_with_jit[] = RUBY_DESCRIPTION_WITH_JIT;
|
||||
const char ruby_copyright[] = RUBY_COPYRIGHT;
|
||||
const char ruby_engine[] = "ruby";
|
||||
|
||||
@ -65,6 +68,7 @@ Init_version(void)
|
||||
rb_define_global_const("RUBY_REVISION", MKINT(revision));
|
||||
/*
|
||||
* The full ruby version string, like <tt>ruby -v</tt> prints'
|
||||
* This might be overwritten by mjit_init().
|
||||
*/
|
||||
rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
|
||||
/*
|
||||
@ -86,7 +90,12 @@ Init_version(void)
|
||||
void
|
||||
ruby_show_version(void)
|
||||
{
|
||||
PRINT(description);
|
||||
if (mjit_opts.on) {
|
||||
PRINT(description_with_jit);
|
||||
}
|
||||
else {
|
||||
PRINT(description);
|
||||
}
|
||||
#ifdef RUBY_LAST_COMMIT_TITLE
|
||||
fputs("last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);
|
||||
#endif
|
||||
|
@ -66,6 +66,12 @@
|
||||
" ("RUBY_RELEASE_DATE \
|
||||
RUBY_REVISION_STR") " \
|
||||
"["RUBY_PLATFORM"]"
|
||||
# define RUBY_DESCRIPTION_WITH_JIT \
|
||||
"ruby "RUBY_VERSION \
|
||||
RUBY_PATCHLEVEL_STR \
|
||||
" ("RUBY_RELEASE_DATE \
|
||||
RUBY_REVISION_STR") +JIT " \
|
||||
"["RUBY_PLATFORM"]"
|
||||
# define RUBY_COPYRIGHT \
|
||||
"ruby - Copyright (C) " \
|
||||
RUBY_BIRTH_YEAR_STR"-" \
|
||||
|
Loading…
x
Reference in New Issue
Block a user