aboutsummaryrefslogtreecommitdiffstats
path: root/include/ruby/internal/intern
Commit message (Collapse)AuthorAgeFilesLines
* Make rb_check_frozen_inline() static inline againAlan Wu2024-07-191-1/+19
| | | | | | | | | | | Since 730e3b2ce01915c4a98b79bb281b2c38a9ff1131 ("Stop exposing `rb_str_chilled_p`"), we noticed a speed loss on a few benchmarks that are string operations heavy. This is partially due to routines no longer having the options to inline rb_check_frozen_inline() in non-LTO builds. Make it an inlining candidate again to recover speed. Testing this patch on my machine, the fannkuchredux benchmark gets a 1.15 speed-up with YJIT and 1.03 without YJIT.
* [DOC] No more is rb_ary_freeze() an alias of rb_obj_freeze()Alan Wu2024-07-171-1/+7
| | | | [Feature #20589]
* Stop exposing `rb_str_chilled_p`Jean Boussier2024-06-022-40/+2
| | | | | | | | | | [Feature #20205] Now that chilled strings no longer appear as frozen, there is no need to offer an API to check for chilled strings. We however need to change `rb_check_frozen_internal` to no longer be a macro, as it needs to check for chilled strings.
* Stop marking chilled strings as frozenÉtienne Barrié2024-05-281-0/+10
| | | | | | | | | | | | | They were initially made frozen to avoid false positives for cases such as: str = str.dup if str.frozen? But this may cause bugs and is generally confusing for users. [Feature #20205] Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
* [DOC] remove repetitive words in commentscrazeteam2024-03-271-1/+1
| | | | Signed-off-by: crazeteam <lilujing@outlook.com>
* Expose rb_str_chilled_pÉtienne Barrié2024-03-261-0/+15
| | | | | | | | | | | | | | Some extensions (like stringio) may need to differentiate between chilled strings and frozen strings. They can now use rb_str_chilled_p but must check for its presence since the function will be removed when chilled strings are removed. [Bug #20389] [Feature #20205] Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
* Implement chilled stringsÉtienne Barrié2024-03-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [Feature #20205] As a path toward enabling frozen string literals by default in the future, this commit introduce "chilled strings". From a user perspective chilled strings pretend to be frozen, but on the first attempt to mutate them, they lose their frozen status and emit a warning rather than to raise a `FrozenError`. Implementation wise, `rb_compile_option_struct.frozen_string_literal` is no longer a boolean but a tri-state of `enabled/disabled/unset`. When code is compiled with frozen string literals neither explictly enabled or disabled, string literals are compiled with a new `putchilledstring` instruction. This instruction is identical to `putstring` except it marks the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags. Chilled strings have the `FL_FREEZE` flag as to minimize the need to check for chilled strings across the codebase, and to improve compatibility with C extensions. Notes: - `String#freeze`: clears the chilled flag. - `String#-@`: acts as if the string was mutable. - `String#+@`: acts as if the string was mutable. - `String#clone`: copies the chilled flag. Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
* [Feature #20265] Remove rb_newobj_of and RB_NEWOBJ_OFPeter Zhu2024-03-142-4/+2
|
* [DOC] fix some commentscui fliter2024-03-052-2/+2
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* Clarify C API documentation about pinned classesJean Boussier2024-03-012-4/+12
| | | | | | | They are not only pinned, but also immortal. Even if the constant referencing them is removed, they will remain alive. It's a precision worth noting.
* Typo fixes for public headers [ci skip]Alan Wu2023-12-214-4/+4
|
* rb_ext_resolve_symbol: C API to resolve and return externed symbols [Feature ↵Satoshi Tagomori2023-12-141-0/+37
| | | | | | | | | | #20005] This is a C API for extensions to resolve and get function symbols of other extensions. Extensions can check the expected symbol is correctly loaded and accessible, and use it if it is available. Otherwise, extensions can raise their own error to guide users to setup their environments correctly and what's missing.
* [DOC] Missing comment markersNobuyoshi Nakada2023-09-271-1/+1
|
* Expose `rb_process_status_wait` and hide `rb_process_status_waitv`. (#8316)Samuel Williams2023-08-291-0/+9
|
* Move `posix_signal` declaration internal with prefix `ruby_`Nobuyoshi Nakada2023-07-171-6/+0
|
* [Feature #19757] Add new API `rb_data_define`Nobuyoshi Nakada2023-07-131-0/+14
|
* Use `rb_reg_nth_defined` instead of `rb_match_nth_defined`Nobuyoshi Nakada2023-06-271-5/+0
|
* [DOC] Should use `NULL` instead of zeroNobuyoshi Nakada2023-06-121-8/+8
| | | | | | | Since no type information is available for variadic arguments, 0 is passed as `int` without promoting to pointer. On platforms where `sizeof(int) < sizeof(void*)`, the terminator argument may be read together with an adjoining word, and may not be found.
* Remove obsoleted MJIT_STATIC macroTakashi Kokubun2023-03-061-1/+1
|
* Merge internal/intern/gc.h into internal/gc.hMatt Valentine-House2023-02-271-392/+0
|
* Never use the storage of another Fiber, that violates the whole designBenoit Daloze2022-12-201-5/+1
| | | | * See https://bugs.ruby-lang.org/issues/19078#note-30
* [DOC] Update `rb_gc_mark_locations` docJimmy Bourassa2022-12-091-1/+1
| | | | The documentation says that the `end` pointer will be marked but looking at the source, that is not the case.
* Clarify the storage argument. (#6849)Samuel Williams2022-12-021-2/+7
| | | * Slightly more consistent indentation with other parts of the document.
* Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612)Samuel Williams2022-12-011-0/+21
|
* Fix -Wundef warningsNobuyoshi Nakada2022-10-261-1/+1
|
* Add Class#attached_objectUfuk Kayserilioglu2022-10-201-0/+12
| | | | | | | Implements [Feature #12084] Returns the object for which the receiver is the singleton class, or raises TypeError if the receiver is not a singleton class.
* object.c: rb_eql returns int not VALUEJean Boussier2022-10-101-2/+2
| | | | | It works, but assumes `Qfalse == 0`, which is true today but might not be forever.
* [Bug #5317] Use `rb_off_t` instead of `off_t`Nobuyoshi Nakada2022-09-081-1/+1
| | | | Get rid of the conflict with system-provided small `off_t`.
* typosspaette2022-08-271-1/+1
|
* Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu2022-07-261-3/+3
| | | | | | rb_ary_tmp_new suggests that the array is temporary in some way, but that's not true, it just creates an array that's hidden and not on the transient heap. This commit renames it to rb_ary_hidden_new.
* Restore rb_exec_recursive_outerJohn Hawthorn2022-06-151-2/+1
| | | | This was a public method, so we should probably keep it.
* Make method id explicit in rb_exec_recursive_outerJohn Hawthorn2022-06-101-1/+2
| | | | | | | | | | | | | | Previously, because opt_aref and opt_aset don't push a frame, when they would call rb_hash to determine the hash value of the key, the initial level of recursion would incorrectly use the method id at the top of the stack instead of "hash". This commit replaces rb_exec_recursive_outer with rb_exec_recursive_outer_mid, which takes an explicit method id, so that we can make the hash calculation behave consistently. rb_exec_recursive_outer was documented as being internal, so I believe this should be okay to change.
* Expose `rb_hash_new_capa(long)`Jean Boussier2022-04-261-0/+11
| | | | | | | | [Feature #18683] This allows parsers and similar libraries to create Hashes of a certain capacity in advance. It's useful when the key and values are streamed, hence `bulk_insert()` can't be used.
* Finer-grained constant cache invalidation (take 2)Kevin Newton2022-04-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This commit reintroduces finer-grained constant cache invalidation. After 8008fb7 got merged, it was causing issues on token-threaded builds (such as on Windows). The issue was that when you're iterating through instruction sequences and using the translator functions to get back the instruction structs, you're either using `rb_vm_insn_null_translator` or `rb_vm_insn_addr2insn2` depending if it's a direct-threading build. `rb_vm_insn_addr2insn2` does some normalization to always return to you the non-trace version of whatever instruction you're looking at. `rb_vm_insn_null_translator` does not do that normalization. This means that when you're looping through the instructions if you're trying to do an opcode comparison, it can change depending on the type of threading that you're using. This can be very confusing. So, this commit creates a new translator function `rb_vm_insn_normalizing_translator` to always return the non-trace version so that opcode comparisons don't have to worry about different configurations. [Feature #18589]
* Revert "Finer-grained inline constant cache invalidation"Nobuyoshi Nakada2022-03-251-7/+0
| | | | | | | | | | | | This reverts commits for [Feature #18589]: * 8008fb7352abc6fba433b99bf20763cf0d4adb38 "Update formatting per feedback" * 8f6eaca2e19828e92ecdb28b0fe693d606a03f96 "Delete ID from constant cache table if it becomes empty on ISEQ free" * 629908586b4bead1103267652f8b96b1083573a8 "Finer-grained inline constant cache invalidation" MSWin builds on AppVeyor have been crashing since the merger.
* Finer-grained inline constant cache invalidationKevin Newton2022-03-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current behavior - caches depend on a global counter. All constant mutations cause caches to be invalidated. ```ruby class A B = 1 end def foo A::B # inline cache depends on global counter end foo # populate inline cache foo # hit inline cache C = 1 # global counter increments, all caches are invalidated foo # misses inline cache due to `C = 1` ``` Proposed behavior - caches depend on name components. Only constant mutations with corresponding names will invalidate the cache. ```ruby class A B = 1 end def foo A::B # inline cache depends constants named "A" and "B" end foo # populate inline cache foo # hit inline cache C = 1 # caches that depend on the name "C" are invalidated foo # hits inline cache because IC only depends on "A" and "B" ``` Examples of breaking the new cache: ```ruby module C # Breaks `foo` cache because "A" constant is set and the cache in foo depends # on "A" and "B" class A; end end B = 1 ``` We expect the new cache scheme to be invalidated less often because names aren't frequently reused. With the cache being invalidated less, we can rely on its stability more to keep our constant references fast and reduce the need to throw away generated code in YJIT.
* Mark `rb_clear_constant_cache` as internal use onlyNobuyoshi Nakada2022-01-201-11/+0
| | | | | | In the past, many internal functions are declared in intern.h under include/ruby directory, because there were no headers for internal use.
* [Feature #18491] Drop support for HP-UXPeter Zhu2022-01-181-3/+0
| | | | | IA64 support was dropped in ticket #15894, so we can drop support for HP-UX.
* [DOC] Fix a typo in a docNobuyoshi Nakada2022-01-131-1/+1
|
* Remove declarations of deprecated functionsNobuyoshi Nakada2021-12-301-12/+0
|
* Remove tainted and trusted featuresNobuyoshi Nakada2021-12-264-143/+0
| | | | Already these had been announced to be removed in 3.2.
* Improved exception usage/classes.Samuel Williams2021-12-211-0/+2
|
* intern/select/posix.h: remove unused parameter from rb_fd_dupYuta Saito2021-12-111-2/+1
| | | | This unused parameter seems to be accidently introduced by https://github.com/ruby/ruby/commit/9e6e39c
* Add Class#subclassesJean Boussier2021-11-231-1/+14
| | | | | | | Implements [Feature #18273] Returns an array containing the receiver's direct subclasses without singleton classes.
* revival of must_not_null()卜部昌平2021-11-111-8/+6
| | | | | | | | Presence of RBIMPL_ATTR_NONNULL let C compilers to eliminate must_not_null(). Because null pointers are not allowed to exist there are no reason to call the function. In reality null pointers are still passed to those functions in a number of ways. Runtime check for them are definitely nice to have. fix [Feature#18280]
* rb_file_size: add doxygen卜部昌平2021-11-111-0/+17
| | | | Must not be a bad idea to improve documents. [ci skip]
* size_t is not for file sizeNobuyoshi Nakada2021-11-101-1/+1
|
* IO::Buffer for scheduler interface.Samuel Williams2021-11-101-0/+2
|
* [Feature #18290] Deprecate rb_gc_force_recycle and remove ↵Peter Zhu2021-11-081-0/+2
| | | | | | | | invalidate_mark_stack_chunk This commit deprecates rb_gc_force_recycle and coverts it to a no-op function. Also removes invalidate_mark_stack_chunk since only rb_gc_force_recycle uses it.
* Fix typosNobuyoshi Nakada2021-11-022-3/+3
|