summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2021-11-26fix to choose correct callcacheKoichi Sasada
It should retun general `cc`, not for overloaded (mandatory only) method call cache. This issue is reported by @shugo and @ktou https://twitter.com/shugomaeda/status/1463699797182119936 Notes: Merged: https://github.com/ruby/ruby/pull/5173
2021-11-25YJIT: Implement new struct accessors (#5161)John Hawthorn
* YJIT: Implement optimized_method_struct_aref * YJIT: Implement struct_aref without method call Struct member reads can be compiled directly into a memory read (with either one or two levels of indirection). * YJIT: Implement optimized struct aset * YJIT: Update tests for struct access * YJIT: Add counters for remaining optimized methods * Check for INT32_MAX overflow It only takes a struct with 0x7fffffff/8+1 members. Also add some cheap compile time checks. * Add tests for non-embedded struct aref/aset Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged-By: jhawthorn <john@hawthorn.email>
2021-11-25Revert "Add GC.stat_size_pool to get stats for a size pool"Peter Zhu
This reverts commit 6157619bb68e4307cdf065cb73d5bfcec30d042d. We'll wait for comments in the open ticket: https://bugs.ruby-lang.org/issues/18364 Notes: Merged: https://github.com/ruby/ruby/pull/5176
2021-11-25Add GC.stat_size_pool to get stats for a size poolPeter Zhu
GC.stat_size_pool will return stats for a particular size pool. This is used for the Variable Width Allocation feature. Notes: Merged: https://github.com/ruby/ruby/pull/5169
2021-11-25test/ruby/test_iseq.rb: Avoid pollution of method namespaceYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20211125T003004Z.log.html.gz ``` [ 4780/21204] TestISeq#test_super_with_anonymous_block/home/chkbuild/chkbuild/tmp/build/20211125T003004Z/ruby/test/ruby/test_iseq.rb:141: warning: method redefined; discarding old touch3 /home/chkbuild/chkbuild/tmp/build/20211125T003004Z/ruby/test/ruby/test_iseq.rb:121: warning: previous definition of touch3 was here = 0.00 s ```
2021-11-24test/ruby/test_iseq.rb: Use __LINE__ to make the error log easy to seeYusuke Endoh
2021-11-23Add setclassvariable to yjit (#5127)Eileen M. Uchitelle
Implements setclassvariable in yjit. Note that this version is not faster than the standard version because we aren't handling the inline cache in assembly. This is still important to implement because it will prevent yjit from exiting in methods that call both a cvar setter and other code that yjit can compile. Co-authored-by: Aaron Patterson tenderlove@ruby-lang.org Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2021-11-23Add an extra failing test case for [Bug #18250]Jean Boussier
The parameter being called `req` specifically causes an assertion error: ``` Assertion failed: (key != 0), function hash_table_raw_insert, file id_table.c, line 153. ``` Renaming the parameter or removing the `*` doesn't reproduce. Notes: Merged: https://github.com/ruby/ruby/pull/5157
2021-11-23Add Class#subclassesJean Boussier
Implements [Feature #18273] Returns an array containing the receiver's direct subclasses without singleton classes. Notes: Merged: https://github.com/ruby/ruby/pull/5045
2021-11-23Suppress the “experimental" warnings for `IO::Buffer`Nobuyoshi Nakada
As this warning is emitted just once per processes, needs in each files when parallel testing.
2021-11-21Fix setting struct member by public_sendNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5152
2021-11-19Add YJIT codegen for objtostring (#5149)Adam Hess
This is the minimal correct objtostring implementation in YJIT. For correctness, it is important that to_string not get called on strings or subclasses of string. There is a new test for this behavior. A follow up should implement an optimized version for other types as performed in `vm_objtostring`. Co-authored-by: John Hawthorn <jhawthorn@github.com> Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2021-11-19Fix test_super_with_anonymous_block test to use anonymous blockJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/5147
2021-11-19optimize `Struct` getter/setterKoichi Sasada
Introduce new optimized method type `OPTIMIZED_METHOD_TYPE_STRUCT_AREF/ASET` with index information. Notes: Merged: https://github.com/ruby/ruby/pull/5131
2021-11-18Optimize dynamic string interpolation for symbol/true/false/nil/0-9Jeremy Evans
This provides a significant speedup for symbol, true, false, nil, and 0-9, class/module, and a small speedup in most other cases. Speedups (using included benchmarks): :symbol :: 60% 0-9 :: 50% Class/Module :: 50% nil/true/false :: 20% integer :: 10% [] :: 10% "" :: 3% One reason this approach is faster is it reduces the number of VM instructions for each interpolated value. Initial idea, approach, and benchmarks from Eric Wong. I applied the same approach against the master branch, updating it to handle the significant internal changes since this was first proposed 4 years ago (such as CALL_INFO/CALL_CACHE -> CALL_DATA). I also expanded it to optimize true/false/nil/0-9/class/module, and added handling of missing methods, refined methods, and RUBY_DEBUG. This renames the tostring insn to anytostring, and adds an objtostring insn that implements the optimization. This requires making a few functions non-static, and adding some non-static functions. This disables 4 YJIT tests. Those tests should be reenabled after YJIT optimizes the new objtostring insn. Implements [Feature #13715] Co-authored-by: Eric Wong <e@80x24.org> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Co-authored-by: Koichi Sasada <ko1@atdot.net> Notes: Merged: https://github.com/ruby/ruby/pull/5002 Merged-By: jeremyevans <code@jeremyevans.net>
2021-11-18Anonymous block forwarding allows a method to forward a passedJeremy Evans
block to another method without having to provide a name for the block parameter. Implements [Feature #11256] Co-authored-by: Yusuke Endoh mame@ruby-lang.org Co-authored-by: Nobuyoshi Nakada nobu@ruby-lang.org Notes: Merged: https://github.com/ruby/ruby/pull/5051
2021-11-18Make Module#{public,private,protected,module_function} return argumentsJeremy Evans
Previously, each of these methods returned self, but it is more useful to return arguments, to allow for simpler method decorators, such as: ```ruby cached private def foo; some_long_calculation; end ``` Where cached sets up caching for the method. For each of these methods, the following behavior is used: 1) No arguments returns nil 2) Single argument is returned 3) Multiple arguments are returned as an array The single argument case is really the case we are trying to optimize for, for the same reason that def was changed to return a symbol for the method. Idea and initial patch from Herwin Quarantainenet. Implements [Feature #12495] Notes: Merged: https://github.com/ruby/ruby/pull/5037
2021-11-18Expect bool as `sort:` option at glob [Feature #18287]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5084 Merged-By: nobu <nobu@ruby-lang.org>
2021-11-17Allow Kernel#load to load code into a specified moduleJeremy Evans
Instead of always using a new anonymous module for Kernel#load if the wrap argument is not false/nil, use the given module if a module is provided. Implements [Feature #6210] Notes: Merged: https://github.com/ruby/ruby/pull/4986
2021-11-17Add tests for cme NULL crashPeter Zhu
Tests for GitHub PR #5122. Originally in GitHub PR #5121. Notes: Merged: https://github.com/ruby/ruby/pull/5132
2021-11-16Make Enumerable#each_cons return object if over sizeJeremy Evans
This behavior changed in dfb47bbd17c3c2b8ce17dbafaf62df023b0224b2, but only for normal exit, not for early exit. Fix it for early exit as well. While here, fix example code in documentation so that it doesn't indicate that the method returns nil. Notes: Merged: https://github.com/ruby/ruby/pull/5129
2021-11-16Add a test for bug 18343Jeremy Evans
This already passes in master, 3.0, and 2.7, but would fail in ruby 2.6 as it segfaults instead of raising an exception. I think it's good to have a test for this to catch possible future regressions. Notes: Merged: https://github.com/ruby/ruby/pull/5128
2021-11-17Validate string type when constructing IO::Buffer for string mapping.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/5115
2021-11-17`Primitive.mandatory_only?` consider splat argsJean Boussier
`vm_ci_argc` gives the number of arguments, but `*[1, 2, 3]` only counts for one. Notes: Merged: https://github.com/ruby/ruby/pull/5124
2021-11-15test/ruby/test_m17n.rb: skip a test that breaks another testYusuke Endoh
See https://bugs.ruby-lang.org/issues/18338
2021-11-15Revert "test/ruby/test_m17n.rb: Run a test under assert_separately"Yusuke Endoh
This reverts commit a698181021c11711dc56b74dacbdebc2895b5384. It failed on macos for a unknown problem. ``` 1) Error: TestM17N#test_object_inspect_external: Encoding::ConverterNotFoundError: code converter not found (US-ASCII to UTF-16BE) /Users/runner/work/ruby/ruby/src/test/ruby/test_m17n.rb:312:in `encode' /Users/runner/work/ruby/ruby/src/test/ruby/test_m17n.rb:312:in `inspect' /Users/runner/work/ruby/ruby/src/test/ruby/test_m17n.rb:315:in `inspect' /Users/runner/work/ruby/ruby/src/test/ruby/test_m17n.rb:315:in `<main>' /Users/runner/work/ruby/ruby/src/test/ruby/test_m17n.rb:299:in `test_object_inspect_external' ``` https://github.com/ruby/ruby/runs/4207871418?check_suite_focus=true
2021-11-15test/ruby/test_m17n.rb: Run a test under assert_separatelyYusuke Endoh
The test uses `Encoding.default_external = Encoding::UTF_16BE`, which may add a wrongly UTF_16BE-encoded path to $LOADED_FEATURES (depending on the order of tests). Unfortunately this breaks another test: http://ci.rvm.jp/results/trunk-test@ruby-sky1/3711615 ``` /tmp/ruby/v3/src/trunk-test/test/io/console/test_io_console.rb:11:in `===': incompatible encoding regexp match (US-ASCII regexp with UTF-16BE string) (Encoding::CompatibilityError) ``` According to @naruse-san, we don't pay effort to such a case, so this change just avoids the issue by running the test in question under another process. Co-Authored-By: Koichi Sasada <ko1@atdot.net>
2021-11-12test/ruby/test_jit.rb: suppress a false-positive warningYusuke Endoh
It reports "opt_regexpmatch2 insn is not included", but actually it is included. This is due to a known bug of ISeq#to_a on which this check depends. https://bugs.ruby-lang.org/issues/18269
2021-11-12Rework implementation of `IO::Buffer.for(string)` to use string locking.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/5109
2021-11-12More immutability and locking tests.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/5109
2021-11-11[Bug #18329] Fix crash when calling non-existent super methodPeter Zhu
The cme is NULL when a method does not exist, so check it before accessing the callcache. Notes: Merged: https://github.com/ruby/ruby/pull/5108
2021-11-11fix a memory leak introduced in 8bbd319Matt Valentine-House
This commit fixes a memory leak introduced in an early part of the variable width allocation project that would prevent the rb_classext_t struct from being free'd when the class is swept. Notes: Merged: https://github.com/ruby/ruby/pull/5103
2021-11-10[ci skip] Fix typo in test namePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/5102
2021-11-10IO::Buffer for scheduler interface.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4621
2021-11-10class.c: descendants must not cause GC until the result array is createdYusuke Endoh
Follow up of 428227472fc6563046d8138aab17f07bef6af753. The previous fix uses `rb_ary_new_from_values` to create the result array, but it may trigger the GC. This second try is to create the result array by `rb_ary_new_capa` before the second iteration, and assume that `rb_ary_push` does not trigger GC. This assumption is very fragile, so should be improved in future. [Bug #18282] [Feature #14394] Notes: Merged: https://github.com/ruby/ruby/pull/5097
2021-11-09test/ruby/test_iseq.rb: Prevent a warningYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20211109T063003Z.log.html.gz ``` [ 9898/21145] TestISeq#test_super_with_block_and_kwrest/home/chkbuild/chkbuild/tmp/build/20211109T063003Z/ruby/test/ruby/test_iseq.rb:1: warning: method redefined; discarding old touch /home/chkbuild/chkbuild/tmp/build/20211109T063003Z/ruby/test/ruby/test_iseq.rb:1: warning: previous definition of touch was here = 0.00 s ```
2021-11-09test/ruby/test_enum.rb: Prevent a warningYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20211109T063003Z.log.html.gz ``` [ 1960/21145] TestEnumerable#test_to_a_keywords/home/chkbuild/chkbuild/tmp/build/20211109T063003Z/ruby/test/ruby/test_enum.rb:138: warning: method redefined; discarding old each /home/chkbuild/chkbuild/tmp/build/20211109T063003Z/ruby/test/ruby/test_enum.rb:11: warning: previous definition of each was here = 0.00 s ```
2021-11-09class.c: calculate the length of Class.descendants in advanceYusuke Endoh
GC must not be triggered during callback of rb_class_foreach_subclass. To prevent GC, we can not use rb_ary_push. Instead, this changeset calls rb_class_foreach_subclass twice: first counts the subclasses, then allocates a buffer (which may cause GC and reduce subclasses, but not increase), and finally stores the subclasses to the buffer. [Bug #18282] [Feature #14394] Notes: Merged: https://github.com/ruby/ruby/pull/5070
2021-11-09test/ruby/test_fiber.rb: Extend timeout on SolarisYusuke Endoh
The test usually takes 200 sec. on Solaris, so the timeout of 300 sec. looks too short.
2021-11-08[Feature #18290] Remove tests that test use of rb_gc_force_recyclePeter Zhu
Remove tests that assume objects get force recycled. Notes: Merged: https://github.com/ruby/ruby/pull/5096
2021-11-07Refine the error message for hidden variablesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5035
2021-11-07rb_id_serial_to_id: return unregistered ID as an internal IDNobuyoshi Nakada
```ruby def foo(*); ->{ super }; end ``` This code makes anonymous parameters which is not registered as an ID. The problem is that when Ractors try to scan `getlocal` instructions, it puts the Symbol corresponding to the parameter in to a hash. Since it is not registered, we end up with a strange exception. This commit wraps the unregistered ID in an internal ID so that we get the same exception for `...` as `*`. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: John Hawthorn <john@hawthorn.email> Notes: Merged: https://github.com/ruby/ruby/pull/5035
2021-11-05YJIT: Implement checkkeyword (#5083)John Hawthorn
Co-authored-by: John Crepezzi <john.crepezzi@gmail.com> Co-authored-by: John Crepezzi <john.crepezzi@gmail.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2021-11-05Delegate keywords from Enumerable#to_a to #eachJeremy Evans
Fixes [Bug #18289] Notes: Merged: https://github.com/ruby/ruby/pull/5086
2021-11-05Add the test of `Dir.glob` when `sort: true` is given explicitlyNobuyoshi Nakada
2021-11-04test/ruby/test_gc_compact.rb: Backpatch the URL to the PRYusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/5077
2021-11-04test/ruby/test_gc_compact.rb: Do not run on s390xYusuke Endoh
The compaction tests get stuck randomly on s390x for unknown reason. http://rubyci.s3.amazonaws.com/s390x/ruby-master/log/20211104T030003Z.fail.html.gz ``` [13715/21145] TestGCCompact#test_gc_compact_statstimeout: output interval exceeds 1800.0 seconds. ``` We spent some time to investigate this issue, but we can't figure out why, and it is unlikely that we'll be able to fix it anytime soon. This random failure makes the CI unuseful, so tentatively we suppress this test for a while. A contribution from those who are familiar with s390x is welcome. Notes: Merged: https://github.com/ruby/ruby/pull/5077
2021-11-02Fix typosNobuyoshi Nakada
2021-10-31Argument forwarding definition without parentheses [Bug #18267]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5065
2021-10-30Apply the timeout scale to also separated workersNobuyoshi Nakada