| Age | Commit message (Collapse) | Author |
|
We need to guard match from GC because otherwise it could end up being
reclaimed or moved in compaction.
|
|
|
|
|
|
|
|
|
|
SplatNodes within ArrayNodes (e.g. [*1..2, 3]) need to be special
cased in the compiler because they use a combination of concatarray
and newarray instructions to treat each sequence of splat or non-splat
elements as independent arrays which get concatenated. This commit
implements those cases.
|
|
|
|
The ary_make_shared call may allocate, which can trigger a GC
compaction. This can cause the array to be embedded because it has a
length of 0.
|
|
There have been some sproradically flaky tests related to GC compaction,
which fail with:
1) Failure:
TestGCCompact#test_moving_hashes_down_size_pools [/test/ruby/test_gc_compact.rb:442]:
Expected 499 to be >= 500.
What's happening here, is that, _sometimes_, depending on very unlucky
combinations of machine things, one of the expected-to-be-moved hashes
might be found on the machine stack during GC, and thus pinned.
One factor which seems to make this _more_ likely is that GCC 11 on
Ubuntu 22.04 seems to want to allocate 440 bytes of stack space for
`gc_start`, which is much more than it actually uses on the common code
path. The result is that there are some 50-odd VALUE-sized cells "live"
on the stack which may well contain valid heap pointers from previous
function calls, and will need to be pinned.
This is, of course, totally normal and expected; Ruby's GC is
conservative and if there is the possibility that a VALUE might be live
on the machine stack, it can't be moved. However, it does make these
tests flaky.
This commit "fixes" the tests by performing the work in a fiber; the
fiber goes out of scope and should be collected by the call to
verify_compaction_references, so there should be no references to the
to-be-moved objects floating around on the machine stack.
Fixes [#20021]
|
|
- Unless `sizeof(BDIGIT) == 4`, (8-byte integer not available), the
size to be loaded was wrong.
- Since `BDIGIT`s are dumped as raw binary, the loaded byte order was
inverted unless little-endian.
|
|
|
|
|
|
Extracted from PR #8932.
Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
|
|
Many tests start by exhausting all shapes, which is a slow process.
By exposing a method to directly move the bump allocator forward
we cut test runtime in half.
Before:
```
Finished tests in 1.544756s
```
After:
```
Finished tests in 0.759733s,
```
|
|
|
|
The lookup in the table is using the wrong key when converting generic
instance variables to too complex, which means that it never looks up
the entry which leaks memory when the entry is overwritten.
|
|
|
|
|
|
|
|
Add a special treatment for when the argument of self is an
integral multiple of 45 degrees.
1i ** (10 ** 100) #=> 1+0i
1i ** (10 ** 100 + 1) #=> 0+1i
(1+1i) ** (10 ** 100) # warning: in a**b, b may be too big
#=> (Infinity+0.0i)
(1+1i) ** (10 ** 100 + 1) # warning: in a**b, b may be too big
#=> (Infinity+Infinity*i)
|
|
When transitioning generic instance variable objects to too complex, we
set the shape first before performing inserting the new gen_ivtbl. The
st_insert for the new gen_ivtbl could allocate and cause a GC. If that
happens, then it will crash because the object will have a too complex
shape but not yet be backed by a st_table.
This commit changes the order so that the insert happens first before
the new shape is set.
The following script reproduces the issue:
```
o = []
o.instance_variable_set(:@a, 1)
i = 0
o = Object.new
while RubyVM::Shape.shapes_available > 0
o.instance_variable_set(:"@i#{i}", 1)
i += 1
end
ary = 1_000.times.map { [] }
GC.stress = true
ary.each do |o|
o.instance_variable_set(:@a, 1)
o.instance_variable_set(:@b, 1)
end
```
|
|
|
|
Prior to this commit, we weren't recursing up scopes to look for
the local definition. With this commit, we do so, fixing local writes
within blocks
|
|
This PR implements the once node on interpolated regexes.
There is a bug in Prism where the interpolated regex with the once flag
only works when there is not a local variable so the test uses a "1".
We'll need to fix that.
|
|
|
|
|
|
Commit e87d0882910001ef3b0c2ccd43bf00cee8c34a0c introduced a
regression where the keyword splat object passed by the caller
would be directly used by callee as keyword splat parameters,
if it implemented #to_hash. The return value of #to_hash would be
ignored in this case.
|
|
Reproduction script:
```
o = Object.new
10.times { |i| o.instance_variable_set(:"@a#{i}", i) }
i = 0
a = Object.new
while RubyVM::Shape.shapes_available > 2
a.instance_variable_set(:"@i#{i}", 1)
i += 1
end
o.remove_instance_variable(:@a0)
puts o.instance_variable_get(:@a1)
```
Before this patch, it would incorrectly output `2` and now it correctly
outputs `1`.
|
|
due to a failure on a CI
http://ci.rvm.jp/results/trunk-iseq_binary@ruby-sp2-docker/4779277
```
expected:
== disasm: #<ISeq:prism_test_forwarding_arguments_node1@<compiled>:2 (2,8)-(4,11)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: 1])
[ 1] "..."@0
0000 putself ( 3)
0001 getlocal_WC_0 ?@-2
0003 splatarray false
0005 getblockparamproxy ?@-1, 0
0008 send <calldata!mid:prism_test_forwarding_arguments_node, argc:1, ARGS_SPLAT|ARGS_BLOCKARG|FCALL>, nil
0011 leave ( 2)
actual:
== disasm: #<ISeq:prism_test_forwarding_arguments_node1@<compiled>:2 (2,8)-(4,11)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: 1])
[ 1] "..."@0
0000 putself ( 3)
0001 getlocal_WC_0 ?@-2
0003 splatarray false
0005 getblockparamproxy "!"@-1, 0
0008 send <calldata!mid:prism_test_forwarding_arguments_node, argc:1, ARGS_SPLAT|ARGS_BLOCKARG|FCALL>, nil
0011 leave ( 2)
/tmp/ruby/src/trunk-iseq_binary/tool/lib/iseq_loader_checker.rb:36:in `exit': exit (SystemExit)
```
|
|
|
|
|
|
`test_thread_trace` is also flaky due to the same reason as #8916.
https://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20231114T213002Z.fail.html.gz
https://rubyci.s3.amazonaws.com/wsl2/ruby-master/log/20231114T090003Z.fail.html.gz
|
|
This test suite is flaky on CI, because the test asserts events from
finalizers also. Tracing events from finalizers is not deterministic
and is not a part of test interests, so this commit changes the test
to assert only events originated from the test file itself.
|
|
Other objects may be using the shape, so we can't change the capacity
otherwise the other objects may have a buffer overflow.
|
|
For better assert failure diagnostics.
|
|
|
|
|
|
Some code out there blind calls `force_encoding` without checking
what the original encoding was, which clears the coderange uselessly.
If the String is big, it can be a rather costly mistake.
For instance the `rack-utf8_sanitizer` gem does this on request
bodies.
|
|
This commit adds tests for the compilation of the
OptionalKeywordParameterNode, and fixes cases on the
RequiredKeywordParameterNode
|
|
|
|
This commit adds tests for BlockParameterNode, RequiredParameterNode,
RequiredKeywordParameterNode and RestParameterNode
|
|
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
|
|
Apply Nobu's suggestions which improve style, memory handling and error correction.
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
This drops the total size of a Time object from 86 bytes to 80 bytes.
Running the benchmark benchmark/time_now.yml, this commit improves
performance of Time.now by about 30%:
```
Time.now
Branch: 13159405.4 i/s
Master: 10036908.7 i/s - 1.31x slower
Time.now(in: "+09:00")
Branch: 2712172.6 i/s
Master: 2138637.9 i/s - 1.27x slower
```
It also decreases memory usage by about 20%:
```
ary = 10_000_000.times.map { Time.now }
puts `ps -o rss= -p #{$$}`
```
Branch: 961792
Master: 1196544
Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
|
|
This commit compiles most parameter types, setting appropriate values on
the ISEQ_BODY. It also adds tests for callers and callees of methods,
using many versions of tests from bootstraptest
|
|
|
|
Compilation now works for MultiWriteNodes and MultiTargetNodes, with
nesting on MultiWrites. See the tests added in this commit for example
behavior.
|
|
|
|
`Kernel#require` converts feature name objects that have the `to_path`
method such as `Pathname`, but had used the original object on error
and had resulted in an unexpected `TypeError`.
|
|
first_column and last_column return byte positions, but existing implementations
did not consider multibyte.
|