Skip to content

ZJIT: Add missing write barrier during profiling #13922

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
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ZJIT: Add missing write barrier during profiling
Fixes `TestZJIT::test_require_rubygems`. It was crashing locally due to
false collection of a live object. See
<https://alanwu.space/post/write-barrier/>.

Co-authored-by: Max Bernstein <max@bernsteinbear.com>
Co-authored-by: Takashi Kokubun <takashi.kokubun@shopify.com>
Co-authored-by: Stan Lo <stan.lo@shopify.com>
  • Loading branch information
4 people committed Jul 16, 2025
commit 077d4ac27044a6212d21947db3e7eef68f2b09eb
1 change: 1 addition & 0 deletions zjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ fn main() {
.allowlist_function("rb_gc_mark_movable")
.allowlist_function("rb_gc_location")
.allowlist_function("rb_gc_writebarrier")
.allowlist_function("rb_gc_writebarrier_remember")

// VALUE variables for Ruby class objects
// From include/ruby/internal/globals.h
Expand Down
1 change: 1 addition & 0 deletions zjit/src/cruby_bindings.inc.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions zjit/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ fn profile_operands(profiler: &mut Profiler, profile: &mut IseqProfile, n: usize
let opnd_type = Type::from_value(profiler.peek_at_stack((n - i - 1) as isize));
types[i] = types[i].union(opnd_type);
}
// In the loop above, we probably added a new reference to the profile through
// the VALUE in Type. It's messy and relatively slow to conditionally run a
// write barrier for each Type, so just remember to re-mark the iseq.
unsafe { rb_gc_writebarrier_remember(profiler.iseq.into()) };
}

#[derive(Debug)]
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy