diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2022-07-22 16:24:18 -0400 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-29 08:47:04 -0700 |
commit | 813df1f27aa52a3050d90dab23bc72093da00e6c (patch) | |
tree | 2a514fc12e2a224208eb43e4d080e8bdad802d39 /yjit/src/codegen.rs | |
parent | 133ad38777db991e20a1feba1acbfe5d97cc2fa0 (diff) | |
download | ruby-813df1f27aa52a3050d90dab23bc72093da00e6c.tar.gz |
Add LiveReg IR instruction to fix stats leave exit code (https://github.com/Shopify/ruby/pull/341)
It allows for reserving a specific register and prevents the register
allocator from clobbering it. Without this
`./miniruby --yjit-stats --yjit-callthreshold=1 -e0` was crashing because
the counter incrementing code was clobbering RAX incorrectly.
Diffstat (limited to 'yjit/src/codegen.rs')
-rw-r--r-- | yjit/src/codegen.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index fa0394eed5..e122d67910 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -213,7 +213,7 @@ macro_rules! gen_counter_incr { let counter_opnd = Opnd::mem(64, ptr_reg, 0); // Increment and store the updated value - $asm.incr_counter(counter_opnd, 1.into() ); + $asm.incr_counter(counter_opnd, 1.into()); } }; } @@ -552,8 +552,9 @@ fn gen_leave_exit(ocb: &mut OutlinedCb) -> CodePtr { let code_ptr = ocb.get_write_ptr(); let mut asm = Assembler::new(); - // NOTE: gen_leave() fully reconstructs interpreter state and leaves the + // gen_leave() fully reconstructs interpreter state and leaves the // return value in C_RET_OPND before coming here. + let ret_opnd = asm.live_reg_opnd(C_RET_OPND); // Every exit to the interpreter should be counted gen_counter_incr!(asm, leave_interp_return); @@ -564,7 +565,7 @@ fn gen_leave_exit(ocb: &mut OutlinedCb) -> CodePtr { asm.frame_teardown(); - asm.cret(C_RET_OPND); + asm.cret(ret_opnd); asm.compile(ocb); |