diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-25 03:03:34 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-27 00:03:55 +0300 |
commit | 23668698cba9bf861c697e65e3d07f9433396b8b (patch) | |
tree | 7b87345f47610c70e7b5a3559b387e822936573e /py/objfun.c | |
parent | 91b576d1472b481f02a9f9f20dd263ef606a186a (diff) | |
download | micropython-23668698cba9bf861c697e65e3d07f9433396b8b.tar.gz micropython-23668698cba9bf861c697e65e3d07f9433396b8b.zip |
py: Add portable framework to query/check C stack usage.
Such mechanism is important to get stable Python functioning, because Python
function calling is handled with C stack. The idea is to sprinkle
STACK_CHECK() calls in places where there can be C recursion.
TODO: Add more STACK_CHECK()'s.
Diffstat (limited to 'py/objfun.c')
-rw-r--r-- | py/objfun.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/py/objfun.c b/py/objfun.c index 29363129b2..f75e9142a2 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -39,6 +39,7 @@ #include "runtime0.h" #include "runtime.h" #include "bc.h" +#include "stackctrl.h" #if 0 // print debugging info #define DEBUG_PRINT (1) @@ -204,6 +205,8 @@ STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, uint expected, ui // code_state should have ->ip filled in (pointing past code info block), // as well as ->n_state. void mp_setup_code_state(mp_code_state *code_state, mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) { + // This function is pretty complicated. It's main aim is to be efficient in speed and RAM + // usage for the common case of positional only args. mp_obj_fun_bc_t *self = self_in; machine_uint_t n_state = code_state->n_state; const byte *ip = code_state->ip; @@ -353,8 +356,7 @@ continue2:; STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) { - // This function is pretty complicated. It's main aim is to be efficient in speed and RAM - // usage for the common case of positional only args. + STACK_CHECK(); DEBUG_printf("Input n_args: %d, n_kw: %d\n", n_args, n_kw); DEBUG_printf("Input pos args: "); |