do not fire the wb when writing immediates

This commit is contained in:
Aaron Patterson 2022-11-16 16:15:43 -08:00 коммит произвёл Takashi Kokubun
Родитель 17f9bcd7d7
Коммит 7b5ee9a8a6
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -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