summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--docs/reference/mpyfiles.rst2
-rw-r--r--examples/embedding/mpconfigport_minimal.h1
-rw-r--r--mpy-cross/README.md5
-rw-r--r--mpy-cross/main.c6
-rw-r--r--mpy-cross/mpconfigport.h2
-rw-r--r--ports/cc3200/mpconfigport.h1
-rw-r--r--ports/nrf/mpconfigport.h1
-rw-r--r--ports/stm32/mpconfigport.h1
-rw-r--r--ports/unix/Makefile5
-rw-r--r--ports/unix/mpconfigport.h3
-rw-r--r--ports/unix/variants/minimal/mpconfigvariant.h1
-rw-r--r--ports/windows/Makefile1
-rw-r--r--ports/windows/mpconfigport.h1
-rw-r--r--ports/windows/msvc/genhdr.targets2
-rw-r--r--py/bc.c14
-rw-r--r--py/dynruntime.mk2
-rw-r--r--py/emitbc.c6
-rw-r--r--py/mpconfig.h9
-rw-r--r--py/mpstate.h1
-rw-r--r--py/persistentcode.h11
-rw-r--r--py/profile.c12
-rw-r--r--py/showbc.c12
-rw-r--r--py/vm.c101
-rw-r--r--tests/cmdline/cmd_parsetree.py.exp10
-rw-r--r--tests/cmdline/cmd_showbc.py.exp24
-rw-r--r--tests/cmdline/cmd_verbose.py.exp12
-rw-r--r--tests/micropython/import_mpy_native_gc.py4
-rw-r--r--tests/micropython/import_mpy_native_x64.py6
-rwxr-xr-xtests/run-tests.py4
-rwxr-xr-xtools/mpy-tool.py28
-rwxr-xr-xtools/mpy_cross_all.py5
-rwxr-xr-xtools/mpy_ld.py9
32 files changed, 42 insertions, 260 deletions
diff --git a/docs/reference/mpyfiles.rst b/docs/reference/mpyfiles.rst
index 4791784ac3..6ba7389cf0 100644
--- a/docs/reference/mpyfiles.rst
+++ b/docs/reference/mpyfiles.rst
@@ -66,8 +66,6 @@ If importing an .mpy file fails then try the following:
print('mpy flags:', end='')
if arch:
print(' -march=' + arch, end='')
- if sys_mpy & 0x100:
- print(' -mcache-lookup-bc', end='')
if not sys_mpy & 0x200:
print(' -mno-unicode', end='')
print()
diff --git a/examples/embedding/mpconfigport_minimal.h b/examples/embedding/mpconfigport_minimal.h
index b5ffd376ae..07180a3225 100644
--- a/examples/embedding/mpconfigport_minimal.h
+++ b/examples/embedding/mpconfigport_minimal.h
@@ -45,7 +45,6 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_STREAMS_NON_BLOCK (0)
#define MICROPY_OPT_COMPUTED_GOTO (0)
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0)
#define MICROPY_CPYTHON_COMPAT (0)
diff --git a/mpy-cross/README.md b/mpy-cross/README.md
index bf743a9031..83f6d6fd8d 100644
--- a/mpy-cross/README.md
+++ b/mpy-cross/README.md
@@ -17,10 +17,7 @@ by the target MicroPython runtime (eg onto a pyboard's filesystem), and then
imported like any other Python module using `import foo`.
Different target runtimes may require a different format of the compiled
-bytecode, and such options can be passed to the cross compiler. For example,
-the unix port of MicroPython requires the following:
-
- $ ./mpy-cross -mcache-lookup-bc foo.py
+bytecode, and such options can be passed to the cross compiler.
If the Python code contains `@native` or `@viper` annotations, then you must
specify `-march` to match the target architecture.
diff --git a/mpy-cross/main.c b/mpy-cross/main.c
index 635e53a719..c677929c33 100644
--- a/mpy-cross/main.c
+++ b/mpy-cross/main.c
@@ -108,7 +108,6 @@ STATIC int usage(char **argv) {
"Target specific options:\n"
"-msmall-int-bits=number : set the maximum bits used to encode a small-int\n"
"-mno-unicode : don't support unicode in compiled strings\n"
- "-mcache-lookup-bc : cache map lookups in the bytecode\n"
"-march=<arch> : set architecture for native emitter; x86, x64, armv6, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin\n"
"\n"
"Implementation specific options:\n", argv[0]
@@ -205,7 +204,6 @@ MP_NOINLINE int main_(int argc, char **argv) {
// set default compiler configuration
mp_dynamic_compiler.small_int_bits = 31;
- mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0;
mp_dynamic_compiler.py_builtins_str_unicode = 1;
#if defined(__i386__)
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86;
@@ -264,10 +262,6 @@ MP_NOINLINE int main_(int argc, char **argv) {
return usage(argv);
}
// TODO check that small_int_bits is within range of host's capabilities
- } else if (strcmp(argv[a], "-mno-cache-lookup-bc") == 0) {
- mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0;
- } else if (strcmp(argv[a], "-mcache-lookup-bc") == 0) {
- mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 1;
} else if (strcmp(argv[a], "-mno-unicode") == 0) {
mp_dynamic_compiler.py_builtins_str_unicode = 0;
} else if (strcmp(argv[a], "-municode") == 0) {
diff --git a/mpy-cross/mpconfigport.h b/mpy-cross/mpconfigport.h
index e7c8edf135..8c716e958d 100644
--- a/mpy-cross/mpconfigport.h
+++ b/mpy-cross/mpconfigport.h
@@ -57,8 +57,6 @@
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1)
#define MICROPY_COMP_RETURN_IF_EXPR (1)
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
-
#define MICROPY_READER_POSIX (1)
#define MICROPY_ENABLE_RUNTIME (0)
#define MICROPY_ENABLE_GC (1)
diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h
index 87689c505e..345b64fe40 100644
--- a/ports/cc3200/mpconfigport.h
+++ b/ports/cc3200/mpconfigport.h
@@ -53,7 +53,6 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define MICROPY_OPT_COMPUTED_GOTO (0)
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
#define MICROPY_READER_VFS (1)
#ifndef DEBUG // we need ram on the launchxl while debugging
#define MICROPY_CPYTHON_COMPAT (1)
diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h
index 6290f85e87..3ffb092c61 100644
--- a/ports/nrf/mpconfigport.h
+++ b/ports/nrf/mpconfigport.h
@@ -66,7 +66,6 @@
#endif
#define MICROPY_OPT_COMPUTED_GOTO (0)
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
#define MICROPY_OPT_MPZ_BITWISE (0)
// fatfs configuration used in ffconf.h
diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h
index 47795c4e71..92f1338d6c 100644
--- a/ports/stm32/mpconfigport.h
+++ b/ports/stm32/mpconfigport.h
@@ -59,7 +59,6 @@
#ifndef MICROPY_OPT_COMPUTED_GOTO
#define MICROPY_OPT_COMPUTED_GOTO (1)
#endif
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH
#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (1)
#endif
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index bf9d290abf..60e37ade0a 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -269,7 +269,6 @@ ifneq ($(FROZEN_MANIFEST)$(FROZEN_MPY_DIR),)
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
CFLAGS += -DMPZ_DIG_SIZE=16 # force 16 bits to work on both 32 and 64 bit archs
-MPY_CROSS_FLAGS += -mcache-lookup-bc
endif
ifneq ($(FROZEN_MANIFEST)$(FROZEN_DIR),)
@@ -285,9 +284,7 @@ endif
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99,$(CFLAGS) $(CXXFLAGS_MOD))
ifeq ($(MICROPY_FORCE_32BIT),1)
-RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc -march=x86'
-else
-RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc'
+RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-march=x86'
endif
ifeq ($(CROSS_COMPILE),arm-linux-gnueabi-)
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index de45a800d3..d6ab4e5ca9 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -79,9 +79,6 @@
#endif
#define MICROPY_STREAMS_POSIX_API (1)
#define MICROPY_OPT_COMPUTED_GOTO (1)
-#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1)
-#endif
#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH
#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (1)
#endif
diff --git a/ports/unix/variants/minimal/mpconfigvariant.h b/ports/unix/variants/minimal/mpconfigvariant.h
index d5eab09546..973febd572 100644
--- a/ports/unix/variants/minimal/mpconfigvariant.h
+++ b/ports/unix/variants/minimal/mpconfigvariant.h
@@ -55,7 +55,6 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_STREAMS_NON_BLOCK (0)
#define MICROPY_OPT_COMPUTED_GOTO (0)
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (0)
#define MICROPY_OPT_MAP_LOOKUP_CACHE (0)
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
diff --git a/ports/windows/Makefile b/ports/windows/Makefile
index d87affa15c..cb2ebc22f7 100644
--- a/ports/windows/Makefile
+++ b/ports/windows/Makefile
@@ -60,7 +60,6 @@ SRC_QSTR_AUTO_DEPS +=
ifneq ($(FROZEN_MANIFEST),)
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool -DMICROPY_MODULE_FROZEN_MPY=1 -DMPZ_DIG_SIZE=16
-MPY_CROSS_FLAGS += -mcache-lookup-bc
endif
include $(TOP)/py/mkrules.mk
diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h
index ffcb5b105f..4a8a902597 100644
--- a/ports/windows/mpconfigport.h
+++ b/ports/windows/mpconfigport.h
@@ -59,7 +59,6 @@
#define MICROPY_STREAMS_NON_BLOCK (1)
#define MICROPY_STREAMS_POSIX_API (1)
#define MICROPY_OPT_COMPUTED_GOTO (0)
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1)
#define MICROPY_MODULE_WEAK_LINKS (1)
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_VFS_POSIX_FILE (1)
diff --git a/ports/windows/msvc/genhdr.targets b/ports/windows/msvc/genhdr.targets
index 9ea6ed28cb..78e57a34ee 100644
--- a/ports/windows/msvc/genhdr.targets
+++ b/ports/windows/msvc/genhdr.targets
@@ -123,7 +123,7 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) {
<PreprocessorDefinitions>MICROPY_MODULE_FROZEN_MPY=1;MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
- <Exec Command="$(PyPython) $(PyBaseDir)tools\makemanifest.py -v MPY_DIR=$(PyBaseDir) -v MPY_LIB_DIR=$(PyBaseDir)../micropython-lib -v PORT_DIR=$(PyWinDir) -f&quot;-mcache-lookup-bc&quot; -o $(PyBuildDir)frozen_content.c -b $(PyBuildDir) $(FrozenManifest)"/>
+ <Exec Command="$(PyPython) $(PyBaseDir)tools\makemanifest.py -v MPY_DIR=$(PyBaseDir) -v MPY_LIB_DIR=$(PyBaseDir)../micropython-lib -v PORT_DIR=$(PyWinDir) -o $(PyBuildDir)frozen_content.c -b $(PyBuildDir) $(FrozenManifest)"/>
<WriteLinesToFile File="$(TLogLocation)frozen.read.1.tlog" Lines="$(FrozenManifest)" Overwrite="True"/>
</Target>
diff --git a/py/bc.c b/py/bc.c
index 58694b97dc..69b6739e8f 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -304,24 +304,10 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
// The following table encodes the number of bytes that a specific opcode
// takes up. Some opcodes have an extra byte, defined by MP_BC_MASK_EXTRA_BYTE.
-// There are 4 special opcodes that have an extra byte only when
-// MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE is enabled (and they take a qstr):
-// MP_BC_LOAD_NAME
-// MP_BC_LOAD_GLOBAL
-// MP_BC_LOAD_ATTR
-// MP_BC_STORE_ATTR
uint mp_opcode_format(const byte *ip, size_t *opcode_size, bool count_var_uint) {
uint f = MP_BC_FORMAT(*ip);
const byte *ip_start = ip;
if (f == MP_BC_FORMAT_QSTR) {
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) {
- if (*ip == MP_BC_LOAD_NAME
- || *ip == MP_BC_LOAD_GLOBAL
- || *ip == MP_BC_LOAD_ATTR
- || *ip == MP_BC_STORE_ATTR) {
- ip += 1;
- }
- }
ip += 3;
} else {
int extra_byte = (*ip & MP_BC_MASK_EXTRA_BYTE) == 0;
diff --git a/py/dynruntime.mk b/py/dynruntime.mk
index cb5ab845eb..db06d41e73 100644
--- a/py/dynruntime.mk
+++ b/py/dynruntime.mk
@@ -46,7 +46,6 @@ ifeq ($(ARCH),x86)
# x86
CROSS =
CFLAGS += -m32 -fno-stack-protector
-MPY_CROSS_FLAGS += -mcache-lookup-bc
MICROPY_FLOAT_IMPL ?= double
else ifeq ($(ARCH),x64)
@@ -54,7 +53,6 @@ else ifeq ($(ARCH),x64)
# x64
CROSS =
CFLAGS += -fno-stack-protector
-MPY_CROSS_FLAGS += -mcache-lookup-bc
MICROPY_FLOAT_IMPL ?= double
else ifeq ($(ARCH),armv7m)
diff --git a/py/emitbc.c b/py/emitbc.c
index d7e8e05f0f..ca74046033 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -560,9 +560,6 @@ void mp_emit_bc_load_global(emit_t *emit, qstr qst, int kind) {
MP_STATIC_ASSERT(MP_BC_LOAD_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_BC_LOAD_GLOBAL);
(void)qst;
emit_write_bytecode_byte_qstr(emit, 1, MP_BC_LOAD_NAME + kind, qst);
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) {
- emit_write_bytecode_raw_byte(emit, 0);
- }
}
void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super) {
@@ -596,9 +593,6 @@ void mp_emit_bc_attr(emit_t *emit, qstr qst, int kind) {
}
emit_write_bytecode_byte_qstr(emit, -2, MP_BC_STORE_ATTR, qst);
}
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) {
- emit_write_bytecode_raw_byte(emit, 0);
- }
}
void mp_emit_bc_store_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 97fc9bb580..6a2edc7dc2 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -423,10 +423,8 @@
// Configure dynamic compiler macros
#if MICROPY_DYNAMIC_COMPILER
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
#else
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
#endif
@@ -520,13 +518,6 @@
#define MICROPY_OPT_COMPUTED_GOTO (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.
-#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
-#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
-#endif
-
// Optimise the fast path for loading attributes from instance types. Increases
// Thumb2 code size by about 48 bytes.
#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH
diff --git a/py/mpstate.h b/py/mpstate.h
index 53b2906872..69360738c2 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -44,7 +44,6 @@
#if MICROPY_DYNAMIC_COMPILER
typedef struct mp_dynamic_compiler_t {
uint8_t small_int_bits; // must be <= host small_int_bits
- bool opt_cache_map_lookup_in_bytecode;
bool py_builtins_str_unicode;
uint8_t native_arch;
uint8_t nlr_buf_num_regs;
diff --git a/py/persistentcode.h b/py/persistentcode.h
index 8769ef584d..94fc3bf2d3 100644
--- a/py/persistentcode.h
+++ b/py/persistentcode.h
@@ -41,16 +41,15 @@
#define MPY_FEATURE_ENCODE_ARCH(arch) ((arch) << 2)
#define MPY_FEATURE_DECODE_ARCH(feat) ((feat) >> 2)
-// The feature flag bits encode the compile-time config options that
-// affect the generate bytecode.
+// The feature flag bits encode the compile-time config options that affect
+// the generate bytecode. Note: position 0 is now unused
+// (formerly MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE).
#define MPY_FEATURE_FLAGS ( \
- ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) << 0) \
- | ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \
+ ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \
)
// This is a version of the flags that can be configured at runtime.
#define MPY_FEATURE_FLAGS_DYNAMIC ( \
- ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) << 0) \
- | ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \
+ ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \
)
// Define the host architecture
diff --git a/py/profile.c b/py/profile.c
index 054a0f9e61..d0ac99e074 100644
--- a/py/profile.c
+++ b/py/profile.c
@@ -540,9 +540,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
instruction->qstr_opname = MP_QSTR_LOAD_NAME;
instruction->arg = qst;
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
- }
break;
case MP_BC_LOAD_GLOBAL:
@@ -550,9 +547,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
instruction->qstr_opname = MP_QSTR_LOAD_GLOBAL;
instruction->arg = qst;
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
- }
break;
case MP_BC_LOAD_ATTR:
@@ -560,9 +554,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
instruction->qstr_opname = MP_QSTR_LOAD_ATTR;
instruction->arg = qst;
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
- }
break;
case MP_BC_LOAD_METHOD:
@@ -618,9 +609,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
instruction->qstr_opname = MP_QSTR_STORE_ATTR;
instruction->arg = qst;
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
- }
break;
case MP_BC_STORE_SUBSCR:
diff --git a/py/showbc.c b/py/showbc.c
index cb81b88359..c321dfd755 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -208,25 +208,16 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) {
case MP_BC_LOAD_NAME:
DECODE_QSTR;
mp_printf(print, "LOAD_NAME %s", qstr_str(qst));
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- mp_printf(print, " (cache=%u)", *ip++);
- }
break;
case MP_BC_LOAD_GLOBAL:
DECODE_QSTR;
mp_printf(print, "LOAD_GLOBAL %s", qstr_str(qst));
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- mp_printf(print, " (cache=%u)", *ip++);
- }
break;
case MP_BC_LOAD_ATTR:
DECODE_QSTR;
mp_printf(print, "LOAD_ATTR %s", qstr_str(qst));
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- mp_printf(print, " (cache=%u)", *ip++);
- }
break;
case MP_BC_LOAD_METHOD:
@@ -270,9 +261,6 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) {
case MP_BC_STORE_ATTR:
DECODE_QSTR;
mp_printf(print, "STORE_ATTR %s", qstr_str(qst));
- if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
- mp_printf(print, " (cache=%u)", *ip++);
- }
break;
case MP_BC_STORE_SUBSCR:
diff --git a/py/vm.c b/py/vm.c
index e5a62e4415..f55d293dc5 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -180,23 +180,6 @@
#define TRACE_TICK(current_ip, current_sp, is_exception)
#endif // MICROPY_PY_SYS_SETTRACE
-#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
-static inline mp_map_elem_t *mp_map_cached_lookup(mp_map_t *map, qstr qst, uint8_t *idx_cache) {
- size_t idx = *idx_cache;
- mp_obj_t key = MP_OBJ_NEW_QSTR(qst);
- mp_map_elem_t *elem = NULL;
- if (idx < map->alloc && map->table[idx].key == key) {
- elem = &map->table[idx];
- } else {
- elem = mp_map_lookup(map, key, MP_MAP_LOOKUP);
- if (elem != NULL) {
- *idx_cache = (elem - &map->table[0]) & 0xff;
- }
- }
- return elem;
-}
-#endif
-
// fastn has items in reverse order (fastn[0] is local[0], fastn[-1] is local[1], etc)
// sp points to bottom of stack which grows up
// returns:
@@ -361,55 +344,20 @@ dispatch_loop:
goto load_check;
}
- #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
ENTRY(MP_BC_LOAD_NAME): {
MARK_EXC_IP_SELECTIVE();
DECODE_QSTR;
PUSH(mp_load_name(qst));
DISPATCH();
}
- #else
- ENTRY(MP_BC_LOAD_NAME): {
- MARK_EXC_IP_SELECTIVE();
- DECODE_QSTR;
- mp_map_elem_t *elem = mp_map_cached_lookup(&mp_locals_get()->map, qst, (uint8_t*)ip);
- mp_obj_t obj;
- if (elem != NULL) {
- obj = elem->value;
- } else {
- obj = mp_load_name(qst);
- }
- PUSH(obj);
- ip++;
- DISPATCH();
- }
- #endif
- #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
ENTRY(MP_BC_LOAD_GLOBAL): {
MARK_EXC_IP_SELECTIVE();
DECODE_QSTR;
PUSH(mp_load_global(qst));
DISPATCH();
}
- #else
- ENTRY(MP_BC_LOAD_GLOBAL): {
- MARK_EXC_IP_SELECTIVE();
- DECODE_QSTR;
- mp_map_elem_t *elem = mp_map_cached_lookup(&mp_globals_get()->map, qst, (uint8_t*)ip);
- mp_obj_t obj;
- if (elem != NULL) {
- obj = elem->value;
- } else {
- obj = mp_load_global(qst);
- }
- PUSH(obj);
- ip++;
- DISPATCH();
- }
- #endif
- #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
ENTRY(MP_BC_LOAD_ATTR): {
FRAME_UPDATE();
MARK_EXC_IP_SELECTIVE();
@@ -436,28 +384,6 @@ dispatch_loop:
SET_TOP(obj);
DISPATCH();
}
- #else
- ENTRY(MP_BC_LOAD_ATTR): {
- FRAME_UPDATE();
- MARK_EXC_IP_SELECTIVE();
- DECODE_QSTR;
- mp_obj_t top = TOP();
- mp_map_elem_t *elem = NULL;
- if (mp_obj_is_instance_type(mp_obj_get_type(top))) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(top);
- elem = mp_map_cached_lookup(&self->members, qst, (uint8_t*)ip);
- }
- mp_obj_t obj;
- if (elem != NULL) {
- obj = elem->value;
- } else {
- obj = mp_load_attr(top, qst);
- }
- SET_TOP(obj);
- ip++;
- DISPATCH();
- }
- #endif
ENTRY(MP_BC_LOAD_METHOD): {
MARK_EXC_IP_SELECTIVE();
@@ -513,7 +439,6 @@ dispatch_loop:
DISPATCH();
}
- #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
ENTRY(MP_BC_STORE_ATTR): {
FRAME_UPDATE();
MARK_EXC_IP_SELECTIVE();
@@ -522,32 +447,6 @@ dispatch_loop:
sp -= 2;
DISPATCH();
}
- #else
- // This caching code works with MICROPY_PY_BUILTINS_PROPERTY and/or
- // MICROPY_PY_DESCRIPTORS enabled because if the attr exists in
- // self->members then it can't be a property or have descriptors. A
- // consequence of this is that we can't use MP_MAP_LOOKUP_ADD_IF_NOT_FOUND
- // in the fast-path below, because that store could override a property.
- ENTRY(MP_BC_STORE_ATTR): {
- FRAME_UPDATE();
- MARK_EXC_IP_SELECTIVE();
- DECODE_QSTR;
- mp_map_elem_t *elem = NULL;
- mp_obj_t top = TOP();
- if (mp_obj_is_instance_type(mp_obj_get_type(top)) && sp[-1] != MP_OBJ_NULL) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(top);
- elem = mp_map_cached_lookup(&self->members, qst, (uint8_t*)ip);
- }
- if (elem != NULL) {
- elem->value = sp[-1];
- } else {
- mp_store_attr(sp[0], qst, sp[-1]);
- }
- sp -= 2;
- ip++;
- DISPATCH();
- }
- #endif
ENTRY(MP_BC_STORE_SUBSCR):
MARK_EXC_IP_SELECTIVE();
diff --git a/tests/cmdline/cmd_parsetree.py.exp b/tests/cmdline/cmd_parsetree.py.exp
index cc8ba82c05..bee4fc99d1 100644
--- a/tests/cmdline/cmd_parsetree.py.exp
+++ b/tests/cmdline/cmd_parsetree.py.exp
@@ -78,11 +78,11 @@ arg names:
45 STORE_NAME g
48 LOAD_CONST_OBJ \.\+
50 LOAD_METHOD format
-53 LOAD_NAME b (cache=0)
-57 CALL_METHOD n=1 nkw=0
-59 STORE_NAME h
-62 LOAD_CONST_NONE
-63 RETURN_VALUE
+53 LOAD_NAME b
+56 CALL_METHOD n=1 nkw=0
+58 STORE_NAME h
+61 LOAD_CONST_NONE
+62 RETURN_VALUE
mem: total=\\d\+, current=\\d\+, peak=\\d\+
stack: \\d\+ out of \\d\+
GC: total: \\d\+, used: \\d\+, free: \\d\+
diff --git a/tests/cmdline/cmd_showbc.py.exp b/tests/cmdline/cmd_showbc.py.exp
index 325efc7dba..d93fd7b487 100644
--- a/tests/cmdline/cmd_showbc.py.exp
+++ b/tests/cmdline/cmd_showbc.py.exp
@@ -119,11 +119,11 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
\\d\+ UNARY_OP 3
\\d\+ STORE_FAST 10
\\d\+ LOAD_DEREF 14
-\\d\+ LOAD_ATTR c (cache=0)
+\\d\+ LOAD_ATTR c
\\d\+ STORE_FAST 11
\\d\+ LOAD_FAST 11
\\d\+ LOAD_DEREF 14
-\\d\+ STORE_ATTR c (cache=0)
+\\d\+ STORE_ATTR c
\\d\+ LOAD_DEREF 14
\\d\+ LOAD_CONST_SMALL_INT 0
\\d\+ LOAD_SUBSCR
@@ -233,7 +233,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
\\d\+ LOAD_DEREF 16
\\d\+ POP_TOP
\\d\+ JUMP \\d\+
-\\d\+ LOAD_GLOBAL y (cache=0)
+\\d\+ LOAD_GLOBAL y
\\d\+ POP_TOP
\\d\+ JUMP \\d\+
\\d\+ LOAD_DEREF 14
@@ -418,13 +418,13 @@ arg names:
(N_EXC_STACK 0)
bc=0 line=1
########
- bc=13 line=150
-00 LOAD_NAME __name__ (cache=0)
-04 STORE_NAME __module__
-07 LOAD_CONST_STRING 'Class'
-10 STORE_NAME __qualname__
-13 LOAD_CONST_NONE
-14 RETURN_VALUE
+ bc=12 line=150
+00 LOAD_NAME __name__
+03 STORE_NAME __module__
+06 LOAD_CONST_STRING 'Class'
+09 STORE_NAME __qualname__
+12 LOAD_CONST_NONE
+13 RETURN_VALUE
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes)
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
########
@@ -434,8 +434,8 @@ arg names: self
(N_EXC_STACK 0)
bc=0 line=1
bc=0 line=157
-00 LOAD_GLOBAL super (cache=0)
-\\d\+ LOAD_GLOBAL __class__ (cache=0)
+00 LOAD_GLOBAL super
+\\d\+ LOAD_GLOBAL __class__
\\d\+ LOAD_FAST 0
\\d\+ LOAD_SUPER_METHOD f
\\d\+ CALL_METHOD n=0 nkw=0
diff --git a/tests/cmdline/cmd_verbose.py.exp b/tests/cmdline/cmd_verbose.py.exp
index a2fdf1f00d..0edd050c22 100644
--- a/tests/cmdline/cmd_verbose.py.exp
+++ b/tests/cmdline/cmd_verbose.py.exp
@@ -8,12 +8,12 @@ arg names:
(N_EXC_STACK 0)
bc=0 line=1
bc=0 line=3
-00 LOAD_NAME print (cache=0)
-04 LOAD_CONST_SMALL_INT 1
-05 CALL_FUNCTION n=1 nkw=0
-07 POP_TOP
-08 LOAD_CONST_NONE
-09 RETURN_VALUE
+00 LOAD_NAME print
+03 LOAD_CONST_SMALL_INT 1
+04 CALL_FUNCTION n=1 nkw=0
+06 POP_TOP
+07 LOAD_CONST_NONE
+08 RETURN_VALUE
1
mem: total=\\d\+, current=\\d\+, peak=\\d\+
stack: \\d\+ out of \\d\+
diff --git a/tests/micropython/import_mpy_native_gc.py b/tests/micropython/import_mpy_native_gc.py
index e8fac8f179..f982a4ee17 100644
--- a/tests/micropython/import_mpy_native_gc.py
+++ b/tests/micropython/import_mpy_native_gc.py
@@ -48,8 +48,8 @@ class UserFS:
# Pre-compiled examples/natmod/features0 example for various architectures, keyed
# by the required value of sys.implementation.mpy.
features0_file_contents = {
- # -march=x64 -mcache-lookup-bc
- 0xB05: b'M\x05\x0b\x1f \x84b\xe9/\x00\x00\x00SH\x8b\x1ds\x00\x00\x00\xbe\x02\x00\x00\x00\xffS\x18\xbf\x01\x00\x00\x00H\x85\xc0u\x0cH\x8bC \xbe\x02\x00\x00\x00[\xff\xe0H\x0f\xaf\xf8H\xff\xc8\xeb\xe6ATUSH\x8b\x1dA\x00\x00\x00H\x8b\x7f\x08L\x8bc(A\xff\xd4H\x8d5\x1f\x00\x00\x00H\x89\xc5H\x8b\x05-\x00\x00\x00\x0f\xb78\xffShH\x89\xefA\xff\xd4H\x8b\x03[]A\\\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x84@\x12factorial\x10\x00\x00\r \x01"\x9f\x1c\x01\x1e\xff',
+ # -march=x64
+ 0xA05: b'M\x05\x0a\x1f \x84b\xe9/\x00\x00\x00SH\x8b\x1ds\x00\x00\x00\xbe\x02\x00\x00\x00\xffS\x18\xbf\x01\x00\x00\x00H\x85\xc0u\x0cH\x8bC \xbe\x02\x00\x00\x00[\xff\xe0H\x0f\xaf\xf8H\xff\xc8\xeb\xe6ATUSH\x8b\x1dA\x00\x00\x00H\x8b\x7f\x08L\x8bc(A\xff\xd4H\x8d5\x1f\x00\x00\x00H\x89\xc5H\x8b\x05-\x00\x00\x00\x0f\xb78\xffShH\x89\xefA\xff\xd4H\x8b\x03[]A\\\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x84@\x12factorial\x10\x00\x00\r \x01"\x9f\x1c\x01\x1e\xff',
# -march=armv7m
0x1605: b"M\x05\x16\x1f \x84\x12\x1a\xe0\x00\x00\x13\xb5\nK\nJ{D\x9cX\x02!\xe3h\x98G\x03F\x01 3\xb9\x02!#i\x01\x93\x02\xb0\xbd\xe8\x10@\x18GXC\x01;\xf4\xe7\x00\xbfj\x00\x00\x00\x00\x00\x00\x00\xf8\xb5\tN\tK~D\xf4X@hgi\xb8G\x05F\x07K\x07I\xf2XyD\x10\x88ck\x98G(F\xb8G h\xf8\xbd6\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x01\x84\x00\x12factorial\x10\x00\x00\r<\x01>\x9f8\x01:\xff",
}
diff --git a/tests/micropython/import_mpy_native_x64.py b/tests/micropython/import_mpy_native_x64.py
index 3e7b2058eb..cad59e9916 100644
--- a/tests/micropython/import_mpy_native_x64.py
+++ b/tests/micropython/import_mpy_native_x64.py
@@ -52,11 +52,11 @@ class UserFS:
# fmt: off
user_files = {
# bad architecture
- '/mod0.mpy': b'M\x05\xff\x00\x10',
+ '/mod0.mpy': b'M\x05\xfe\x00\x10',
# test loading of viper and asm
'/mod1.mpy': (
- b'M\x05\x0b\x1f\x20' # header
+ b'M\x05\x0a\x1f\x20' # header
b'\x20' # n bytes, bytecode
b'\x00\x08\x02m\x02m' # prelude
@@ -78,7 +78,7 @@ user_files = {
# test loading viper with additional scope flags and relocation
'/mod2.mpy': (
- b'M\x05\x0b\x1f\x20' # header
+ b'M\x05\x0a\x1f\x20' # header
b'\x20' # n bytes, bytecode
b'\x00\x08\x02m\x02m' # prelude
diff --git a/tests/run-tests.py b/tests/run-tests.py
index 3e97a7c87d..a8a31c0ae5 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -742,9 +742,7 @@ the last matching regex is used:
cmd_parser.add_argument(
"--via-mpy", action="store_true", help="compile .py files to .mpy first"
)
- cmd_parser.add_argument(
- "--mpy-cross-flags", default="-mcache-lookup-bc", help="flags to pass to mpy-cross"
- )
+ cmd_parser.add_argument("--mpy-cross-flags", default="", help="flags to pass to mpy-cross")
cmd_parser.add_argument(
"--keep-path", action="store_true", help="do not clear MICROPYPATH when running tests"
)
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py
index bfc3cf27e3..6868ed5d4e 100755
--- a/tools/mpy-tool.py
+++ b/tools/mpy-tool.py
@@ -132,14 +132,6 @@ def mp_opcode_format(bytecode, ip, count_var_uint):
ip_start = ip
f = (0x000003A4 >> (2 * ((opcode) >> 4))) & 3
if f == MP_BC_FORMAT_QSTR:
- if config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE:
- if (
- opcode == MP_BC_LOAD_NAME
- or opcode == MP_BC_LOAD_GLOBAL
- or opcode == MP_BC_LOAD_ATTR
- or opcode == MP_BC_STORE_ATTR
- ):
- ip += 1
ip += 3
else:
extra_byte = (opcode & MP_BC_MASK_EXTRA_BYTE) == 0
@@ -440,10 +432,7 @@ class RawCodeBytecode(RawCode):
"// frozen bytecode for file %s, scope %s%s"
% (self.source_file.str, parent_name, self.simple_name.str)
)
- print("STATIC ", end="")
- if not config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE:
- print("const ", end="")
- print("byte fun_data_%s[%u] = {" % (self.escaped_name, len(self.bytecode)))
+ print("STATIC const byte fun_data_%s[%u] = {" % (self.escaped_name, len(self.bytecode)))
print(" ", end="")
for i in range(self.ip2):
print(" 0x%02x," % self.bytecode[i], end="")
@@ -798,7 +787,6 @@ def read_mpy(filename):
raise Exception("incompatible .mpy version")
feature_byte = header[2]
qw_size = read_uint(f)
- config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = (feature_byte & 1) != 0
config.MICROPY_PY_BUILTINS_STR_UNICODE = (feature_byte & 2) != 0
mpy_native_arch = feature_byte >> 2
if mpy_native_arch != MP_NATIVE_ARCH_NONE:
@@ -836,14 +824,6 @@ def freeze_mpy(base_qstrs, raw_codes):
print('#include "py/nativeglue.h"')
print()
- print(
- "#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE != %u"
- % config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
- )
- print('#error "incompatible MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE"')
- print("#endif")
- print()
-
print("#if MICROPY_LONGINT_IMPL != %u" % config.MICROPY_LONGINT_IMPL)
print('#error "incompatible MICROPY_LONGINT_IMPL"')
print("#endif")
@@ -940,11 +920,7 @@ def merge_mpy(raw_codes, output_file):
header = bytearray(5)
header[0] = ord("M")
header[1] = config.MPY_VERSION
- header[2] = (
- config.native_arch << 2
- | config.MICROPY_PY_BUILTINS_STR_UNICODE << 1
- | config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
- )
+ header[2] = config.native_arch << 2 | config.MICROPY_PY_BUILTINS_STR_UNICODE << 1
header[3] = config.mp_small_int_bits
header[4] = 32 # qstr_win_size
merged_mpy.extend(header)
diff --git a/tools/mpy_cross_all.py b/tools/mpy_cross_all.py
index d542bde42e..4b1edf9d6c 100755
--- a/tools/mpy_cross_all.py
+++ b/tools/mpy_cross_all.py
@@ -6,14 +6,11 @@ import os.path
argparser = argparse.ArgumentParser(description="Compile all .py files to .mpy recursively")
argparser.add_argument("-o", "--out", help="output directory (default: input dir)")
argparser.add_argument("--target", help="select MicroPython target config")
-argparser.add_argument(
- "-mcache-lookup-bc", action="store_true", help="cache map lookups in the bytecode"
-)
argparser.add_argument("dir", help="input directory")
args = argparser.parse_args()
TARGET_OPTS = {
- "unix": "-mcache-lookup-bc",
+ "unix": "",
"baremetal": "",
}
diff --git a/tools/mpy_ld.py b/tools/mpy_ld.py
index 8522499438..6bc1dbac05 100755
--- a/tools/mpy_ld.py
+++ b/tools/mpy_ld.py
@@ -48,7 +48,6 @@ MP_CODE_NATIVE_VIPER = 4
MP_SCOPE_FLAG_VIPERRELOC = 0x10
MP_SCOPE_FLAG_VIPERRODATA = 0x20
MP_SCOPE_FLAG_VIPERBSS = 0x40
-MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = 1
MICROPY_PY_BUILTINS_STR_UNICODE = 2
MP_SMALL_INT_BITS = 31
QSTR_WINDOW_SIZE = 32
@@ -118,9 +117,7 @@ class ArchData:
ARCH_DATA = {
"x86": ArchData(
"EM_386",
- MP_NATIVE_ARCH_X86 << 2
- | MICROPY_PY_BUILTINS_STR_UNICODE
- | MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE,
+ MP_NATIVE_ARCH_X86 << 2 | MICROPY_PY_BUILTINS_STR_UNICODE,
2,
4,
(R_386_PC32, R_386_GOT32, R_386_GOT32X),
@@ -128,9 +125,7 @@ ARCH_DATA = {
),
"x64": ArchData(
"EM_X86_64",
- MP_NATIVE_ARCH_X64 << 2
- | MICROPY_PY_BUILTINS_STR_UNICODE
- | MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE,
+ MP_NATIVE_ARCH_X64 << 2 | MICROPY_PY_BUILTINS_STR_UNICODE,
2,
8,
(R_X86_64_GOTPCREL, R_X86_64_REX_GOTPCRELX),