vm: If there's no heap to call function in stackless manner, call via C stack.

This commit is contained in:
Paul Sokolovsky 2015-03-28 01:14:44 +02:00
parent 2039757b85
commit 332a909d44
2 changed files with 10 additions and 5 deletions

View File

@ -161,7 +161,10 @@ mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, mp_uint_t n_arg
// allocate state for locals and stack
mp_uint_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t);
mp_code_state *code_state;
code_state = m_new_obj_var(mp_code_state, byte, state_size);
code_state = m_new_obj_var_maybe(mp_code_state, byte, state_size);
if (!code_state) {
return NULL;
}
code_state->n_state = n_state;
code_state->ip = ip;

10
py/vm.c
View File

@ -874,10 +874,12 @@ unwind_jump:;
code_state->sp = sp;
code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block);
mp_code_state *new_state = mp_obj_fun_bc_prepare_codestate(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1);
new_state->prev = code_state;
code_state = new_state;
nlr_pop();
goto run_code_state;
if (new_state) {
new_state->prev = code_state;
code_state = new_state;
nlr_pop();
goto run_code_state;
}
}
#endif
SET_TOP(mp_call_function_n_kw(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1));