From 05e827427f8eaf3958ba8d29c96ae1125e06fbe0 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Thu, 24 Aug 2023 14:40:52 -0400 Subject: [PATCH] Make cfp constant and use it more in vm_exec_handle_exception() For writing THROW_DATA_VAL, being able to see that it's writing to the same frame after modifying PC and SP is nice. --- vm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vm.c b/vm.c index ad1520b55c..3f0cac109a 100644 --- a/vm.c +++ b/vm.c @@ -2449,7 +2449,6 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V const struct iseq_catch_table *ct; unsigned long epc, cont_pc, cont_sp; const rb_iseq_t *catch_iseq; - rb_control_frame_t *cfp; VALUE type; const rb_control_frame_t *escape_cfp; @@ -2469,7 +2468,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V rb_vm_pop_frame(ec); } - cfp = ec->cfp; + rb_control_frame_t *const cfp = ec->cfp; epc = cfp->pc - ISEQ_BODY(cfp->iseq)->iseq_encoded; escape_cfp = NULL; @@ -2508,7 +2507,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V } else { /* TAG_BREAK */ - *ec->cfp->sp++ = THROW_DATA_VAL(err); + *cfp->sp++ = THROW_DATA_VAL(err); ec->errinfo = Qnil; return Qundef; } @@ -2581,7 +2580,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V cfp->sp = vm_base_ptr(cfp) + entry->sp; if (state != TAG_REDO) { - *ec->cfp->sp++ = THROW_DATA_VAL(err); + *cfp->sp++ = THROW_DATA_VAL(err); } ec->errinfo = Qnil; VM_ASSERT(ec->tag->state == TAG_NONE);