aboutsummaryrefslogtreecommitdiffstats
path: root/yjit/src/asm
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-11-07 16:49:48 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2022-11-08 16:09:02 -0500
commit5d95cd99f4ed425c416cc91e8986a3402d5b557a (patch)
tree3057f421d99b3cb697d49d509617fb6d285976de /yjit/src/asm
parent1466682a23ce0d7bf1f30d8b9627b4597c037e4d (diff)
downloadruby-5d95cd99f4ed425c416cc91e8986a3402d5b557a.tar.gz
YJIT: Reset dropped_bytes when patching code
We switch to a new page when we detect dropped_bytes flipping from false to true. Previously, when we patch code for invalidation during code gc, we start with the flag being set to true, so we failed to apply patches that straddle pages. We would write out jumps half way and then stop, which left the code corrupted. Reset the flag before patching so we patch across pages properly.
Diffstat (limited to 'yjit/src/asm')
-rw-r--r--yjit/src/asm/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/yjit/src/asm/mod.rs b/yjit/src/asm/mod.rs
index 497f7687ed..4f3d20f5e5 100644
--- a/yjit/src/asm/mod.rs
+++ b/yjit/src/asm/mod.rs
@@ -463,6 +463,12 @@ impl CodeBlock {
self.dropped_bytes
}
+ /// To patch code that straddle pages correctly, we need to start with
+ /// the dropped bytes flag unset so we can detect when to switch to a new page.
+ pub fn set_dropped_bytes(&mut self, dropped_bytes: bool) {
+ self.dropped_bytes = dropped_bytes;
+ }
+
/// Allocate a new label with a given name
pub fn new_label(&mut self, name: String) -> usize {
assert!(!name.contains(' '), "use underscores in label names, not spaces");