summaryrefslogtreecommitdiff
path: root/object.c
AgeCommit message (Collapse)Author
2022-02-23Constant time class to class ancestor lookupJohn Hawthorn
Previously when checking ancestors, we would walk all the way up the ancestry chain checking each parent for a matching class or module. I believe this was especially unfriendly to CPU cache since for each step we need to check two cache lines (the class and class ext). This check is used quite often in: * case statements * rescue statements * Calling protected methods * Class#is_a? * Module#=== * Module#<=> I believe it's most common to check a class against a parent class, to this commit aims to improve that (unfortunately does not help checking for an included Module). This is done by storing on each class the number and an array of all parent classes, in order (BasicObject is at index 0). Using this we can check whether a class is a subclass of another in constant time since we know the location to expect it in the hierarchy. Notes: Merged: https://github.com/ruby/ruby/pull/5568
2022-02-23Never call kind_of with klass=0John Hawthorn
Notes: Merged: https://github.com/ruby/ruby/pull/5568
2022-02-18Enhanced RDoc concerning command injection (#5537)Burdette Lamar
Clarifies security vulnerabilities for commands. Treats: Kernel.system Kernel.` (backtick) IO.popen IO.read IO.write IO.binread IO.binwrite IO.readlines IO.foreach Notes: Merged-By: BurdetteLamar <[email protected]>
2022-02-12[DOC] Simplify operator method referencesNobuyoshi Nakada
2022-02-07[DOC] Use RDoc link style for links in the same class/modulePeter Zhu
I used this regex: (?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2 Notes: Merged: https://github.com/ruby/ruby/pull/5530
2022-02-07[DOC] Use RDoc link style for links to other classes/modulesPeter Zhu
I used this regex: ([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2 Notes: Merged: https://github.com/ruby/ruby/pull/5530
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
2022-01-06Allow include before calling Module#initializeJeremy Evans
This is to allow Module subclasses that include modules before calling super in the subclass's initialize. Remove rb_module_check_initializable from Module#initialize. Module#initialize only calls module_exec if a block is passed, it doesn't have other issues that would cause problems if called multiple times or with an already initialized module. Move initialization of super to Module#allocate, though I'm not sure it is required there. However, it's needed to be removed from Module#initialize for this to work. Fixes [Bug #18292] Notes: Merged: https://github.com/ruby/ruby/pull/5398
2022-01-03Kernel#=~: delete卜部昌平
Has been deprecated since ebff9dc10e6e72239c23e50acc7d3cbfdc659e7a.
2022-01-01Negative RBOOL usageNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5385
2021-12-26Remove tainted and trusted featuresNobuyoshi Nakada
Already these had been announced to be removed in 3.2. Notes: Merged: https://github.com/ruby/ruby/pull/5348
2021-12-20Remove Class#descendantsJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/5309
2021-12-08Add `to_f` to predefined conversion method name to ID tableNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5228
2021-11-23Add Class#subclassesJean Boussier
Implements [Feature #18273] Returns an array containing the receiver's direct subclasses without singleton classes. Notes: Merged: https://github.com/ruby/ruby/pull/5045
2021-11-18Optimize dynamic string interpolation for symbol/true/false/nil/0-9Jeremy Evans
This provides a significant speedup for symbol, true, false, nil, and 0-9, class/module, and a small speedup in most other cases. Speedups (using included benchmarks): :symbol :: 60% 0-9 :: 50% Class/Module :: 50% nil/true/false :: 20% integer :: 10% [] :: 10% "" :: 3% One reason this approach is faster is it reduces the number of VM instructions for each interpolated value. Initial idea, approach, and benchmarks from Eric Wong. I applied the same approach against the master branch, updating it to handle the significant internal changes since this was first proposed 4 years ago (such as CALL_INFO/CALL_CACHE -> CALL_DATA). I also expanded it to optimize true/false/nil/0-9/class/module, and added handling of missing methods, refined methods, and RUBY_DEBUG. This renames the tostring insn to anytostring, and adds an objtostring insn that implements the optimization. This requires making a few functions non-static, and adding some non-static functions. This disables 4 YJIT tests. Those tests should be reenabled after YJIT optimizes the new objtostring insn. Implements [Feature #13715] Co-authored-by: Eric Wong <[email protected]> Co-authored-by: Alan Wu <[email protected]> Co-authored-by: Yusuke Endoh <[email protected]> Co-authored-by: Koichi Sasada <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/5002 Merged-By: jeremyevans <[email protected]>
2021-11-17Improve performance Kernel#Float with using Primitive.mandatory_only? method ↵S.H
[Feature #18344] (#5133) Notes: Merged-By: k0kubun <[email protected]>
2021-10-26Add Class#descendantsJeremy Evans
Doesn't include receiver or singleton classes. Implements [Feature #14394] Co-authored-by: fatkodima <[email protected]> Co-authored-by: Benoit Daloze <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/4974 Merged-By: jeremyevans <[email protected]>
2021-10-21Deprecate include/prepend in refinements and add Refinement#import_methods ↵Shugo Maeda
instead Refinement#import_methods imports methods from modules. Unlike Module#include, it copies methods and adds them into the refinement, so the refinement is activated in the imported methods. [Bug #17429] [ruby-core:101639]
2021-10-20Add comments about special runtime routines YJIT callsAlan Wu
When YJIT make calls to routines without reconstructing interpreter state through jit_prepare_routine_call(), it relies on the routine to never allocate, raise, and push/pop control frames. Comment about this on the routines that YJTI calls. This is probably something we should dynamically verify on debug builds. It's hard to statically verify this as it requires verifying all functions in the call tree. Maybe something to look at in the future.
2021-09-19Fix a typo [Bug #17048]Nobuyoshi Nakada
2021-09-17Removed Module.allocate [Bug #17048]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4858
2021-09-17Already initialized modules cannot be replaced [Bug #17048]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4858
2021-09-12Using RB_FLOAT_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4821
2021-09-11Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4805
2021-09-10include/ruby/ruby.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-10include/ruby/internal/arithmetic/double.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-10include/ruby/internal/intern/object.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-10include/ruby/internal/core/rbasic.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-10include/ruby/internal/core/rclass.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-10include/ruby/internal/fl_type.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-10include/ruby/internal/globals.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-10include/ruby/internal/newobj.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-08-02Using RBOOL macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4695 Merged-By: nobu <[email protected]>
2021-07-27Use predefined IDsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4684
2021-07-20Use RB_INTEGER_TYPE_PNobuyoshi Nakada
2021-07-18Make boolean expected messages more consitentNobuyoshi Nakada
2021-07-18Constified a local tableNobuyoshi Nakada
2021-07-16Add Integer.try_convert [Feature #15211]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4654
2021-07-11Move rb_str_escape function declarationS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4607
2021-06-30Specify version to remove as bare numbersNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3972
2021-06-30rb_warn_deprecated_to_remove_at [Feature #17432]Nobuyoshi Nakada
At compilation time with RUBY_DEBUG enabled, check if the removal version has been reached. Notes: Merged: https://github.com/ruby/ruby/pull/3972
2021-06-28Share freeze option handlingNobuyoshi Nakada
2021-06-17Adjust styles [ci skip]Nobuyoshi Nakada
* --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
2021-06-02Implemented some NilClass method in Ruby code is faster [Feature #17054] (#3366)S.H
Notes: Merged-By: k0kubun <[email protected]>
2021-05-18Object whats here (#4503)Burdette Lamar
What's Here section for class Object. Notes: Merged-By: BurdetteLamar <[email protected]>
2021-05-13What's Here for BasicObject (#4499)Burdette Lamar
* What's Here for BasicObject Notes: Merged-By: BurdetteLamar <[email protected]>
2021-05-13What's Here for Kernel (#4488)Burdette Lamar
Notes: Merged-By: BurdetteLamar <[email protected]>
2021-05-03Eagerly allocate instance variable tables along with objectAaron Patterson
This allows us to allocate the right size for the object in advance, meaning that we don't have to pay the cost of ivar table extension later. The idea is that if an object type ever became "extended" at some point, then it is very likely it will become extended again. So we may as well allocate the ivar table up front. Notes: Merged: https://github.com/ruby/ruby/pull/4216
2021-04-01[Doc] Update to FrozenError from RuntimeError in Object#freezeKenichi Kamiya
Notes: Merged: https://github.com/ruby/ruby/pull/4346
2021-02-07[DOC] Modified prefixes to get rid of conflictsNobuyoshi Nakada