From ed85e8a33ac13c75967f8a893bb5de22b729c1ef Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Fri, 27 Aug 2021 15:41:24 -0400 Subject: [PATCH] Use reg1 in GEN_COUNTER_INC to avoid clobbering RAX --- yjit_codegen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yjit_codegen.c b/yjit_codegen.c index 0abf2376c6..a42bd1b871 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -306,9 +306,11 @@ static void _gen_counter_inc(codeblock_t *cb, int64_t *counter) { if (!rb_yjit_opts.gen_stats) return; - mov(cb, REG0, const_ptr_opnd(counter)); - cb_write_lock_prefix(cb); // for ractors. - add(cb, mem_opnd(64, REG0, 0), imm_opnd(1)); + + // Use REG1 because there might be return value in REG0 + mov(cb, REG1, const_ptr_opnd(counter)); + cb_write_lock_prefix(cb); // for ractors. + add(cb, mem_opnd(64, REG1, 0), imm_opnd(1)); } // Increment a counter then take an existing side exit.