diff options
author | David Lechner <david@pybricks.com> | 2021-05-10 21:53:22 -0500 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-06-19 09:43:44 +1000 |
commit | ca920f72184c50f61002aa9d5cd01555b1e28b7b (patch) | |
tree | a46b6cb9c91a275015b351443d1cb1181d8c5d14 /py/vm.c | |
parent | 7c51cb2307eaca1a1ccc071e0bb5eb4a5f734610 (diff) |
py/mpstate: Make exceptions thread-local.
This moves mp_pending_exception from mp_state_vm_t to mp_state_thread_t.
This allows exceptions to be scheduled on a specific thread.
Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'py/vm.c')
-rw-r--r-- | py/vm.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1375,9 +1375,9 @@ pending_exception_check: // Re-check state is still pending now that we're in the atomic section. if (MP_STATE_VM(sched_state) == MP_SCHED_PENDING) { MARK_EXC_IP_SELECTIVE(); - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); + mp_obj_t obj = MP_STATE_THREAD(mp_pending_exception); if (obj != MP_OBJ_NULL) { - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; if (!mp_sched_num_pending()) { MP_STATE_VM(sched_state) = MP_SCHED_IDLE; } @@ -1391,10 +1391,10 @@ pending_exception_check: } #else // This is an inlined variant of mp_handle_pending - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { + if (MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_NULL) { MARK_EXC_IP_SELECTIVE(); - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + mp_obj_t obj = MP_STATE_THREAD(mp_pending_exception); + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; RAISE(obj); } #endif |