ruby-changes:62172
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 10 Jul 2020 12:24:02 +0900 (JST)
Subject: [ruby-changes:62172] 0e276dc458 (master): vm_push_frame: move assignments around
https://git.ruby-lang.org/ruby.git/commit/?id=0e276dc458 From 0e276dc458f94d9d79a0f7c7669bde84abe80f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Mon, 6 Jul 2020 15:10:10 +0900 Subject: vm_push_frame: move assignments around Struct assignment using a compound literal is more readable than before, to me at least. It seems compilers reorder assignments anyways. Neither speedup nor slowdown is observed on my machine. diff --git a/vm_insnhelper.c b/vm_insnhelper.c index fffe540..e026667 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -352,14 +352,6 @@ vm_push_frame(rb_execution_context_t *ec, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L352 CHECK_VM_STACK_OVERFLOW0(cfp, sp, local_size + stack_max); vm_check_canary(ec, sp); - ec->cfp = cfp; - - /* setup new frame */ - cfp->pc = (VALUE *)pc; - cfp->iseq = (rb_iseq_t *)iseq; - cfp->self = self; - cfp->block_code = NULL; - /* setup vm value stack */ /* initialize local variables */ @@ -370,15 +362,23 @@ vm_push_frame(rb_execution_context_t *ec, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L362 /* setup ep with managing data */ *sp++ = cref_or_me; /* ep[-2] / Qnil or T_IMEMO(cref) or T_IMEMO(ment) */ *sp++ = specval /* ep[-1] / block handler or prev env ptr */; - *sp = type; /* ep[-0] / ENV_FLAGS */ - - /* Store initial value of ep as bp to skip calculation cost of bp on JIT cancellation. */ - cfp->ep = sp; - cfp->__bp__ = cfp->sp = sp + 1; + *sp++ = type; /* ep[-0] / ENV_FLAGS */ + /* setup new frame */ + *cfp = (const struct rb_control_frame_struct) { + .pc = pc, + .sp = sp, + .iseq = iseq, + .self = self, + .ep = sp - 1, + .block_code = NULL, + .__bp__ = sp, /* Store initial value of ep as bp to skip calculation cost of bp on JIT cancellation. */ #if VM_DEBUG_BP_CHECK - cfp->bp_check = sp + 1; + .bp_check = sp, #endif + }; + + ec->cfp = cfp; if (VMDEBUG == 2) { SDR(); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/