Browse Source

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.
pull/512/head
Damien George 11 years ago
parent
commit
5b65f0c7d3
  1. 4
      py/mpconfig.h
  2. 6
      py/vm.c
  3. 1
      stmhal/mpconfigport.h
  4. 2
      unix/mpconfigport.h

4
py/mpconfig.h

@ -166,8 +166,8 @@ typedef double mp_float_t;
// Whether to use computed gotos in the VM, or a switch // 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 // Computed gotos are roughly 10% faster, and increase VM code size by a little
#ifndef MICROPY_USE_COMPUTED_GOTOS #ifndef MICROPY_USE_COMPUTED_GOTO
#define MICROPY_USE_COMPUTED_GOTOS (0) #define MICROPY_USE_COMPUTED_GOTO (0)
#endif #endif
// Additional builtin function definitions - see builtintables.c:builtin_object_table for format. // Additional builtin function definitions - see builtintables.c:builtin_object_table for format.

6
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_obj_t *fastn, mp_obj_t **sp_in_out,
mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out,
volatile mp_obj_t inject_exc) { volatile mp_obj_t inject_exc) {
#if MICROPY_USE_COMPUTED_GOTOS #if MICROPY_USE_COMPUTED_GOTO
#include "vmentrytable.h" #include "vmentrytable.h"
#define DISPATCH() do { \ #define DISPATCH() do { \
save_ip = ip; \ save_ip = ip; \
@ -220,7 +220,7 @@ outer_dispatch_loop:
// loop to execute byte code // loop to execute byte code
for (;;) { for (;;) {
dispatch_loop: dispatch_loop:
#if MICROPY_USE_COMPUTED_GOTOS #if MICROPY_USE_COMPUTED_GOTO
DISPATCH(); DISPATCH();
#else #else
save_ip = ip; save_ip = ip;
@ -935,7 +935,7 @@ yield:
fastn[0] = obj1; fastn[0] = obj1;
return MP_VM_RETURN_EXCEPTION; return MP_VM_RETURN_EXCEPTION;
#if !MICROPY_USE_COMPUTED_GOTOS #if !MICROPY_USE_COMPUTED_GOTO
} // switch } // switch
#endif #endif
} // for loop } // for loop

1
stmhal/mpconfigport.h

@ -11,6 +11,7 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_PATH_MAX (128) #define MICROPY_PATH_MAX (128)
#define MICROPY_USE_COMPUTED_GOTO (1)
/* Enable FatFS LFNs /* Enable FatFS LFNs
0: Disable LFN feature. 0: Disable LFN feature.
1: Enable LFN with static working buffer on the BSS. Always NOT reentrant. 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.

2
unix/mpconfigport.h

@ -13,7 +13,7 @@
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_PATH_MAX (PATH_MAX) #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_MOD_SYS_STDFILES (1)
#define MICROPY_ENABLE_MOD_CMATH (1) #define MICROPY_ENABLE_MOD_CMATH (1)

Loading…
Cancel
Save