diff options
author | Damien George <damien.p.george@gmail.com> | 2014-06-30 05:17:25 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-06-30 05:17:25 +0100 |
commit | b601d9574ad03a18d3eb476d631f547c7ea28243 (patch) | |
tree | 9fceb779e8109b1c147f6c30fe9a24e9d2b19d22 /py/emitcpy.c | |
parent | 5813efd634a282caea3cca6e8448bda253f21c35 (diff) | |
download | micropython-b601d9574ad03a18d3eb476d631f547c7ea28243.tar.gz micropython-b601d9574ad03a18d3eb476d631f547c7ea28243.zip |
py: Improvements to native emitter.
Native emitter can now compile try/except blocks using nlr_push/nlr_pop.
It probably only works for 1 level of exception handling. It doesn't
work on Thumb (only x64).
Native emitter can also handle some additional op codes.
With this patch, 198 tests now pass using "-X emit=native" option to
micropython.
Diffstat (limited to 'py/emitcpy.c')
-rw-r--r-- | py/emitcpy.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/py/emitcpy.c b/py/emitcpy.c index fbca3805b3..4ff99866a0 100644 --- a/py/emitcpy.c +++ b/py/emitcpy.c @@ -792,6 +792,14 @@ STATIC void emit_cpy_yield_from(emit_t *emit) { } } +STATIC void emit_cpy_start_except_handler(emit_t *emit) { + emit_cpy_adjust_stack_size(emit, 3); // stack adjust for the 3 exception items +} + +STATIC void emit_cpy_end_except_handler(emit_t *emit) { + emit_cpy_adjust_stack_size(emit, -5); // stack adjust +} + STATIC void emit_cpy_load_const_verbatim_str(emit_t *emit, const char *str) { emit_pre(emit, 1, 3); if (emit->pass == MP_PASS_EMIT) { @@ -899,6 +907,9 @@ const emit_method_table_t emit_cpython_method_table = { emit_cpy_yield_value, emit_cpy_yield_from, + emit_cpy_start_except_handler, + emit_cpy_end_except_handler, + // emitcpy specific functions emit_cpy_load_const_verbatim_str, emit_cpy_load_closure, |