Age | Commit message (Collapse) | Author |
|
Previously, you could override the class initialize_dup/initialize_clone
method and the class hierarchy would not be set correctly inside the
method before calling super.
This removes Module#initialize_copy, and instead makes Object#dup/clone
call the underlying C function (rb_mod_init_copy) before calling the
appropriate initialize_dup/initialize_clone method.
This results in the following fixes:
* The appropriate initialize_dup method is called (dup on a class
will respect superclass initialize_dup).
* Inside class initialize_dup/initialize_clone/initialize_copy,
class ancestor hierarchy is correct.
* Calling singleton_class inside initialize_dup no longer raises
a TypeError later in dup.
* Calling singleton_class.ancestors inside initialize_dup no
longer results in missing ancestors.
Fixes [Bug #21538]
|
|
|
|
|
|
`Kernel#class` can't possibly be called on an hidden object,
hence we don't need to check for `klass == 0`.
```
compare-ruby: ruby 3.5.0dev (2025-08-30T01:45:42Z obj-class 01a57bd6cd) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-30T10:21:10Z obj-class b67c16c477) +YJIT +PRISM [arm64-darwin24]
| |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|obj | 445.217| 642.446|
| | -| 1.44x|
|extended | 136.826| 117.974|
| | 1.16x| -|
|singleton | 166.269| 166.695|
| | -| 1.00x|
|immediate | 380.243| 515.775|
| | -| 1.36x|
```
|
|
This requires ensuring T_MODULE never has FL_SINGLETON set,
so RMODULE_IS_REFINEMENT had to be moved.
|
|
Since `BUILTIN_TYPE` and `RCLASS_SINGLETON_P` are both stored in
`RBasic.flags`, we can combine these two checks in a single bitmask.
This rely on `T_ICLASS` and `T_CLASS` not overlapping, and assume
`klass` is always either of these types.
Just combining the masks brings a small but consistent 1.08x speedup on the simple case benchmark.
```
compare-ruby: ruby 3.5.0dev (2025-08-30T01:45:42Z obj-class 01a57bd6cd) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-30T09:56:24Z obj-class 2685f8dbb4) +YJIT +PRISM [arm64-darwin24]
| |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|obj | 444.410| 478.895|
| | -| 1.08x|
|extended | 135.139| 140.206|
| | -| 1.04x|
|singleton | 165.155| 155.832|
| | 1.06x| -|
|immediate | 380.103| 432.090|
| | -| 1.14x|
```
But with the RB_UNLIKELY compiler hint, it's much more significant, however
the singleton and enxtended cases are slowed down.
However we can assume the simple case is way more common than the other two.
```
compare-ruby: ruby 3.5.0dev (2025-08-30T01:45:42Z obj-class 01a57bd6cd) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-30T09:51:01Z obj-class 12d01a1b02) +YJIT +PRISM [arm64-darwin24]
| |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|obj | 444.951| 556.191|
| | -| 1.25x|
|extended | 136.836| 113.871|
| | 1.20x| -|
|singleton | 166.335| 167.747|
| | -| 1.01x|
|immediate | 379.642| 509.515|
| | -| 1.34x|
```
|
|
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.
|
|
|
|
Now that the shape_id has been unified across all types
this helper function doesn't do much over `RBASIC_SET_SHAPE_ID`.
It still check if the write is needed, but it doesn't seem useful
in places where it's used.
|
|
|
|
|
|
|
|
The `FL_FREEZE` flag is redundant with `SHAPE_ID_FL_FROZEN`, so
ideally it should be eliminated in favor of the later.
Doing so would eliminate the risk of desync between the two, but
also solve the problem of the frozen status being global in namespace
context (See Bug #21330).
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13620
|
|
We still keep setting `FL_EXIVAR` so that `rb_shape_verify_consistency`
can detect discrepancies.
Notes:
Merged: https://github.com/ruby/ruby/pull/13612
|
|
The type isn't opaque because Ruby isn't often compiled with LTO,
so for optimization purpose it's better to allow as much inlining
as possible.
However ideally only `shape.c` and `shape.h` should deal with
the actual struct, and everything else should just deal with opaque
`shape_id_t`.
Notes:
Merged: https://github.com/ruby/ruby/pull/13586
|
|
Make Kernel#inspect ask which instance variables should be dumped by
the result of `#instance_variables_to_inspect`.
Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
Notes:
Merged: https://github.com/ruby/ruby/pull/13555
|
|
Now that we have the `heap_index` in shape flags we no longer
need `T_OBJECT` shapes.
Notes:
Merged: https://github.com/ruby/ruby/pull/13556
|
|
This is preparation to getting rid of `T_OBJECT` transitions.
By first only replicating the information it's easier to ensure
consistency.
Notes:
Merged: https://github.com/ruby/ruby/pull/13556
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13524
|
|
Instead `shape_id_t` higher bits contain flags, and the first one
tells whether the shape is frozen.
This has multiple benefits:
- Can check if a shape is frozen with a single bit check instead of
dereferencing a pointer.
- Guarantees it is always possible to transition to frozen.
- This allow reclaiming `FL_FREEZE` (not done yet).
The downside is you have to be careful to preserve these flags
when transitioning.
Notes:
Merged: https://github.com/ruby/ruby/pull/13289
|
|
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
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13450
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13450
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13450
|
|
It still exists but only in `shape.c`.
Notes:
Merged: https://github.com/ruby/ruby/pull/13450
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13448
|
|
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
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13420
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13350
|
|
Fix a regression introduced by: https://github.com/ruby/ruby/pull/13155
Notes:
Merged: https://github.com/ruby/ruby/pull/13350
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13116
|
|
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13291
|
|
As well as `RB_OBJ_SHAPE_ID` -> `rb_obj_shape_id`
and `RSHAPE` is now a simple alias for `rb_shape_lookup`.
I tried to turn all these into `static inline` but I'm having
trouble with `RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;`
not being exposed as I'd expect.
Notes:
Merged: https://github.com/ruby/ruby/pull/13283
|
|
And `rb_shape_get_shape` -> `RB_OBJ_SHAPE`.
Notes:
Merged: https://github.com/ruby/ruby/pull/13283
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13283
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13283
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13283
|
|
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 <matt@eightbitraptor.com>
Notes:
Merged: https://github.com/ruby/ruby/pull/13159
|
|
This opens the door to store more informations in shapes, such
as the `object_id` or object address in case it has been observed
and the object has to be moved.
Notes:
Merged: https://github.com/ruby/ruby/pull/13159
|
|
Also refactor checks for `->type == SHAPE_OBJ_TOO_COMPLEX`.
Notes:
Merged: https://github.com/ruby/ruby/pull/13159
|
|
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
|
|
Most of this code use the `type * name` style, while the
overwhemling majority of the rest of ruby use the `type *name`
style.
This is a cosmetic change, but helps with readability.
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12759
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12878
|
|
Issue was visible in https://docs.ruby-lang.org/en/3.4/Kernel.html#module-Kernel-label-IO
Notes:
Merged: https://github.com/ruby/ruby/pull/12613
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12496
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12496
|