From 7ee91cf86136f4774a9143a3f745d37f314662da Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 6 Jan 2015 12:51:39 +0000 Subject: py: Add option to cache map lookup results in bytecode. This is a simple optimisation inspired by JITing technology: we cache in the bytecode (using 1 byte) the offset of the last successful lookup in a map. This allows us next time round to check in that location in the hash table (mp_map_t) for the desired entry, and if it's there use that entry straight away. Otherwise fallback to a normal map lookup. Works for LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR and STORE_ATTR opcodes. On a few tests it gives >90% cache hit and greatly improves speed of code. Disabled by default. Enabled for unix and stmhal ports. --- stmhal/mpconfigport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'stmhal') diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h index c01587f4f..d75102df3 100644 --- a/stmhal/mpconfigport.h +++ b/stmhal/mpconfigport.h @@ -40,6 +40,7 @@ #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_OPT_COMPUTED_GOTO (1) +#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1) /* Enable FatFS LFNs 0: Disable LFN feature. 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant. -- cgit v1.2.3