summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2022-11-16 16:15:43 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2022-12-02 12:53:51 -0800
commit7b5ee9a8a60bb4d8cdc68aab9795109e766dbc96 (patch)
tree47c0e4fa235a2f937fdc4f54a758c68be4db0b8e
parent17f9bcd7d77c0d9fdd4be605f0791f3f03fd6caf (diff)
downloadruby-7b5ee9a8a60bb4d8cdc68aab9795109e766dbc96.tar.gz
do not fire the wb when writing immediates
-rw-r--r--yjit/src/codegen.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 6686a41a8c..6b2ef6806f 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -2342,14 +2342,27 @@ fn gen_setinstancevariable(
},
}
+ let write_val = ctx.stack_pop(1);
+
+ let skip_wb = asm.new_label("skip_wb");
+ // If the value we're writing is an immediate, we don't need to WB
+ asm.test(write_val, (RUBY_IMMEDIATE_MASK as u64).into());
+ asm.jnz(skip_wb);
+
+ // If the value we're writing is nil or false, we don't need to WB
+ asm.cmp(write_val, Qnil.into());
+ asm.jbe(skip_wb);
+
asm.comment("write barrier");
asm.ccall(
rb_gc_writebarrier as *const u8,
vec![
recv,
- ctx.stack_pop(1),
+ write_val,
]
);
+
+ asm.write_label(skip_wb);
}
KeepCompiling