Skip to content

Conversation

@jhawthorn
Copy link
Member

@jhawthorn jhawthorn commented May 14, 2025

[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.

@launchable-app

This comment has been minimized.

@jhawthorn jhawthorn force-pushed the shape_id_in_flags_32 branch from 96f185e to 9755585 Compare May 15, 2025 17:19
@jhawthorn jhawthorn changed the title WIP: Add shape_id to RBasic under 32 bit Add shape_id to RBasic under 32 bit May 17, 2025
@jhawthorn jhawthorn marked this pull request as ready for review May 17, 2025 01:35
#if RBASIC_SHAPE_ID_FIELD
RBASIC(obj)->shape_id = 0;
#endif
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@byroot byroot force-pushed the shape_id_in_flags_32 branch 3 times, most recently from 0f06ba1 to d4f6fa4 Compare May 26, 2025 07:25
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>
@byroot byroot force-pushed the shape_id_in_flags_32 branch from d4f6fa4 to 1e552ba Compare May 26, 2025 07:38
@byroot byroot enabled auto-merge (rebase) May 26, 2025 08:06
@byroot byroot merged commit f483bef into ruby:master May 26, 2025
83 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants