summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2018-02-21test_process.rb: unlimited getgroups on darwinnobu
* test/ruby/test_process.rb (TestProcess#test_maxgroups): Darwin extension of getgroups(2) which is not limited to MAXGROUPS is used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-21test_time_tz.rb: past Japanese DST tzdata fixnobu
* test/ruby/test_time_tz.rb (TestTimeTZ#test_asia_tokyo): fix the expected data at the end of DST. [Bug #14438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-21test_time_tz.rb: past Japanese DST tzdata fixnobu
* test/ruby/test_time_tz.rb (TestTimeTZ#test_asia_tokyo): follow the tzdata 2018 fix of Japanese DST transitions (1948-1951). [ruby-core:85373] [Bug #14438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-20random.c: Random.bytesnobu
* random.c (random_s_bytes): new method Random.bytes, which is equivalent to Random::DEFAULT.bytes. [Feature #4938] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-18thread.c (thread_join_m): handle negative timeouts correctlynormal
Users may subtract and round into negative values when using Thread#join, so clamp the timeout to zero to avoid infinite/long timeouts. Note: other methods such as Kernel#sleep and IO.select will raise on negative values, but Thread#join is an outlier *shrug* This restores Ruby 2.5 (and earlier) behavior. Fixes: r62182 (commit c915390b9530c31b4665aacf27c1adfc114f768e) ("thread.c: avoid FP for Thread#join") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17Remove unnecessary `[]`skazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17a C source code must end with EOLshyouhei
cf: ISO 9899 section 5.1.1.2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17long long is a C99ismshyouhei
so SIZEOF_LONG_LONG is not always available. We have to check its defined?-ness before using. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16fix regexp literal warning.nagachika
test/rubygems/test_gem_server.rb: eliminate duplicated character class warning. [Bug #14481] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16Fixed tempfile leak.hsbt
From: SHIBATA Hiroshi <hsbt@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16Merge RubyGems 2.7.6 from upstream.hsbt
It fixed some security vulnerabilities. http://blog.rubygems.org/2018/02/15/2.7.6-released.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16compile.c: keep debug infonobu
* compile.c (iseq_peephole_optimize): keep freezestring insn with debug info. [Bug #14475] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16test_rubyoptions.rb: assert_same to check identitynobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16test_rubyoptions.rb: show code in failure messagesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-15test/io/console/test_io_console.rb (test_oflush): Avoid race conditionmame
Add a ad-hoc wait. Follows test_ioflush2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-14compile.c: drop freezestring insn on String#-@normal
Followup to r62039 and remove the redundant freezestring insn which was preventing deduplication from String#-@ * compile.c (iseq_peephole_optimize): drop freezestring insn on String#-@ [ruby-core:85542] [Bug #14475] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-14test/ruby/test_optimization.rb: fix compile kwargnormal
Fixes: r62177 ("compile.c: fix string Range optimization with FSL") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-14skip "TestException#test_thread_signal_location" as a known bug [Bug #14474]ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-13mjit_compile.inc.erb: replace opt_key insnk0kubun
with opt_send_without_block insn if call cache has valid ISeq. If the receiver is not optimized target of opt_key (i.e. Hash or Array), it triggers JIT cancel and it would be slow. This change allows JIT to drop the check for Hash/Array and continue to execute JIT even if the receiver is not Hash or Array. See the following benchmark results. It's not improved so much, but it would be effective when we achieve Ruby method inlining in _mjit_compile_send.erb. * Micro benchmark Given the following bench.rb, ``` class HashWithIndifferentAccess < Hash def []=(key, value) super(key.to_s, value) end def [](key) super(key.to_s) end end indhash = HashWithIndifferentAccess.new indhash[:foo] = 'bar' key = 'foo' 100000000.times do indhash[key] end ``` ** before ``` $ time ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb JIT success (31.4ms): block in <main>@/tmp/bench.rb:15 -> /tmp/_ruby_mjit_p18206u0.c JIT success (669.3ms): []@/tmp/bench.rb:6 -> /tmp/_ruby_mjit_p18206u1.c Successful MJIT finish ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb 12.21s user 0.04s system 107% cpu 11.394 total ``` ** after ``` $ time ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb JIT success (41.0ms): block in <main>@/tmp/bench.rb:15 -> /tmp/_ruby_mjit_p17293u0.c JIT success (679.0ms): []@/tmp/bench.rb:6 -> /tmp/_ruby_mjit_p17293u1.c Successful MJIT finish ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb 11.54s user 0.06s system 108% cpu 10.726 total ``` The execution time is shortened. * optcarrot benchmark Optcarrot has no room to be improved by this change. Almost nothing is changed. fps: 59.54 (before) -> 59.51 (after) * discourse benchmark I expected this to be improved a little, but it isn't too. ** before (JIT) ``` categories_admin: 50: 12 75: 13 90: 14 99: 22 home_admin: 50: 12 75: 13 90: 16 99: 22 topic_admin: 50: 12 75: 13 90: 15 99: 21 categories: 50: 18 75: 19 90: 23 99: 27 home: 50: 3 75: 4 90: 4 99: 12 topic: 50: 11 75: 11 90: 14 99: 20 ``` ** after (JIT) ``` categories_admin: 50: 12 75: 12 90: 16 99: 24 home_admin: 50: 12 75: 12 90: 14 99: 21 topic_admin: 50: 12 75: 13 90: 16 99: 21 categories: 50: 17 75: 18 90: 23 99: 32 home: 50: 3 75: 4 90: 4 99: 10 topic: 50: 11 75: 12 90: 13 99: 20 ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-13variable.c: flags at autoloadingnobu
* variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [ruby-core:85516] [Bug #14469] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-13revert r62392usa
check the declaration of `rb_autoloading_value()` in vm_core.h and the call in vm_insnhelper.c, and retry it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-13variable.c: flags at autoloadingnobu
* variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [ruby-core:85516] [Bug #14469] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-12test_jit.rb: prettify script in messagek0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-12test_jit.rb: explicitly skip for unsupported onesk0kubun
MSP-Greg watches this metrics and this would be helpful for him. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-12test_jit.rb: split test_compile_insnsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-10insns.def: cache nil constnobu
* insns.def (getinlinecache): Qnil is a valid value as a constant. this can be observable when accessing a deprecated constant which is nil. non-nil constant is warned just once for each location, but every time if it is nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-10test_jit.rb: cover most insn compilationsk0kubun
test_compile_insns has only basic tests to improve coverage. Other severer tests should be added with different names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09compile.c: popped hashnobu
* compile.c (compile_array): skip creating new hash if preceeding elements are popped all. [ruby-core:85486] [Bug #14459] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09.travis.yml: force to execute JIT test on Travisk0kubun
test_jit.rb: with environment variable RUBY_FORCE_TEST_JIT, we can force to test JIT availability. I wanted to have such CI, but Travis was the only option which I can modify easily. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: don't force to test --jit-waitk0kubun
for platforms which can't use JIT. Such platforms can time out with eval_with_jit. http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/509911 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/509904 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: fix typok0kubun
This is notified by zns-san. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: add forgotten checkk0kubun
I was going to check this in r62310... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: check JIT support more conservativelyk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: remove unnecessary requirek0kubun
At first I was going to check the name of `RbConfig::CONFIG['CC']` and use shellwords for it, but I decided not to do so. Thus removing obsoleted require in r62307. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: try to test JIT againk0kubun
This commit reverts r62297, revising the check if JIT is supported or not. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08revert r62302 and force to define the version constantusa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08no need to set bundled bundler unless Gem::USE_BUNDLER_FOR_GEMDEPSusa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_gem_commands_setup_command.rb: BUNDLER_VERSnobu
* test/rubygems/test_gem_commands_setup_command.rb: run bundled gem command, instead of installed one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08revert r62291 for nowk0kubun
While some of CIs are succeeding and the test succeeds on my laptop, some other CIs are failing. As I don't have time to fix it until I come back to home, reverting this for now. Failures: https://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20180208T000401Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20180207T201706Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu1604/ruby-trunk/log/20180207T183004Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/gentoo/ruby-trunk/log/20180207T213004Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos6/ruby-trunk/log/20180207T213003Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/fedora25/ruby-trunk/log/20180207T213003Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/fedora26/ruby-trunk/log/20180207T213003Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/opensuseleap/ruby-trunk/log/20180207T213001Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel_zlinux/ruby-trunk/log/20180207T223303Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1011/ruby-trunk/log/20180207T234501Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1012/ruby-trunk/log/20180207T234501Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/icc-x64/ruby-trunk/log/20180207T210002Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable10x/ruby-trunk/log/20180207T231805Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11x/ruby-trunk/log/20180207T232403Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable10s/ruby-trunk/log/20180207T171914Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11s/ruby-trunk/log/20180207T232503Z.fail.html.gz https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20180207T172813Z.fail.html.gz http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506100 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506114 http://ci.rvm.jp/results/trunk_clang_40@silicon-docker/506119 http://ci.rvm.jp/results/trunk_clang_39@silicon-docker/506170 http://ci.rvm.jp/results/trunk-nopara@silicon-docker/506176 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506192 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506202 http://ci.rvm.jp/results/trunk_clang_39@silicon-docker/506244 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506271 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506280 http://ci.rvm.jp/results/trunk-nopara@silicon-docker/506323 http://ci.rvm.jp/results/trunk_clang_50@silicon-docker/506325 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506342 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506354 http://ci.rvm.jp/results/trunk_clang_39@silicon-docker/506385 http://ci.rvm.jp/results/trunk_clang_40@silicon-docker/506389 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506409 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506425 http://ci.rvm.jp/results/trunk_clang_40@silicon-docker/506471 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506484 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506495 http://ci.rvm.jp/results/trunk-test@x2/506524 http://ci.rvm.jp/results/trunk-vm-asserts@silicon-docker/506547 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506556 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506579 http://ci.rvm.jp/results/trunk-nopara@silicon-docker/506582 http://ci.rvm.jp/results/trunk_clang_50@silicon-docker/506634 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506638 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506663 http://ci.rvm.jp/results/trunk-test@frontier/506690 http://ci.rvm.jp/results/trunk_clang_40@silicon-docker/506718 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506728 http://ci.rvm.jp/results/trunk-nopara@silicon-docker/506752 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506754 http://ci.rvm.jp/results/trunk-gc-asserts@silicon-docker/506782 http://ci.rvm.jp/results/trunk_clang_38@silicon-docker/506799 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506816 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506835 http://ci.rvm.jp/results/trunk-nopara@silicon-docker/506879 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506903 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/506920 http://ci.rvm.jp/results/trunk-test@frontier/506955 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/506994 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/507012 http://ci.rvm.jp/results/trunk-vm-asserts@silicon-docker/507036 http://ci.rvm.jp/results/trunk_clang_40@silicon-docker/507037 http://ci.rvm.jp/results/trunk-nopara@silicon-docker/507053 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/507081 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/507097 http://ci.rvm.jp/results/trunk_clang_40@silicon-docker/507136 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/507165 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/507178 http://ci.rvm.jp/results/trunk-nopara@silicon-docker/507180 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/507257 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/507268 http://ci.rvm.jp/results/trunk-gc-asserts@silicon-docker/507303 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/507342 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/507355 http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/507434 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/507448 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-07test_jit.rb: make JIT count test optionalk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-07test_jit.rb: add initial test for JITk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06lib/ostruct.rb: Use `FrozenError` instead of `RuntimeError`.marcandre
Patch by Yuuji Yaginuma. [Fixes GH-1808] In other classes, `FrozenError` will be raised if change the frozen object. In order to match the behavior, I think that `FrozenError` should use in `OpenStruct`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06test_gem_util.rb: fix broken testnobu
* test/rubygems/test_gem_util.rb: no guarantee that tmpdir is always underneath the root directory at all. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06Merge RubyGems-2.7.5 from upstream.hsbt
Please see its details: http://blog.rubygems.org/2018/02/06/2.7.5-released.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04mjit_compile.c: merge initial JIT compilerk0kubun
which has been developed by Takashi Kokubun <takashikkbn@gmail> as YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>. This JIT compiler is designed to be a safe migration path to introduce JIT compiler to MRI. So this commit does not include any bytecode changes or dynamic instruction modifications, which are done in original MJIT. This commit even strips off some aggressive optimizations from YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still fairly faster than Ruby 2.5 in some benchmarks (attached below). Note that this JIT compiler passes `make test`, `make test-all`, `make test-spec` without JIT, and even with JIT. Not only it's perfectly safe with JIT disabled because it does not replace VM instructions unlike MJIT, but also with JIT enabled it stably runs Ruby applications including Rails applications. I'm expecting this version as just "initial" JIT compiler. I have many optimization ideas which are skipped for initial merging, and you may easily replace this JIT compiler with a faster one by just replacing mjit_compile.c. `mjit_compile` interface is designed for the purpose. common.mk: update dependencies for mjit_compile.c. internal.h: declare `rb_vm_insn_addr2insn` for MJIT. vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to compiler. This avoids to include some functions which take a long time to compile, e.g. vm_exec_core. Some of the purpose is achieved in transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are manually resolved for now. Load mjit_helper.h for MJIT header. mjit_helper.h: New. This is a file used only by JIT-ed code. I'll refactor `mjit_call_cfunc` later. vm_eval.c: add some #ifdef switches to skip compiling some functions like Init_vm_eval. win32/mkexports.rb: export thread/ec functions, which are used by MJIT. include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify that a function is exported only for MJIT. array.c: export a function used by MJIT. bignum.c: ditto. class.c: ditto. compile.c: ditto. error.c: ditto. gc.c: ditto. hash.c: ditto. iseq.c: ditto. numeric.c: ditto. object.c: ditto. proc.c: ditto. re.c: ditto. st.c: ditto. string.c: ditto. thread.c: ditto. variable.c: ditto. vm_backtrace.c: ditto. vm_insnhelper.c: ditto. vm_method.c: ditto. I would like to improve maintainability of function exports, but I believe this way is acceptable as initial merging if we clarify the new exports are for MJIT (so that we can use them as TODO list to fix) and add unit tests to detect unresolved symbols. I'll add unit tests of JIT compilations in succeeding commits. Author: Takashi Kokubun <takashikkbn@gmail.com> Contributor: wanabe <s.wanabe@gmail.com> Part of [Feature #14235] --- * Known issues * Code generated by gcc is faster than clang. The benchmark may be worse in macOS. Following benchmark result is provided by gcc w/ Linux. * Performance is decreased when Google Chrome is running * JIT can work on MinGW, but it doesn't improve performance at least in short running benchmark. * Currently it doesn't perform well with Rails. We'll try to fix this before release. --- * Benchmark reslts Benchmarked with: Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores - 2.0.0-p0: Ruby 2.0.0-p0 - r62186: Ruby trunk (early 2.6.0), before MJIT changes - JIT off: On this commit, but without `--jit` option - JIT on: On this commit, and with `--jit` option ** Optcarrot fps Benchmark: https://github.com/mame/optcarrot | |2.0.0-p0 |r62186 |JIT off |JIT on | |:--------|:--------|:--------|:--------|:--------| |fps |37.32 |51.46 |51.31 |58.88 | |vs 2.0.0 |1.00x |1.38x |1.37x |1.58x | ** MJIT benchmarks Benchmark: https://github.com/benchmark-driver/mjit-benchmarks (Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks) | |2.0.0-p0 |r62186 |JIT off |JIT on | |:----------|:--------|:--------|:--------|:--------| |aread |1.00 |1.09 |1.07 |2.19 | |aref |1.00 |1.13 |1.11 |2.22 | |aset |1.00 |1.50 |1.45 |2.64 | |awrite |1.00 |1.17 |1.13 |2.20 | |call |1.00 |1.29 |1.26 |2.02 | |const2 |1.00 |1.10 |1.10 |2.19 | |const |1.00 |1.11 |1.10 |2.19 | |fannk |1.00 |1.04 |1.02 |1.00 | |fib |1.00 |1.32 |1.31 |1.84 | |ivread |1.00 |1.13 |1.12 |2.43 | |ivwrite |1.00 |1.23 |1.21 |2.40 | |mandelbrot |1.00 |1.13 |1.16 |1.28 | |meteor |1.00 |2.97 |2.92 |3.17 | |nbody |1.00 |1.17 |1.15 |1.49 | |nest-ntimes|1.00 |1.22 |1.20 |1.39 | |nest-while |1.00 |1.10 |1.10 |1.37 | |norm |1.00 |1.18 |1.16 |1.24 | |nsvb |1.00 |1.16 |1.16 |1.17 | |red-black |1.00 |1.02 |0.99 |1.12 | |sieve |1.00 |1.30 |1.28 |1.62 | |trees |1.00 |1.14 |1.13 |1.19 | |while |1.00 |1.12 |1.11 |2.41 | ** Discourse's script/bench.rb Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb NOTE: Rails performance was somehow a little degraded with JIT for now. We should fix this. (At least I know opt_aref is performing badly in JIT and I have an idea to fix it. Please wait for the fix.) *** JIT off Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 17 75: 18 90: 22 99: 29 home_admin: 50: 21 75: 21 90: 27 99: 40 topic_admin: 50: 17 75: 18 90: 22 99: 32 categories: 50: 35 75: 41 90: 43 99: 77 home: 50: 39 75: 46 90: 49 99: 95 topic: 50: 46 75: 52 90: 56 99: 101 *** JIT on Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 19 75: 21 90: 25 99: 33 home_admin: 50: 24 75: 26 90: 30 99: 35 topic_admin: 50: 19 75: 20 90: 25 99: 30 categories: 50: 40 75: 44 90: 48 99: 76 home: 50: 42 75: 48 90: 51 99: 89 topic: 50: 49 75: 55 90: 58 99: 99 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04mjit.c: merge MJIT infrastructurek0kubun
that allows to JIT-compile Ruby methods by generating C code and using C compiler. See the first comment of mjit.c to know what this file does. mjit.c is authored by Vladimir Makarov <vmakarov@redhat.com>. After he invented great method JIT infrastructure for MRI as MJIT, Lars Kanis <lars@greiz-reinsdorf.de> sent the patch to support MinGW in MJIT. In addition to merging it, I ported pthread to Windows native threads. Now this MJIT infrastructure can be compiled on Visual Studio. This commit simplifies mjit.c to decrease code at initial merge. For example, this commit does not provide multiple JIT threads support. We can resurrect them later if we really want them, but I wanted to minimize diff to make it easier to review this patch. `/tmp/_mjitXXX` file is renamed to `/tmp/_ruby_mjitXXX` because non-Ruby developers may not know the name "mjit" and the file name should make sure it's from Ruby and not from some harmful programs. TODO: it may be better to store this to some temporary directory which Ruby is already using by Tempfile, if it's not bad for performance. mjit.h: New. It has `mjit_exec` interface similar to `vm_exec`, which is for triggering MJIT. This drops interface for AOT compared to the original MJIT. Makefile.in: define macros to let MJIT know the path of MJIT header. Probably we can refactor this to reduce the number of macros (TODO). win32/Makefile.sub: ditto. common.mk: compile mjit.o and mjit_compile.o. Unlike original MJIT, this commit separates MJIT infrastructure and JIT compiler code as independent object files. As initial patch is NOT going to have ultra-fast JIT compiler, it's likely to replace JIT compiler, e.g. original MJIT's compiler or some future JIT impelementations which are not public now. inits.c: define MJIT module. This is added because `MJIT.enabled?` was necessary for testing. test/lib/zombie_hunter.rb: skip if `MJIT.enabled?`. Obviously this wouldn't work with current code when JIT is enabled. test/ruby/test_io.rb: skip this too. This would make no sense with MJIT. ruby.c: define MJIT CLI options. As major difference from original MJIT, "-j:l"/"--jit:llvm" are renamed to "--jit-cc" because I want to support not only gcc/clang but also cl.exe (Visual Studio) in the future. But it takes only "--jit-cc=gcc", "--jit-cc=clang" for now. And only long "--jit" options are allowed since some Ruby committers preferred it at Ruby developers Meeting on January, and some of options are renamed. This file also triggers to initialize MJIT thread and variables. eval.c: finalize MJIT worker thread and variables. test/ruby/test_rubyoptions.rb: fix number of CLI options for --jit. thread_pthread.c: change for pthread abstraction in MJIT. Prefix rb_ for functions which are used by other files. thread_win32.c: ditto, for Windows. Those pthread porting is one of major works that YARV-MJIT created, which is my fork of MJIT, in Feature 14235. thread.c: follow rb_ prefix changes vm.c: trigger MJIT call on VM invocation. Also trigger `mjit_mark` to avoid SEGV by race between JIT and GC of ISeq. The improvement was provided by wanabe <s.wanabe@gmail.com>. In JIT compiler I created and am going to add in my next commit, I found that having `mjit_exec` after `vm_loop_start:` is harmful because the JIT-ed function doesn't proceed other ISeqs on RESTORE_REGS of leave insn. Executing non-FINISH frame is unexpected for my JIT compiler and `exception_handler` triggers executions of such ISeqs. So `mjit_exec` here should be executed only when it directly comes from `vm_exec` call. `RubyVM::MJIT` module and `.enabled?` method is added so that we can skip some tests which don't expect JIT threads or compiler file descriptors. vm_insnhelper.h: trigger MJIT on method calls during VM execution. vm_core.h: add fields required for mjit.c. `bp` must be `cfp[6]` because rb_control_frame_struct is likely to be casted to another struct. The last position is the safest place to add the new field. vm_insnhelper.c: save initial value of cfp->ep as cfp->bp. This is an optimization which are done in both MJIT and YARV-MJIT. So this change is added in this commit. Calculating bp from ep is a little heavy work, so bp is kind of cache for it. iseq.c: notify ISeq GC to MJIT. We should know which iseq in MJIT queue is GCed to avoid SEGV. TODO: unload some GCed units in some safe way. gc.c: add hooks so that MJIT can wait GC, and vice versa. Simultaneous JIT and GC executions may cause SEGV and so we should synchronize them. cont.c: save continuation information in MJIT worker. As MJIT shouldn't unload JIT-ed code which is being used, MJIT wants to know full list of saved execution contexts for continuation and detect ISeqs in use. mjit_compile.c: added empty JIT compiler so that you can reuse this commit to build your own JIT compiler. This commit tries to compile ISeqs but all of them are considered as not supported in this commit. So you can't use JIT compiler in this commit yet while we added --jit option now. Patch author: Vladimir Makarov <vmakarov@redhat.com>. Contributors: Takashi Kokubun <takashikkbn@gmail.com>. wanabe <s.wanabe@gmail.com>. Lars Kanis <lars@greiz-reinsdorf.de>. Part of Feature 12589 and 14235. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-03thread.c (thread_join_m): avoid NUM2TIMET for Bignumnormal
Bignums exceed the range of time_t (or long). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-03compile.c: fix string Range optimization with FSLnormal
The optimization in [Feature #13355] needs to be detected differently to work with "frozen_string_literal: true" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-03process.c: command_name encodingnobu
* process.c (rb_exec_fillarg): share subsequence of argv_buf for command_name, and copy the encoding from the command string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e