From 5b65f0c7d386646229b6647332e7a09277872e4c Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 17 Apr 2014 23:24:13 +0100 Subject: [PATCH] py: Rename USE_COMPUTED_GOTOS to USE_COMPUTED_GOTO and enable on stmhal. On stmhal, computed gotos make the binary about 1k bigger, but makes it run faster, and we have the room, so why not. All tests pass on pyboard using computed gotos. --- py/mpconfig.h | 4 ++-- py/vm.c | 6 +++--- stmhal/mpconfigport.h | 1 + unix/mpconfigport.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/py/mpconfig.h b/py/mpconfig.h index 43c931cd66..4c3e0706a7 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -166,8 +166,8 @@ typedef double mp_float_t; // Whether to use computed gotos in the VM, or a switch // Computed gotos are roughly 10% faster, and increase VM code size by a little -#ifndef MICROPY_USE_COMPUTED_GOTOS -#define MICROPY_USE_COMPUTED_GOTOS (0) +#ifndef MICROPY_USE_COMPUTED_GOTO +#define MICROPY_USE_COMPUTED_GOTO (0) #endif // Additional builtin function definitions - see builtintables.c:builtin_object_table for format. diff --git a/py/vm.c b/py/vm.c index f14899ab41..c8e4ba9f48 100644 --- a/py/vm.c +++ b/py/vm.c @@ -165,7 +165,7 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, volatile mp_obj_t inject_exc) { -#if MICROPY_USE_COMPUTED_GOTOS +#if MICROPY_USE_COMPUTED_GOTO #include "vmentrytable.h" #define DISPATCH() do { \ save_ip = ip; \ @@ -220,7 +220,7 @@ outer_dispatch_loop: // loop to execute byte code for (;;) { dispatch_loop: -#if MICROPY_USE_COMPUTED_GOTOS +#if MICROPY_USE_COMPUTED_GOTO DISPATCH(); #else save_ip = ip; @@ -935,7 +935,7 @@ yield: fastn[0] = obj1; return MP_VM_RETURN_EXCEPTION; -#if !MICROPY_USE_COMPUTED_GOTOS +#if !MICROPY_USE_COMPUTED_GOTO } // switch #endif } // for loop diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h index d7045c42f7..24ab20b16b 100644 --- a/stmhal/mpconfigport.h +++ b/stmhal/mpconfigport.h @@ -11,6 +11,7 @@ #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_PATH_MAX (128) +#define MICROPY_USE_COMPUTED_GOTO (1) /* Enable FatFS LFNs 0: Disable LFN feature. 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant. diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h index 5abfe2d9d3..2d252427f0 100644 --- a/unix/mpconfigport.h +++ b/unix/mpconfigport.h @@ -13,7 +13,7 @@ #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_PATH_MAX (PATH_MAX) -#define MICROPY_USE_COMPUTED_GOTOS (1) +#define MICROPY_USE_COMPUTED_GOTO (1) #define MICROPY_MOD_SYS_STDFILES (1) #define MICROPY_ENABLE_MOD_CMATH (1)