From dfe93a23d2e08f476c6a1a10961ea0e4708a0b59 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sun, 24 Nov 2019 23:37:25 +0100 Subject: [PATCH] :shirt: Compiler warnings --- benchmark/fib-recurs.gw | 8 ++++++++ src/vm/vm.c | 17 ++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 benchmark/fib-recurs.gw diff --git a/benchmark/fib-recurs.gw b/benchmark/fib-recurs.gw new file mode 100644 index 00000000..be2c4ab7 --- /dev/null +++ b/benchmark/fib-recurs.gw @@ -0,0 +1,8 @@ +fun int recursive_fib(int n) { + if (n < 2) + return n; + else + return recursive_fib(n - 2) + recursive_fib(n - 1); +} +#!<<< 5 => recursive_fib >>>; +<<< 40 => recursive_fib >>>; diff --git a/src/vm/vm.c b/src/vm/vm.c index f690029e..e29d7a02 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -170,6 +170,7 @@ DISPATCH() *(t*)(reg - sz) = op*(t*)(reg - sz);\ DISPATCH(); +// check me #define R(t, sz, op, ...) \ reg -= SZ_INT;\ __VA_ARGS__\ @@ -612,7 +613,9 @@ PRAGMA_PUSH() goto *dispatch[next]; PRAGMA_POP() funcusrend: +PRAGMA_PUSH() byte = bytecode = (code = a.code)->bytecode; +PRAGMA_POP() SDISPATCH(); funcmemberend: VM_OUT @@ -703,6 +706,8 @@ arrayaddr: *(m_bit**)(reg + (m_int)VAL2) = m_vector_addr(ARRAY(a.obj), *(m_int*)(reg + SZ_INT * VAL)); DISPATCH() arrayvalid: +// are we sure it is the array ? +// rather increase ref vector_pop(&shred->gc); goto regpush; newobj: @@ -715,18 +720,16 @@ addref: ++a.obj->ref; DISPATCH() objassign: -{ // use a.obj ? - register const M_Object tgt = **(M_Object**)(reg -SZ_INT); - if(tgt) { - --tgt->ref; - _release(tgt, shred); -} + a.obj = **(M_Object**)(reg -SZ_INT); + if(a.obj) { + --a.obj->ref; + _release(a.obj, shred); + } assign: reg -= SZ_INT; a.obj = *(M_Object*)(reg-SZ_INT); **(M_Object**)reg = a.obj; DISPATCH() -} remref: release(*(M_Object*)(mem + VAL), shred); DISPATCH() -- 2.43.0