summaryrefslogtreecommitdiff
path: root/object.c
Commit message (Collapse)AuthorAgeFilesLines
...
* [DOC] Repair format of What's Here sections in object.c (#5722)Burdette Lamar2022-03-291-155/+147
| | | | | * Repair format of What's Here sections in object.c
* Revert "Faster rb_class_superclass"John Hawthorn2022-03-171-6/+7
| | | | This reverts commit 29b68b89a0c0ea7de46c058fab746550398151f0.
* Faster rb_class_superclassJohn Hawthorn2022-03-171-7/+6
| | | | | This uses the RCLASS_SUPERCLASSES array to quickly find the next SUPERCLASS of klass which is a T_CLASS.
* Fast rb_class_inherited_pJohn Hawthorn2022-03-151-10/+31
| | | | | | | | | This uses the superclass table recently introduced to implement fast inheritance checking between classes (ex. Foo < Bar). This is almost identical to what we do in class_search_class_ancestor (as called by rb_obj_is_kind_of) except that we are checking both directions: ie. both whether Foo < Bar and whether Bar < Foo.
* Fast object is iclass checksJohn Hawthorn2022-03-111-9/+29
| | | | | | | | | | | | | | | Calling rb_obj_is_kind_of with an ICLASS returns the same result as calling it with the ICLASS's original Module. Most of the time we encounter an ICLASS here checking the validity of a protected method or super call, which we expect to return true (or raise a slow exception anyways). We can take advantage of this by performing a fast class inheritance check on the ICLASS's "includer" in hopes that it returns true. If the includer class check returns false we still have to fallback to the full inheritance chain scan for the module's inclusion, but this should be less common.
* Revert "Fast object is iclass checks"John Hawthorn2022-03-101-23/+9
| | | | This reverts commit 1b15756d24c11ed6bfddb5ae53402a071a20ea97.
* Fast object is iclass checksJohn Hawthorn2022-03-101-9/+23
| | | | | | | | | | | | | | | Calling rb_obj_is_kind_of with an ICLASS returns the same result as calling it with the ICLASS's original Module. Most of the time we encounter an ICLASS here checking the validity of a protected method or super call, which we expect to return true (or raise a slow exception anyways). We can take advantage of this by performing a fast class inheritance check on the ICLASS's "includer" in hopes that it returns true. If the includer class check returns false we still have to fallback to the full inheritance chain scan for the module's inclusion, but this should be less common.
* Constant time class to class ancestor lookupJohn Hawthorn2022-02-231-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Never call kind_of with klass=0John Hawthorn2022-02-231-0/+2
|
* Enhanced RDoc concerning command injection (#5537)Burdette Lamar2022-02-181-1/+1
| | | | | | | | | | | | | | | | Clarifies security vulnerabilities for commands. Treats: Kernel.system Kernel.` (backtick) IO.popen IO.read IO.write IO.binread IO.binwrite IO.readlines IO.foreach
* [DOC] Simplify operator method referencesNobuyoshi Nakada2022-02-121-18/+14
|
* [DOC] Use RDoc link style for links in the same class/modulePeter Zhu2022-02-071-15/+15
| | | | | | | | | | 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
* [DOC] Use RDoc link style for links to other classes/modulesPeter Zhu2022-02-071-2/+2
| | | | | | | | | | 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
* Add a Module#const_added callbackJean Boussier2022-01-141-0/+23
| | | | | | | | | | | | [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) ```
* Allow include before calling Module#initializeJeremy Evans2022-01-061-1/+0
| | | | | | | | | | | | | | | | 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]
* Kernel#=~: delete卜部昌平2022-01-031-22/+2
| | | | Has been deprecated since ebff9dc10e6e72239c23e50acc7d3cbfdc659e7a.
* Negative RBOOL usageNobuyoshi Nakada2022-01-011-4/+4
|
* Remove tainted and trusted featuresNobuyoshi Nakada2021-12-261-98/+0
| | | | Already these had been announced to be removed in 3.2.
* Remove Class#descendantsJeremy Evans2021-12-201-1/+0
|
* Add `to_f` to predefined conversion method name to ID tableNobuyoshi Nakada2021-12-081-0/+1
|
* Add Class#subclassesJean Boussier2021-11-231-0/+1
| | | | | | | Implements [Feature #18273] Returns an array containing the receiver's direct subclasses without singleton classes.
* Optimize dynamic string interpolation for symbol/true/false/nil/0-9Jeremy Evans2021-11-181-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <e@80x24.org> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Co-authored-by: Koichi Sasada <ko1@atdot.net>
* Improve performance Kernel#Float with using Primitive.mandatory_only? method ↵S.H2021-11-171-0/+6
| | | | [Feature #18344] (#5133)
* Add Class#descendantsJeremy Evans2021-10-261-0/+1
| | | | | | | | Doesn't include receiver or singleton classes. Implements [Feature #14394] Co-authored-by: fatkodima <fatkodima123@gmail.com> Co-authored-by: Benoit Daloze <eregontp@gmail.com>
* Deprecate include/prepend in refinements and add Refinement#import_methods ↵Shugo Maeda2021-10-211-0/+2
| | | | | | | | | | 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]
* Add comments about special runtime routines YJIT callsAlan Wu2021-10-201-0/+2
| | | | | | | | | | | 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.
* Fix a typo [Bug #17048]Nobuyoshi Nakada2021-09-191-1/+1
|
* Removed Module.allocate [Bug #17048]Nobuyoshi Nakada2021-09-171-0/+2
|
* Already initialized modules cannot be replaced [Bug #17048]Nobuyoshi Nakada2021-09-171-15/+9
|
* Using RB_FLOAT_TYPE_P macroS-H-GAMELINKS2021-09-121-1/+1
|
* Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS2021-09-111-1/+1
|
* include/ruby/ruby.h: add doxygen卜部昌平2021-09-101-11/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/arithmetic/double.h: add doxygen卜部昌平2021-09-101-7/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/intern/object.h: add doxygen卜部昌平2021-09-101-216/+12
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/core/rbasic.h: add doxygen卜部昌平2021-09-101-20/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/core/rclass.h: add doxygen卜部昌平2021-09-101-7/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/fl_type.h: add doxygen卜部昌平2021-09-101-4/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/globals.h: add doxygen卜部昌平2021-09-101-9/+9
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/newobj.h: add doxygen卜部昌平2021-09-101-8/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* Using RBOOL macroS.H2021-08-021-15/+9
|
* Use predefined IDsNobuyoshi Nakada2021-07-271-2/+2
|
* Use RB_INTEGER_TYPE_PNobuyoshi Nakada2021-07-201-2/+1
|
* Make boolean expected messages more consitentNobuyoshi Nakada2021-07-181-1/+1
|
* Constified a local tableNobuyoshi Nakada2021-07-181-1/+1
|
* Add Integer.try_convert [Feature #15211]Nobuyoshi Nakada2021-07-161-3/+13
|
* Move rb_str_escape function declarationS-H-GAMELINKS2021-07-111-1/+1
|
* Specify version to remove as bare numbersNobuyoshi Nakada2021-06-301-7/+7
|
* rb_warn_deprecated_to_remove_at [Feature #17432]Nobuyoshi Nakada2021-06-301-7/+7
| | | | | At compilation time with RUBY_DEBUG enabled, check if the removal version has been reached.
* Share freeze option handlingNobuyoshi Nakada2021-06-281-7/+7
|
* Adjust styles [ci skip]Nobuyoshi Nakada2021-06-171-1/+1
| | | | | | | | | * --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while