aboutsummaryrefslogtreecommitdiffstats
path: root/internal
Commit message (Collapse)AuthorAgeFilesLines
* Don't export rb_gc_ractor_newobj_cache_clearPeter Zhu2021-07-281-1/+1
|
* Remove duplicate declarationsNobuyoshi Nakada2021-07-281-2/+0
| | | | | Also defined in include/ruby/internal/core/rarray.h which always will be included.
* Add Integer.try_convert [Feature #15211]Nobuyoshi Nakada2021-07-161-0/+1
|
* [Bug #18014] Fix memory leak in GC when using RactorsPeter Zhu2021-07-151-0/+6
| | | | | | | When a Ractor is removed, the freelist in the Ractor cache is not returned to the GC, leaving the freelist permanently lost. This commit recycles the freelist when the Ractor is destroyed, preventing a memory leak from occurring.
* Expose `rb_obj_is_fiber`.Samuel Williams2021-07-131-1/+0
|
* Move rb_str_escape function declarationS-H-GAMELINKS2021-07-111-0/+1
|
* Specify version to remove as bare numbersNobuyoshi Nakada2021-06-301-3/+3
|
* Ensure that version number starts with digitsNobuyoshi Nakada2021-06-301-1/+2
|
* Show the removal versionNobuyoshi Nakada2021-06-301-3/+3
|
* rb_warn_deprecated_to_remove_at [Feature #17432]Nobuyoshi Nakada2021-06-301-1/+44
| | | | | At compilation time with RUBY_DEBUG enabled, check if the removal version has been reached.
* Share freeze option handlingNobuyoshi Nakada2021-06-281-0/+1
|
* Add a cache for class variableseileencodes2021-06-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Redo of 34a2acdac788602c14bf05fb616215187badd504 and 931138b00696419945dc03e10f033b1f53cd50f3 which were reverted. GitHub PR #4340. This change implements a cache for class variables. Previously there was no cache for cvars. Cvar access is slow due to needing to travel all the way up th ancestor tree before returning the cvar value. The deeper the ancestor tree the slower cvar access will be. The benefits of the cache are more visible with a higher number of included modules due to the way Ruby looks up class variables. The benchmark here includes 26 modules and shows with the cache, this branch is 6.5x faster when accessing class variables. ``` compare-ruby: ruby 3.1.0dev (2021-03-15T06:22:34Z master 9e5105c) [x86_64-darwin19] built-ruby: ruby 3.1.0dev (2021-03-15T12:12:44Z add-cache-for-clas.. c6be009) [x86_64-darwin19] | |compare-ruby|built-ruby| |:--------|-----------:|---------:| |vm_cvar | 5.681M| 36.980M| | | -| 6.51x| ``` Benchmark.ips calling `ActiveRecord::Base.logger` from within a Rails application. ActiveRecord::Base.logger has 71 ancestors. The more ancestors a tree has, the more clear the speed increase. IE if Base had only one ancestor we'd see no improvement. This benchmark is run on a vanilla Rails application. Benchmark code: ```ruby require "benchmark/ips" require_relative "config/environment" Benchmark.ips do |x| x.report "logger" do ActiveRecord::Base.logger end end ``` Ruby 3.0 master / Rails 6.1: ``` Warming up -------------------------------------- logger 155.251k i/100ms Calculating ------------------------------------- ``` Ruby 3.0 with cvar cache / Rails 6.1: ``` Warming up -------------------------------------- logger 1.546M i/100ms Calculating ------------------------------------- logger 14.857M (± 4.8%) i/s - 74.198M in 5.006202s ``` Lastly we ran a benchmark to demonstate the difference between master and our cache when the number of modules increases. This benchmark measures 1 ancestor, 30 ancestors, and 100 ancestors. Ruby 3.0 master: ``` Warming up -------------------------------------- 1 module 1.231M i/100ms 30 modules 432.020k i/100ms 100 modules 145.399k i/100ms Calculating ------------------------------------- 1 module 12.210M (± 2.1%) i/s - 61.553M in 5.043400s 30 modules 4.354M (± 2.7%) i/s - 22.033M in 5.063839s 100 modules 1.434M (± 2.9%) i/s - 7.270M in 5.072531s Comparison: 1 module: 12209958.3 i/s 30 modules: 4354217.8 i/s - 2.80x (± 0.00) slower 100 modules: 1434447.3 i/s - 8.51x (± 0.00) slower ``` Ruby 3.0 with cvar cache: ``` Warming up -------------------------------------- 1 module 1.641M i/100ms 30 modules 1.655M i/100ms 100 modules 1.620M i/100ms Calculating ------------------------------------- 1 module 16.279M (± 3.8%) i/s - 82.038M in 5.046923s 30 modules 15.891M (± 3.9%) i/s - 79.459M in 5.007958s 100 modules 16.087M (± 3.6%) i/s - 81.005M in 5.041931s Comparison: 1 module: 16279458.0 i/s 100 modules: 16087484.6 i/s - same-ish: difference falls within error 30 modules: 15891406.2 i/s - same-ish: difference falls within error ``` Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Make it possible to get AST::Node from Thread::Backtrace::LocationYusuke Endoh2021-06-181-0/+2
| | | | | | | | | RubyVM::AST.of(Thread::Backtrace::Location) returns a node that corresponds to the location. Typically, the node is a method call, but not always. This change also includes iseq's dump/load support of node_ids for each instructions.
* ast.rb: RubyVM::AST.parse and .of accepts `save_script_lines: true`Yusuke Endoh2021-06-181-0/+1
| | | | | | | This option makes the parser keep the original source as an array of the original code lines. This feature exploits the mechanism of `SCRIPT_LINES__` but records only the specified code that is passed to RubyVM::AST.of or .parse, instead of recording all parsed program texts.
* Warn more duplicate literal hash keysNobuyoshi Nakada2021-06-031-0/+2
| | | | | Following non-special_const literals: * T_REGEXP
* Warn more duplicate literal hash keysNobuyoshi Nakada2021-06-031-0/+2
| | | | | | | | Following non-special_const literals: * T_BIGNUM * T_FLOAT (non-flonum) * T_RATIONAL * T_COMPLEX
* Refactor rb_vm_insn_addr2insn callsTakashi Kokubun2021-06-021-0/+1
| | | | It's been a way too much amount of ifdefs.
* Remove unneeded rb_ary_ptr_use_start defination in internal/array.h (#4427)S.H2021-06-011-1/+0
|
* Remove unneeded rb_str_initialize defination in internal/string.h (#4465)S.H2021-06-011-1/+0
|
* cdhash_cmp: can also take complex卜部昌平2021-05-121-0/+1
| | | | There are complex literals `123i`, which can also be a case condition.
* cdhash_cmp: can take rational literals卜部昌平2021-05-121-0/+1
| | | | | | | Rational literals are those integers suffixed with `r`. They tend to be a part of more complex expressions like `123/456r`, but in theory they can live alone. When such "bare" rational literals are passed to case-when branch, we have to take care of them. Fixes [Bug #17854]
* Revert "Filling cache values on cvar write"Aaron Patterson2021-05-111-8/+0
| | | | | This reverts commit 08de37f9fa3469365e6b5c964689ae2bae0eb9f3. This reverts commit e8ae922b62adb00a80d3d4c49f7d7b0e6026eaba.
* Add a cache for class variableseileencodes2021-05-111-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change implements a cache for class variables. Previously there was no cache for cvars. Cvar access is slow due to needing to travel all the way up th ancestor tree before returning the cvar value. The deeper the ancestor tree the slower cvar access will be. The benefits of the cache are more visible with a higher number of included modules due to the way Ruby looks up class variables. The benchmark here includes 26 modules and shows with the cache, this branch is 6.5x faster when accessing class variables. ``` compare-ruby: ruby 3.1.0dev (2021-03-15T06:22:34Z master 9e5105ca45) [x86_64-darwin19] built-ruby: ruby 3.1.0dev (2021-03-15T12:12:44Z add-cache-for-clas.. c6be0093ae) [x86_64-darwin19] | |compare-ruby|built-ruby| |:--------|-----------:|---------:| |vm_cvar | 5.681M| 36.980M| | | -| 6.51x| ``` Benchmark.ips calling `ActiveRecord::Base.logger` from within a Rails application. ActiveRecord::Base.logger has 71 ancestors. The more ancestors a tree has, the more clear the speed increase. IE if Base had only one ancestor we'd see no improvement. This benchmark is run on a vanilla Rails application. Benchmark code: ```ruby require "benchmark/ips" require_relative "config/environment" Benchmark.ips do |x| x.report "logger" do ActiveRecord::Base.logger end end ``` Ruby 3.0 master / Rails 6.1: ``` Warming up -------------------------------------- logger 155.251k i/100ms Calculating ------------------------------------- ``` Ruby 3.0 with cvar cache / Rails 6.1: ``` Warming up -------------------------------------- logger 1.546M i/100ms Calculating ------------------------------------- logger 14.857M (± 4.8%) i/s - 74.198M in 5.006202s ``` Lastly we ran a benchmark to demonstate the difference between master and our cache when the number of modules increases. This benchmark measures 1 ancestor, 30 ancestors, and 100 ancestors. Ruby 3.0 master: ``` Warming up -------------------------------------- 1 module 1.231M i/100ms 30 modules 432.020k i/100ms 100 modules 145.399k i/100ms Calculating ------------------------------------- 1 module 12.210M (± 2.1%) i/s - 61.553M in 5.043400s 30 modules 4.354M (± 2.7%) i/s - 22.033M in 5.063839s 100 modules 1.434M (± 2.9%) i/s - 7.270M in 5.072531s Comparison: 1 module: 12209958.3 i/s 30 modules: 4354217.8 i/s - 2.80x (± 0.00) slower 100 modules: 1434447.3 i/s - 8.51x (± 0.00) slower ``` Ruby 3.0 with cvar cache: ``` Warming up -------------------------------------- 1 module 1.641M i/100ms 30 modules 1.655M i/100ms 100 modules 1.620M i/100ms Calculating ------------------------------------- 1 module 16.279M (± 3.8%) i/s - 82.038M in 5.046923s 30 modules 15.891M (± 3.9%) i/s - 79.459M in 5.007958s 100 modules 16.087M (± 3.6%) i/s - 81.005M in 5.041931s Comparison: 1 module: 16279458.0 i/s 100 modules: 16087484.6 i/s - same-ish: difference falls within error 30 modules: 15891406.2 i/s - same-ish: difference falls within error ``` Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Protoized old pre-ANSI K&R style declarations and definitionsNobuyoshi Nakada2021-05-071-1/+1
|
* Allow newobj_of0 and newobj_slowpath to allocate into multiple heap slotsMatt Valentine-House2021-05-061-7/+22
|
* Add RBIMPL_RVALUE_EMBED_LEN_MAX neeeded by internal/bignum.hBenoit Daloze2021-05-041-2/+2
| | | | | | | * It evaluated to 0 before, revealed by -Wundef * See [Feature #17752] Co-authored-by: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
* Partially revert 2c7d3b3a722c4636ab1e9d289cbca47ddd168d3eYusuke Endoh2021-04-271-1/+0
| | | | to make imemo_ast WB-protected again. Only the test is kept.
* node.c (rb_ast_new): imemo_ast is WB-unprotectedYusuke Endoh2021-04-261-0/+1
| | | | | | | | | | | | | | | | | | Previously imemo_ast was handled as WB-protected which caused a segfault of the following code: # shareable_constant_value: literal M0 = {} M1 = {} ... M100000 = {} My analysis is here: `shareable_constant_value: literal` creates many Hash instances during parsing, and add them to node_buffer of imemo_ast. However, the contents are missed because imemo_ast is incorrectly WB-protected. This changeset makes imemo_ast as WB-unprotected.
* Fix some typos by spell checkerRyuta Kamizono2021-04-261-1/+1
|
* get rid of using `__builtin_unreachable` directly [Bug #17787]Nobuyoshi Nakada2021-04-101-3/+3
| | | | | As it is an independent feature from `clz`, `ctz` and `popcount`, it might be unavailable even if the latters are built in.
* rb_enc_interned_str: handle autoloaded encodingsJean Boussier2021-03-221-0/+3
| | | | | | | | If called with an autoloaded encoding that was not yet initialized, `rb_enc_interned_str` would crash with a NULL pointer exception. See: https://github.com/ruby/ruby/pull/4119#issuecomment-800189841
* RBASIC_SET_CLASS_RAW: follow strict aliasing rule卜部昌平2021-03-021-2/+2
| | | | | | | | Instead of rather euphemistic struct cast, just reomve the const qualifier and assign directly. According to ISO/IEC 9899:2018 section 6.5 paragraph 7, `VALUE` and `const VALUE` are allowed to alias (but two distinct structs are not, even when their structures are the same). [Bug #17540]
* Define rb_to_array which converts with to_aNobuyoshi Nakada2021-02-121-0/+1
|
* Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams2021-02-092-44/+1
| | | | | | | | | * Rename `rb_scheduler` to `rb_fiber_scheduler`. * Use public interface if available. * Use `rb_check_funcall` where possible. * Don't use `unblock` unless the fiber was non-blocking.
* Add RCLASS_SUBCLASSES MacroMatt Valentine-House2021-02-011-0/+1
|
* Add RCLASS_ALLOCATOR MacroMatt Valentine-House2021-02-011-0/+1
|
* Add PARENT_MODULE_SUBCLASSES MacroMatt Valentine-House2021-02-011-0/+1
|
* Add RCLASS_PARENT_SUBMODULES MacroMatt Valentine-House2021-02-011-0/+1
|
* Move rb_big_isqrt declarationS-H-GAMELINKS2021-01-311-0/+1
|
* Revert "[Bug #11213] let defined?(super) call respond_to_missing?"Nobuyoshi Nakada2021-01-131-1/+1
| | | | | | This reverts commit fac2498e0299f13dffe4f09a7dd7657fb49bf643 for now, due to [Bug #17509], the breakage in the case `super` is called in `respond_to?`.
* Check stack overflow in recursive glob_helper [Bug #17162]Nobuyoshi Nakada2021-01-131-0/+1
|
* remove unused declKoichi Sasada2021-01-081-6/+0
|
* enable constant cache on ractorsKoichi Sasada2021-01-051-0/+1
| | | | | | | | | | | | | | | | constant cache `IC` is accessed by non-atomic manner and there are thread-safety issues, so Ruby 3.0 disables to use const cache on non-main ractors. This patch enables it by introducing `imemo_constcache` and allocates it by every re-fill of const cache like `imemo_callcache`. [Bug #17510] Now `IC` only has one entry `IC::entry` and it points to `iseq_inline_constant_cache_entry`, managed by T_IMEMO object. `IC` is atomic data structure so `rb_mjit_before_vm_ic_update()` and `rb_mjit_after_vm_ic_update()` is not needed.
* Update compilers.h [ci skip]Gui Heurich2021-01-051-1/+1
|
* Optimize calls to `Kernel#hash` (#3987)Marc-André Lafortune2020-12-251-0/+1
| | | | This avoids recursive checks when the `hash` method of an object isn't specialized.
* Allow inlining Integer#-@ and #~Takashi Kokubun2020-12-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | ``` $ benchmark-driver -v --rbenv 'before --jit;after --jit' benchmark/mjit_integer.yml --filter '(comp|uminus)' before --jit: ruby 3.0.0dev (2020-12-23T05:41:44Z master 0dd4896175) +JIT [x86_64-linux] after --jit: ruby 3.0.0dev (2020-12-23T06:25:41Z master 8887d78992) +JIT [x86_64-linux] last_commit=Allow inlining Integer#-@ and #~ Calculating ------------------------------------- before --jit after --jit mjit_comp(1) 44.006M 70.417M i/s - 40.000M times in 0.908967s 0.568042s mjit_uminus(1) 44.333M 68.422M i/s - 40.000M times in 0.902255s 0.584603s Comparison: mjit_comp(1) after --jit: 70417331.4 i/s before --jit: 44005980.4 i/s - 1.60x slower mjit_uminus(1) after --jit: 68422468.8 i/s before --jit: 44333371.0 i/s - 1.54x slower ```
* Prefer stdbool in vm_execTakashi Kokubun2020-12-211-1/+1
| | | | Make the code a bit modern and consistent with some other places.
* Switch rb_category_warn{,ing} to accept an rb_warning_category_tJeremy Evans2020-12-181-7/+0
| | | | | | | | | | Since we decided to only allowing specific warning categories, there is no reason to have an API that accepts a general string, as it is more error-prone. Switch to only allowing the specific warning categories. As rb_category_warn{,ing} are public API, this requires making rb_warning_category_t public API as well.
* tuning ivar setKoichi Sasada2020-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * make rb_init_iv_list() simple * introduce vm_setivar_slowpath() for cache miss cases ../clean/miniruby is 647ee6f091. Calculating ------------------------------------- ./miniruby ../clean/miniruby ../ruby_2_7/miniruby vm_ivar_init 7.388M 6.814M 5.771M i/s - 30.000M times in 4.060420s 4.402534s 5.198781s vm_ivar_init_subclass 2.158M 2.147M 1.974M i/s - 3.000M times in 1.390328s 1.397587s 1.519951s vm_ivar_set 128.607M 97.931M 140.668M i/s - 30.000M times in 0.233269s 0.306338s 0.213268s vm_ivar 144.315M 151.722M 117.734M i/s - 30.000M times in 0.207879s 0.197730s 0.254811s Comparison: vm_ivar_init ./miniruby: 7388398.8 i/s ../clean/miniruby: 6814257.1 i/s - 1.08x slower ../ruby_2_7/miniruby: 5770583.9 i/s - 1.28x slower vm_ivar_init_subclass ./miniruby: 2157763.6 i/s ../clean/miniruby: 2146557.0 i/s - 1.01x slower ../ruby_2_7/miniruby: 1973747.9 i/s - 1.09x slower vm_ivar_set ../ruby_2_7/miniruby: 140668063.8 i/s ./miniruby: 128606912.1 i/s - 1.09x slower ../clean/miniruby: 97931027.8 i/s - 1.44x slower vm_ivar ../clean/miniruby: 151722121.9 i/s ./miniruby: 144314526.5 i/s - 1.05x slower ../ruby_2_7/miniruby: 117734305.5 i/s - 1.29x slower
* fix inline method cache sync bugKoichi Sasada2020-12-151-3/+2
| | | | | | | | | `cd` is passed to method call functions to method invocation functions, but `cd` can be manipulated by other ractors simultaneously so it contains thread-safety issue. To solve this issue, this patch stores `ci` and found `cc` to `calling` and stops to pass `cd`.