Skip to content

Allow pass special constants to the write barrier #13497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

peterzhu2118
Copy link
Member

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.

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.
@composerinteralia
Copy link
Contributor

composerinteralia commented Jun 3, 2025

Ah, I think this makes my comment over in ruby/strscan#156 (comment) incorrect. Do you think there are other places where folks might have skipped over special consts like I did because they didn't think it mattered? Will that cause problems with other GC implementations?

@peterzhu2118
Copy link
Member Author

Do you think there are other places where folks might have skipped over special consts like I did because they didn't think it mattered?

For sure. There are plenty of micro-optimizations taken because of assumptions of how the garbage collector works. We're slowly removing these assumptions, but it won't be a small task.

Will that cause problems with other GC implementations?

Potentially., but not right now. We currently don't need this information to be accurate, just a best effort. We'll think about how to improve this when we need this information to be accurate.

@peterzhu2118 peterzhu2118 merged commit ea8b53a into ruby:master Jun 3, 2025
83 checks passed
@peterzhu2118 peterzhu2118 deleted the wb-special-const branch June 3, 2025 16:04
@@ -24,7 +24,7 @@
* In released versions of Ruby, this number is not defined since teeny
* versions of Ruby should guarantee ABI compatibility.
*/
#define RUBY_ABI_VERSION 1
#define RUBY_ABI_VERSION 2
Copy link
Member

Choose a reason for hiding this comment

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

What needs this?

Copy link
Member Author

Choose a reason for hiding this comment

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

include/ruby/internal/gc.h changed in an incompatible way so we need to bump the ABI version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants