summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)Author
3 daysFix `blocking_operation_wait` use-after-free bug.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/13437
6 daysAllow 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
7 daysshape.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é <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13441
10 days[Feature #21205] Define File::Stat#birthtime by statxNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13474
12 daysUse 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 <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13341
2025-05-23Bump fiber scheduler version and add missing documentation. (#13424)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2025-05-23Allow `IO#close` to interrupt IO operations on fibers using ↵Samuel Williams
`fiber_interrupt` hook. (#12839) Notes: Merged-By: ioquatix <[email protected]>
2025-05-22Fix for old mingw without `clock_gettime` and `clock_getres`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13405
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-14Reduce `Object#object_id` contention.Jean Boussier
If the object isn't shareable and already has a object_id we can access it without a lock. If we need to generate an ID, we may need to lock to find the child shape. We also generate the next `object_id` using atomics. Notes: Merged: https://github.com/ruby/ruby/pull/13298
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 <[email protected]>
2025-05-12Fix redefinition of `clock_gettime` and `clock_getres`Nobuyoshi Nakada
winpthreads-git 12.0.0.r720 provides `clock_gettime` and `clock_getres` as inline functions. Notes: Merged: https://github.com/ruby/ruby/pull/13302
2025-05-11namespace on readSatoshi Tagomori
2025-05-08Move `object_id` in object fields.Jean Boussier
And get rid of the `obj_to_id_tbl` It's no longer needed, the `object_id` is now stored inline in the object alongside instance variables. We still need the inverse table in case `_id2ref` is invoked, but we lazily build it by walking the heap if that happens. The `object_id` concern is also no longer a GC implementation concern, but a generic implementation. Co-Authored-By: Matt Valentine-House <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13159
2025-05-08Rename `ivptr` -> `fields`, `next_iv_index` -> `next_field_index`Jean Boussier
Ivars will longer be the only thing stored inline via shapes, so keeping the `iv_index` and `ivptr` names would be confusing. Instance variables won't be the only thing stored inline via shapes, so keeping the `ivptr` name would be confusing. `field` encompass anything that can be stored in a VALUE array. Similarly, `gen_ivtbl` becomes `gen_fields_tbl`. Notes: Merged: https://github.com/ruby/ruby/pull/13159
2025-05-05Add `RBIMPL_ATTR_NONSTRING_ARRAY()` macro for GCC 15Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13256
2025-05-05Save one VALUE per embedded RTypedDataJeremy Evans
This halves the amount of memory used for embedded RTypedData if they are one VALUE (8 bytes on 64-bit platforms) over the slot size limit. For Set, on 64-bit it uses an embedded 56-byte struct. With the previous implementation, the embedded structs starts at offset 32, resulting in a total size of 88. Since that is over the 80 byte limit, it goes to the next highest bucket, 160 bytes, wasting 72 bytes. This allows it to fit in a 80 byte bucket, which reduces the total size for small sets of from 224 bytes (160 bytes embedded, 64 bytes malloc, 72 bytes wasted in embedding) to 144 bytes (80 bytes embedded, 64 bytes malloc, 0 bytes wasted in embedding). Any other embedded RTypedData will see similar advantages if they are currently one VALUE over the limit. To implement this, remove the typed_flag from struct RTypedData. Embed the typed_flag information in the type member, which is now a tagged pointer using VALUE type, using the bottom low 2 bits as flags (1 bit for typed flag, the other for the embedded flag). To get the actual pointer, RTYPEDDATA_TYPE masks out the low 2 bits and then casts. That moves the RTypedData data pointer from offset 32 to offset 24 (on 64-bit). Vast amount of code in the internals (and probably external C extensions) expects the following code to work for both RData and non-embedded RTypedData: ```c DATA_PTR(obj) = some_pointer; ``` Allow this to work by moving the data pointer in RData between the dmark and dfree pointers, so it is at the same offset (24 on 64-bit). Other than these changes to the include files, the only changes needed were to gc.c, to account for the new struct layouts, handle setting the low bits in the type member, and to use RTYPEDDATA_TYPE(obj) instead of RTYPEDDATA(obj)->type. Notes: Merged: https://github.com/ruby/ruby/pull/13190
2025-04-30get_next_shape_internal: Skip VM lock for single child caseJean Boussier
If the shape has only one child, we check it lock-free without compromising thread safety. I haven't computed hard data as to how often that it the case, but we can assume that it's not too rare for shapes to have a single child that is often requested, typically when freezing and object. Notes: Merged: https://github.com/ruby/ruby/pull/13191
2025-04-30Suppress gcc 15 unterminated-string-initialization warningsNobuyoshi Nakada
2025-04-30Fix C23 (GCC 15) WIN32 compatibility for rb_define_* functionsAlan Wu
Fixes [Bug #21286] Notes: Merged: https://github.com/ruby/ruby/pull/13202
2025-04-30RUBY_T_{TRUE,FALSE} comments were reversedMatt Valentine-House
[ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/13207
2025-04-18Work on ATOMIC_VALUE_SETJohn Hawthorn
Notes: Merged: https://github.com/ruby/ruby/pull/12921
2025-04-16Introduce `enum rb_io_mode`. (#7894)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2025-04-14Expose `ruby_thread_has_gvl_p`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/11975
2025-03-28Mark first argument to all C-API tracepoint functions as nonnullRichard Böhme
Notes: Merged: https://github.com/ruby/ruby/pull/12553
2025-03-28Make rb_tracearg_(parameters|eval_script|instruction_sequence) public C-APIRichard Böhme
This allows C-Extension developers to call those methods to retrieve information about a TracePoint's parameters, eval script and instruction sequence. Implements [Feature #20757] Notes: Merged: https://github.com/ruby/ruby/pull/12553
2025-03-18Suppress sign-conversion warning [ci skip]Nobuyoshi Nakada
2025-03-16Make wrapper of `main` for wasm more genericNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12933
2025-03-16Make ASAN default option string built-in librubyNobuyoshi Nakada
The content depends on ruby internal, not responsibility of the caller. Revive `RUBY_GLOBAL_SETUP` macro to define the hook function. Notes: Merged: https://github.com/ruby/ruby/pull/12933
2025-02-28[DOC] Fix the comment for RUBY_CONST_ID and rb_internNobuyoshi Nakada
RUBY_CONST_ID has never been deprecated; `rb_intern` is handy but it is using non-standard GCC extensions and does not cache the ID with other compilers.
2025-02-12Remove dead iv_index_tbl field in RObjectPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12739
2025-01-14[Bug #21024] <cstdbool> header has been uselessNobuyoshi Nakada
And finally deprecated at C++-17. Patched by jprokop (Jarek Prokop). Notes: Merged: https://github.com/ruby/ruby/pull/12573
2025-01-14Mark `rb_path_check` as internal onlyNobuyoshi Nakada
2025-01-13Move the declaration of `rb_path_check`Nobuyoshi Nakada
Although this function is unrelated to hash, it was defined in hash.c to check PATH environment variable originally. Then the definition was moeved to file.c but the declaration was left in the hash.c block. Notes: Merged: https://github.com/ruby/ruby/pull/12564
2025-01-12[DOC] Fix the description of `rb_path_check`Nobuyoshi Nakada
c.f. #20971
2025-01-11[Bug #21024] <cstdbool> header is deprecated in C++17Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12551
2025-01-02Move rbimpl_size_add_overflow from gc.c to memory.hPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12459
2024-12-25Development of 3.5.0 started.Yukihiro "Matz" Matsumoto
2024-12-18use RBIMPL_ATTR_MAYBE_UNUSEDNaohisa Goto
The macro MAYBE_UNUSED, prepared by ./configure, may not be defined in some environments such as Oracle Developer Studio 12.5 on Solaris 10. This fixes [Bug #20963]
2024-12-17[DOC] rb_id2name(): Note truncation danger (+minor copyediting)Alan Wu
Thanks, nobu!
2024-12-17[DOC] Add note to rb_id2name about GC compactionPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12376
2024-12-17Win32: Fix `rbimpl_size_mul_overflow` on arm64Nobuyoshi Nakada
`_umul128` is specific to x86_64 platform, see higher words by `__umulh` on arm64. Notes: Merged: https://github.com/ruby/ruby/pull/12367
2024-12-13[DOC] Update `rb_strlen_lit`Nobuyoshi Nakada
It is not "in bytes" for wide char literal.
2024-12-04Fix typos in public headers [ci skip]Alan Wu
2024-11-29[DOC] Rewrite docs for rb_sym2str()Alan Wu
Explaining this by reference to rb_id2str() obscures a few important details because IDs and symbols don't map to each other perfectly (you can have a dynamic symbol without an ID!) Also, it used to take 2 redirections to get to concrete information, and I think being more direct is friendlier.
2024-11-29[DOC] Mention that rb_id2str() returns a frozen stringAlan Wu
2024-11-20Introduce `Fiber::Scheduler#blocking_operation_wait`. (#12016)Samuel Williams
Redirect `rb_nogvl` blocking operations to the fiber scheduler if possible to prevent stalling the event loop. [Feature #20876] Notes: Merged-By: ioquatix <[email protected]>