Add shape_id to RBasic under 32 bit#13341
Merged
byroot merged 1 commit intoruby:masterfrom May 26, 2025
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
96f185e to
9755585
Compare
eregon
reviewed
May 21, 2025
include/ruby/internal/core/rbasic.h
Outdated
| #if RBASIC_SHAPE_ID_FIELD | ||
| RBASIC(obj)->shape_id = 0; | ||
| #endif | ||
| } |
Member
There was a problem hiding this comment.
Since this is added, how about adding RBASIC_FLAGS & RBASIC_SET_FLAGS as in truffleruby/truffleruby#3118 (comment) ?
That would help reduce the amount of direct accesses to that field, and could add extra asserts (e.g. catching some code trying to set the frozen flag directly), etc.
Should RBASIC_SET_FLAGS(obj, 0) reset the shape too?
Member
There was a problem hiding this comment.
Why not, but there's currently too many raw accesses to the flags field, so if we do this I think it should be a standalone PR.
eregon
reviewed
May 21, 2025
0f06ba1 to
d4f6fa4
Compare
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>
d4f6fa4 to
1e552ba
Compare
casperisfine
referenced
this pull request
Jun 2, 2025
We don't want the default GC to depend on Ruby internals so we can build it as a modular GC.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
casperisfine
pushed a commit
to Shopify/ruby
that referenced
this pull request
Jun 3, 2025
Followup: ruby#13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
byroot
added a commit
that referenced
this pull request
Jun 3, 2025
Followup: #13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[Feature #21353]
This adds a separate VALUE-sized shape_id field for 32-bit platforms. Allowing them to work much more similarly to how shapes always being available on 64-bit.
This does increase the size of objects by 4 bytes on 32 bit platforms, but shape access should be faster, more consistent, of the same size (32 bits) and much simpler.