| Age | Commit message (Collapse) | Author |
|
|
|
Fix https://github.com/Shopify/ruby/issues/627
|
|
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>.
|
|
|
|
|
|
|
|
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Stan Lo <stan.lo@shopify.com>
|
|
|
|
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
|
|
* ZJIT: Avoid optimizing locals on eval
* Maintain the local state for eval
|
|
... 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
```
|
|
|
|
|
|
|
|
|
|
0a0eb2807ed7 has already replaced most of that code.
|
|
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.
|
|
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.
|
|
This reverts commit cf4d37fbc079116453e69cf08ea8007d0e1c73e6.
|
|
This reverts commit dda5a04f2b4835582dba09ba33797258a61efafe.
|
|
Also, make sure autoloading of encodings is safe across ractors.
|
|
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
```
|
|
|
|
|
|
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
|
|
These methods return fixed `true` or `false` so we can be certain about their return types.
|
|
|
|
|
|
Lots of stdlib methods such as Integer#times and Kernel#then use this,
so at least this will make writing tests slightly easier.
|
|
|
|
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.
|
|
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.
|
|
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]
|
|
Fixes [Bug #21377]
Co-authored-by: zzak <zzak@hey.com>
|
|
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]
|
|
[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.
|
|
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
|
|
* [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.
|
|
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
|
|
[Bug #21445]
|
|
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.
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13641
|
|
* `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>
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13238
|
|
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
|
|
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
|
|
* `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
|
|
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
|
|
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
|
|
in that case
Notes:
Merged: https://github.com/ruby/ruby/pull/13615
|