py/emitnative: Implement yield and yield-from in native emitter.

This commit adds first class support for yield and yield-from in the native
emitter, including send and throw support, and yields enclosed in exception
handlers (which requires pulling down the NLR stack before yielding, then
rebuilding it when resuming).

This has been fully tested and is working on unix x86 and x86-64, and
stm32.  Also basic tests have been done with the esp8266 port.  Performance
of existing native code is unchanged.
This commit is contained in:
Damien George
2018-10-01 13:07:04 +10:00
parent 8fec6f5434
commit cc2bd63c57
9 changed files with 377 additions and 84 deletions

View File

@@ -66,6 +66,7 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
[MP_F_SETUP_CODE_STATE] = 4,
[MP_F_SMALL_INT_FLOOR_DIVIDE] = 2,
[MP_F_SMALL_INT_MODULO] = 2,
[MP_F_NATIVE_YIELD_FROM] = 3,
};
#define N_X86 (1)