Age | Commit message (Collapse) | Author |
|
This makes:
```ruby
args = [1, 2, -> {}]; foo(*args, &args.pop)
```
call `foo` with 1, 2, and the lambda, in addition to passing the
lambda as a block. This is different from the previous behavior,
which passed the lambda as a block but not as a regular argument,
which goes against the expected left-to-right evaluation order.
This is how Ruby already compiled arguments if using leading
arguments, trailing arguments, or keywords in the same call.
This works by disabling the optimization that skipped duplicating
the array during the splat (splatarray instruction argument
switches from false to true). In the above example, the splat
call duplicates the array. I've tested and cases where a
local variable or symbol are used do not duplicate the array,
so I don't expect this to decrease the performance of most Ruby
programs. However, programs such as:
```ruby
foo(*args, &bar)
```
could see a decrease in performance, if `bar` is a method call
and not a local variable.
This is not a perfect solution, there are ways to get around
this:
```ruby
args = Struct.new(:a).new([:x, :y])
def args.to_a; a; end
def args.to_proc; a.pop; ->{}; end
foo(*args, &args)
# calls foo with 1 argument (:x)
# not 2 arguments (:x and :y)
```
A perfect solution would require completely disabling the
optimization.
Fixes [Bug #16504]
Fixes [Bug #16500]
Notes:
Merged: https://github.com/ruby/ruby/pull/3157
|
|
3556a834a2847e52162d1d3302d4c64390df1694 added support for
Module#include to affect the iclasses of the module. It didn't add
support for Module#prepend because there were bugs in the object model
and GC at the time that prevented it. Those problems have been
addressed in ad729a1d11c6c57efd2e92803b4e937db0f75252 and
98286e9850936e27e8ae5e4f20858cc9c13d2dde, and now adding support for
it is straightforward and does not break any tests or specs.
Fixes [Bug #9573]
Notes:
Merged: https://github.com/ruby/ruby/pull/3181
|
|
|
|
* Remove obsoleted opt_call_c_function insn
* Keep opt_call_c_function with DEFINE_INSN_IF
Notes:
Merged-By: k0kubun <takashikkbn@gmail.com>
|
|
Ensure that the argument is an Integer or implicitly convert to,
before dereferencing as a Bignum. Addressed a regression in
b99833baec2.
Reported by u75615 at https://hackerone.com/reports/898614
|
|
|
|
We observed test failures on test_latest_gc_info with random
order CI.
http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/2998078l0ll
To solve it, use a pre-allocated hash object and rehearsal.
|
|
Setting class varibles goes through the ancestor list which can
contain iclasses. Iclasses share a lot of information with the
module they are made from, but not the frozen status.
Check the frozen status of the module instead of the iclass.
Notes:
Merged: https://github.com/ruby/ruby/pull/3203
|
|
Implements [Feature #15973]
Notes:
Merged: https://github.com/ruby/ruby/pull/3209
|
|
The warning for these was added in 2.7.
Notes:
Merged: https://github.com/ruby/ruby/pull/3208
|
|
Fixes [Bug #16173]
Co-Authored-By: Burdette Lamar <burdettelamar@yahoo.com>
Co-Authored-By: Jeremy Evans <code@jeremyevans.net>
Notes:
Merged: https://github.com/ruby/ruby/pull/3206
|
|
module (#3201)
For ZSUPER methods with no defined class for the method entry, start the next lookup at the superclass of the origin class of the method owner, instead of the superclass of the method owner.
Fixes [Bug #16942]
Notes:
Merged-By: jeremyevans <code@jeremyevans.net>
|
|
CI fails with GC while `foo{}`, so that disable GC for this script.
|
|
|
|
The idFWD_KWREST sections may be wrong. However, the existing
idFWD_KWREST sections for ... without leading arguments are already
broken.
Implements [Feature #16378]
Notes:
Merged: https://github.com/ruby/ruby/pull/3190
|
|
This test should not depend on the bahaviour of the did_you_mean gem.
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3180
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3180
|
|
This fixes various issues when a module is included in or prepended
to a module or class, and then refined, or refined and then included
or prepended to a module or class.
Implement by renaming ensure_origin to rb_ensure_origin, making it
non-static, and calling it when refining a module.
Fix Module#initialize_copy to handle origins correctly. Previously,
Module#initialize_copy did not handle origins correctly. For example,
this code:
```ruby
module B; end
class A
def b; 2 end
prepend B
end
a = A.dup.new
class A
def b; 1 end
end
p a.b
```
Printed 1 instead of 2. This is because the super chain for
a.singleton_class was:
```
a.singleton_class
A.dup
B(iclass)
B(iclass origin)
A(origin) # not A.dup(origin)
```
The B iclasses would not be modified, so the includer entry would be
still be set to A and not A.dup.
This modifies things so that if the class/module has an origin,
all iclasses between the class/module and the origin are duplicated
and have the correct includer entry set, and the correct origin
is created.
This requires other changes to make sure all tests still pass:
* rb_undef_methods_from doesn't automatically handle classes with
origins, so pass it the origin for Comparable when undefing
methods in Complex. This fixed a failure in the Complex tests.
* When adding a method, the method cache was not cleared
correctly if klass has an origin. Clear the method cache for
the klass before switching to the origin of klass. This fixed
failures in the autoload tests related to overridding require,
without breaking the optimization tests. Also clear the method
cache for both the module and origin when removing a method.
* Module#include? is fixed to skip origin iclasses.
* Refinements are fixed to use the origin class of the module that
has an origin.
* RCLASS_REFINED_BY_ANY is removed as it was only used in a single
place and is no longer needed.
* Marshal#dump is fixed to skip iclass origins.
* rb_method_entry_make is fixed to handled overridden optimized
methods for modules that have origins.
Fixes [Bug #16852]
Notes:
Merged: https://github.com/ruby/ruby/pull/3140
|
|
Protected methods are restricted to be called according to the
class/module in where it is defined, not the actual receiver's
class. [Bug #16931]
|
|
|
|
getgrnam(3) says:
```
ERRORS
0 or ENOENT or ESRCH or EBADF or EPERM or ...
The given name or gid was not found.
```
Process::GID.from_name raises an ArgumentError for 0, but Errno::ESRCH
for ESRCH. Actually, WSL 2 raises Errno::ESRCH. This change accepts
all exceptions above.
|
|
|
|
21991e6ca5 enables `__builtin_assume()` for clang and it seems
skip SEGV on rb_class_of() with unexpected value. This test expects
a [BUG] output, so this patch causes [BUG] to show [BUG] message.
https://github.com/ruby/ruby/runs/707088232?check_suite_focus=true#step:12:230
```
1) Failure:
TestVMDump#test_darwin_invalid_access [/Users/runner/runners/2.262.1/work/ruby/ruby/src/test/ruby/test_vm_dump.rb:19]:
pid 43128 exit 0.
1. [2/2] Assertion for "stderr"
| Expected /^\[IMPORTANT\]/ to match "".
```
|
|
If a module has an origin, and that module is included in another
module or class, previously the iclass created for the module had
an origin pointer to the module's origin instead of the iclass's
origin.
Setting the origin pointer correctly requires using a stack, since
the origin iclass is not created until after the iclass itself.
Use a hidden ruby array to implement that stack.
Correctly assigning the origin pointers in the iclass caused a
use-after-free in GC. If a module with an origin is included
in a class, the iclass shares a method table with the module
and the iclass origin shares a method table with module origin.
Mark iclass origin with a flag that notes that even though the
iclass is an origin, it shares a method table, so the method table
should not be garbage collected. The shared method table will be
garbage collected when the module origin is garbage collected.
I've tested that this does not introduce a memory leak.
This change caused a VM assertion failure, which was traced to callable
method entries using the incorrect defined_class. Update
rb_vm_check_redefinition_opt_method and find_defined_class_by_owner
to treat iclass origins different than class origins to avoid this
issue.
This also includes a fix for Module#included_modules to skip
iclasses with origins.
Fixes [Bug #16736]
Notes:
Merged: https://github.com/ruby/ruby/pull/3136
|
|
This reverts commit c745a60634260ba2080d35af6fdeaaae86fe5193.
This triggers a VM assertion. Reverting until the issue can be
debugged.
|
|
If a module has an origin, and that module is included in another
module or class, previously the iclass created for the module had
an origin pointer to the module's origin instead of the iclass's
origin.
Setting the origin pointer correctly requires using a stack, since
the origin iclass is not created until after the iclass itself.
Use a hidden ruby array to implement that stack.
Correctly assigning the origin pointers in the iclass caused a
use-after-free in GC. If a module with an origin is included
in a class, the iclass shares a method table with the module
and the iclass origin shares a method table with module origin.
Mark iclass origin with a flag that notes that even though the
iclass is an origin, it shares a method table, so the method table
should not be garbage collected. The shared method table will be
garbage collected when the module origin is garbage collected.
I've tested that this does not introduce a memory leak.
This also includes a fix for Module#included_modules to skip
iclasses with origins.
Fixes [Bug #16736]
Notes:
Merged: https://github.com/ruby/ruby/pull/2978
|
|
Same as 02705b27be207fce57bd0253251f81108c7ed57b
http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/2955433
```
1)
TestGc#test_start_full_mark [/tmp/ruby/v3/src/trunk-random1/test/ruby/test_gc.rb:61]:
Expected :oldmalloc to be nil.
```
|
|
instead of :TOTAL of ObjectSpace.count_objects.
This test had failed very occasionally:
https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos8/ruby-master/log/20200521T033004Z.fail.html.gz
```
1) Failure:
TestRubyOptimization#test_block_parameter_should_not_create_objects [/home/chkbuild/chkbuild/tmp/build/20200521T033004Z/ruby/test/ruby/test_optimization.rb:713]:
<0> expected but was
<407>.
```
This test of lazy proc creation checks if no object is created during a
method call. However, calling a method itself increases the count of
objects because method cache is now an object (T_MEMO).
The reason why this test rarely fails is because the test was buggy; it
checked the count of :TOTAL, but :TOTAL count changes only when the GC
heap is expanded. Creating one object rarely causes heap expansion.
The test must have checked not only :TOTAL but also the count of :FREE.
Instead, this change more directly checks :T_DATA. Note that a Proc
object is T_DATA.
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3116
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3112
|
|
TestAutoload#test_source_location can't run multiple test-run so
that use assert_separately().
repro command:
make yes-test-all TESTS='--repeat-count=50 ruby/test_autoload -n test_source_location'
Notes:
Merged: https://github.com/ruby/ruby/pull/3111
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3108
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3032
Merged-By: ioquatix <samuel@codeotaku.com>
|
|
It would be a relatively frequent case. It is still slower than
`float * float` because `*` has a dedicated VM instruction (opt_mult),
though.
|
|
This limit was introduced on Nov 20 1996
in 554b989ba1623b9f6a0b76f00824c83a23fbcbc1
Apparently to protect from a buffer overflow:
* eval.c (f_missing): オブジェクトの文字列表現が長すぎる時バッファ
を書き潰していた
However I tested that path with very large strings
and it works fine.
Notes:
Merged: https://github.com/ruby/ruby/pull/3090
|
|
not only when !w but also when w == WAITPID_LOCK_ONLY.
See also: f7c0cc36920a4ed14a3ab1ca6cfdf18ceff1e5d5 and a2264342063260d660b99872eaf5080f6ab08e81.
We thought this change was an oversight in the latter commit.
Without this change, the test fails like:
$ make test-all TESTS="../test/ruby/test_process.rb -n test_exec_failure_leaves_no_child" RUN_OPTS="--jit"
...
1) Failure:
TestProcess#test_exec_failure_leaves_no_child [/home/k0kubun/src/github.com/ruby/ruby/test/ruby/test_process.rb:2493]:
Expected [[26799, #<Process::Status: pid 26799 exit 127>]] to be empty.
Co-Authored-By: Yusuke Endoh <mame@ruby-lang.org>
|
|
[Bug #16465] [Bug #16801]
[Fix GH-2795] [Fix GH-2944] [Fix GH-3045] [Fix GH-3093]
Note: Backporting shouldn't modify object.h and instead can use
struct_new_kw which is basically a duplicate implementation of
rb_class_new_instance_pass_kw
Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
Co-authored-by: John Hawthorn <john@hawthorn.email>
Co-authored-by: Adam Hess <HParker@github.com>
Co-authored-by: Jose Cortinas <jacortinas@gmail.com>
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Notes:
Merged: https://github.com/ruby/ruby/pull/3093
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3091
|
|
|
|
So that `TEST_EXCLUDES` option in common.mk works.
|
|
|
|
I think 9aa5fe1bf89db8cd215b24d8ddfb668714681b83 helps this issue too.
|
|
It turned out that the pdb corruption happens on Visual Studio 2015 as
well.
https://ci.appveyor.com/project/ruby/ruby/builds/32602953/job/3gj43q18wqeiy729
|
|
Fix https://github.com/ruby/ruby/runs/636020145 without skipping too
many tests.
It seems that .c -> .o with debug flags and .o -> .so without debug
flags did not generate .dSYM but now .c -> .so with debug flags seems to
generate a .dSYM directory. As --jit-debug should not be used by normal
users, let me skip implementing the removal for now.
|
|
caused by 818d6d33368a396d9cd3d1a34a84015a9e76c5c8, for now.
I'll take a look at them tomorrow.
|
|
to improve code locality.
Using benchmark-driver/sinatra with 100 methods JIT-ed,
[Before] 12149.97 rps
1.3M /tmp/_ruby_mjit_p31171u145.so
[After] 12818.83 rps
260K /tmp/_ruby_mjit_p32155u145.so
(VM is 13714.89 rps)
|
|
because we support JIT compaction on it
|