From: Jérémie Astor Date: Sat, 12 Jun 2021 17:18:49 +0000 (+0200) Subject: :art: Improve func calls, use less adds X-Git-Tag: nightly~601 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=518affab0b0ea7f8111d8e5800fc187775ea914e;p=gwion.git :art: Improve func calls, use less adds --- diff --git a/src/vm/gack.c b/src/vm/gack.c index 4ffa777e..dd49b76c 100644 --- a/src/vm/gack.c +++ b/src/vm/gack.c @@ -49,7 +49,7 @@ ANN2(2) int gw_asprintf(MemPool mp, char **str, const char *fmt, ...) { ANN static void prepare_call(const VM_Shred shred, const m_uint offset) { shred->mem += offset + SZ_INT + sizeof(struct frame_t); register struct frame_t *frame = (struct frame_t*)(shred->mem - sizeof(struct frame_t)); - frame->push = offset + SZ_INT; + frame->push = offset + SZ_INT + sizeof(struct frame_t); frame->code = shred->code; frame->pc = shred->pc; shred->pc = 0; diff --git a/src/vm/vm.c b/src/vm/vm.c index 42d67446..ce3710bb 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -44,7 +44,7 @@ ANN static inline void shred_unwind(const VM_Shred shred) { register struct frame_t *frame = &*(struct frame_t*)(shred->mem - sizeof(struct frame_t)); shred->code = frame->code; shred->pc = frame->pc; - shred->mem -= (frame->push + sizeof(struct frame_t)); + shred->mem -= frame->push; } ANN static bool unwind(VM_Shred shred, const Symbol effect, const m_uint size) { @@ -549,7 +549,7 @@ funcreturn: { register struct frame_t frame = *(struct frame_t*)(mem - sizeof(struct frame_t)); bytecode = (code = frame.code)->bytecode; - mem -= (frame.push + sizeof(struct frame_t)); + mem -= frame.push; PC_DISPATCH(frame.pc); } _goto: @@ -711,8 +711,8 @@ timeadv: break; recurs: { - register const uint push = *(m_uint*)reg + code->stack_depth; - mem += push + sizeof(struct frame_t); + register const uint push = *(m_uint*)reg + code->stack_depth + sizeof(struct frame_t); + mem += push; *(struct frame_t*)(mem - sizeof(struct frame_t)) = (struct frame_t){.code=code,.pc=VAL2,.push=push}; reg += (m_int)VAL; next = eFuncUsrEnd2; @@ -722,8 +722,8 @@ setcode: PRAGMA_PUSH() a.code = *(VM_Code*)(reg - SZ_INT); if(!a.code->builtin) { - register const uint push = *(m_uint*)reg + code->stack_depth; - mem += push + sizeof(struct frame_t); + register const uint push = *(m_uint*)reg + code->stack_depth + sizeof(struct frame_t); + mem += push; *(struct frame_t*)(mem - sizeof(struct frame_t)) = (struct frame_t){.code=code,.pc=PC+VAL2,.push=push}; next = eFuncUsrEnd; } else {