From c689c194710f4acf4cabd193795b57e5a101420e Mon Sep 17 00:00:00 2001 From: Damien George <damien.p.george@gmail.com> Date: Sat, 29 Mar 2014 14:06:14 +0000 Subject: [PATCH] py: Make MP_BC_SETUP_WITH use the bytecode stack for load_method. The compiler allocates 7 entries on the stack for a with statement (following CPython, but probably can be reduced). This is enough for the method load and call in SETUP_WITH. --- py/vm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/py/vm.c b/py/vm.c index f097ff0a8..09da2c37d 100644 --- a/py/vm.c +++ b/py/vm.c @@ -381,16 +381,14 @@ dispatch_loop: break; */ - case MP_BC_SETUP_WITH: { + case MP_BC_SETUP_WITH: obj1 = TOP(); SET_TOP(rt_load_attr(obj1, MP_QSTR___exit__)); - mp_obj_t dest[2]; - rt_load_method(obj1, MP_QSTR___enter__, dest); - obj2 = rt_call_method_n_kw(0, 0, dest); + rt_load_method(obj1, MP_QSTR___enter__, sp + 1); + obj2 = rt_call_method_n_kw(0, 0, sp + 1); SETUP_BLOCK(); PUSH(obj2); break; - } case MP_BC_WITH_CLEANUP: { static const mp_obj_t no_exc[] = {mp_const_none, mp_const_none, mp_const_none}; -- GitLab