summaryrefslogtreecommitdiffstatshomepage
path: root/py/persistentcode.h
diff options
context:
space:
mode:
Diffstat (limited to 'py/persistentcode.h')
-rw-r--r--py/persistentcode.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/py/persistentcode.h b/py/persistentcode.h
index 29ccce4a3d..e664358737 100644
--- a/py/persistentcode.h
+++ b/py/persistentcode.h
@@ -30,24 +30,23 @@
#include "py/reader.h"
#include "py/emitglue.h"
-// The current version of .mpy files
+// The current version of .mpy files. A bytecode-only .mpy file can be loaded
+// as long as MPY_VERSION matches, but a native .mpy (i.e. one with an arch
+// set) must also match MPY_SUB_VERSION. This allows 3 additional updates to
+// the native ABI per bytecode revision.
#define MPY_VERSION 6
+#define MPY_SUB_VERSION 1
-// Macros to encode/decode flags to/from the feature byte
-#define MPY_FEATURE_ENCODE_FLAGS(flags) (flags)
-#define MPY_FEATURE_DECODE_FLAGS(feat) ((feat) & 3)
+// Macros to encode/decode sub-version to/from the feature byte. This replaces
+// the bits previously used to encode the flags (map caching and unicode)
+// which are no longer used starting at .mpy version 6.
+#define MPY_FEATURE_ENCODE_SUB_VERSION(version) (version)
+#define MPY_FEATURE_DECODE_SUB_VERSION(feat) ((feat) & 3)
// Macros to encode/decode native architecture to/from the feature byte
#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. Note: no longer used.
-// (formerly MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE and MICROPY_PY_BUILTINS_STR_UNICODE).
-#define MPY_FEATURE_FLAGS (0)
-// This is a version of the flags that can be configured at runtime.
-#define MPY_FEATURE_FLAGS_DYNAMIC (0)
-
// Define the host architecture
#if MICROPY_EMIT_X86
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_X86)
@@ -82,7 +81,7 @@
// 16-bit little-endian integer with the second and third bytes of supported .mpy files
#define MPY_FILE_HEADER_INT (MPY_VERSION \
- | (MPY_FEATURE_ENCODE_FLAGS(MPY_FEATURE_FLAGS) | MPY_FEATURE_ENCODE_ARCH(MPY_FEATURE_ARCH)) << 8)
+ | (MPY_FEATURE_ENCODE_SUB_VERSION(MPY_SUB_VERSION) | MPY_FEATURE_ENCODE_ARCH(MPY_FEATURE_ARCH)) << 8)
enum {
MP_NATIVE_ARCH_NONE = 0,