summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2020-07-19Special case Range#max for integer beginning and Float::Infinity endJeremy Evans
Popular Ruby libraries such as Rails and Rubocop relying on the previous behavior, even though it is technically a bug. The correct behavior is probably raising RangeError, since that is what an endless range raises. Related to [Bug #17017]
2020-07-19Fix Range#max for beginless Integer ranges [Bug #17034]Michael Kohl
* Fix Range#max for beginless Integer ranges * Update test/ruby/test_range.rb * Fix formatting https://github.com/ruby/ruby/pull/3328 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged-By: nobu <nobu@ruby-lang.org>
2020-07-18Optimize Array#min (#3324)Kenta Murata
The benchmark result is below: | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |ary2.min | 39.105M| 39.442M| | | -| 1.01x| |ary10.min | 23.995M| 30.762M| | | -| 1.28x| |ary100.min | 6.249M| 10.783M| | | -| 1.73x| |ary500.min | 1.408M| 2.714M| | | -| 1.93x| |ary1000.min | 828.397k| 1.465M| | | -| 1.77x| |ary2000.min | 332.256k| 570.504k| | | -| 1.72x| |ary3000.min | 338.079k| 573.868k| | | -| 1.70x| |ary5000.min | 168.217k| 286.114k| | | -| 1.70x| |ary10000.min | 85.512k| 143.551k| | | -| 1.68x| |ary20000.min | 43.264k| 71.935k| | | -| 1.66x| |ary50000.min | 17.317k| 29.107k| | | -| 1.68x| |ary100000.min | 9.072k| 14.540k| | | -| 1.60x| |ary1000000.min | 872.930| 1.436k| | | -| 1.64x| compare-ruby is 9f4b7fc82e. Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2020-07-18Optimize Array#max (#3325)Kenta Murata
The benchmark result is below: | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |ary2.max | 38.837M| 40.830M| | | -| 1.05x| |ary10.max | 23.035M| 32.626M| | | -| 1.42x| |ary100.max | 5.490M| 11.020M| | | -| 2.01x| |ary500.max | 1.324M| 2.679M| | | -| 2.02x| |ary1000.max | 699.167k| 1.403M| | | -| 2.01x| |ary2000.max | 284.321k| 570.446k| | | -| 2.01x| |ary3000.max | 282.613k| 571.683k| | | -| 2.02x| |ary5000.max | 145.120k| 285.546k| | | -| 1.97x| |ary10000.max | 72.102k| 142.831k| | | -| 1.98x| |ary20000.max | 36.065k| 72.077k| | | -| 2.00x| |ary50000.max | 14.343k| 29.139k| | | -| 2.03x| |ary100000.max | 7.586k| 14.472k| | | -| 1.91x| |ary1000000.max | 726.915| 1.495k| | | -| 2.06x| Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2020-07-15Fixed infinite loop at error in printing cause [Bug #17033]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3320
2020-07-13Fix Range#{max,minmax} for range with integer beginning and non-integer endJeremy Evans
Previously, for inclusive ranges, the max would show up as the end of the range, even though the end was not an integer and would not be the maximum value. For exclusive ranges, max/minmax would previously raise a TypeError, even though it is possible to get the correct maximum. This change to max/minmax also uncovered a similar error in cover?, which calls max in certain cases, so adjust the code there so that cover? still works as expected. Fixes [Bug #17017] Notes: Merged: https://github.com/ruby/ruby/pull/3306 Merged-By: jeremyevans <code@jeremyevans.net>
2020-07-12Fixed yday and wday with timezone [Bug #17024]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3312
2020-07-10Encode ' as &apos; when using encode(xml: :attr)Jeremy Evans
Fixes [Bug #16922] Notes: Merged: https://github.com/ruby/ruby/pull/3177
2020-07-10Fix an inaccurate comment in test_jitTakashi Kokubun
2020-07-10Make sure vm_call_cfunc uses inlined ccTakashi Kokubun
which is checked by the first guard. When JIT-inlined cc and operand cd->cc are different, the JIT-ed code might wrongly dispatch cd->cc even while class check is done with another cc inlined by JIT. This fixes SEGV on railsbench.
2020-07-08Added `NODE_SPECIAL_EXCESSIVE_COMMA` info to `ARGS` of ↵manga_osyo
`RubyVM::AbstractSyntaxTree`. Notes: Merged: https://github.com/ruby/ruby/pull/3298
2020-07-06Add operator info to `OP_ASGN2` of `RubyVM::AbstractSyntaxTree`.manga_osyo
Notes: Merged: https://github.com/ruby/ruby/pull/3294
2020-07-04Check ROBJECT_EMBED on guards-merged ivar accessTakashi Kokubun
Fix CI failure like http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3043247 introduced by a69dd699ee630dd1086627dbca15a218a8538b6f
2020-07-04Fix non-numeric exclusive Range#minmax bugSam Bostock
The implementation of Range#minmax added in d5c60214c45 causes the following incorrect behaviour: ('a'...'c').minmax => ["a", ["a", "b"]] instead of ('a'...'c').minmax => ["a", "b"] This is because the C implementation of Range#minmax (range_minmax) directly delegates to the C implementation of Range#min (range_min) and Range#max (range_max), without changing the execution context. Range#max's C implementation (range_max), when given a non-numeric exclusive range, delegates to super, which is meant to call Enumerable#max. However, because range_max is called directly by range_minmax, super calls Enumerable#minmax instead, causing the incorrect nesting. Perhaps it is possible to change the execution context in an optimized manner, but the simplest solution seems to be to just explicitly delegate from Range#minmax to Range#min and Range#max. Notes: Merged: https://github.com/ruby/ruby/pull/3285
2020-07-03Make Kernel#then, #yield_self, #frozen? builtin (#3283)Takashi Kokubun
* Make Kernel#then, #yield_self, #frozen? builtin * Fix test_jit Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-07-03Rewrite Kernel#tap with Ruby (#3281)Takashi Kokubun
* Rewrite Kernel#tap with Ruby This was good for VM too, but of course my intention is to unblock JIT's inlining of a block over yield (inlining invokeyield has not been committed though). * Fix test_settracefunc About the :tap deletions, the :tap events are actually traced (we already have a TracePoint test for builtin methods), but it's filtered out by tp.path == "xyzzy" (it became "<internal:kernel>"). We could trace tp.path == "<internal:kernel>" cases too, but the lineno is impacted by kernel.rb changes and I didn't want to make it fragile for kernel.rb lineno changes. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-27Suppress "assigned but unused variable" warningsKazuki Tsujimoto
2020-06-27Add #deconstruct cache to find patternVladimir Dementyev
Notes: Merged: https://github.com/ruby/ruby/pull/3104
2020-06-27Optimize array pattern matching by caching #deconstruct valueVladimir Dementyev
Notes: Merged: https://github.com/ruby/ruby/pull/3104
2020-06-25Collect insns from a child processTakashi Kokubun
to make sure :opt_invokebuiltin_delegate_leave doesn't become :(trace_)opt_invokebuiltin_delegate. This is to prevent a warning like > /tmp/ruby/v3/src/trunk-test/test/ruby/test_jit.rb:618: warning: 'opt_invokebuiltin_delegate_leave' insn is not included in the script. Actual insns are: opt_invokebuiltin_delegate leave
2020-06-26test/ruby/test_settracefunc.rb: Suppress a warningYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200626T033003Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20200626T033003Z/ruby/test/ruby/test_settracefunc.rb:2299: warning: ambiguous first argument; put parentheses or a space even after `/' operator ```
2020-06-26fix return event and opt_invokebuiltin_delegate_leave (#3256)Koichi Sasada
If :return event is specified for a opt_invokebuiltin_delegate_leave and leave combination, the instructions should be opt_invokebuiltin_delegate trace_return instructions. To make it, opt_invokebuiltin_delegate_leave instruction will be changed to opt_invokebuiltin_delegate even if it is not an event target instruction. Notes: Merged-By: ko1 <ko1@atdot.net>
2020-06-24Do not JIT inline builtin methodsTakashi Kokubun
It's probably not worth it because there's nothing we can optimize in such builtin methods. It's worth JIT only when inlined.
2020-06-24Run a TracePoint test in an insolated processTakashi Kokubun
to prevent a random failure like http://ci.rvm.jp/results/trunk-random2@phosphorus-docker/3024287
2020-06-25Drop token info for endless method definitionNobuyoshi Nakada
Because it does not have closing `end`.
2020-06-24Fix a random test failure by TracePointTakashi Kokubun
A test worker process may already be enabling TracePoint, which results in changing the insn name in this test. http://ci.rvm.jp/results/trunk-random0@phosphorus-docker/3022750
2020-06-23Trace :return of builtin methodsTakashi Kokubun
using opt_invokebuiltin_delegate_leave insn. Since Ruby 2.7, :return of methods using builtin have not been traced properly.
2020-06-21test/ruby/test_jit.rb: Change the condition to detect RHEL 7.1 s390xYusuke Endoh
2020-06-20Skip a test_jit with builtin for rhel_zlinuxTakashi Kokubun
Either 95b0fed371 or 7561db8c00 started to cause https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel_zlinux/ruby-master/log/20200621T053303Z.fail.html.gz But so far no idea why it's happening. Until I get direct ssh access to debug the details, let me skip this as it's essentially not ruby's fault.
2020-06-20Make Integer#zero? a separated method and builtin (#3226)Takashi Kokubun
A prerequisite to fix https://bugs.ruby-lang.org/issues/15589 with JIT. This commit alone doesn't make a significant difference yet, but I thought this commit should be committed independently. This method override was discussed in [Misc #16961]. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-19Implement Proc#== and #eql?Jeremy Evans
Previously, these were not implemented, and Object#== and #eql? were used. This tries to check the proc internals to make sure that procs created from separate blocks are treated as not equal, but procs created from the same block are treated as equal, even when the lazy proc allocation optimization is used. Implements [Feature #14267] Notes: Merged: https://github.com/ruby/ruby/pull/3174
2020-06-19test/ruby/test_refinement.rb: suppress warning yb $VEROBSE = nilYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200619T003004Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20200619T003004Z/ruby/test/ruby/test_refinement.rb:2428: warning: method redefined; discarding old foo /home/chkbuild/chkbuild/tmp/build/20200619T003004Z/ruby/test/ruby/test_refinement.rb:2418: warning: previous definition of foo was here ```
2020-06-18Allow refining a frozen classJeremy Evans
Doing so modifies the class's method table, but not in a way that should be detectable from Ruby, so it may be safe to avoid checking if the class is frozen. Fixes [Bug #11669] Notes: Merged: https://github.com/ruby/ruby/pull/3175
2020-06-18Raise RuntimeError for class variable overtaken in nonverbose modeJeremy Evans
900e83b50115afda3f79712310e4cb95e4508972 changed from a warning to an error in this case, but the warning was only issued in verbose mode, and therefore the error was only raised in verbose mode. That was not intentional, verbose mode should only change whether warnings are emitted, not other behavior. This issues the RuntimeError in all cases. This change broke a couple tests, as the tests actually issued the warning and therefore now raise an error. This wasn't caught earlier as test_variable suppressed the warning in this case, effectively setting $VERBOSE = false around the code that warned. basictest isn't run in verbose mode and therefore didn't expose the issue previously. Fix these tests. Fixes [Bug #14541] Notes: Merged: https://github.com/ruby/ruby/pull/3210
2020-06-18Dup splat array in certain cases where there is a block argumentJeremy Evans
This makes: ```ruby args = [1, 2, -> {}]; foo(*args, &args.pop) ``` call `foo` with 1, 2, and the lambda, in addition to passing the lambda as a block. This is different from the previous behavior, which passed the lambda as a block but not as a regular argument, which goes against the expected left-to-right evaluation order. This is how Ruby already compiled arguments if using leading arguments, trailing arguments, or keywords in the same call. This works by disabling the optimization that skipped duplicating the array during the splat (splatarray instruction argument switches from false to true). In the above example, the splat call duplicates the array. I've tested and cases where a local variable or symbol are used do not duplicate the array, so I don't expect this to decrease the performance of most Ruby programs. However, programs such as: ```ruby foo(*args, &bar) ``` could see a decrease in performance, if `bar` is a method call and not a local variable. This is not a perfect solution, there are ways to get around this: ```ruby args = Struct.new(:a).new([:x, :y]) def args.to_a; a; end def args.to_proc; a.pop; ->{}; end foo(*args, &args) # calls foo with 1 argument (:x) # not 2 arguments (:x and :y) ``` A perfect solution would require completely disabling the optimization. Fixes [Bug #16504] Fixes [Bug #16500] Notes: Merged: https://github.com/ruby/ruby/pull/3157
2020-06-18Make Module#prepend affect the iclasses of the moduleJeremy Evans
3556a834a2847e52162d1d3302d4c64390df1694 added support for Module#include to affect the iclasses of the module. It didn't add support for Module#prepend because there were bugs in the object model and GC at the time that prevented it. Those problems have been addressed in ad729a1d11c6c57efd2e92803b4e937db0f75252 and 98286e9850936e27e8ae5e4f20858cc9c13d2dde, and now adding support for it is straightforward and does not break any tests or specs. Fixes [Bug #9573] Notes: Merged: https://github.com/ruby/ruby/pull/3181
2020-06-18Add Hash#except ENV#except [Feature #15822]Timo Schilling
2020-06-17Remove obsoleted opt_call_c_function insn (#3232)Takashi Kokubun
* Remove obsoleted opt_call_c_function insn * Keep opt_call_c_function with DEFINE_INSN_IF Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-16Check argument to ObjectSpace._id2refNobuyoshi Nakada
Ensure that the argument is an Integer or implicitly convert to, before dereferencing as a Bignum. Addressed a regression in b99833baec2. Reported by u75615 at https://hackerone.com/reports/898614
2020-06-14Introduce find pattern [Feature #16828]Kazuki Tsujimoto
2020-06-12prevent memory allocation for GC testsKoichi Sasada
We observed test failures on test_latest_gc_info with random order CI. http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/2998078l0ll To solve it, use a pre-allocated hash object and rehearsal.
2020-06-11Prohibit setting class variable on frozen module through inheritanceAlan Wu
Setting class varibles goes through the ancestor list which can contain iclasses. Iclasses share a lot of information with the module they are made from, but not the frozen status. Check the frozen status of the module instead of the iclass. Notes: Merged: https://github.com/ruby/ruby/pull/3203
2020-06-11Warn when passing a non-literal block to Kernel#lambdaJeremy Evans
Implements [Feature #15973] Notes: Merged: https://github.com/ruby/ruby/pull/3209
2020-06-10Make proc/Proc.new without block an error instead of warningJeremy Evans
The warning for these was added in 2.7. Notes: Merged: https://github.com/ruby/ruby/pull/3208
2020-06-10ENV.delete should return the result of block on non-existing keyNobuyoshi Nakada
Fixes [Bug #16173] Co-Authored-By: Burdette Lamar <burdettelamar@yahoo.com> Co-Authored-By: Jeremy Evans <code@jeremyevans.net> Notes: Merged: https://github.com/ruby/ruby/pull/3206
2020-06-09Work around infinite loop when overriding method visibility in prepended ↵Jeremy Evans
module (#3201) For ZSUPER methods with no defined class for the method entry, start the next lookup at the superclass of the origin class of the method owner, instead of the superclass of the method owner. Fixes [Bug #16942] Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2020-06-09disable GC on a testKoichi Sasada
CI fails with GC while `foo{}`, so that disable GC for this script.
2020-06-07Differentiate `...` in lambda argumentsNobuyoshi Nakada
2020-06-06Add leading arguments support to arguments forwardingJeremy Evans
The idFWD_KWREST sections may be wrong. However, the existing idFWD_KWREST sections for ... without leading arguments are already broken. Implements [Feature #16378] Notes: Merged: https://github.com/ruby/ruby/pull/3190
2020-06-06Make test for no method error more reliableYuki Nishijima
This test should not depend on the bahaviour of the did_you_mean gem.