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.
This commit is contained in:
Damien George 2014-03-29 14:06:14 +00:00
parent 21a07dc50f
commit c689c19471
1 changed files with 3 additions and 5 deletions

View File

@ -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};