summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2025-07-17ZJIT: Give up JIT-to-JIT calls for 6+ args (#13939)Takashi Kokubun
2025-07-16ZJIT: Split shift with immediate operand (#13914)Max Bernstein
Fix https://github.com/Shopify/ruby/issues/627
2025-07-16test_process.rb: UID.from_name may raise Errno::ENOENTTakashi Kokubun
See: 58bc97628c1 getpwnam(3) says the same thing. I got ENOENT in my Linux environment. 1) Failure: TestProcess#test_uid_from_name [/home/k0kubun/src/github.com/ruby/ruby/test/ruby/test_process.rb:1685]: Exception(ArgumentError) with message matches to /\u{4e0d 5b58 5728}/. [ArgumentError] exception expected, not #<Errno::ENOENT: No such file or directory - getpwnam_r>.
2025-07-16ZJIT: Fix SP alignment on JIT entry for x86_64Takashi Kokubun
2025-07-15ZJIT: Add failing test to test_spilled_method_args()Alan Wu
2025-07-16Suppress warnings for variablesNobuyoshi Nakada
2025-07-14ZJIT: Restore SP register after JIT-to-JIT call (#13882)Takashi Kokubun
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Stan Lo <stan.lo@shopify.com>
2025-07-11ZJIT: Mark objects baked in JIT code (#13862)Takashi Kokubun
2025-07-10ZJIT: Implement patch points on BOP redefinition (#13850)Takashi Kokubun
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
2025-07-10ZJIT: Avoid optimizing locals on eval (#13840)Takashi Kokubun
* ZJIT: Avoid optimizing locals on eval * Maintain the local state for eval
2025-07-10[Bug #19417] Make word prop match join_control ...Janosch Müller
... to conform to UTS 18 as mentioned in https://bugs.ruby-lang.org/issues/19417#note-3 https://unicode.org/reports/tr18/#word states word should match join_control chars. It currently does not: ```ruby [*0x0..0xD799, *0xE000..0x10FFFF].map { |n| n.chr 'utf-8' } => all_chars all_chars.grep(/\p{join_control}/) => jc jc.count # => 2 jc.grep(/\p{word}/).count # => 0 ```
2025-07-09ZJIT: Mark profiled objects when marking ISEQ (#13784)Takashi Kokubun
2025-07-09ZJIT: Name side-exit test cases correctlyStan Lo
2025-07-09ZJIT: Optimize `opt_and` and `opt_or` instructions for FixnumStan Lo
2025-07-09Rename variables to suit each methodNobuyoshi Nakada
2025-07-09Removed a left over from c71a60c1dd02Nobuyoshi Nakada
0a0eb2807ed7 has already replaced most of that code.
2025-07-08ZJIT: Support guarding *Exact types (#13797)Stan Lo
ZJIT already can generate guard type instructions for *Exact types. For example: ``` def test(strings) strings.map do |string| string.bytesize end end test(["foo", "bar"]) ``` ``` HIR: fn block in test: bb0(v0:BasicObject, v1:BasicObject): PatchPoint MethodRedefined(String@0x1014be890, bytesize@0x19f1) v7:StringExact = GuardType v1, StringExact v8:Fixnum = CCall bytesize@0x16fa4cc18, v7 Return v8 ``` But zjit only supported guarding fixnums so this script would panic. This commit adds support for guarding *Exact types.
2025-07-07Autoload encodings on the main ractorJean Boussier
None of the datastructures involved in the require process are safe to call on a secondary ractor, however when autoloading encodings, we do so from the current ractor. So all sorts of corruption can happen when using an autoloaded encoding for the first time from a secondary ractor.
2025-07-03Revert "Add locks around accesses/modifications to global encodings table"John Hawthorn
This reverts commit cf4d37fbc079116453e69cf08ea8007d0e1c73e6.
2025-07-03Revert "Make get/set default internal/external encoding lock-free"John Hawthorn
This reverts commit dda5a04f2b4835582dba09ba33797258a61efafe.
2025-07-03Make get/set default internal/external encoding lock-freeLuke Gruber
Also, make sure autoloading of encodings is safe across ractors.
2025-07-03Add locks around accesses/modifications to global encodings tableLuke Gruber
This fixes segfaults and errors of the type "Encoding not found" when using encoding-related methods and internal encoding c functions across ractors. Example of a possible segfault in release mode or assertion error in debug mode: ```ruby rs = [] 100.times do rs << Ractor.new do "abc".force_encoding(Encoding.list.shuffle.first) end end while rs.any? r, obj = Ractor.select(*rs) rs.delete(r) end ```
2025-07-03ZJIT: Panic on BOP redefinition only when needed (#13782)Takashi Kokubun
2025-07-03ZJIT: Bail out on register spill (#13773)Takashi Kokubun
2025-07-02ZJIT: Support spilling basic block arguments (#13761)Takashi Kokubun
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
2025-07-02ZJIT: Annotate NilClass#nil? and Kernel#nil?Stan Lo
These methods return fixed `true` or `false` so we can be certain about their return types.
2025-06-30ZJIT: Add codegen for IsNilywenc
2025-06-30ZJIT: Don't compile functions with unhandled parameter types (#13749)Max Bernstein
2025-06-28ZJIT: Codegen for `defined?(yield)`Alan Wu
Lots of stdlib methods such as Integer#times and Kernel#then use this, so at least this will make writing tests slightly easier.
2025-06-27ZJIT: Add TODOs and omitted test for nested scope local accessAlan Wu
2025-06-27ZJIT: Add codegen for GetLocal and SetLocalAlan Wu
They're only used when level≠0. Same EP hopping logic as interpreter and YJIT. Change assert_compiles() to get ISeq by method name since the old code didn't support methods defined using define_method() which I need for the new test.
2025-06-26Fix flaky TestGc#test_heaps_grow_independentlyPeter Zhu
The test sometimes fails with "Expected 2062788 to be < 2000000" because heap 0 has not been cleared yet by GC. This commit fixes it to run GC before the assertion to ensure that it does not flake.
2025-06-26Introduce Namespace#evalAaron Patterson
This commit adds an `eval` method to `Namespace` that takes a string and evaluates the string as Ruby code within the context of that namespace. For example: ```ruby n = Namespace.new n.eval("class TestClass; def hello; 'from namespace'; end; end") instance = n::TestClass.new instance.hello # => "from namespace" ``` [Feature #21365]
2025-06-25Include Set subclass name in Set#inspect outputJeremy Evans
Fixes [Bug #21377] Co-authored-by: zzak <zzak@hey.com>
2025-06-25Simplify Set#inspect outputJeremy Evans
As Set is now a core collection class, it should have special inspect output. Ideally, inspect output should be suitable to eval, similar to array and hash (assuming the elements are also suitable to eval): set = Set[1, 2, 3] eval(set.inspect) == set # should be true The simplest way to do this is to use the Set[] syntax. This deliberately does not use any subclass name in the output, similar to array and hash. It is more important that users know they are dealing with a set than which subclass: Class.new(Set)[] # this does: Set[] # not: #<Class:0x00000c21c78699e0>[] This inspect change breaks the power_assert bundled gem tests, so add power_assert to TEST_BUNDLED_GEMS_ALLOW_FAILURES in the workflows. Implements [Feature #21389]
2025-06-24Disallow forking from non-main ractorJean Boussier
[Bug #17516] `fork(2)` only leave the calling thread alive in the child. Because of this forking from the non-main ractor can easily leave the VM in a corrupted state. It may be possible in the future to carefully allow forking from non-main Ractor, but shot term it's preferable to add this restriction.
2025-06-24Set up callable_method_entry for DUMMY frame on ArgumentErrorYusuke Endoh
Before the patch: ``` $ ./miniruby -e '[1, 2].inject(:tap)' -e:1:in '<main>': wrong number of arguments (given 1, expected 0) (ArgumentError) from -e:1:in 'Enumerable#inject' from -e:1:in '<main>' ``` After the patch: ``` $ ./miniruby -e '[1, 2].inject(:tap)' -e:1:in 'Kernel#tap': wrong number of arguments (given 1, expected 0) (ArgumentError) from -e:1:in 'Enumerable#inject' from -e:1:in '<main>' ``` Fixes https://bugs.ruby-lang.org/issues/20968#change-113811
2025-06-24[Bug #21449] Fix Set#divide{|a,b|} using Union-find structure (#13680)tomoya ishida
* [Bug #21449] Fix Set#divide{|a,b|} using Union-find structure Implements Union-find structure with path compression. Since divide{|a,b|} calls the given block n**2 times in the worst case, there is no need to implement union-by-rank or union-by-size optimization. * Avoid internal arrays from being modified from block passed to Set#divide Internal arrays can be modified from yielded block through ObjectSpace. Freeze readonly array, use ALLOCV_N instead of mutable array.
2025-06-22Avoid allocation for positional splat for literal array keyword argumentJeremy Evans
If all nodes in the array are safe, then it is safe to avoid allocation for the positional splat: ```ruby m(*a, kw: [:a]) # Safe m(*a, kw: [meth]) # Unsafe ``` This avoids an unnecessary allocation in a Rails method call. Details: https://github.com/rails/rails/pull/54949/files#r2052645431
2025-06-21variable.c: avoid out of bound write in `generic_field_set`Jean Boussier
[Bug #21445]
2025-06-21Fix handling of PM_CONSTANT_PATH_NODE node in keyword arguments with ARGS_SPLATJeremy Evans
This was handled correctly in parse.y (NODE_COLON2), but not in prism. This wasn't caught earlier, because I only added tests for the optimized case and not the unoptimized case. Add tests for the unoptimized case. In code terms: ```ruby m(*a, kw: lvar::X) # Does not require allocation for *a m(*a, kw: method()::X) # Requires allocation for *a ``` This commit fixes the second case when prism is used.
2025-06-19ZJIT: Add `dupn` supportAlan Wu
Notes: Merged: https://github.com/ruby/ruby/pull/13641
2025-06-18ZJIT: Support invokebuiltin opcodes (#13632)Daniel Colson
* `invokebuiltin` * `invokebuiltin_delegate` * `invokebuiltin_delegate_leave` These instructions all call out to a C function, passing EC, self, and some number of arguments. `invokebuiltin` gets the arguments from the stack, whereas the `_delegate` instructions use a subset of the locals. `opt_invokebuiltin_delegate_leave` has a fast path for `leave`, but I'm not sure we need to do anything special for that here (FWIW YJIT appears to treat the two delegate instructions the same). Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-06-18Add a test for the previous commitYusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/13238
2025-06-17Refactor generic fields to use `T_IMEMO/fields` objects.Jean Boussier
Followup: https://github.com/ruby/ruby/pull/13589 This simplify a lot of things, as we no longer need to manually manage the memory, we can use the Read-Copy-Update pattern and avoid numerous race conditions. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/13626
2025-06-17ZJIT: Add codegen (and FrameState) for GetConstPathAlan Wu
Issue a call to rb_vm_opt_getconstant_path() like the interpreter, but since that allocates the IC, we need to save the PC before calling. Add FrameState to GetConstPath to get access to the PC. Notes: Merged: https://github.com/ruby/ruby/pull/13628
2025-06-17ZJIT: Parse opt freeze insns to HIRDaniel Colson
* `opt_hash_freeze` * `opt_ary_freeze` * `opt_str_freeze` * `opt_str_uminus` Similar to `opt_neq`, but there are no args for `freeze` Co-authored-by: ywenc <ywenc@github.com> Co-authored-by: Max Bernstein <max@bernsteinbear.com> Notes: Merged: https://github.com/ruby/ruby/pull/13588
2025-06-17io_buffer: Reimplement dcompact for IO::BufferKasumi Hanazuki
The `source` field in IO::Buffer can have a String or an IO::Buffer object, if not nil. - When the `source` is a String object. The `base` field points to the memory location of the String content, which can be embedded in RSTRING, and in that case, GC compaction can move the memory region along with the String object. Thus, IO::Buffer needs to pin the `source` object to prevent `base` pointer from becoming invalid. - When the `source` is an IO::Buffer, then `base` is a pointer to a malloced or mmapped memory region, managed by the source IO::Buffer. In this case, we don't need to pin the source IO::Buffer object, since the referred memory region won't get moved by GC. Closes: [Bug #21210] Notes: Merged: https://github.com/ruby/ruby/pull/13033
2025-06-17ZJIT: Add codegen for StringCopyDaniel Colson
Prior to this commit we compiled `putstring` and `putchilledstring` to `StringCopy`, but then failed to compile past HIR. This commit adds codegen for `StringCopy` to call `rb_ec_str_ressurrect` as the VM does for these instructions. Notes: Merged: https://github.com/ruby/ruby/pull/13625
2025-06-16Add test for `IO::Buffer.for(frozen_string) {}` and omit rb_str_{,un}locktmp ↵Benoit Daloze
in that case Notes: Merged: https://github.com/ruby/ruby/pull/13615