py: Add independent config for debugging sentinel object values.

The new compile-time option is MICROPY_DEBUG_MP_OBJ_SENTINELS, disabled by
default.  This is to allow finer control of whether this debugging feature
is enabled or not (because, for example, this setting must be the same for
mpy-cross and the MicroPython main code when using native code generation).
This commit is contained in:
Damien George
2019-03-08 15:48:20 +11:00
parent f2ebee9cf1
commit 02cc288edb
3 changed files with 14 additions and 9 deletions

View File

@@ -65,14 +65,14 @@ typedef struct _mp_obj_base_t mp_obj_base_t;
// For debugging purposes they are all different. For non-debug mode, we alias
// as many as we can to MP_OBJ_NULL because it's cheaper to load/compare 0.
#ifdef NDEBUG
#define MP_OBJ_NULL (MP_OBJ_FROM_PTR((void*)0))
#define MP_OBJ_STOP_ITERATION (MP_OBJ_FROM_PTR((void*)0))
#define MP_OBJ_SENTINEL (MP_OBJ_FROM_PTR((void*)4))
#else
#if MICROPY_DEBUG_MP_OBJ_SENTINELS
#define MP_OBJ_NULL (MP_OBJ_FROM_PTR((void*)0))
#define MP_OBJ_STOP_ITERATION (MP_OBJ_FROM_PTR((void*)4))
#define MP_OBJ_SENTINEL (MP_OBJ_FROM_PTR((void*)8))
#else
#define MP_OBJ_NULL (MP_OBJ_FROM_PTR((void*)0))
#define MP_OBJ_STOP_ITERATION (MP_OBJ_FROM_PTR((void*)0))
#define MP_OBJ_SENTINEL (MP_OBJ_FROM_PTR((void*)4))
#endif
// These macros/inline functions operate on objects and depend on the