mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
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>
This commit is contained in:
committed by
Damien George
parent
7c51cb2307
commit
ca920f7218
10
py/vm.c
10
py/vm.c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user