summaryrefslogtreecommitdiff
path: root/include/ruby/internal
AgeCommit message (Collapse)Author
2025-12-18thread_sync.c: declare queue_data_type as parent of szqueue_data_type.Jean Boussier
Allows to remove some duplicated code like szqueue_length, etc.
2025-12-18[DOC] Fix documents of `rb_intern_str` and so onNobuyoshi Nakada
* `rb_intern_str`: the argument must be `T_STRING`, no conversion. * `rb_intern_str`, `rb_check_id`, `rb_to_id`, `rb_check_symbol`: raise `EncodingError` unless the "name" argument is a valid string in its encoding.
2025-12-18[DOC] Re-fill the paragraphNobuyoshi Nakada
2025-12-18[DOC] Fix double-word typos in commentsv4.0.0-preview3Augustin Gottlieb
Found via `grep` for repeated words. * set.c: Fix "or or" * include/ruby/internal/symbol.h: Fix "is is" * include/ruby/internal/ctype.h: Fix "in in"
2025-12-17Rename to `struct rbimpl_size_overflow_tag`Nobuyoshi Nakada
This struct is used for addition not only for multiplication, so remove the word `mul`, and make the member names more descriptive.
2025-12-16gc.h: Reintroduce immediate guard in `rb_obj_written`Jean Boussier
This guard was removed in https://github.com/ruby/ruby/pull/13497 on the justification that some GC may need to be notified even for immediate. But the two currently available GCs don't, and there are plenty of assumtions GCs don't everywhere, notably in YJIT and ZJIT. This optimization is also not so micro (but not huge either). I routinely see 1-2% wasted there on micro-benchmarks. So perhaps if in the future we actually need this, it might make sense to introduce a way for GCs to declare that as an option, but in the meantime it's extra overhead with little gain.
2025-12-13Fix documentation of RB_PASS_CALLED_KEYWORDS in C APIBenoit Daloze
2025-12-12Fewer calls to `GET_EC()` and `GET_THREAD()` (#15506)Luke Gruber
The changes are to `io.c` and `thread.c`. I changed the API of 2 exported thread functions from `internal/thread.h` that didn't look like they had any use in C extensions: * rb_thread_wait_for_single_fd * rb_thread_io_wait I didn't change the following exported internal function because it's used in C extensions: * rb_thread_fd_select I added a comment to note that this function, although internal, is used in C extensions.
2025-12-10Add `NUM2PTR` and `PTR2NUM` macrosNobuyoshi Nakada
These macros have been defined here and there, so collect them.
2025-12-09Don't declare `rbimpl_check_typeddata` as pureJean Boussier
[Bug #21771] It may raise so it's incorrect and can lead to the compiler optimizing the call out.
2025-12-09Fix a typo in the deprecation warning messageNobuyoshi Nakada
2025-12-08Move RBIMPL_ATTR_DEPRECATED_* macros to the appropriate header fileKazuki Yamaguchi
Move these macros from include/ruby/backward.h to include/ruby/internal/attr/deprecated.h, alongside the other similar macros. include/ruby/internal/intern/vm.h cannot currently use them because include/ruby/backward.h is included too late.
2025-12-05fix typo s/sharable/shareable/Koichi Sasada
2025-12-05(experimental) RUBY_TYPED_FROZEN_SHAREABLE_NO_RECKoichi Sasada
`T_DATA` has a flag `RUBY_TYPED_FROZEN_SHAREABLE` which means if the `T_DATA` object is frozen, it can be sharable. On the `Ractor.make_sharable(obj)`, rechable objects from the `T_DATA` object will be apply `Ractor.make_shareable` recursively. `RUBY_TYPED_FROZEN_SHAREABLE_NO_REC` is similar to the `RUBY_TYPED_FROZEN_SHAREABLE`, but doesn't apply `Ractor.make_sharable` recursively for children. If it refers to unshareable objects, it will simply raise an error. I'm not sure this pattern is common or not, so it is not in public. If we find more cases, we can discuss publication.
2025-12-04Deprecate `rb_eval_cmd_kw`Nobuyoshi Nakada
2025-12-03Speedup TypedData_Get_StructJean Boussier
While profiling `Monitor#synchronize` and `Mutex#synchronize` I noticed a fairly significant amount of time spent in `rb_check_typeddata`. By implementing a fast path that assumes the object is valid and that can be inlined, it does make a significant difference: Before: ``` Mutex 13.548M (± 3.6%) i/s (73.81 ns/i) - 68.566M in 5.067444 Monitor 10.497M (± 6.5%) i/s (95.27 ns/i) - 52.529M in 5.032698s ``` After: ``` Mutex 20.887M (± 0.3%) i/s (47.88 ns/i) - 106.021M in 5.075989s Monitor 16.245M (±13.3%) i/s (61.56 ns/i) - 80.705M in 5.099680s ``` ```ruby require 'bundler/inline' gemfile do gem "benchmark-ips" end mutex = Mutex.new require "monitor" monitor = Monitor.new Benchmark.ips do |x| x.report("Mutex") { mutex.synchronize { } } x.report("Monitor") { monitor.synchronize { } } end ```
2025-11-19Win32: Drop support for older than MSVC 8.0/_MSC_VER 1400Nobuyoshi Nakada
Visual C++ 2005 (8.0): - _MSC_VER: 1400 - MSVCRT_VERSION: 80
2025-11-11simplify RSRING_GETMEM() definition.nagachika
2025-11-11include/ruby/internal/core/rstring.h: Remove rbimpl_rstring_getmem() definition.nagachika
2025-11-11Remove rbimpl_rstring_getmem() usage as workaround for GCC 15.2.1 ↵nagachika
optimization bug. [Bug #21655]
2025-11-07Remove `rb_path_check` declarationEarlopain
Implementation was removed in https://github.com/ruby/ruby/commit/a4c051b870ac7f7b3c5482baf05600e1f6751b47
2025-11-07Development of 4.0.0 started.Yukihiro "Matz" Matsumoto
2025-11-07Rename Namespace to Ruby::BoxSatoshi Tagomori
2025-10-25Use pointer to the memberNobuyoshi Nakada
Instead of the offset calculation.
2025-10-25[DOC] Follow up GH-14470Nobuyoshi Nakada
`IS_TYPED_DATA` is no longer a flag in `type`, and the "embedded" flag has been shifted accordingly. ruby/ruby#14470
2025-10-08[Bug #21629] Initialize `struct RString`Nobuyoshi Nakada
2025-10-08[Bug #21629] Enable `nonstring` attribute on clang 21Nobuyoshi Nakada
2025-09-15[DOC] Fix typos in commentsÉtienne Barrié
2025-09-08Bump ABI versionJean Boussier
Followup changes in https://github.com/ruby/ruby/pull/14470 / 03c86b053197f3cd6bece1925e634c1d74d196d0
2025-09-08Move `IS_TYPED_DATA` in RBasic.flagsJean Boussier
Ref: https://github.com/ruby/ruby/pull/14134#issuecomment-3207733725 We can't safely use low-bit pointer tagging anymore because `RTypedData.type` lines up with `RData.dfree` and there is no aligment guarantee on function pointers, as evidenced by `memcached` and `gpgme` gems. We also can't use FL_USER* for this, because extensions may use these for other purposes. Using a general flag for this is a bit unfortunate, as general flags are hard to come by, however I recently freed several of them, and we still have two or three free ones left.
2025-08-29[DOC] rb_str_resurrect(): Reword to remove wrong guess; used by zlibAlan Wu
2025-08-27Replace ROBJECT_EMBED by ROBJECT_HEAPJean Boussier
The embed layout is way more common than the heap one, especially since WVA. I think it makes for more readable code to inverse the flag.
2025-08-26Ensure T_OBJECT and T_IMEMO/fields have identical layoutJean Boussier
2025-08-14Fix a static assertion incompatible with C++98 (#14229)Takashi Kokubun
2025-08-14Fix documentation about struct RData's data fieldÉtienne Barrié
Also adds a static assertion to ensure the documented behavior stays true, namely that the data field is at the same position in the RData and RTypedData structs.
2025-08-12RTypedData: keep direct reference to IMEMO/fieldsJean Boussier
Similar to f3206cc79bec2fd852e81ec56de59f0a67ab32b7 but for TypedData. It's quite common for TypedData objects to have a mix of reference in their struct and some ivars. Since we do happen to have 8B free in the RtypedData struct, we could use it to keep a direct reference to the IMEMO/fields saving having to synchronize the VM and lookup the `gen_fields_tbl` on every ivar access. For old school Data classes however, we don't have free space, but this API is soft-deprecated and no longer very common.
2025-07-28[DOC] Fix return value of rb_str_hash_cmpPeter Zhu
rb_str_hash_cmp returns 0 if the two strings are identical and 1 if they are different.
2025-07-24Support `cause:` in `Thread#raise` and `Fiber#raise`. (#13967)Samuel Williams
* Add support for `cause:` argument to `Fiber#raise` and `Thread#raise`. The implementation behaviour is consistent with `Kernel#raise` and `Exception#initialize` methods, allowing the `cause:` argument to be passed to `Fiber#raise` and `Thread#raise`. This change ensures that the `cause:` argument is handled correctly, providing a more consistent and expected behavior when raising exceptions in fibers and threads. [Feature #21360] * Shared specs for Fiber/Thread/Kernel raise. --------- Co-authored-by: Samuel Williams <samuel.williams@shopify.com>
2025-07-11Add Set C-APIJeremy Evans
This should be a minimal C-API needed to deal with Set objects. It supports creating the sets, checking whether an element is the set, adding and removing elements, iterating over the elements, clearing a set, and returning the size of the set. Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
2025-06-25Never use flags on T_NODEJohn Hawthorn
Previously, any time we used FL_TEST or variations we would need to add an additional test that it wasn't a T_NODE. I think that was only needed historically and we can avoid generating that extra code.
2025-06-13Get rid of FL_EXIVARJean Boussier
Now that the shape_id gives us all the same information, it's no longer needed. Notes: Merged: https://github.com/ruby/ruby/pull/13612
2025-06-03Allow pass special constants to the write barrierPeter Zhu
Some GC implementations want to always know when an object is written to, even if the written value is a special constant. Checking special constants in rb_obj_written was a micro-optimization that made assumptions about the GC implementation. Notes: Merged: https://github.com/ruby/ruby/pull/13497
2025-06-02shape.c: Implement a lock-free version of get_next_shape_internalJean Boussier
Whenever we run into an inline cache miss when we try to set an ivar, we may need to take the global lock, just to be able to lookup inside `shape->edges`. To solve that, when we're in multi-ractor mode, we can treat the `shape->edges` as immutable. When we need to add a new edge, we first copy the table, and then replace it with CAS. This increases memory allocations, however we expect that creating new transitions becomes increasingly rare over time. ```ruby class A def initialize(bool) @a = 1 if bool @b = 2 else @c = 3 end end def test @d = 4 end end def bench(iterations) i = iterations while i > 0 A.new(true).test A.new(false).test i -= 1 end end if ARGV.first == "ractor" ractors = 8.times.map do Ractor.new do bench(20_000_000 / 8) end end ractors.each(&:take) else bench(20_000_000) end ``` The above benchmark takes 27 seconds in Ractor mode on Ruby 3.4, and only 1.7s with this branch. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/13441
2025-05-28Use flag for RCLASS_IS_INITIALIZEDJohn Hawthorn
Previously we used a flag to set whether a module was uninitialized. When checked whether a class was initialized, we first had to check that it had a non-zero superclass, as well as that it wasn't BasicObject. With the advent of namespaces, RCLASS_SUPER is now an expensive operation, and though we could just check for the prime superclass, we might as well take this opportunity to use a flag so that we can perform the initialized check with as few instructions as possible. It's possible in the future that we could prevent uninitialized classes from being available to the user, but currently there are a few ways to do that. Notes: Merged: https://github.com/ruby/ruby/pull/13443
2025-05-26Add shape_id to RBasic under 32 bitJohn Hawthorn
This makes `RBobject` `4B` larger on 32 bit systems but simplifies the implementation a lot. [Feature #21353] Co-authored-by: Jean Boussier <byroot@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/13341
2025-05-20Include stdbool.h without checking with autoconfAlan Wu
As reported in <https://bugs.ruby-lang.org/issues/21340>, older autoconf have an AC_HEADER_STDBOOL that's incompatible with C23. Autoconf 2.72 fixed the macro, but also mentions that it's obsolescent since all current compilers have this header. Since we require C99 [1] and VS 2015 [2], we might actually be able take that suggestion and include stdbool.h without a check. I want to try this on rubyci.org and will revert if this cause any issues. Not touching AC_HEADER_STDBOOL in configure.ac for now. [1]: https://bugs.ruby-lang.org/issues/15347 [2]: https://bugs.ruby-lang.org/issues/19982 Notes: Merged: https://github.com/ruby/ruby/pull/13384 Merged-By: XrXr
2025-05-14Bump ABI_VERSIONJean Boussier
`struct RTypedData` was changed significantly in https://github.com/ruby/ruby/pull/13190 which breaks many extensions. Bumping the ABI version might save some people from needlessly investigating crashes.
2025-05-13Remove outdated references to FL_SEEN_OBJ_IDJean Boussier
2025-05-13Make `waiting_fd` behaviour per-IO. (#13127)Samuel Williams
- `rb_thread_fd_close` is deprecated and now a no-op. - IO operations (including close) no longer take a vm-wide lock. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2025-05-11namespace on readSatoshi Tagomori