summaryrefslogtreecommitdiff
path: root/internal
Commit message (Collapse)AuthorAgeFilesLines
* internal/*.h: skip doxygen卜部昌平2021-09-1050-50/+0
| | | | | These contents are purely implementation details, not worth appearing in CAPI documents. [ci skip]
* [Feature #18045] Implement size classes for GCPeter Zhu2021-08-251-1/+1
| | | | | | | | | This commits implements size classes in the GC for the Variable Width Allocation feature. Unless `USE_RVARGC` compile flag is set, only a single size class is created, maintaining current behaviour. See the redmine ticket for more details. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* [Feature #18045] Remove T_PAYLOADPeter Zhu2021-08-251-4/+0
| | | | | | | This commit removes T_PAYLOAD since the new VWA implementation no longer requires T_PAYLOAD types. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Moved rb_deprecate_constant declaration [Feature #18051]Nobuyoshi Nakada2021-08-241-1/+0
|
* Moved rb_int_positive_pow declaration [Feature #18051]Nobuyoshi Nakada2021-08-241-1/+0
|
* Moved exported symbols in internal/util.h to ruby/util.hNobuyoshi Nakada2021-08-241-3/+0
| | | | [Feature #18051]
* Revert "[Feature #18045] Implement size classes for GC"Peter Zhu2021-08-231-1/+5
| | | | | | This reverts commits 48ff7a9f3e47bffb3e4d067a12ba9b936261caa0 and b2e2cf2dedd104acad8610721db5e4d341f135ef because it is causing crashes in SPARC solaris and i386 debian.
* [Feature #18045] Implement size classes for GCPeter Zhu2021-08-231-1/+1
| | | | | | | | | This commits implements size classes in the GC for the Variable Width Allocation feature. Unless `USE_RVARGC` compile flag is set, only a single size class is created, maintaining current behaviour. See the redmine ticket for more details. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* [Feature #18045] Remove T_PAYLOADPeter Zhu2021-08-231-4/+0
| | | | | | | This commit removes T_PAYLOAD since the new VWA implementation no longer requires T_PAYLOAD types. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* ast.c: Rename "save_script_lines" to "keep_script_lines"Yusuke Endoh2021-08-201-1/+1
| | | | | | | ... as per ko1's preference. He is preparing to extend this feature to ISeq for his new debugger. He prefers "keep" to "save" for this wording. This API is internal and not included in any released version, so I change it in advance.
* Add RBIMPL_TODONobuyoshi Nakada2021-08-201-6/+27
| | | | | | Make `RUBY_VERSION_SINCE` and `RUBY_VERSION_BEFORE` to take major and minor numbers so usable also in preprocessor directives. Old macros are renamed with "STRING".
* Remove old warning aged nearly 8 yearsNobuyoshi Nakada2021-08-191-1/+0
|
* Use Rational for Float#round with ndigits > 14Jeremy Evans2021-08-061-0/+1
| | | | | | | | | | | ndigits higher than 14 can result in values that are slightly too large due to floating point limitations. Converting to rational for the calculation and then back to float fixes these issues. Fixes [Bug #14635] Fixes [Bug #17183] Co-authored by: Yusuke Endoh <mame@ruby-lang.org>
* 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
|