diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-12-09 10:57:40 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-12-09 11:01:34 +0200 |
commit | d72370def72c74ca98c1ec4eb7b58ba0fbcc9629 (patch) | |
tree | 6fe46b90e93d71850b529d86c144ba4275b80c01 /py/objfun.c | |
parent | fca1d1aa62306fc523d192c1e2dd2d20dccbe94f (diff) |
py/objfun, vm: Add comments on codestate allocation in stackless mode.
Diffstat (limited to 'py/objfun.c')
-rw-r--r-- | py/objfun.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/py/objfun.c b/py/objfun.c index 445f25d46..e27413e40 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -218,8 +218,12 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args size_t n_state, state_size; DECODE_CODESTATE_SIZE(self->bytecode, n_state, state_size); - // allocate state for locals and stack mp_code_state_t *code_state; + // If we use m_new_obj_var(), then on no memory, MemoryError will be + // raised. But this is not correct exception for a function call, + // RuntimeError should be raised instead. So, we use m_new_obj_var_maybe(), + // return NULL, then vm.c takes the needed action (either raise + // RuntimeError or fallback to stack allocation). code_state = m_new_obj_var_maybe(mp_code_state_t, byte, state_size); if (!code_state) { return NULL; |