summaryrefslogtreecommitdiff
path: root/test/ruby
Commit message (Collapse)AuthorAgeFilesLines
* [Feature #18901] Don't run size pool move tests without VWAMatt Valentine-House2022-07-121-0/+2
|
* [Feature #18901] Support size pool movement for ArraysMatt Valentine-House2022-07-121-0/+40
| | | | | | | | | | | | | This commit enables Arrays to move between size pools during compaction. This can occur if the array is mutated such that it would fit in a different size pool when embedded. The move is carried out in two stages: 1. The RVALUE is moved to a destination heap during object movement phase of compaction 2. The array data is re-embedded and the original buffer free'd if required. This happens during the update references step
* Replace use of double_heap in tests with expand_heapMatt Valentine-House2022-07-111-5/+5
|
* Use NO_JIT_DESCRIPTION only when neededTakashi Kokubun2022-07-101-4/+5
| | | | Apparently 203801566a186b7b1cbe899a06d0832923a1bdf9 broke YJIT's CI.
* Fix #5872 for MJIT GitHub ActionsTakashi Kokubun2022-07-101-9/+5
| | | | | If you run tests with RUN_OPTS=--mjit, the test fixes in https://github.com/ruby/ruby/pull/5872 don't work.
* [Bug #18890] Suppress warnings and fix the messageNobuyoshi Nakada2022-07-082-6/+15
| | | | | | | | | | | | ``` test/ruby/test_parse.rb:1384: warning: assigned but unused variable - obj test/ruby/test_pattern_matching.rb:1162: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1165: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1161: warning: assigned but unused variable - a test/ruby/test_pattern_matching.rb:1164: warning: assigned but unused variable - b ``` And a newline should be significant here.
* Thread#value: handle threads killed by a forkJean Boussier2022-07-071-0/+14
| | | | | | | [Bug #18902] When a thread is killed because we forked, the `value` if left to `Qundef`. Returning it woudl crash the VM.
* [Bug #18892] Reset `ARGF.lineno` after reading shebangNobuyoshi Nakada2022-07-071-0/+11
|
* [Bug #18898] Fallback invalid external encoding to the defaultNobuyoshi Nakada2022-07-061-0/+10
|
* [Bug #18890] newline should be insignificant after pattern labelNobuyoshi Nakada2022-07-062-0/+48
|
* Synchronize the test thread not to die before assertionsNobuyoshi Nakada2022-07-051-1/+6
|
* [Bug #18877] Let `lex_ctxt` not to eat escaped whitespaceNobuyoshi Nakada2022-06-301-0/+4
|
* Refactor tests for moving strings with compactionPeter Zhu2022-06-291-28/+22
|
* [Bug #18884] `class` cannot be just followed by modifiersNobuyoshi Nakada2022-06-291-0/+7
|
* Fix infinite loop when b_return TracePoint throwsAlan Wu2022-06-221-0/+27
| | | | | | | | | Previously, we didn't pop the frame that runs the TracePoint hook for b_return events for blocks running as methods (bmethods). In case the hook raises, that formed an infinite loop during stack unwinding in hook_before_rewind(). [Bug #18060]
* Include JIT information in crash reportsChris Seaton2022-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Since enabling YJIT or MJIT drastically changes what could go wrong at runtime, it's good to be front and center about whether they are enabled when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the description printed when crashing can be different when a JIT is on. Introduce a new internal data global, `rb_dynamic_description`, and set it to be the same as `RUBY_DESCRIPTION` during initialization; use it when crashing. * version.c: Init_ruby_description(): Initialize and use `rb_dynamic_description`. * error.c: Change crash reports to use `rb_dynamic_description`. * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work for when we exit right after printing the description but that was deemed acceptable. * include/ruby/version.h: Talk about how JIT info is not in `ruby_description`. * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for crash description being different from `RUBY_DESCRIPTION`. * test/ruby/test_rubyoptions.rb: ditto Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
* [Feature #18788] Support options as `String` to `Regexp.new`Nobuyoshi Nakada2022-06-201-0/+17
| | | | | `Regexp.new` now supports passing the regexp flags not only as an `Integer`, but also as a `String. Unknown flags raise errors.
* Warn suspicious flag to `Regexp.new`Nobuyoshi Nakada2022-06-201-0/+6
| | | | | Now second argument should be `true`, `false`, `nil` or Integer. This flag is confused with third argument some times.
* Prevent a warning "possibly useless use of a literal in void context"Yusuke Endoh2022-06-201-0/+6
|
* Prevent a warning "Expected ... to define AutoloadTest but it didn't"Yusuke Endoh2022-06-201-0/+3
| | | | related: [Bugs #18813] and eca31d24d606a73def3674938112dc3c5b79c445
* [Bug #18813] Warn when autoload has to lookup in parent namespaceJean Boussier2022-06-181-0/+17
| | | | This is a verbose mode only warning.
* Skip failing test on FreeBSD [ci skip]Nobuyoshi Nakada2022-06-171-1/+3
|
* Allow calling protected methods from refinementsJohn Hawthorn2022-06-161-0/+35
| | | | | | | | | | | | | | Previously protected methods on refinements could never be called because they were seen as being "defined" on the hidden refinement ICLASS. This commit updates calling refined protected methods so that they are considered to be defined on the original class (the one being refined). This ended up using the same behaviour that was used to check whether a call to super was allowed, so I extracted that into a method. [Bug #18806]
* Respect the encoding of the source [Bug #18827]Nobuyoshi Nakada2022-06-172-0/+22
| | | | | Do not override the input string encoding at the time of preparation, the source encoding is not determined from the input yet.
* ENV.merge! support multile arguments [Feature #18279]Nobuyoshi Nakada2022-06-171-0/+8
|
* Added tests for setting ivars on frozen objsJemma Issroff2022-06-161-0/+30
|
* Adding more clone tests, and adding dup testsJemma Issroff2022-06-162-0/+156
|
* MJIT: Handle JIT failure properlyTakashi Kokubun2022-06-151-0/+12
|
* Remove MJIT worker thread (#6006)Takashi Kokubun2022-06-151-1/+5
| | | [Misc #18830]
* MJIT: Add a test for Process.waitall handlingTakashi Kokubun2022-06-141-0/+13
|
* Move String RVALUES between poolsMatt Valentine-House2022-06-131-0/+39
| | | | | And re-embed any strings that can now fit inside the slot they've been moved to
* Prevent a warning: assigned but unused variable - outYusuke Endoh2022-06-131-3/+3
| | | | | | | | | http://rubyci.s3.amazonaws.com/ubuntu1804/ruby-master/log/20220613T003003Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20220613T003003Z/ruby/test/ruby/test_yjit_exit_locations.rb:96: warning: assigned but unused variable - out /home/chkbuild/chkbuild/tmp/build/20220613T003003Z/ruby/test/ruby/test_yjit_exit_locations.rb:96: warning: assigned but unused variable - err /home/chkbuild/chkbuild/tmp/build/20220613T003003Z/ruby/test/ruby/test_yjit_exit_locations.rb:96: warning: assigned but unused variable - status ```
* Make method id explicit in rb_exec_recursive_outerJohn Hawthorn2022-06-101-0/+21
| | | | | | | | | | | | | | Previously, because opt_aref and opt_aset don't push a frame, when they would call rb_hash to determine the hash value of the key, the initial level of recursion would incorrectly use the method id at the top of the stack instead of "hash". This commit replaces rb_exec_recursive_outer with rb_exec_recursive_outer_mid, which takes an explicit method id, so that we can make the hash calculation behave consistently. rb_exec_recursive_outer was documented as being internal, so I believe this should be okay to change.
* Fix nested bmethod TracePoint and memory leakAlan Wu2022-06-101-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | df317151a5b4e0c5a30fcc321a9dc6abad63f7ed removed the code to free rb_hook_list_t, so repeated targeting of the same bmethod started to leak the hook list. You can observe how the maximum memory use scales with input size in the following script with `/usr/bin/time -v`. ```ruby o = Object.new o.define_singleton_method(:foo) {} trace = TracePoint.new(:return) {} bmethod = o.method(:foo) ARGV.first.to_i.times { trace.enable(target:bmethod){} } 4.times {GC.start} ``` After this change the maximum doesn't grow as quickly. To plug the leak, check whether the hook list is already allocated when enabling the targeting TracePoint for the bmethod. This fix also allows multiple TracePoints to target the same bmethod, similar to other valid TracePoint targets. Finally, free the rb_hook_list_t struct when freeing the method definition it lives on. Freeing in the GC is a good way to avoid lifetime problems similar to the one fixed in df31715. [Bug #18031]
* Remove a leftover requireTakashi Kokubun2022-06-091-1/+0
| | | | | I thought about using it in 2931957d6ff16b5c095f6e8095384c98130133ad once and then ended up not using it.
* Fix exit locations test (#5995)Eileen M. Uchitelle2022-06-091-3/+12
| | | | | | | | | | | | | | | | | I originally added the check for RubyVM::YJIT.trace_exit_locations_enabled? to fix errors when these tests run without the stats feature enabled. However I forgot that this will never be true when this test is booting, so nothing was running when the stats feature is turned on. Instead I've decided to make a new hash in the dump file and check if exit locations are enabled there. If they aren't enabled we return early to avoid checking for keys that won't exit in the dumped exit locations. I chose to add this additional enabled check because empty exit locations might not indicate that stats isn't enabled, it could mean the feature is entirely broken. I do want these tests to fail if stats are on and nothing was collected. Followup to #5970
* Add ability to trace exit locations in yjit (#5970)Eileen M. Uchitelle2022-06-091-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running with `--yjit-stats` turned on, yjit can inform the user what the most common exits are. While this is useful information it doesn't tell you the source location of the code that exited or what the code that exited looks like. This change intends to fix that. To use the feature, run yjit with the `--yjit-trace-exits` option, which will record the backtrace for every exit that occurs. This functionality requires the stats feature to be turned on. Calling `--yjit-trace-exits` will automatically set the `--yjit-stats` option. Users must call `RubyVM::YJIT.dump_exit_locations(filename)` which will Marshal dump the contents of `RubyVM::YJIT.exit_locations` into a file based on the passed filename. *Example usage:* Given the following script, we write to a file called `concat_array.dump` the results of `RubyVM::YJIT.exit_locations`. ```ruby def concat_array ["t", "r", *x = "u", "e"].join end 1000.times do concat_array end RubyVM::YJIT.dump_exit_locations("concat_array.dump") ``` When we run the file with this branch and the appropriate flags the stacktrace will be recorded. Note Stackprof needs to be installed or you need to point to the library directly. ``` ./ruby --yjit --yjit-call-threshold=1 --yjit-trace-exits -I/Users/eileencodes/open_source/stackprof/lib test.rb ``` We can then read the dump file with Stackprof: ``` ./ruby -I/Users/eileencodes/open_source/stackprof/lib/ /Users/eileencodes/open_source/stackprof/bin/stackprof --text concat_array.dump ``` Results will look similar to the following: ``` ================================== Mode: () Samples: 1817 (0.00% miss rate) GC: 0 (0.00%) ================================== TOTAL (pct) SAMPLES (pct) FRAME 1001 (55.1%) 1001 (55.1%) concatarray 335 (18.4%) 335 (18.4%) invokeblock 178 (9.8%) 178 (9.8%) send 140 (7.7%) 140 (7.7%) opt_getinlinecache ...etc... ``` Simply inspecting the `concatarray` method will give `SOURCE UNAVAILABLE` because the source is insns.def. ``` ./ruby -I/Users/eileencodes/open_source/stackprof/lib/ /Users/eileencodes/open_source/stackprof/bin/stackprof --text concat_array.dump --method concatarray ``` Result: ``` concatarray (nonexistent.def:1) samples: 1001 self (55.1%) / 1001 total (55.1%) callers: 1000 ( 99.9%) Object#concat_array 1 ( 0.1%) Gem.suffixes callees (0 total): code: SOURCE UNAVAILABLE ``` However if we go deeper to the callee we can see the exact source of the `concatarray` exit. ``` ./ruby -I/Users/eileencodes/open_source/stackprof/lib/ /Users/eileencodes/open_source/stackprof/bin/stackprof --text concat_array.dump --method Object#concat_array ``` ``` Object#concat_array (/Users/eileencodes/open_source/rust_ruby/test.rb:1) samples: 0 self (0.0%) / 1000 total (55.0%) callers: 1000 ( 100.0%) block in <main> callees (1000 total): 1000 ( 100.0%) concatarray code: | 1 | def concat_array 1000 (55.0%) | 2 | ["t", "r", *x = "u", "e"].join | 3 | end ``` The `--walk` option is recommended for this feature as it make it easier to traverse the tree of exits. *Goals of this feature:* This feature is meant to give more information when working on YJIT. The idea is that if we know what code is exiting we can decide what areas to prioritize when fixing exits. In some cases this means adding prioritizing avoiding certain exits in yjit. In more complex cases it might mean changing the Ruby code to be more performant when run with yjit. Ultimately the more information we have about what code is exiting AND why, the better we can make yjit. *Known limitations:* * Due to tracing exits, running this on large codebases like Rails can be quite slow. * On complex methods it can still be difficult to pinpoint the exact cause of an exit. * Stackprof is a requirement to to view the backtrace information from the dump file. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Stop ignoring 4th positional argument to IO.#{foreach,readlines}Jeremy Evans2022-06-091-0/+3
| | | | Fixes [Bug #18771]
* Fix MJIT's ISEQ_BODY macro usage at 5f10bd634fbTakashi Kokubun2022-06-081-0/+10
|
* MJIT: Ignore existence of .bundle.dSYM on macOSTakashi Kokubun2022-06-081-4/+16
| | | | | | | We could fix it, but removing files in the directory recursively is tedious in C and --mjit-debug is not a concern for users. We have TestMJITDebug for detecting linker problems that are ignored by -O. It's not really for maintaining --mjit-debug itself.
* Add key force_major_gc_count to GC.stat_heapPeter Zhu2022-06-081-0/+1
| | | | | force_major_gc_count is the number of times the size pool forced major GC to run.
* Revert "error.c: Let Exception#inspect inspect its message"Yusuke Endoh2022-06-071-6/+0
| | | | This reverts commit 9d927204e7b86eb00bfd07a060a6383139edf741.
* error.c: Let Exception#inspect inspect its messageYusuke Endoh2022-06-071-0/+6
| | | | | | | | | | | | ... only when the message string has a newline. `p StandardError.new("foo\nbar")` now prints `#<StandardError: "foo\nbar">' instead of: #<StandardError: bar> [Bug #18170]
* Ignore invalid escapes in regexp commentsJeremy Evans2022-06-061-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Invalid escapes are handled at multiple levels. The first level is in parse.y, so skip invalid unicode escape checks for regexps in parse.y. Make rb_reg_preprocess and unescape_nonascii accept the regexp options. In unescape_nonascii, if the regexp is an extended regexp, when "#" is encountered, ignore all characters until the end of line or end of regexp. Unfortunately, in extended regexps, you can use "#" as a non-comment character inside a character class, so also parse "[" and "]" specially for extended regexps, and only skip comments if "#" is not inside a character class. Handle nested character classes as well. This issue doesn't just affect extended regexps, it also affects "(#?" comments inside all regexps. So for those comments, scan until trailing ")" and ignore content inside. I'm not sure if there are other corner cases not handled. A better fix would be to redesign the regexp parser so that it unescaped during parsing instead of before parsing, so you already know the current parsing state. Fixes [Bug #18294] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Fix Module#const_source_location for autoload constants with direct requiresJeremy Evans2022-06-061-0/+17
| | | | | | | | | | If an autoload exists for a constant, but the path for the autoload was required, const_source_location would return [false, 0] instead of the actual file and line. This fixes it by setting the appropriate file and line in rb_const_set, and saving the file and line in const_tbl_update before they get reset by current_autoload_data. Fixes [Bug #18624]
* Fix Range#cover? returning true for beginless ranges of different typesJeremy Evans2022-06-061-0/+29
| | | | | | | | | | | | | Previously `(2..).cover?("2"..)` was false, but `(..2).cover?(.."2")` was true. This changes it so both are false, treating beginless ranges the same as endless ranges in regards to type checks. This also adds documentation to #cover? to describe behavior with beginless and endless ranges, testing each documentation example, which is how this bug was found. Fixes [Bug #18155]
* Add Module#undefined_instance_methodsJeremy Evans2022-06-061-0/+9
| | | | | Implements [Feature #12655] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Move `GC.verify_compaction_references` [Bug #18779]Nobuyoshi Nakada2022-06-021-10/+1
| | | | | Define `GC.verify_compaction_references` as a built-in ruby method, according to GC compaction support via `GC::OPTS`.
* Fix the condition when a new buffer is needed without GMPNobuyoshi Nakada2022-06-021-0/+9
|
* Skip failing test with freebsdHiroshi SHIBATA2022-05-311-0/+2
|