py/objfun, vm: Add comments on codestate allocation in stackless mode.
This commit is contained in:
parent
fca1d1aa62
commit
d72370def7
|
@ -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;
|
size_t n_state, state_size;
|
||||||
DECODE_CODESTATE_SIZE(self->bytecode, 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;
|
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);
|
code_state = m_new_obj_var_maybe(mp_code_state_t, byte, state_size);
|
||||||
if (!code_state) {
|
if (!code_state) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
12
py/vm.c
12
py/vm.c
|
@ -937,6 +937,9 @@ unwind_jump:;
|
||||||
deep_recursion_error:
|
deep_recursion_error:
|
||||||
mp_exc_recursion_depth();
|
mp_exc_recursion_depth();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// If we couldn't allocate codestate on heap, in
|
||||||
|
// non non-strict case fall thru to stack allocation.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -974,6 +977,9 @@ unwind_jump:;
|
||||||
else {
|
else {
|
||||||
goto deep_recursion_error;
|
goto deep_recursion_error;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// If we couldn't allocate codestate on heap, in
|
||||||
|
// non non-strict case fall thru to stack allocation.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1008,6 +1014,9 @@ unwind_jump:;
|
||||||
else {
|
else {
|
||||||
goto deep_recursion_error;
|
goto deep_recursion_error;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// If we couldn't allocate codestate on heap, in
|
||||||
|
// non non-strict case fall thru to stack allocation.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1045,6 +1054,9 @@ unwind_jump:;
|
||||||
else {
|
else {
|
||||||
goto deep_recursion_error;
|
goto deep_recursion_error;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// If we couldn't allocate codestate on heap, in
|
||||||
|
// non non-strict case fall thru to stack allocation.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue