| Age | Commit message (Collapse) | Author |
|
Allows to remove some duplicated code like szqueue_length, etc.
|
|
* `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.
|
|
|
|
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"
|
|
This struct is used for addition not only for multiplication, so
remove the word `mul`, and make the member names more descriptive.
|
|
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.
|
|
|
|
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.
|
|
These macros have been defined here and there, so collect them.
|
|
[Bug #21771]
It may raise so it's incorrect and can lead to the compiler
optimizing the call out.
|
|
|
|
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.
|
|
|
|
`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.
|
|
|
|
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
```
|
|
Visual C++ 2005 (8.0):
- _MSC_VER: 1400
- MSVCRT_VERSION: 80
|
|
|
|
|
|
optimization bug. [Bug #21655]
|
|
Implementation was removed in https://github.com/ruby/ruby/commit/a4c051b870ac7f7b3c5482baf05600e1f6751b47
|
|
|
|
|
|
Instead of the offset calculation.
|
|
`IS_TYPED_DATA` is no longer a flag in `type`, and the "embedded" flag
has been shifted accordingly.
ruby/ruby#14470
|
|
|
|
|
|
|
|
Followup changes in https://github.com/ruby/ruby/pull/14470 /
03c86b053197f3cd6bece1925e634c1d74d196d0
|
|
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.
|
|
|
|
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.
|
|
|
|
|
|
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.
|
|
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.
|
|
rb_str_hash_cmp returns 0 if the two strings are identical and 1 if they
are different.
|
|
* 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>
|
|
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>
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
`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.
|
|
|
|
- `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>
|
|
|