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:
parent
f2ebee9cf1
commit
02cc288edb
@ -2094,12 +2094,12 @@ STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
|
||||
emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, MP_OBJ_ITER_BUF_NSLOTS);
|
||||
adjust_stack(emit, MP_OBJ_ITER_BUF_NSLOTS);
|
||||
emit_call(emit, MP_F_NATIVE_ITERNEXT);
|
||||
#ifdef NDEBUG
|
||||
MP_STATIC_ASSERT(MP_OBJ_STOP_ITERATION == 0);
|
||||
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label, false);
|
||||
#else
|
||||
#if MICROPY_DEBUG_MP_OBJ_SENTINELS
|
||||
ASM_MOV_REG_IMM(emit->as, REG_TEMP1, (mp_uint_t)MP_OBJ_STOP_ITERATION);
|
||||
ASM_JUMP_IF_REG_EQ(emit->as, REG_RET, REG_TEMP1, label);
|
||||
#else
|
||||
MP_STATIC_ASSERT(MP_OBJ_STOP_ITERATION == 0);
|
||||
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label, false);
|
||||
#endif
|
||||
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
|
||||
}
|
||||
|
@ -414,6 +414,11 @@
|
||||
#define MICROPY_DEBUG_VERBOSE (0)
|
||||
#endif
|
||||
|
||||
// Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
|
||||
#ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
|
||||
#define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
|
||||
#endif
|
||||
|
||||
// Whether to enable a simple VM stack overflow check
|
||||
#ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
|
||||
#define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
|
||||
|
10
py/obj.h
10
py/obj.h
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user