summaryrefslogtreecommitdiffstatshomepage
path: root/py/mpstate.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-05-09 11:03:04 +1000
committerDamien George <damien@micropython.org>2023-06-02 21:50:57 +1000
commit2757acf6ed1fe165e4d8aa72ba8090fb9bc60c31 (patch)
tree5e5147282e4f70da121c7868ac2ce8983e441086 /py/mpstate.h
parentf36ae5edcb5556c35b2dfe10be7ba54a21da0c9b (diff)
downloadmicropython-2757acf6ed1fe165e4d8aa72ba8090fb9bc60c31.tar.gz
micropython-2757acf6ed1fe165e4d8aa72ba8090fb9bc60c31.zip
py/nlr: Implement jump callbacks.
NLR buffers are usually quite large (use lots of C stack) and expensive to push and pop. Some of the time they are only needed to perform clean up if an exception happens, and then they re-raise the exception. This commit allows optimizing that scenario by introducing a linked-list of NLR callbacks that are called automatically when an exception is raised. They are essentially a light-weight NLR handler that can implement a "finally" block, i.e. clean-up when an exception is raised, or (by passing `true` to nlr_pop_jump_callback) when execution leaves the scope. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/mpstate.h')
-rw-r--r--py/mpstate.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/mpstate.h b/py/mpstate.h
index f6b911af56..80b49cb6b6 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -271,6 +271,7 @@ typedef struct _mp_state_thread_t {
mp_obj_dict_t *dict_globals;
nlr_buf_t *nlr_top;
+ nlr_jump_callback_node_t *nlr_jump_callback_top;
// pending exception object (MP_OBJ_NULL if not pending)
volatile mp_obj_t mp_pending_exception;