Skip to content

Commit c689c19

Browse files
committed
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.
1 parent 21a07dc commit c689c19

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

py/vm.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,14 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
381381
break;
382382
*/
383383

384-
case MP_BC_SETUP_WITH: {
384+
case MP_BC_SETUP_WITH:
385385
obj1 = TOP();
386386
SET_TOP(rt_load_attr(obj1, MP_QSTR___exit__));
387-
mp_obj_t dest[2];
388-
rt_load_method(obj1, MP_QSTR___enter__, dest);
389-
obj2 = rt_call_method_n_kw(0, 0, dest);
387+
rt_load_method(obj1, MP_QSTR___enter__, sp + 1);
388+
obj2 = rt_call_method_n_kw(0, 0, sp + 1);
390389
SETUP_BLOCK();
391390
PUSH(obj2);
392391
break;
393-
}
394392

395393
case MP_BC_WITH_CLEANUP: {
396394
static const mp_obj_t no_exc[] = {mp_const_none, mp_const_none, mp_const_none};

0 commit comments

Comments
 (0)