aboutsummaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Fixed tempfile leak.hsbt2018-02-161-0/+1
| | | | | | From: SHIBATA Hiroshi <hsbt@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.svn2018-02-161-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge RubyGems 2.7.6 from upstream.hsbt2018-02-167-5/+312
| | | | | | | | 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
* compile.c: keep debug infonobu2018-02-161-0/+2
| | | | | | | * 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
* test_rubyoptions.rb: assert_same to check identitynobu2018-02-161-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_rubyoptions.rb: show code in failure messagesnobu2018-02-161-3/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/io/console/test_io_console.rb (test_oflush): Avoid race conditionmame2018-02-151-0/+1
| | | | | | 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
* compile.c: drop freezestring insn on String#-@normal2018-02-141-0/+15
| | | | | | | | | | 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
* test/ruby/test_optimization.rb: fix compile kwargnormal2018-02-141-2/+3
| | | | | | 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
* skip "TestException#test_thread_signal_location" as a known bug [Bug #14474]ko12018-02-141-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_compile.inc.erb: replace opt_key insnk0kubun2018-02-131-5/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* variable.c: flags at autoloadingnobu2018-02-131-0/+40
| | | | | | | | * 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
* revert r62392usa2018-02-131-40/+0
| | | | | | | | 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
* variable.c: flags at autoloadingnobu2018-02-131-0/+40
| | | | | | | | * 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
* test_jit.rb: prettify script in messagek0kubun2018-02-121-1/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_jit.rb: explicitly skip for unsupported onesk0kubun2018-02-121-2/+6
| | | | | | 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
* test_jit.rb: split test_compile_insnsnobu2018-02-121-192/+270
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.def: cache nil constnobu2018-02-101-0/+11
| | | | | | | | | * 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
* test_jit.rb: cover most insn compilationsk0kubun2018-02-101-3/+344
| | | | | | | | 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
* compile.c: popped hashnobu2018-02-091-0/+5
| | | | | | | * 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
* .travis.yml: force to execute JIT test on Travisk0kubun2018-02-091-0/+6
| | | | | | | | | | 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
* test_jit.rb: don't force to test --jit-waitk0kubun2018-02-081-2/+2
| | | | | | | | | | 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
* test_jit.rb: fix typok0kubun2018-02-081-1/+1
| | | | | | This is notified by zns-san. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_jit.rb: add forgotten checkk0kubun2018-02-081-1/+2
| | | | | | 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
* test_jit.rb: check JIT support more conservativelyk0kubun2018-02-081-5/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_jit.rb: remove unnecessary requirek0kubun2018-02-081-1/+0
| | | | | | | | | 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
* test_jit.rb: try to test JIT againk0kubun2018-02-081-0/+68
| | | | | | | 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
* revert r62302 and force to define the version constantusa2018-02-081-5/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* no need to set bundled bundler unless Gem::USE_BUNDLER_FOR_GEMDEPSusa2018-02-081-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_gem_commands_setup_command.rb: BUNDLER_VERSnobu2018-02-081-1/+3
| | | | | | | * 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
* revert r62291 for nowk0kubun2018-02-081-60/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* test_jit.rb: make JIT count test optionalk0kubun2018-02-071-6/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_jit.rb: add initial test for JITk0kubun2018-02-071-0/+58
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/ostruct.rb: Use `FrozenError` instead of `RuntimeError`.marcandre2018-02-061-3/+3
| | | | | | | | | | | 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
* test_gem_util.rb: fix broken testnobu2018-02-061-5/+2
| | | | | | | * 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
* Merge RubyGems-2.7.5 from upstream.hsbt2018-02-0630-129/+182
| | | | | | 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
* mjit_compile.c: merge initial JIT compilerk0kubun2018-02-0410-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* mjit.c: merge MJIT infrastructurek0kubun2018-02-043-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* thread.c (thread_join_m): avoid NUM2TIMET for Bignumnormal2018-02-031-0/+9
| | | | | | 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
* compile.c: fix string Range optimization with FSLnormal2018-02-031-6/+8
| | | | | | | 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
* process.c: command_name encodingnobu2018-02-031-0/+16
| | | | | | | * 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
* test_system.rb: tests without shellnobu2018-02-021-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_system.rb: exit by abort for portabilitynobu2018-02-021-4/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix testkazu2018-02-021-6/+2
| | | | | | Followup to r62158 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add test for Forwardable#def_delegator with r55366.hsbt2018-02-011-0/+8
| | | | | | | Patch by @aycabta [Bug #12837][ruby-core:77611] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32.c: EPIPE for ERROR_NO_DATAnobu2018-02-011-0/+19
| | | | | | | * win32/win32.c (rb_w32_write): writing to closed pipe fails with ERROR_NO_DATA but msvcrt maps it to EINVAL. map it to EPIPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fptr_copy_finalizernobu2018-01-311-1/+2
| | | | | | | | * io.c (fptr_copy_finalizer): remove fptr from pipe_list when pipe became ordinary file, to fix access after free. to be finalized by pipe_finalize and being in pipe_list must match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: pipe_register_fptrnobu2018-01-311-0/+9
| | | | | | | * io.c (pipe_register_fptr): get rid of double registration which causes access after free and segfault. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* trick ruby-mode.el by heredocsnobu2018-01-314-7/+15
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.h: relax rb_funcall check on extra args for clangnormal2018-01-301-0/+11
| | | | | | | | | | | | | | | clang 5.+ (tested clang 7.0.0) seems to be attempting division-by-zero and giving a very large number for static args to rb_funcall. * include/ruby/ruby.h (rb_varargs_bad_length): relax check for clang * ext/-test-/funcall/funcall.c: renamed from passing_block.c define extra_args_name function * test/-ext-/funcall/test_funcall.rb: new test [ruby-core:85266] [Bug #14425] From: Eric Wong <e@80x24.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e