From 7b5ee9a8a60bb4d8cdc68aab9795109e766dbc96 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 16 Nov 2022 16:15:43 -0800 Subject: [PATCH] do not fire the wb when writing immediates --- yjit/src/codegen.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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