Age | Commit message (Collapse) | Author |
|
Previously we would add code to check if an ivar was defined when using
`@foo ||= 123`, which was slower than `@foo || (@foo = 123)` when `@foo`
was already defined.
Recently 01b7d5acc702df22d306ae95f1a9c3096e63e624 made it so that
accessing an undefined variable no longer generates a warning, making
the defined check unnecessary and both statements exactly equal.
This commit avoids emitting the defined instruction when compiling
NODE_OP_ASGN_OR with a NODE_IVAR.
Before:
$ ruby --dump=insn -e '@foo ||= 123'
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putnil ( 1)[Li]
0001 defined instance-variable, :@foo, false
0005 branchunless 14
0007 getinstancevariable :@foo, <is:0>
0010 dup
0011 branchif 20
0013 pop
0014 putobject 123
0016 dup
0017 setinstancevariable :@foo, <is:0>
0020 leave
After:
$ ./ruby --dump=insn -e '@foo ||= 123'
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 getinstancevariable :@foo, <is:0> ( 1)[Li]
0003 dup
0004 branchif 13
0006 pop
0007 putobject 123
0009 dup
0010 setinstancevariable :@foo, <is:0>
0013 leave
This seems to be about 50% faster in this benchmark:
require "benchmark/ips"
class Foo
def initialize
@foo = nil
end
def test1
@foo ||= 123
end
def test2
@foo || (@foo = 123)
end
end
FOO = Foo.new
Benchmark.ips do |x|
x.report("test1", "FOO.test1")
x.report("test2", "FOO.test2")
end
Before:
$ ruby benchmark_ivar.rb
Warming up --------------------------------------
test1 1.957M i/100ms
test2 3.125M i/100ms
Calculating -------------------------------------
test1 20.030M (± 1.7%) i/s - 101.780M in 5.083040s
test2 31.227M (± 4.5%) i/s - 156.262M in 5.015936s
After:
$ ./ruby benchmark_ivar.rb
Warming up --------------------------------------
test1 3.205M i/100ms
test2 3.197M i/100ms
Calculating -------------------------------------
test1 32.066M (± 1.1%) i/s - 163.440M in 5.097581s
test2 31.438M (± 4.9%) i/s - 159.860M in 5.098961s
Notes:
Merged: https://github.com/ruby/ruby/pull/3904
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3622
Merged-By: nobu <nobu@ruby-lang.org>
|
|
* `GC.auto_compact=`, `GC.auto_compact` can be used to control when
compaction runs. Setting `auto_compact=` to true will cause
compaction to occurr duing major collections. At the moment,
compaction adds significant overhead to major collections, so please
test first!
[Feature #17176]
|
|
`remove_unreachable_chunk()` after `iseq_set_sequence()`"
This reverts commit 3685ed7303fc08bf68cd3cc8d11e22a8ce63a067 and 5dc107b03f5cf32656a5308574b90458486c633c.
Because of some CI failures https://github.com/ruby/ruby/pull/3404#issuecomment-719868313.
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3404
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3404
|
|
|
|
Isolated Proc prohibit to access outer local variables, but it was
violated by binding and so on, so they should be error.
Notes:
Merged: https://github.com/ruby/ruby/pull/3721
|
|
Notes:
Merged-By: mrkn <mrkn@ruby-lang.org>
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3589
|
|
iv_index_tbl manages instance variable indexes (ID -> index).
This data structure should be synchronized with other ractors
so introduce some VM locks.
This patch also introduced atomic ivar cache used by
set/getinlinecache instructions. To make updating ivar cache (IVC),
we changed iv_index_tbl data structure to manage (ID -> entry)
and an entry points serial and index. IVC points to this entry so
that cache update becomes atomically.
Notes:
Merged: https://github.com/ruby/ruby/pull/3662
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3445
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3445
|
|
The write barrier wasn't being called for this object, so add the
missing WB. Automatic compaction moved the reference because it didn't
know about the relationship (that's how I found the missing WB).
|
|
|
|
|
|
Range literal is now frozen so we can reuse same Range object if
the begin and the last are Numeric (frozen), such as `(1..2)`.
Notes:
Merged: https://github.com/ruby/ruby/pull/3587
|
|
[Feature #17104]
|
|
* Remove freezestring instruction since this was the only usage for it.
* [Feature #17104]
Notes:
Merged: https://github.com/ruby/ruby/pull/3488
|
|
This commit introduces Ractor mechanism to run Ruby program in
parallel. See doc/ractor.md for more details about Ractor.
See ticket [Feature #17100] to see the implementation details
and discussions.
[Feature #17100]
This commit does not complete the implementation. You can find
many bugs on using Ractor. Also the specification will be changed
so that this feature is experimental. You will see a warning when
you make the first Ractor with `Ractor.new`.
I hope this feature can help programmers from thread-safety issues.
Notes:
Merged: https://github.com/ruby/ruby/pull/3365
|
|
|
|
Just moved "case base" after allocating cache space.
|
|
This reverts commit 3a4be429b50062122d1616256de38649464d3146.
To fix following warning:
```
compiling ../compile.c
../compile.c:6336:20: warning: variable 'line' is uninitialized when used here [-Wuninitialized]
ADD_INSN(head, line, putnil); /* allocate stack for cached #deconstruct value */
^~~~
../compile.c:220:57: note: expanded from macro 'ADD_INSN'
ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
^~~~
../compile.c:6327:13: note: initialize the variable 'line' to silence this warning
int line;
^
= 0
1 warning generated.
```
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3403
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3401
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3401
|
|
Use ID instead of GENTRY for gvars.
Global variables are compiled into GENTRY (a pointer to struct
rb_global_entry). This patch replace this GENTRY to ID and
make the code simple.
We need to search GENTRY from ID every time (st_lookup), so
additional overhead will be introduced.
However, the performance of accessing global variables is not
important now a day and this simplicity helps Ractor development.
Notes:
Merged-By: ko1 <ko1@atdot.net>
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
|
|
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3104
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3104
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3262
|