summaryrefslogtreecommitdiff
path: root/test/ruby
Commit message (Collapse)AuthorAgeFilesLines
* Move ar_hint to ar_table_structPeter Zhu2023-05-172-1/+4
| | | | This allows Hashes with ST tables to fit int he 80 byte size pool.
* Implement Hash AR tables on VWAPeter Zhu2023-05-172-2/+24
|
* Unskip the test skipped in #4173 (#7809)KJ Tsanaktsidis2023-05-151-5/+0
| | | | | | | | | | | | | | | | | | | | | | | This test was skipped 12 years ago because it was flaky on FreeBSD and OpenBSD. Since then, Ruby's SIGCHLD handling has been substantially re-written (mostly by Eric Wong @normalperson in 44fc3d08). These tests now in fact pass reliably on Ruby master on FreeBSD 13.2 and OpenBSD 7.3. I stress-tested the test_wait_and_sigchild test on my laptop by running four copies of the test in a loop on a 8-core VM; both by itself and also as part of the whole test_process.rb file. I did not see any failures. Let's unskip the test and close [#4173] out. I'll keep an eye out on Ruby CI for any flakes in this file on BSD after this gets merged, but if we don't see any I'm going to assume 44fc3d08 or related changes around that time accidently fixed this bug. It's also probably important to unskip this test so that if another attempt at removing the special SIGCHLD handling is made (like was reverted in https://github.com/ruby/ruby/pull/7517), we get signal if that breaks on FreeBSD/OpenBSD. [Fixes #4173]
* [Bug #19025] Numbered parameter names are always local variablesNobuyoshi Nakada2023-05-141-0/+1
|
* Prevent warning: assigned but unused variableYusuke Endoh2023-05-102-2/+2
| | | | | | | | | http://rubyci.s3.amazonaws.com/debian10/ruby-master/log/20230510T123003Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20230510T123003Z/ruby/test/objspace/test_objspace.rb:224: warning: assigned but unused variable - c4 /home/chkbuild/chkbuild/tmp/build/20230510T123003Z/ruby/test/ruby/test_class.rb:362: warning: assigned but unused variable - e /home/chkbuild/chkbuild/tmp/build/20230510T123003Z/ruby/test/ruby/test_process.rb:2602: warning: assigned but unused variable - parent_pid ```
* [Bug #19597] Freeze script nameNobuyoshi Nakada2023-05-101-0/+5
|
* Continue checking all gemspec files after errorsNobuyoshi Nakada2023-05-051-1/+1
|
* test_default_gems.rb: Stop using `git ls-files`Nobuyoshi Nakada2023-05-041-7/+11
| | | | | | | | Just validate syntax and the result class instead. Not only `git ls-files` doesn't make sence under ruby's repository, some gemspec files hardcode `2>/dev/null`, which doesn't work of course on other than Unix-like platforms.
* Make the maximum shapes variation warning non-verboseJean Boussier2023-05-031-1/+1
| | | | | | | | [Feature #19538] Since that category is not enabled by default, making it a verbose warning is redundant. Enabling performance warning should work with the default verbosity level.
* Allow EPIPE when the child process has exited before interruptNobuyoshi Nakada2023-05-021-0/+2
|
* [Bug #19619] Preserve numbered parameters contextNobuyoshi Nakada2023-05-021-0/+2
| | | | Preserve numbered parameters context across method definitions
* [Bug #19624] Hide internal IO for backquoteNobuyoshi Nakada2023-05-011-0/+13
|
* Handle private AREF call in compile.cNobuyoshi Nakada2023-04-301-0/+8
|
* Relax timeout limit for FreeBSD again [ci skip]Nobuyoshi Nakada2023-04-301-1/+1
|
* [Bug #19611] Remove never-reachable branch in logical expressionNobuyoshi Nakada2023-04-271-0/+10
|
* Wrap `undef_method :a` with `ensure`Gary Tou2023-04-261-2/+2
|
* Test: `defined?(super)` in `BasicObject` returns `nil`Gary Tou2023-04-261-0/+14
| | | | Ensure it returns `nil` instead of segmentation faulting
* Speed up calling iseq bmethodsJeremy Evans2023-04-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, bmethod arguments are copied from the VM stack to the C stack in vm_call_bmethod, then copied from the C stack to the VM stack later in invoke_iseq_block_from_c. This is inefficient. This adds vm_call_iseq_bmethod and vm_call_noniseq_bmethod. vm_call_iseq_bmethod is an optimized method that skips stack copies (though there is one copy to remove the receiver from the stack), and avoids calling vm_call_bmethod_body, rb_vm_invoke_bmethod, invoke_block_from_c_proc, invoke_iseq_block_from_c, and vm_yield_setup_args. Th vm_call_iseq_bmethod argument handling is similar to the way normal iseq methods are called, and allows for similar performance optimizations when using splats or keywords. However, even in the no argument case it's still significantly faster. A benchmark is added for bmethod calling. In my environment, it improves bmethod calling performance by 38-59% for simple bmethod calls, and up to 180% for bmethod calls passing literal keywords on both sides. ``` ./miniruby-iseq-bmethod: 18159792.6 i/s ./miniruby-m: 13174419.1 i/s - 1.38x slower bmethod_simple_1 ./miniruby-iseq-bmethod: 15890745.4 i/s ./miniruby-m: 10008972.7 i/s - 1.59x slower bmethod_simple_0_splat ./miniruby-iseq-bmethod: 13142804.3 i/s ./miniruby-m: 11168595.2 i/s - 1.18x slower bmethod_simple_1_splat ./miniruby-iseq-bmethod: 12375791.0 i/s ./miniruby-m: 8491140.1 i/s - 1.46x slower bmethod_no_splat ./miniruby-iseq-bmethod: 10151258.8 i/s ./miniruby-m: 8716664.1 i/s - 1.16x slower bmethod_0_splat ./miniruby-iseq-bmethod: 8138802.5 i/s ./miniruby-m: 7515600.2 i/s - 1.08x slower bmethod_1_splat ./miniruby-iseq-bmethod: 8028372.7 i/s ./miniruby-m: 5947658.6 i/s - 1.35x slower bmethod_10_splat ./miniruby-iseq-bmethod: 6953514.1 i/s ./miniruby-m: 4840132.9 i/s - 1.44x slower bmethod_100_splat ./miniruby-iseq-bmethod: 5287288.4 i/s ./miniruby-m: 2243218.4 i/s - 2.36x slower bmethod_kw ./miniruby-iseq-bmethod: 8931358.2 i/s ./miniruby-m: 3185818.6 i/s - 2.80x slower bmethod_no_kw ./miniruby-iseq-bmethod: 12281287.4 i/s ./miniruby-m: 10041727.9 i/s - 1.22x slower bmethod_kw_splat ./miniruby-iseq-bmethod: 5618956.8 i/s ./miniruby-m: 3657549.5 i/s - 1.54x slower ```
* Generalize cfunc large array splat fix to fix many additional cases raising ↵Jeremy Evans2023-04-251-1/+882
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SystemStackError Originally, when 2e7bceb34ea858649e1f975a934ce1894d1f06a6 fixed cfuncs to no longer use the VM stack for large array splats, it was thought to have fully fixed Bug #4040, since the issue was fixed for methods defined in Ruby (iseqs) back in Ruby 2.2. After additional research, I determined that same issue affects almost all types of method calls, not just iseq and cfunc calls. There were two main types of remaining issues, important cases (where large array splat should work) and pedantic cases (where large array splat raised SystemStackError instead of ArgumentError). Important cases: ```ruby define_method(:a){|*a|} a(*1380888.times) def b(*a); end send(:b, *1380888.times) :b.to_proc.call(self, *1380888.times) def d; yield(*1380888.times) end d(&method(:b)) def self.method_missing(*a); end not_a_method(*1380888.times) ``` Pedantic cases: ```ruby def a; end a(*1380888.times) def b(_); end b(*1380888.times) def c(_=nil); end c(*1380888.times) c = Class.new do attr_accessor :a alias b a= end.new c.a(*1380888.times) c.b(*1380888.times) c = Struct.new(:a) do alias b a= end.new c.a(*1380888.times) c.b(*1380888.times) ``` This patch fixes all usage of CALLER_SETUP_ARG with splatting a large number of arguments, and required similar fixes to use a temporary hidden array in three other cases where the VM would use the VM stack for handling a large number of arguments. However, it is possible there may be additional cases where splatting a large number of arguments still causes a SystemStackError. This has a measurable performance impact, as it requires additional checks for a large number of arguments in many additional cases. This change is fairly invasive, as there were many different VM functions that needed to be modified to support this. To avoid too much API change, I modified struct rb_calling_info to add a heap_argv member for storing the array, so I would not have to thread it through many functions. This struct is always stack allocated, which helps ensure sure GC doesn't collect it early. Because of how invasive the changes are, and how rarely large arrays are actually splatted in Ruby code, the existing test/spec suites are not great at testing for correct behavior. To try to find and fix all issues, I tested this in CI with VM_ARGC_STACK_MAX to -1, ensuring that a temporary array is used for all array splat method calls. This was very helpful in finding breaking cases, especially ones involving flagged keyword hashes. Fixes [Bug #4040] Co-authored-by: Jimmy Miller <jimmy.miller@shopify.com>
* Allow anonymous memberless StructJeremy Evans2023-04-241-1/+0
| | | | | | | Previously, named memberless Structs were allowed, but anonymous memberless Structs were not. Fixes [Bug #19416]
* Use UTF-8 encoding for literal extended regexps with UTF-8 characters in ↵Jeremy Evans2023-04-231-0/+7
| | | | | | comments Fixes [Bug #19455]
* YJIT: invokesuper: Remove cme mid matching checkJohn Hawthorn2023-04-201-0/+19
| | | | | | | | | | This check was introduced to match an assertion in the C YJIT when this was originally introduced. I don't believe it's necessary for correctness of the generated code. Co-authored-by: Adam Hess <HParker@github.com> Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> Co-authored-by: Luan Vieira <luanzeba@github.com>
* fix `NameError` messageKoichi Sasada2023-04-191-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following code produces two NameErrors respectively and they are independent, but the second one can show `private constant` message because of first NameError. ```ruby class C class PrivateClass; end private_constant :PrivateClass end begin eval('class C::PrivateClass; end') rescue => e p e end begin Object.const_get 'Foo' rescue => e p e end #<NameError: private constant C::PrivateClass referenced> #<NameError: private constant C::Foo referenced> #=> should be #<NameError: uninitialized constant Foo> ``` It fails the test-all tests with `make test-all TESTS='ruby/class ruby/parse --seed=58891 -v`. The reason is clear miss from https://github.com/ruby/ruby/commit/7387c08373a
* * remove trailing spaces. [ci skip]git2023-04-191-1/+1
|
* Refactor `Regexp#match` cache implementation (#7724)TSUYUSATO Kitsune2023-04-191-3/+11
| | | | | | | | | | * Refactor Regexp#match cache implementation Improved variable and function names Fixed [Bug 19537] (Maybe fixed in https://github.com/ruby/ruby/pull/7694) * Add a comment of the glossary for "match cache" * Skip to reset match cache when no cache point on null check
* MatchData#named_captures: add optional symbolize_names keyword (#6952)Vladimir Dementyev2023-04-191-0/+3
|
* skip if `DidYouMean.formatter=` is not definedKoichi Sasada2023-04-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ruby/test_default_gems.rb can define empty `DidYouMean` module because of the following line (second require) in the `lib/did_you_mean/did_you_mean.gemspec`: ```ruby begin require_relative "lib/did_you_mean/version" rescue LoadError # Fallback to load version file in ruby core repository require_relative "version" end ``` It defines only `::DidYouMean::VERSION`. However, in the `test/ruby/test_patten_matching.rb` assumes that if `defined?(DidYouMean)` is true, then there is a method `DidYouMean.formatter=` and this assumption fails all tests in `test/ruby/test_patten_matching.rb` if there is only a `::DidYouMean::VERSION`. To reproduce the failures, we need to repeat the following command: `make test-all TESTS='-v ruby/test_default_gems.rb ruby/pattern_matching'` (because the ruby/test_default_gems.rb should be run before the ruby/pattern_matching`) This patch introduces more strict gurds.
* Implement ObjectSpace::WeakMap#delete and ObjectSpace::WeakKeyMap#deleteJean Boussier2023-04-152-4/+33
| | | | | | [Feature #19561] It's useful to be able to remove references from weak maps.
* [Bug #19533] Fix infinite range inclusion with numeric valueNobuyoshi Nakada2023-04-141-0/+2
|
* Emit a performance warning when a class reached max variationsJean Boussier2023-04-132-5/+22
| | | | | | | [Feature #19538] This new `peformance` warning category is disabled by default. It needs to be specifically enabled via `-W:performance` or `Warning[:performance] = true`
* [Feature #19590] Show the invalid clock argumentNobuyoshi Nakada2023-04-131-2/+6
| | | | | Include the failed clock argument in the error message from `Process.clock_gettime` and `Process.clock_getres`.
* [Bug #19587] Fix `reset_match_cache` argumentsNobuyoshi Nakada2023-04-121-0/+8
|
* hash.c: Fix hash_iter_lev_dec corrupting shapeJean Boussier2023-04-111-0/+11
| | | | | | | [Bug #19589] When decrementing `iter_lev` from `65` to `64` the flags would be corrupted, causing the shape_id to be invalid.
* [Bug #19570] Propagate message encoding to decorated messageNobuyoshi Nakada2023-04-101-0/+13
|
* Add guard to compaction test in WeakMapPeter Zhu2023-04-061-0/+2
| | | | Some platforms don't support compaction, so we should skip this test.
* Add missing test for Data.initializeMarc-Andre Lafortune2023-04-061-0/+1
|
* Revert "Fix transient heap mode"Aaron Patterson2023-04-041-8/+0
| | | | | | | | This reverts commit 87253d047ce35e7836b6f97edbb4f819879a3b25. Revert "Implement `Process.warmup`" This reverts commit ba6ccd871442f55080bffd53e33678c0726787d2.
* Implement `Process.warmup`Jean Boussier2023-04-041-0/+8
| | | | | | | | | | | | [Feature #18885] For now, the optimizations performed are: - Run a major GC - Compact the heap - Promote all surviving objects to oldgen Other optimizations may follow.
* Fix crash in Time on 32-bit systemsPeter Zhu2023-04-041-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [Bug #19575] struct vtm is packed causing it to have a size that is not aligned on 32-bit systems. When allocating it on the stack, it will have unaligned addresses which means that the fields won't be marked by the GC when scanning the stack (since the GC only marks aligned addresses). This can cause crashes when the fields are heap allocated objects like Bignums. This commit moves the flags in struct time_object into struct vtm for space efficiency and removes the need for packing. This is an example of a crash: ruby(rb_print_backtrace+0xd) [0x56848945] ../src/vm_dump.c:785 ruby(rb_vm_bugreport) ../src/vm_dump.c:1101 ruby(rb_assert_failure+0x7a) [0x56671857] ../src/error.c:878 ruby(vm_search_cc+0x0) [0x56666e47] ../src/vm_method.c:1366 ruby(rb_vm_search_method_slowpath) ../src/vm_insnhelper.c:2090 ruby(callable_method_entry+0x5) [0x568232d3] ../src/vm_method.c:1406 ruby(rb_callable_method_entry) ../src/vm_method.c:1413 ruby(gccct_method_search_slowpath) ../src/vm_eval.c:427 ruby(gccct_method_search+0x20f) [0x568237ef] ../src/vm_eval.c:476 ruby(opt_equality_by_mid_slowpath+0x2c) [0x5682388c] ../src/vm_insnhelper.c:2338 ruby(rb_equal+0x37) [0x566fe577] ../src/object.c:133 ruby(rb_big_eq+0x34) [0x56876ee4] ../src/bignum.c:5554 ruby(rb_int_equal+0x14) [0x566f3ed4] ../src/numeric.c:4640 ruby(rb_int_equal) ../src/numeric.c:4634 ruby(vm_call0_cfunc_with_frame+0x6d) [0x568303c2] ../src/vm_eval.c:148 ruby(vm_call0_cfunc) ../src/vm_eval.c:162 ruby(vm_call0_body) ../src/vm_eval.c:208 ruby(rb_funcallv_scope+0xd1) [0x56833971] ../src/vm_eval.c:85 ruby(RB_TEST+0x0) [0x567e8488] ../src/time.c:78 ruby(eq) ../src/time.c:78 ruby(small_vtm_sub) ../src/time.c:1523 ruby(timelocalw+0x23b) [0x567f3e9b] ../src/time.c:1593 ruby(time_s_alloc+0x0) [0x567f536b] ../src/time.c:3698 ruby(time_new_timew) ../src/time.c:2694 ruby(time_s_mktime) ../src/time.c:3698
* Avoid failing test_enable on warningsTakashi Kokubun2023-04-031-1/+6
| | | | | | This fails on RubyCI due to RJIT warnings too often. It should be enough to test RJIT feature in test_rjit_version. We only want warnings instead of test failures when there are warnings, at least for this case.
* [Bug #19547] Add token for unescaped backslashNobuyoshi Nakada2023-03-301-2/+16
| | | | | This token is exposed only when `RubyVM::AbstractSyntaxTree` with `keep_tokens` option.
* YJIT: Add `--yjit-pause` and `RubyVM::YJIT.resume` (#7609)Maxime Chevalier-Boisvert2023-03-281-0/+23
| | | | | | | | | | | | | | | | | | | * YJIT: Add --yjit-pause and RubyVM::YJIT.resume This allows booting YJIT in a suspended state. We chose to add a new command line option as opposed to simply allowing YJIT.resume to work without any command line option because it allows for combining with YJIT tuning command line options. It also simpifies implementation. Paired with Kokubun and Maxime. * Update yjit.rb Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> --------- Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* Fix memory leak for iclassPeter Zhu2023-03-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | [Bug #19550] If !RCLASS_EXT_EMBEDDED (e.g. 32 bit systems) then the rb_classext_t is allocated throug malloc so it must be freed. The issue can be seen in the following script: ``` 20.times do 100_000.times do mod = Module.new Class.new do include mod end end # Output the Resident Set Size (memory usage, in KB) of the current Ruby process puts `ps -o rss= -p #{$$}` end ``` Before this fix, the max RSS is 280MB, while after this change, it's 30MB.
* Historical timezones of Lisbon in tzdata are unstableNobuyoshi Nakada2023-03-261-2/+1
|
* [Bug #19175] p_rest should be `assignable'Kazuki Tsujimoto2023-03-261-0/+8
| | | | It should also check for duplicate names.
* Skip test_europe_lisbon on macOSTakashi Kokubun2023-03-251-0/+1
| | | | until we figure out why it's failing.
* IO::Buffer#resize: Free internal buffer if new size is zero (#7569)Kasumi Hanazuki2023-03-251-0/+18
| | | | | | | | | | `#resize(0)` on an IO::Buffer with internal buffer allocated will result in calling `realloc(data->base, 0)`. The behavior of `realloc` with size = 0 is implementation-defined (glibc frees the object and returns NULL, while BSDs return an inaccessible object). And thus such usage is deprecated in standard C (upcoming C23 will make it UB). To avoid this problem, just `free`s the memory when the new size is zero.
* Raise ArgumentError if IO.read is provided negative offsetJeremy Evans2023-03-241-0/+3
| | | | Fixes [Bug #19380]
* Add Dir.for_fdJeremy Evans2023-03-241-0/+15
| | | | | | | This returns a Dir instance for the given directory file descriptor. If fdopendir is not supported, this raises NotImplementedError. Implements [Feature #19347]
* Add Dir#chdirJeremy Evans2023-03-241-1/+40
| | | | | | This uses Dir.fchdir if supported, or Dir.chdir otherwise. Implements [Feature #19347]