summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-29 14:06:14 +0000
committerDamien George <damien.p.george@gmail.com>2014-03-29 14:06:14 +0000
commitc689c194710f4acf4cabd193795b57e5a101420e (patch)
treea37e3115b81e83fd8fbfac4bef7f09a3e9a0738e
parent21a07dc50f764b72e6cb1d109160b17545db70ba (diff)
downloadmicropython-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.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/py/vm.c b/py/vm.c
index f097ff0a82..09da2c37d1 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};