py/emitnative: Add support for return/break/continue in try and with.

This patch adds full support for unwinding jumps to the native emitter.
This means that return/break/continue can be used in try-except,
try-finally and with statements.  For code that doesn't use unwinding jumps
there is almost no overhead added to the generated code.
This commit is contained in:
Damien George
2018-09-04 14:31:28 +10:00
parent 3cd2c281d7
commit 4ae7111573
7 changed files with 146 additions and 38 deletions

View File

@@ -9,8 +9,10 @@
#define GENERIC_ASM_API (1)
#include "py/asmx86.h"
// Word index of REG_LOCAL_1(=ebx) in nlr_buf_t
#define NLR_BUF_IDX_LOCAL_1 (5)
// Word indices of REG_LOCAL_x in nlr_buf_t
#define NLR_BUF_IDX_LOCAL_1 (5) // ebx
#define NLR_BUF_IDX_LOCAL_2 (7) // esi
#define NLR_BUF_IDX_LOCAL_3 (6) // edi
// x86 needs a table to know how many args a given function has
STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {