Commit c689c194 authored by Damien George's avatar Damien George
Browse files

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.
parent 21a07dc5
...@@ -381,16 +381,14 @@ dispatch_loop: ...@@ -381,16 +381,14 @@ dispatch_loop:
break; break;
*/ */
case MP_BC_SETUP_WITH: { case MP_BC_SETUP_WITH:
obj1 = TOP(); obj1 = TOP();
SET_TOP(rt_load_attr(obj1, MP_QSTR___exit__)); SET_TOP(rt_load_attr(obj1, MP_QSTR___exit__));
mp_obj_t dest[2]; rt_load_method(obj1, MP_QSTR___enter__, sp + 1);
rt_load_method(obj1, MP_QSTR___enter__, dest); obj2 = rt_call_method_n_kw(0, 0, sp + 1);
obj2 = rt_call_method_n_kw(0, 0, dest);
SETUP_BLOCK(); SETUP_BLOCK();
PUSH(obj2); PUSH(obj2);
break; break;
}
case MP_BC_WITH_CLEANUP: { case MP_BC_WITH_CLEANUP: {
static const mp_obj_t no_exc[] = {mp_const_none, mp_const_none, mp_const_none}; static const mp_obj_t no_exc[] = {mp_const_none, mp_const_none, mp_const_none};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment