diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-03-28 01:14:45 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-04-03 00:26:47 +0300 |
commit | 7f1c98177bb27a45886fd7e42aa72bef9b1e4a0f (patch) | |
tree | 915706975a238a9944cdc45f4bd944bd201580bd /py/stackctrl.c | |
parent | f0a8f2119066943553ba2dc1f27a402ad5ef0a7b (diff) |
vm: Support strict stackless mode, with proper exception reporting.
I.e. in this mode, C stack will never be used to call a Python function,
but if there's no free heap for a call, it will be reported as
RuntimeError (as expected), not MemoryError.
Diffstat (limited to 'py/stackctrl.c')
-rw-r--r-- | py/stackctrl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/py/stackctrl.c b/py/stackctrl.c index 7d7bbc1be..4c5165372 100644 --- a/py/stackctrl.c +++ b/py/stackctrl.c @@ -27,6 +27,7 @@ #include "py/mpstate.h" #include "py/nlr.h" #include "py/obj.h" +#include "py/runtime.h" #include "py/stackctrl.h" void mp_stack_ctrl_init(void) { @@ -46,10 +47,14 @@ void mp_stack_set_limit(mp_uint_t limit) { MP_STATE_VM(stack_limit) = limit; } +void mp_exc_recursion_depth(void) { + nlr_raise(mp_obj_new_exception_arg1(&mp_type_RuntimeError, + MP_OBJ_NEW_QSTR(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded))); +} + void mp_stack_check(void) { if (mp_stack_usage() >= MP_STATE_VM(stack_limit)) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_RuntimeError, - MP_OBJ_NEW_QSTR(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded))); + mp_exc_recursion_depth(); } } |