From adf29c9a986cb3510b9ddd55e0738b18076f41ad Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Mon, 29 Jan 2024 10:36:34 -0500 Subject: [PATCH] YJIT: add asm comment when we clear local types (#9713) Small PR to add a comment when we clear local variable types, so we can be aware that it's happening when looking at the disasm. --- yjit/src/backend/ir.rs | 7 +++++++ yjit/src/codegen.rs | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs index 303026d830..3dae4b6f7c 100644 --- a/yjit/src/backend/ir.rs +++ b/yjit/src/backend/ir.rs @@ -1173,6 +1173,13 @@ impl Assembler } } + /// Erase local variable type information + /// eg: because of a call we can't track + pub fn clear_local_types(&mut self) { + asm_comment!(self, "clear local variable types"); + self.ctx.clear_local_types(); + } + /// Spill all live stack temps from registers to the stack pub fn spill_temps(&mut self) { // Forget registers above the stack top diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index a8c77b8d01..cb979b247b 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -356,7 +356,7 @@ fn jit_prepare_routine_call( // In case the routine calls Ruby methods, it can set local variables // through Kernel#binding and other means. - asm.ctx.clear_local_types(); + asm.clear_local_types(); } /// Record the current codeblock write position for rewriting into a jump into @@ -5892,7 +5892,7 @@ fn gen_send_cfunc( asm.store(ec_cfp_opnd, CFP); // cfunc calls may corrupt types - asm.ctx.clear_local_types(); + asm.clear_local_types(); // Note: the return block of gen_send_iseq() has ctx->sp_offset == 1 // which allows for sharing the same successor. @@ -6951,7 +6951,7 @@ fn gen_send_iseq( callee_ctx.upgrade_opnd_type(SelfOpnd, recv_type); // The callee might change locals through Kernel#binding and other means. - asm.ctx.clear_local_types(); + asm.clear_local_types(); // Pop arguments and receiver in return context and // mark it as a continuation of gen_leave() @@ -8012,7 +8012,7 @@ fn gen_invokeblock_specialized( asm.mov(stack_ret, ret); // cfunc calls may corrupt types - asm.ctx.clear_local_types(); + asm.clear_local_types(); // Share the successor with other chains jump_to_next_insn(jit, asm, ocb); @@ -8170,7 +8170,7 @@ fn gen_invokesuper_specialized( jit.assume_method_lookup_stable(asm, ocb, cme); // Method calls may corrupt types - asm.ctx.clear_local_types(); + asm.clear_local_types(); match cme_def_type { VM_METHOD_TYPE_ISEQ => {