vm: Make the speed-size trade-off compile time settable
.. and enable for all samd21 boards
This commit is contained in:
parent
7b359d7a8a
commit
4f040af481
@ -36,6 +36,7 @@ CIRCUITPY_AUDIOMIXER ?= 0
|
||||
CIRCUITPY_BINASCII ?= 0
|
||||
CIRCUITPY_AUDIOMP3 ?= 0
|
||||
CIRCUITPY_BUILTINS_POW3 ?= 0
|
||||
CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 1
|
||||
CIRCUITPY_FREQUENCYIO ?= 0
|
||||
CIRCUITPY_JSON ?= 0
|
||||
CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1
|
||||
|
@ -75,6 +75,7 @@
|
||||
#define MICROPY_MODULE_BUILTIN_INIT (1)
|
||||
#define MICROPY_NONSTANDARD_TYPECODES (0)
|
||||
#define MICROPY_OPT_COMPUTED_GOTO (1)
|
||||
#define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE)
|
||||
#define MICROPY_PERSISTENT_CODE_LOAD (1)
|
||||
|
||||
#define MICROPY_PY_ARRAY (1)
|
||||
|
@ -130,6 +130,9 @@ CFLAGS += -DCIRCUITPY_CANIO=$(CIRCUITPY_CANIO)
|
||||
CIRCUITPY_DIGITALIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO)
|
||||
|
||||
CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 0
|
||||
CFLAGS += -DCIRCUITPY_COMPUTED_GOTO_SAVE_SPACE=$(CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE)
|
||||
|
||||
CIRCUITPY_COUNTIO ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO)
|
||||
|
||||
|
@ -413,6 +413,14 @@
|
||||
#define MICROPY_OPT_COMPUTED_GOTO (0)
|
||||
#endif
|
||||
|
||||
// Whether to save trade flash space for speed in MICROPY_OPT_COMPUTED_GOTO.
|
||||
// Costs about 3% speed, saves about 1500 bytes space. In addition to the assumptions
|
||||
// of MICROPY_OPT_COMPUTED_GOTO, also assumes that mp_execute_bytecode is less than
|
||||
// 32kB in size.
|
||||
#ifndef MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
|
||||
#define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (0)
|
||||
#endif
|
||||
|
||||
// Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR,
|
||||
// STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and
|
||||
// uses a bit of extra code ROM, but greatly improves lookup speed.
|
||||
|
9
py/vm.c
9
py/vm.c
@ -129,12 +129,21 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t *code_sta
|
||||
#endif
|
||||
#if MICROPY_OPT_COMPUTED_GOTO
|
||||
#include "py/vmentrytable.h"
|
||||
#if MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
|
||||
#define ONE_TRUE_DISPATCH() one_true_dispatch: do { \
|
||||
TRACE(ip); \
|
||||
MARK_EXC_IP_GLOBAL(); \
|
||||
goto *(void*)((char*)&&entry_MP_BC_LOAD_CONST_FALSE + entry_table[*ip++]); \
|
||||
} while (0)
|
||||
#define DISPATCH() do { goto one_true_dispatch; } while(0)
|
||||
#else
|
||||
#define DISPATCH() do { \
|
||||
TRACE(ip); \
|
||||
MARK_EXC_IP_GLOBAL(); \
|
||||
goto *entry_table[*ip++]; \
|
||||
} while (0)
|
||||
#define ONE_TRUE_DISPATCH() DISPATCH()
|
||||
#endif
|
||||
#define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check
|
||||
#define ENTRY(op) entry_##op
|
||||
#define ENTRY_DEFAULT entry_default
|
||||
|
@ -31,9 +31,15 @@
|
||||
|
||||
#include "supervisor/linker.h"
|
||||
|
||||
#if MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
|
||||
#define COMPUTE_ENTRY(x) ((char*)(x) - (char*)&&entry_MP_BC_LOAD_CONST_FALSE)
|
||||
typedef int16_t entry_table_type;
|
||||
#else
|
||||
#define COMPUTE_ENTRY(x) (x)
|
||||
typedef void *entry_table_type;
|
||||
#endif
|
||||
|
||||
static int16_t const PLACE_IN_DTCM_DATA(entry_table[256]) = {
|
||||
static entry_table_type const PLACE_IN_DTCM_DATA(entry_table[256]) = {
|
||||
[0 ... 255] = COMPUTE_ENTRY(&&entry_default),
|
||||
[MP_BC_LOAD_CONST_FALSE] = COMPUTE_ENTRY(&&entry_MP_BC_LOAD_CONST_FALSE),
|
||||
[MP_BC_LOAD_CONST_NONE] = COMPUTE_ENTRY(&&entry_MP_BC_LOAD_CONST_NONE),
|
||||
|
Loading…
Reference in New Issue
Block a user