summaryrefslogtreecommitdiff
path: root/defs/id.def
AgeCommit message (Collapse)Author
2023-04-18Emit special instruction for array literal + .(hash|min|max)Aaron Patterson
This commit introduces a new instruction `opt_newarray_send` which is used when there is an array literal followed by either the `hash`, `min`, or `max` method. ``` [a, b, c].hash ``` Will emit an `opt_newarray_send` instruction. This instruction falls back to a method call if the "interested" method has been monkey patched. Here are some examples of the instructions generated: ``` $ ./miniruby --dump=insns -e '[@a, @b].max' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :max 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].min' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :min 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].hash' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :hash 0009 leave ``` [Feature #18897] [ruby-core:109147] Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6090
2023-02-16Move `attached_object` into `rb_classext_struct`Jean Boussier
Given that signleton classes don't have an allocator, we can re-use these bytes to store the attached object in `rb_classext_struct` without making it larger. Notes: Merged: https://github.com/ruby/ruby/pull/7309
2022-12-17Use a BOP for Hash#defaultJohn Hawthorn
On a hash miss we need to call default if it is redefined in order to return the default value to be used. Previously we checked this with rb_method_basic_definition_p, which avoids the method call but requires a method lookup. This commit replaces the previous check with BASIC_OP_UNREDEFINED_P and a new BOP_DEFAULT. We still need to fall back to rb_method_basic_definition_p when called on a subclasss of hash. | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |hash_aref_miss | 2.692| 3.531| | | -| 1.31x| Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> Co-authored-by: "Ian C. Anderson" <ian@iancanderson.com> Co-authored-by: Jack McCracken <me@jackmc.xyz> Notes: Merged: https://github.com/ruby/ruby/pull/6945
2022-12-08Introduce `IO.new(..., path:)` and promote `File#path` to `IO#path`. (#6867)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-08Generate token ID indexes in id.defNobuyoshi Nakada
Separate the logic accross the tables from the template view for id.h.
2022-01-14Add a Module#const_added callbackJean Boussier
[Feature #17881] Works similarly to `method_added` but for constants. ```ruby Foo::BAR = 42 # call Foo.const_added(:FOO) class Foo::Baz; end # call Foo.const_added(:Baz) Foo.autoload(:Something, "path") # call Foo.const_added(:Something) ``` Notes: Merged: https://github.com/ruby/ruby/pull/4521
2021-08-15Show verbose error messages when single pattern match failsKazuki Tsujimoto
[0] => [0, *, a] #=> [0] length mismatch (given 1, expected 2+) (NoMatchingPatternError) Ignore test failures of typeprof caused by this change for now.
2021-07-27Predefine recursive key IDNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4684
2021-07-27Added intern_ids.rbNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4684
2019-11-12Revert "Method reference operator"Nobuyoshi Nakada
This reverts commit 67c574736912003c377218153f9d3b9c0c96a17b. [Feature #16275]
2019-09-25Removed idNUMPARAM_0Nobuyoshi Nakada
2019-09-23Lazy init thread local storageLourens Naudé
Notes: Merged: https://github.com/ruby/ruby/pull/2295
2019-09-06Warn local variables which conflict with new numbered parametersNobuyoshi Nakada
2019-09-01Made :nil static IDNobuyoshi Nakada
2019-08-29Revert "Add pipeline operator [Feature #15799]"Nobuyoshi Nakada
This reverts commits: * d365fd5a024254d7c105a62a015a7ea29ccf3e5d * d780c3662484d6072b3a6945b840049de72c2096 * aa7211836b769231a2a8ef6b6ec2fd0ec882ef29 * 043f010c28e82ea38978bf8ed885416f133b5b75 * bb4dd7c6af05c7821d572e2592ea3d0cc748d81f * 043f010c28e82ea38978bf8ed885416f133b5b75 * f169043d81524b5b529f2c1e9c35437ba5bc3a7a http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/94645
2019-08-03Predefine some IDsNobuyoshi Nakada
2019-08-02Revert "Revert "Add a specialized instruction for `.nil?` calls""Yusuke Endoh
This reverts commit a0980f2446c0db735b8ffeb37e241370c458a626. Retry for macOS Mojave.
2019-08-02Revert "Add a specialized instruction for `.nil?` calls"Yusuke Endoh
This reverts commit 9faef3113fb4331524b81ba73005ba13fa0ef6c6. It seemed to cause a failure on macOS Mojave, though I'm unsure how. https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1014/ruby-master/log/20190802T034503Z.fail.html.gz This tentative revert is to check if the issue is actually caused by the change or not.
2019-07-31Add a specialized instruction for `.nil?` callsAaron Patterson
This commit adds a specialized instruction for called to `.nil?`. It is about 27% faster than master in the case where the object is nil or not nil. In the case where an object implements `nil?`, I think it may be slightly slower. Here is a benchmark: ```ruby require "benchmark/ips" class Niller def nil?; true; end end not_nil = Object.new xnil = nil niller = Niller.new Benchmark.ips do |x| x.report("nil?") { xnil.nil? } x.report("not nil") { not_nil.nil? } x.report("niller") { niller.nil? } end ``` On Ruby master: ``` [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 429.195k i/100ms not nil 437.889k i/100ms niller 437.935k i/100ms Calculating ------------------------------------- nil? 20.166M (± 8.1%) i/s - 100.002M in 5.002794s not nil 20.046M (± 7.6%) i/s - 99.839M in 5.020086s niller 22.467M (± 6.1%) i/s - 112.111M in 5.013817s [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 449.660k i/100ms not nil 433.836k i/100ms niller 443.073k i/100ms Calculating ------------------------------------- nil? 19.997M (± 8.8%) i/s - 99.375M in 5.020458s not nil 20.529M (± 7.0%) i/s - 102.385M in 5.020689s niller 21.796M (± 8.0%) i/s - 108.110M in 5.002300s [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 402.119k i/100ms not nil 438.968k i/100ms niller 398.226k i/100ms Calculating ------------------------------------- nil? 20.050M (±12.2%) i/s - 98.519M in 5.008817s not nil 20.614M (± 8.0%) i/s - 102.280M in 5.004531s niller 22.223M (± 8.8%) i/s - 110.309M in 5.013106s ``` On this branch: ``` [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 468.371k i/100ms not nil 456.517k i/100ms niller 454.981k i/100ms Calculating ------------------------------------- nil? 27.849M (± 7.8%) i/s - 138.169M in 5.001730s not nil 26.417M (± 8.7%) i/s - 131.020M in 5.011674s niller 21.561M (± 7.5%) i/s - 107.376M in 5.018113s [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 477.259k i/100ms not nil 428.712k i/100ms niller 446.109k i/100ms Calculating ------------------------------------- nil? 28.071M (± 7.3%) i/s - 139.837M in 5.016590s not nil 25.789M (±12.9%) i/s - 126.470M in 5.011144s niller 20.002M (±12.2%) i/s - 98.144M in 5.001737s [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 467.676k i/100ms not nil 445.791k i/100ms niller 415.024k i/100ms Calculating ------------------------------------- nil? 26.907M (± 8.0%) i/s - 133.755M in 5.013915s not nil 25.319M (± 7.9%) i/s - 125.713M in 5.007758s niller 19.569M (±11.8%) i/s - 96.286M in 5.008533s ``` Co-Authored-By: Ashe Connor <kivikakk@github.com>
2019-06-13Add pipeline operator [Feature #15799]Nobuyoshi Nakada
2019-04-17Introduce pattern matching [EXPERIMENTAL]ktsj
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10compile.c: name a hidden local variable as a predefined IDnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10Reverting all commits from r67479 to r67496 because of CI failureskazu
Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10compile.c: name a hidden local variable as a predefined IDnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-03Introduce beginless range [Feature#14799]mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31Method reference operatornobu
Introduce the new operator for method reference, `.:`. [Feature #12125] [Feature #13581] [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-24introduce new YARV insn newhashfromarray.ko1
* insns.def (newhashfromarray): added to replace `core_hash_from_ary` method to eliminate method call overhead. On my environment, I got the following benchmark results: x = {x: 1} modified: 7864988.6 i/s trunk: 6004098.1 i/s - 1.31x slower x = {x: 1, y: 2} trunk: 6127338.4 i/s modified: 5232380.0 i/s - 1.17x slower x = {x: 1, y: 2, z: 3} modified: 6089553.1 i/s trunk: 5249333.5 i/s - 1.16x slower This trivial improvement should be reconsider because of usage of this instruction. * compile.c: ditto. * defs/id.def, vm.c: remove unused functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26revert r64847, r64846 and r64839k0kubun
because r64849 seems to fix issues which we were confused about. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26revert r64838 and r64839k0kubun
because some build failures persisted git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-25Revert "Revert r64824 to fix build failure on AppVeyor"k0kubun
This reverts commit r64829. I'll prepare another temporary fix, but I'll separately commit that to make it easier to revert that later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-25Revert r64824 to fix build failure on AppVeyork0kubun
AppVeyor msys2/MinGW build started to fail like: https://ci.appveyor.com/project/ruby/ruby/build/9722/job/b94kixi004klmye3 Until I can investigate that, I revert this for now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-24insns.def: optimize & and | of Integer [experimental]k0kubun
not optimizing Array#& and Array#| because vm_insnhelper.c can't easily inline it (large amount of array.c code would be needed in vm_insnhelper.c) and the method body is a little complicated compared to Integer's ones. So I thought only Integer#& and Integer#| have a significant impact, and eliminating unnecessary branches would contribute to JIT's performance. vm_insnhelper.c: ditto tool/transform_mjit_header.rb: make sure these instructions are inlined on JIT. compile.c: compile vm_opt_and and vm_opt_or. id.def: define id for them to be used in compile.c and vm*.c vm.c: track redefinition of Integer#& and Integer#| vm_core.h: allow detecting redefinition of & and | test/ruby/test_jit.rb: test new insns test/ruby/test_optimization.rb: ditto * Optcarrot benchmark This is a kind of experimental thing but I'm committing this since the performance impact is significant especially on Optcarrot with JIT. $ benchmark-driver benchmark.yml --rbenv 'before::before --disable-gems;before+JIT::before --disable-gems --jit;after::after --disable-gems;after+JIT::after --disable-gems --jit' -v --repeat-count 24 before: ruby 2.6.0dev (2018-09-24 trunk 64821) [x86_64-linux] before+JIT: ruby 2.6.0dev (2018-09-24 trunk 64821) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-09-24 opt_and 64821) [x86_64-linux] last_commit=opt_or after+JIT: ruby 2.6.0dev (2018-09-24 opt_and 64821) +JIT [x86_64-linux] last_commit=opt_or Calculating ------------------------------------- before before+JIT after after+JIT Optcarrot Lan_Master.nes 51.460 66.315 53.023 71.173 fps Comparison: Optcarrot Lan_Master.nes after+JIT: 71.2 fps before+JIT: 66.3 fps - 1.07x slower after: 53.0 fps - 1.34x slower before: 51.5 fps - 1.38x slower [close https://github.com/ruby/ruby/pull/1963] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-27defs/id.def: predefine to_f IDnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14Improve performance of type conversion using to_rmrkn
* object.c: Add to_r in conv_method_tbl. * defs/id.def: add to_r. * benchmark/bm_int_quo.rb: added. * benchmark/bm_time_subsec.rb: added. [Bug #13426] [ruby-core:80665] [Fix GH-1582] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-12parse.y: logopnobu
* defs/id.def (predefined): add keywords `and` and `or`. * parse.y (log_op): unify parser and ripper, and use tokens instead of node types and symbols. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-12parse.y: call_uni_opnobu
* defs/id.def (predefined): add keyword `not`. * parse.y (call_uni_op): unify parser and ripper, and use IDs instead of tokens. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-09parse.y: fix idCOLON2nobu
* defs/id.def: remove idDSTAR and idCOLON3. * parse.y (tCOLON2): make same as id.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17* compile.c (NODE_CALL): add optimization shortcut for Array#max/min.mame
Now `[x, y].max` is optimized so that a temporal array object is not created in some condition. * insns.def (opt_newarray_max, opt_newarray_min): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-17id.def: $~ and $_nobu
* defs/id.def (predefined): add idLASTLINE and idBACKREF for $~ and $_ respectively. * parse.y: use idLASTLINE and idBACKREF instead of rb_intern. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-20* compile.c (iseq_compile_each): add debug information to NODE_STRko1
strings as default. [Feature #11725] * insns.def (freezestring): add new instruction to support adding debug information for dynamically constracted strings. * compile.c (iseq_compile_each): support adding debug information for NODE_DSTR with freezestring instruction. * error.c (rb_error_frozen): change the debug information ID name id_debug_created_info and this field should have a 2 element array containing path and line information. * defs/id.def: ditto. * test/ruby/test_rubyoptions.rb: catch up this fix. * test/ruby/test_iseq.rb: now frozen strings are not same. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10Rename DOTQ to ANDDOTnobu
* defs/id.def, parse.y: Switch internal token name to reflect current form of safe-call operator. [Fix GH-1090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-06change DOTQnobu
* defs/id.def (token_ops), parse.y (parser_yylex): change DOTQ from ".?" to "&.". [ruby-core:71363] [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-05id.def: token_opsnobu
* defs/id.def (token_ops): gather associations between IDs, operators, and parser tokens. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-27id.def: anonymous IDsnobu
* defs/id.def: enable anonymous IDs not to expose internal IDs for frozen-string-literal-debug by Marshal.dump. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-27id.def: internal IDsnobu
* defs/id.def: move internal IDs for frozen-string-literal-debug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-16id.def: move IDs for exceptionnobu
* defs/id.def: add :mesg and :exception and move from other sources. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-14id.def: attrsetnobu
* defs/id.def: add attrset IDs, which no longer shares serial numbers with local name IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27parse.y: optimize IDs in rippernobu
* parse.y: optimize ripper_intern calls, ::, **, -@, +@, <=>, >=, <=, ==, ===, !=, =~, !~, <<, >>, and call. * parse.y: use initialized IDs, warn and warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-28eval.c: no method calls at stack overflownobu
* eval.c (setup_exception): get rid of method calls before raising stack overflow, not to cause stack overflow again. * defs/id.def: add IDs for backtraces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-20id.def: predefine to_inobu
* defs/id.def: predefine `to_i` as well as `to_int`. * numeric.c (id_to_i): use predefined `idTo_i`. * object.c (conv_method_names): add `to_i` ID. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e