scmno****@osdn*****
scmno****@osdn*****
Tue Jun 12 05:20:20 JST 2018
changeset 6cc8c962b06d in quipu/quipu details: http://hg.osdn.jp/view/quipu/quipu?cmd=changeset;node=6cc8c962b06d user: Agustina Arzille <avarz****@riseu*****> date: Mon Jun 11 17:20:10 2018 -0300 description: Adapt continuations to new stack model diffstat: compiler.cpp | 16 ++++++++++------ continuation.cpp | 11 +++-------- continuation.h | 4 +--- 3 files changed, 14 insertions(+), 17 deletions(-) diffs (105 lines): diff -r dc2dd55b5f9a -r 6cc8c962b06d compiler.cpp --- a/compiler.cpp Mon Jun 11 02:31:13 2018 +0000 +++ b/compiler.cpp Mon Jun 11 17:20:10 2018 -0300 @@ -7,7 +7,6 @@ #include "quipu.h" #include "builtins.h" #include "bytecode.h" -#include "utils/lstack.h" #include "utils/sorted_list.h" QP_DECLS_BEGIN @@ -399,6 +398,12 @@ nargs = 0; inst = *argp == intobj (0) ? OPX_(LOADC00) : OPX_(LOADC01); } + else if (inst == OPX_(LOADAP) && as_int (*argp) <= 0xff && + as_int (argp[1]) <= 1) + { + inst = OPX_(LOADAP0) + as_int (argp[1]); + nargs = 1; + } object lasti = cv.empty () ? UNBOUND : cv.back (); @@ -2159,7 +2164,6 @@ object*& stack = interp->stack; object*& stkend = interp->stkend; object& retval = interp->retval; - locals_stack lstack (interp); #if defined (__GNUC__) && !defined (QP_NO_THREADED_GOTO) # define GOTO_LABELS @@ -2203,11 +2207,11 @@ else if (cont != UNBOUND) { // Continuation-passing style. continuation *cnp = as_continuation (cont); - cnp->push (interp, lstack); - bp = interp->cur_frame - interpreter::frame_size - - as_int (stack[interp->cur_frame - 3]); - fn = stack[bp - 1]; + cnp->push (interp); + fn = stack[interp->cur_frame - interpreter::frame_size - + as_int (stack[interp->cur_frame - 3]) - 1]; set_lastf (interp, fn, lastf); + bp = lastf - interpreter::frame_size - as_int (stack[lastf - 3]); ip = as_bvector(fct_bcode (fn))->data + cnp->ip_offset; } else diff -r dc2dd55b5f9a -r 6cc8c962b06d continuation.cpp --- a/continuation.cpp Mon Jun 11 02:31:13 2018 +0000 +++ b/continuation.cpp Mon Jun 11 17:20:10 2018 -0300 @@ -33,12 +33,12 @@ return (ap->as_obj ()); } -void continuation::push (interpreter *interp, locals_stack& lstack) +void continuation::push (interpreter *interp) { array *ap = as_array (this->argv); interp->growstk (ap->len - this->nframes + - as_fct(xaref(this->argv, this->nframes))->max_sp); + as_fct (ap->data[this->nframes])->max_sp); copy_objs (interp->stkend, ap->data + this->nframes, ap->len - this->nframes); @@ -46,16 +46,11 @@ for (int i = 0; i < this->nframes; ++i) { nsp += as_int (ap->data[i]) + interpreter::frame_size + 1; - interp->stack[nsp - 2] = intobj (nsp); interp->stack[nsp - 4] = intobj (interp->cur_frame); - - object *bp = interp->stkend + 1; - lstack.push (interp->dynframe_captured (nsp - 1) ? - &xaref(*bp, 0) : bp); - interp->stkend += nsp; interp->cur_frame = nsp; } + interp->stkend = interp->stack + nsp + this->sp_diff; interp->stkend += this->sp_diff; interp->push (this->value); } diff -r dc2dd55b5f9a -r 6cc8c962b06d continuation.h --- a/continuation.h Mon Jun 11 02:31:13 2018 +0000 +++ b/continuation.h Mon Jun 11 17:20:10 2018 -0300 @@ -5,8 +5,6 @@ QP_DECLS_BEGIN -class locals_stack; - class continuation : public varobj { public: @@ -14,7 +12,7 @@ static object make (interpreter *__interp, uint32_t __lastf); - void push (interpreter *__interp, locals_stack& __lstk); + void push (interpreter *__interp); object value; object argv;