diff options
| author | Damien George <damien@micropython.org> | 2023-05-09 11:03:17 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-06-02 21:59:47 +1000 |
| commit | ce31e5a2dc0736ebc7976098f1fdf520b2c32892 (patch) | |
| tree | fb901c8effc2de6a29afd3b4aed00fa712fc573c /py/runtime.h | |
| parent | 2757acf6ed1fe165e4d8aa72ba8090fb9bc60c31 (diff) | |
py: Use nlr jump callbacks to optimise compile/execute functions.
The changed functions now use less stack, and don't have any issues with
local variables needing to be declared volatile.
Testing on a PYBv1.0, imports (of .py, .mpy and frozen code) now use 64
less bytes of C stack per import depth.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/runtime.h')
| -rw-r--r-- | py/runtime.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/py/runtime.h b/py/runtime.h index 9b99e594b..78194973d 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -66,6 +66,13 @@ typedef struct _mp_sched_node_t { struct _mp_sched_node_t *next; } mp_sched_node_t; +// For use with mp_globals_locals_set_from_nlr_jump_callback. +typedef struct _nlr_jump_callback_node_globals_locals_t { + nlr_jump_callback_node_t callback; + mp_obj_dict_t *globals; + mp_obj_dict_t *locals; +} nlr_jump_callback_node_globals_locals_t; + // Tables mapping operator enums to qstrs, defined in objtype.c extern const byte mp_unary_op_method_name[]; extern const byte mp_binary_op_method_name[]; @@ -113,6 +120,8 @@ static inline void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_globals) = d; } +void mp_globals_locals_set_from_nlr_jump_callback(void *ctx_in); + mp_obj_t mp_load_name(qstr qst); mp_obj_t mp_load_global(qstr qst); mp_obj_t mp_load_build_class(void); |
