summaryrefslogtreecommitdiff
path: root/internal
Commit message (Collapse)AuthorAgeFilesLines
* Constant time class to class ancestor lookupJohn Hawthorn2022-02-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Change darray size to size_t and add functions that use GC mallocPeter Zhu2022-02-161-0/+1
| | | | | | | Changes size and capacity of darray to size_t to support more elements. Adds functions to darray that use GC allocation functions.
* Mark `rb_clear_constant_cache` as internal use onlyNobuyoshi Nakada2022-01-201-0/+2
| | | | | | In the past, many internal functions are declared in intern.h under include/ruby directory, because there were no headers for internal use.
* Parenthesize the macro argumentNobuyoshi Nakada2022-01-171-1/+1
|
* * expand tabs. [ci skip]git2022-01-151-4/+4
| | | | | Tabs were expanded because the file did not have any tab indentation in unedited lines. Please update your editor config, and use misc/expand_tabs.rb in the pre-commit hook.
* Transfer the responsibility for MJIT options to mjit.cNobuyoshi Nakada2022-01-151-0/+61
|
* Separately allocate class_serial on 32-bit systemsPeter Zhu2022-01-141-2/+9
| | | | | | | | On 32-bit systems, VWA causes class_serial to not be aligned (it only guarantees 4 byte alignment but class_serial is 8 bytes and requires 8 byte alignment). This commit uses a hack to allocate class_serial through malloc. Once VWA allocates with 8 byte alignment in the future, we will revert this commit.
* Make RubyVM::AbstractSyntaxTree.of raise for backtrace location in evalYusuke Endoh2021-12-191-1/+2
| | | | | | | | | This check is needed to fix a bug of error_highlight when NameError occurred in eval'ed code. https://github.com/ruby/error_highlight/pull/16 The same check for proc/method has been already introduced since 64ac984129a7a4645efe5ac57c168ef880b479b2.
* Speed up Ractors for Variable Width AllocationPeter Zhu2021-11-231-1/+11
| | | | | | | | | | | | | | | | This commit adds a Ractor cache for every size pool. Previously, all VWA allocated objects used the slowpath and locked the VM. On a micro-benchmark that benchmarks String allocation: VWA turned off: 29.196591 0.889709 30.086300 ( 9.434059) VWA before this commit: 29.279486 41.477869 70.757355 ( 12.527379) VWA after this commit: 16.782903 0.557117 17.340020 ( 4.255603)
* Assign temporary ID to anonymous ID [Bug #18250]Nobuyoshi Nakada2021-11-231-0/+1
| | | | | | | | Dumped iseq binary can not have unnamed symbols/IDs, and ID 0 is stored instead. As `struct rb_id_table` disallows ID 0, also for the distinction, re-assign a new temporary ID based on the local variable table index when loading from the binary, as well as the parser.
* Make RCLASS_EXT(c)->subclasses a doubly linked listMatt Valentine-House2021-11-221-4/+6
| | | | | | | | Updating RCLASS_PARENT_SUBCLASSES and RCLASS_MODULE_SUBCLASSES while compacting can trigger the read barrier. This commit makes RCLASS_SUBCLASSES a doubly linked list with a dedicated head object so that we can add and remove entries from the list without having to touch an object in the Ruby heap
* Remove RCLASS(obj)->ptr when RVARGC is enabledMatt Valentine-House2021-11-111-1/+7
| | | | | | | With RVARGC we always store the rb_classext_t in the same slot as the RClass struct that refers to it. So we don't need to store the pointer or access through the pointer anymore and can switch the RCLASS_EXT macro to use an offset
* gc.h: move rb_objspace_garbage_object_p to internal/gc.hYusuke Endoh2021-11-101-0/+1
| | | | ... to allow class.c to use the function
* Embed bare `double` if `sizeof(double) == sizeof(VALUE)`Nobuyoshi Nakada2021-10-271-2/+2
|
* Align `RFloat` at VALUE boundaryNobuyoshi Nakada2021-10-271-11/+16
|
* Fix unaligned access to `double` in RFloatNobuyoshi Nakada2021-10-261-0/+12
|
* [Feature #18239] Implement VWA for stringsPeter Zhu2021-10-251-15/+12
| | | | | This commit adds support for embedded strings with variable capacity and uses Variable Width Allocation to allocate strings.
* [Feature #18239] Refactor RVARGC alloc functionsPeter Zhu2021-10-251-5/+6
| | | | | The allocation functions no longer assume that one RVALUE needs to be allocated.
* ast.c: Use kept script_lines data instead of re-opening the source file (#5019)Yusuke Endoh2021-10-261-1/+1
| | | ast.c: Use kept script_lines data instead of re-open the source file
* process.c: Add Process._fork (#5017)Yusuke Endoh2021-10-251-1/+1
| | | | | | | | | | * process.c: Add Process._fork This API is supposed for application monitoring libraries to hook fork event. [Feature #17795] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* `RubyVM.keep_script_lines`Koichi Sasada2021-10-211-0/+1
| | | | | | | | | | | | | | `RubyVM.keep_script_lines` enables to keep script lines for each ISeq and AST. This feature is for debugger/REPL support. ```ruby RubyVM.keep_script_lines = true RubyVM::keep_script_lines = true eval("def foo = nil\ndef bar = nil") pp RubyVM::InstructionSequence.of(method(:foo)).script_lines ```
* Extract yjit_force_iv_index and make it work when object is frozenAlan Wu2021-10-201-0/+1
| | | | | | | | | | | | | | | | | | In an effort to simplify the logic YJIT generates for accessing instance variable, YJIT ensures that a given name-to-index mapping exists at compile time. In the case that the mapping doesn't exist, it was created by using rb_ivar_set() with Qundef on the sample object we see at compile time. This hack isn't fine if the sample object happens to be frozen, in which case YJIT would raise a FrozenError unexpectedly. To deal with this, make a new function that only reserves the mapping but doesn't touch the object. This is rb_obj_ensure_iv_index_mapping(). This new function superceeds the functionality of rb_iv_index_tbl_lookup() so it was removed. Reported by and includes a test case from John Hawthorn <john@hawthorn.email> Fixes: GH-282
* Add comments about special runtime routines YJIT callsAlan Wu2021-10-202-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.
* Restore Hash#compare_by_identity mode [Bug #18171]Nobuyoshi Nakada2021-10-021-0/+2
|
* Add rb_ident_hash_new_with_sizeNobuyoshi Nakada2021-10-021-0/+1
|
* Skip broken strings as the locale encodingNobuyoshi Nakada2021-10-011-0/+1
|
* Move some function declaration to internal/io.hS-H-GAMELINKS2021-09-281-0/+4
|
* Consider modified modules initialized [Bug #18185]Nobuyoshi Nakada2021-09-241-0/+1
|
* Add support for non-blocking `Kernel.system`.Samuel Williams2021-09-221-0/+2
|
* Fix a typo [Bug #17048]Nobuyoshi Nakada2021-09-191-1/+1
|
* Already initialized modules cannot be replaced [Bug #17048]Nobuyoshi Nakada2021-09-171-0/+3
|
* suppress GCC's -Wsuggest-attribute=format卜部昌平2021-09-101-0/+3
| | | | I was not aware of this because I use clang these days.
* include/ruby/internal/core/rarray.h: add doxygen卜部昌平2021-09-101-4/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* 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.