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:
David Lechner
2021-05-10 21:53:22 -05:00
committed by Damien George
parent 7c51cb2307
commit ca920f7218
13 changed files with 27 additions and 26 deletions

View File

@@ -174,6 +174,8 @@ STATIC void *thread_entry(void *args_in) {
// The GC starts off unlocked on this thread.
ts.gc_lock_depth = 0;
ts.mp_pending_exception = MP_OBJ_NULL;
// set locals and globals from the calling context
mp_locals_set(args->dict_locals);
mp_globals_set(args->dict_globals);
@@ -184,7 +186,6 @@ STATIC void *thread_entry(void *args_in) {
mp_thread_start();
// TODO set more thread-specific state here:
// mp_pending_exception? (root pointer)
// cur_exception (root pointer)
DEBUG_printf("[thread] start ts=%p args=%p stack=%p\n", &ts, &args, MP_STATE_THREAD(stack_top));