summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2022-05-24Define unsupported GC compaction methods as rb_f_notimplementMike Dalessio
Fixes [Bug #18779] Define the following methods as `rb_f_notimplement` on unsupported platforms: - GC.compact - GC.auto_compact - GC.auto_compact= - GC.latest_compact_info - GC.verify_compaction_references This change allows users to call `GC.respond_to?(:compact)` to properly test for compaction support. Previously, it was necessary to invoke `GC.compact` or `GC.verify_compaction_references` and check if those methods raised `NotImplementedError` to determine if compaction was supported. This follows the precedent set for other platform-specific methods. For example, in `process.c` for methods such as `Process.fork`, `Process.setpgid`, and `Process.getpriority`. Notes: Merged: https://github.com/ruby/ruby/pull/5934
2022-05-20Make the test class naming consistentTakashi Kokubun
forgot to commit this in ead96e7b44b98bef4896d836239345012821f1d2
2022-05-20Rename test_jit to test_mjitTakashi Kokubun
to avoid confusion with YJIT
2022-05-19YJIT: Add opt_succ (#5919)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-05-17Restore implicit relationship between `autoload_const` and `autoload_data` ↵Samuel Williams
during GC. (#5911) Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-05-17Delete autoload data from global features after autoload has completed. (#5910)Samuel Williams
* Update naming of critical section assertions macros. * Improved locking for autoload. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-05-12YJIT: Implement getblockparamAaron Patterson
This implements the getblockparam instruction. There are two cases we need to handle depending on whether or not VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM is set in the environment flag. When the modified flag is unset, we need to call rb_vm_bh_to_procval to get a proc from our passed block, save the proc in the environment, and set the modified flag. In the case that the modified flag is set we are able to just use the existing proc in the environment. One quirk of this is that we need to call jit_prepare_routine_call early and ensure we update PC and SP regardless of the branch taken, so that we have a consistent SP offset at the start of the next instruction. We considered using a chain guard to generate these two paths separately, but decided against it because it's very common to see both and the modified case is basically a subset of the instructions in the unmodified case. This includes tests for both getblockparam and getblockparamproxy which was previously missing a test. Notes: Merged: https://github.com/ruby/ruby/pull/5881
2022-05-11Ruby shovel operator (<<) speedup. (#5896)Noah Gibbs
For string concat, see if compile-time encoding of strings matches. If so, use simple buffer string concat at runtime. Otherwise, use encoding-checking string concat. Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-05-10Fix the order of assert_eqaul and remove unused variablesNobuyoshi Nakada
2022-05-09Add basic binary operators (and, or, xor, not) to `IO::Buffer`. (#5893)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-05-09Explicit handling of frozen strings in `IO::Buffer#for`. (#5892)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-05-03Add a regression test for opt_plus with unknown type (#5878)Maxime Chevalier-Boisvert
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-04-28Add missing write barriers to Array#replaceAlan Wu
Previously it made object references without using write barriers, creating GC inconsistencies. See: http://ci.rvm.jp/results/trunk-gc-asserts@phosphorus-docker/3925529 Notes: Merged: https://github.com/ruby/ruby/pull/5851
2022-04-27Rust YJITAlan Wu
In December 2021, we opened an [issue] to solicit feedback regarding the porting of the YJIT codebase from C99 to Rust. There were some reservations, but this project was given the go ahead by Ruby core developers and Matz. Since then, we have successfully completed the port of YJIT to Rust. The new Rust version of YJIT has reached parity with the C version, in that it passes all the CRuby tests, is able to run all of the YJIT benchmarks, and performs similarly to the C version (because it works the same way and largely generates the same machine code). We've even incorporated some design improvements, such as a more fine-grained constant invalidation mechanism which we expect will make a big difference in Ruby on Rails applications. Because we want to be careful, YJIT is guarded behind a configure option: ```shell ./configure --enable-yjit # Build YJIT in release mode ./configure --enable-yjit=dev # Build YJIT in dev/debug mode ``` By default, YJIT does not get compiled and cargo/rustc is not required. If YJIT is built in dev mode, then `cargo` is used to fetch development dependencies, but when building in release, `cargo` is not required, only `rustc`. At the moment YJIT requires Rust 1.60.0 or newer. The YJIT command-line options remain mostly unchanged, and more details about the build process are documented in `doc/yjit/yjit.md`. The CI tests have been updated and do not take any more resources than before. The development history of the Rust port is available at the following commit for interested parties: https://github.com/Shopify/ruby/commit/1fd9573d8b4b65219f1c2407f30a0a60e537f8be Our hope is that Rust YJIT will be compiled and included as a part of system packages and compiled binaries of the Ruby 3.2 release. We do not anticipate any major problems as Rust is well supported on every platform which YJIT supports, but to make sure that this process works smoothly, we would like to reach out to those who take care of building systems packages before the 3.2 release is shipped and resolve any issues that may come up. [issue]: https://bugs.ruby-lang.org/issues/18481 Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> Co-authored-by: Noah Gibbs <the.codefolio.guy@gmail.com> Co-authored-by: Kevin Newton <kddnewton@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/5826
2022-04-22Avoid defining the same test class in multiple filesJeremy Evans
Should fix issues with parallel testing sometimes not running all tests. This should be viewed skipping whitespace changes. Fixes [Bug #18731] Notes: Merged: https://github.com/ruby/ruby/pull/5839
2022-04-21Uncomment code to raise LocalJumpError for yield across thread through enumJeremy Evans
Not sure if this is the correct fix. It does raise LocalJumpError in the yielding thread as you would expect, but the value yielded to the calling thread is still yielded without an exception. Fixes [Bug #18649] Notes: Merged: https://github.com/ruby/ruby/pull/5692
2022-04-21Private local variables should shadow outer variables [Bug #18629]Nobuyoshi Nakada
2022-04-16Fix class ancestry checks for duped classesJohn Hawthorn
Previously in some when classes were duped (specifically those with a prepended module), they would not correctly have their "superclasses" array or depth filled in. This could cause ancestry checks (like is_a? and Module comparisons) to return incorrect results. This happened because rb_mod_init_copy builds origin classes in an order that doesn't have the super linked list fully connected until it's finished. This commit fixes the previous issue by calling rb_class_update_superclasses before returning the cloned class. This is similar to what's already done in make_metaclass. Notes: Merged: https://github.com/ruby/ruby/pull/5808
2022-04-15Compare predicate methods as a boolean valueNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5803
2022-04-15[Win32] Fix mode of character/pipe device stat [Bug #18732]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5803
2022-04-12Use an empty string when building File.expand_pathPeter Zhu
Allocating a string of length MAXPATHLEN and then shrinking the string is inefficient when the resulting path is short. Preallocating a large string is also a problem for Variable Width Allocation since we can't easily downsize the capacity. I ran the following benchmark: ```ruby Benchmark.ips do |x| { "empty" => "", "short" => "a/" * 10, "medium" => "a/" * 100, "long" => "a/" * 500 }.each do |name, path| x.report(name) do |times| i = 0 while i < times File.expand_path(path) i += 1 end end end end ``` On this commit: ``` empty 97.486k (± 0.7%) i/s - 492.915k in 5.056507s short 96.026k (± 2.4%) i/s - 486.489k in 5.068966s medium 86.304k (± 1.3%) i/s - 435.336k in 5.045112s long 59.395k (± 1.7%) i/s - 302.175k in 5.089026s ``` On master: ``` empty 94.138k (± 1.4%) i/s - 472.158k in 5.016590s short 92.043k (± 1.4%) i/s - 468.180k in 5.087496s medium 84.910k (± 2.3%) i/s - 425.750k in 5.017007s long 61.503k (± 2.7%) i/s - 309.723k in 5.039429s ``` Notes: Merged: https://github.com/ruby/ruby/pull/5789
2022-04-12Fix dtoa buffer overrunNobuyoshi Nakada
https://hackerone.com/reports/1248108 Notes: Merged: https://github.com/ruby/ruby/pull/5794
2022-04-12Just free compiled pattern if no space is usedNobuyoshi Nakada
https://hackerone.com/reports/1220911 Notes: Merged: https://github.com/ruby/ruby/pull/5793
2022-04-11test/ruby/test_keyword.rb: Prevent warning: assigned but unused variableYusuke Endoh
2022-04-06Raise RuntimeError if Kernel#binding is called from a non-Ruby frameJeremy Evans
Check whether the current or previous frame is a Ruby frame in call_trace_func and rb_tracearg_binding before attempting to create a binding for the frame. Fixes [Bug #18487] Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged: https://github.com/ruby/ruby/pull/5767 Merged-By: jeremyevans <code@jeremyevans.net>
2022-04-05Fix using anonymous block in method accepting explicit keywordsJeremy Evans
Record block ID before vtable_pop, so the incorrect one doesn't override it. Fixes [Bug #18673] Notes: Merged: https://github.com/ruby/ruby/pull/5761
2022-04-05Unflag a splatted flagged hash if the method doesn't use ruby2_keywordsJeremy Evans
For a method such as: def foo(*callee_args) end If this method is called with a flagged hash (created by a method flagged with ruby2_keywords), this previously passed the hash through without modification. With this change, it acts as if the last hash was passed as keywords, so a call to: foo(*caller_args) where the last element of caller_args is a flagged hash, will be treated as: foo(*caller_args[0...-1], **caller_args[-1]) As a result, inside foo, callee_args[-1] is an unflagged duplicate of caller_args[-1] (all other elements of callee_args match caller_args). Fixes [Bug #18625] Notes: Merged: https://github.com/ruby/ruby/pull/5684
2022-04-05Apply timescale configuration for tests of Regexp.timeoutYusuke Endoh
2022-04-01Finer-grained constant cache invalidation (take 2)Kevin Newton
This commit reintroduces finer-grained constant cache invalidation. After 8008fb7 got merged, it was causing issues on token-threaded builds (such as on Windows). The issue was that when you're iterating through instruction sequences and using the translator functions to get back the instruction structs, you're either using `rb_vm_insn_null_translator` or `rb_vm_insn_addr2insn2` depending if it's a direct-threading build. `rb_vm_insn_addr2insn2` does some normalization to always return to you the non-trace version of whatever instruction you're looking at. `rb_vm_insn_null_translator` does not do that normalization. This means that when you're looping through the instructions if you're trying to do an opcode comparison, it can change depending on the type of threading that you're using. This can be very confusing. So, this commit creates a new translator function `rb_vm_insn_normalizing_translator` to always return the non-trace version so that opcode comparisons don't have to worry about different configurations. [Feature #18589] Notes: Merged: https://github.com/ruby/ruby/pull/5716
2022-04-01Revert "Raise RuntimeError if Kernel#binding is called from a non-Ruby frame"Jeremy Evans
This reverts commit 343ea9967e4a6b279eed6bd8e81ad0bdc747f254. This causes an assertion failure with -DRUBY_DEBUG=1 -DRGENGC_CHECK_MODE=2
2022-03-31Return only captured range in `MatchData` [Bug #18670]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5740 Merged-By: nobu <nobu@ruby-lang.org>
2022-03-31re.c: stop a wrong warning of "flags ignored" on Regexp.new(//)Yusuke Endoh
[Bug #18669]
2022-03-30Do not autosplat array in block call just because keywords acceptedJeremy Evans
If the block only accepts a single positional argument plus keywords, then do not autosplat. Still autosplat if the block accepts more than one positional argument in addition to keywords. Autosplatting a single positional argument plus keywords made sense in Ruby 2, since a final positional hash could be used as keywords, but it does not make sense in Ruby 3. Fixes [Bug #18633] Notes: Merged: https://github.com/ruby/ruby/pull/5665 Merged-By: jeremyevans <code@jeremyevans.net>
2022-03-30re.c: raise Regexp::TimeoutError instead of RuntimeErrorYusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/5703
2022-03-30re.c: Add `timeout` keyword for Regexp.new and Regexp#timeoutYusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/5703
2022-03-30re.c: Add Regexp.timeout= and Regexp.timeoutYusuke Endoh
[Feature #17837] Notes: Merged: https://github.com/ruby/ruby/pull/5703
2022-03-29Avoid trace events in implementation of TracePoint#enableJeremy Evans
This is more backwards compatible, and should fix issues with power_assert. Unfortunately, it requires using a sentinel value as the default value of target_thread, instead of the more natural expression used in the original approach. Notes: Merged: https://github.com/ruby/ruby/pull/5359
2022-03-29Make TracePoint#enable with block target current thread by defaultJeremy Evans
If TracePoint#enable is passed a block, it previously started the trace on all threads. This changes it to trace only the current thread by default. To limit the scope of the change, the current thread is only used by default if target and target_line are both nil. You can pass target_thread: nil to enable tracing on all threads, to get the previous default behavior. Fixes [Bug #16889] Notes: Merged: https://github.com/ruby/ruby/pull/5359
2022-03-29Fix multiplex backreferencs near end of string in regexp matchJeremy Evans
Idea from Jirka Marsik. Fixes [Bug #18631] Notes: Merged: https://github.com/ruby/ruby/pull/5710
2022-03-29Make define_singleton_method always define a public methodJeremy Evans
In very unlikely cases, it could previously define a non-public method starting in Ruby 2.1. Fixes [Bug #18561] Notes: Merged: https://github.com/ruby/ruby/pull/5636
2022-03-25Revert "Finer-grained inline constant cache invalidation"Nobuyoshi Nakada
This reverts commits for [Feature #18589]: * 8008fb7352abc6fba433b99bf20763cf0d4adb38 "Update formatting per feedback" * 8f6eaca2e19828e92ecdb28b0fe693d606a03f96 "Delete ID from constant cache table if it becomes empty on ISEQ free" * 629908586b4bead1103267652f8b96b1083573a8 "Finer-grained inline constant cache invalidation" MSWin builds on AppVeyor have been crashing since the merger. Notes: Merged: https://github.com/ruby/ruby/pull/5715 Merged-By: nobu <nobu@ruby-lang.org>
2022-03-24Raise RuntimeError if Kernel#binding is called from a non-Ruby frameJeremy Evans
Check whether the current or previous frame is a Ruby frame in call_trace_func before attempting to create a binding for the frame. Fixes [Bug #18487] Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged: https://github.com/ruby/ruby/pull/5567
2022-03-24Finer-grained inline constant cache invalidationKevin Newton
Current behavior - caches depend on a global counter. All constant mutations cause caches to be invalidated. ```ruby class A B = 1 end def foo A::B # inline cache depends on global counter end foo # populate inline cache foo # hit inline cache C = 1 # global counter increments, all caches are invalidated foo # misses inline cache due to `C = 1` ``` Proposed behavior - caches depend on name components. Only constant mutations with corresponding names will invalidate the cache. ```ruby class A B = 1 end def foo A::B # inline cache depends constants named "A" and "B" end foo # populate inline cache foo # hit inline cache C = 1 # caches that depend on the name "C" are invalidated foo # hits inline cache because IC only depends on "A" and "B" ``` Examples of breaking the new cache: ```ruby module C # Breaks `foo` cache because "A" constant is set and the cache in foo depends # on "A" and "B" class A; end end B = 1 ``` We expect the new cache scheme to be invalidated less often because names aren't frequently reused. With the cache being invalidated less, we can rely on its stability more to keep our constant references fast and reduce the need to throw away generated code in YJIT. Notes: Merged: https://github.com/ruby/ruby/pull/5433
2022-03-23Raise ArgumentError when calling Enumberable#inject without block or argumentsJeremy Evans
Previously, this would work as expected if the enumerable contained 0 or 1 element, and would raise LocalJumpError otherwise. That inconsistent behavior is likely to lead to bugs. Fixes [Bug #18635] Notes: Merged: https://github.com/ruby/ruby/pull/5690
2022-03-19Make a dedecated assertion to clarify failed assertionsNobuyoshi Nakada
2022-03-18Add String#bytespliceShugo Maeda
Notes: Merged: https://github.com/ruby/ruby/pull/5584
2022-03-17Make Proc#parameters support lambda keyword for returning parameters as if ↵Jeremy Evans
lambda This makes it easier to use Proc#parameters to build wrappers. Implements [Feature #15357] Notes: Merged: https://github.com/ruby/ruby/pull/5677
2022-03-18A positional Hash is not keyword arguments [Bug #18632]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5676
2022-03-17A positional Hash is not keyword arguments [Bug #18632]Nobuyoshi Nakada
2022-03-16Revert "Fix version check to use Emoji version for ↵Martin Dürst
emoji-variation-sequences.txt" This reverts commit 48f1e8c5d85043e6adb8e93c94532daa201d42e9.