diff options
author | Damien George <damien.p.george@gmail.com> | 2014-03-29 14:06:14 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-03-29 14:06:14 +0000 |
commit | c689c194710f4acf4cabd193795b57e5a101420e (patch) | |
tree | a37e3115b81e83fd8fbfac4bef7f09a3e9a0738e | |
parent | 21a07dc50f764b72e6cb1d109160b17545db70ba (diff) | |
download | micropython-c689c194710f4acf4cabd193795b57e5a101420e.tar.gz micropython-c689c194710f4acf4cabd193795b57e5a101420e.zip |
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.
-rw-r--r-- | py/vm.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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}; |