always define DEBUG to 1 or 0
This commit is contained in:
parent
f843c7e96d
commit
e2e73a5987
@ -204,9 +204,7 @@ NOINLINE B leading_axis_arith(FC2 fc2, B w, B x, usz* wsh, usz* xsh, ur mr) { //
|
|||||||
assert(isArr(w) && isArr(x) && TI(w,elType)!=el_B && TI(x,elType)!=el_B && IA(w)!=0 && IA(x)!=0);
|
assert(isArr(w) && isArr(x) && TI(w,elType)!=el_B && TI(x,elType)!=el_B && IA(w)!=0 && IA(x)!=0);
|
||||||
ur wr = RNK(w);
|
ur wr = RNK(w);
|
||||||
ur xr = RNK(x);
|
ur xr = RNK(x);
|
||||||
#if DEBUG
|
if (DEBUG) assert(wr!=xr && (mr==wr || mr==xr) && eqShPart(wsh, xsh, mr));
|
||||||
assert(wr!=xr && (mr==wr || mr==xr) && eqShPart(wsh, xsh, mr));
|
|
||||||
#endif
|
|
||||||
usz cam = shProd(xsh, 0, mr);
|
usz cam = shProd(xsh, 0, mr);
|
||||||
|
|
||||||
B b = mr==wr? x : w; // bigger argument
|
B b = mr==wr? x : w; // bigger argument
|
||||||
|
|||||||
@ -72,13 +72,13 @@ extern u8 const arrTypeBitsLog[];
|
|||||||
#define arrNewType(X) el2t(TIi(X,elType))
|
#define arrNewType(X) el2t(TIi(X,elType))
|
||||||
|
|
||||||
SHOULD_INLINE void arr_check_size(u64 sz, u8 type, u64 ia) {
|
SHOULD_INLINE void arr_check_size(u64 sz, u8 type, u64 ia) {
|
||||||
#if DEBUG
|
if (DEBUG) {
|
||||||
assert(IS_ANY_ARR(type) || type==t_harrPartial);
|
assert(IS_ANY_ARR(type) || type==t_harrPartial);
|
||||||
if (!IS_SLICE(type)) {
|
if (!IS_SLICE(type)) {
|
||||||
if (type==t_harr || type==t_harrPartial) assert(sz >= fsizeof(HArr,a,B,ia));
|
if (type==t_harr || type==t_harrPartial) assert(sz >= fsizeof(HArr,a,B,ia));
|
||||||
else assert(sz >= offsetof(TyArr,a) + (((ia<<arrTypeBitsLog(type))+7)>>3));
|
else assert(sz >= offsetof(TyArr,a) + (((ia<<arrTypeBitsLog(type))+7)>>3));
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
// Log of width in bits: max of 7, and also return 7 if not power of 2
|
// Log of width in bits: max of 7, and also return 7 if not power of 2
|
||||||
SHOULD_INLINE u8 multWidthLog(usz n, u8 lw) { // Of n elements, 1<<lw bit
|
SHOULD_INLINE u8 multWidthLog(usz n, u8 lw) { // Of n elements, 1<<lw bit
|
||||||
|
|||||||
@ -109,9 +109,7 @@ NOINLINE bool fillEqualF(B w, B x) { // doesn't consume; both args must be array
|
|||||||
|
|
||||||
B withFill(B x, B fill) { // consumes both
|
B withFill(B x, B fill) { // consumes both
|
||||||
assert(isArr(x));
|
assert(isArr(x));
|
||||||
#if DEBUG
|
if (DEBUG) validateFill(fill);
|
||||||
validateFill(fill);
|
|
||||||
#endif
|
|
||||||
u8 xt = TY(x);
|
u8 xt = TY(x);
|
||||||
if (noFill(fill) && xt!=t_fillarr && xt!=t_fillslice) return x;
|
if (noFill(fill) && xt!=t_fillarr && xt!=t_fillslice) return x;
|
||||||
switch(xt) {
|
switch(xt) {
|
||||||
|
|||||||
11
src/h.h
11
src/h.h
@ -21,6 +21,9 @@
|
|||||||
#ifndef RANDSEED
|
#ifndef RANDSEED
|
||||||
#define RANDSEED 0
|
#define RANDSEED 0
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef DEBUG
|
||||||
|
#define DEBUG 0
|
||||||
|
#endif
|
||||||
#ifndef FFI
|
#ifndef FFI
|
||||||
#define FFI 2
|
#define FFI 2
|
||||||
#ifndef CBQN_EXPORT
|
#ifndef CBQN_EXPORT
|
||||||
@ -655,16 +658,12 @@ static inline B inc(B x) {
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
static inline void decG(B x) {
|
static inline void decG(B x) {
|
||||||
#if DEBUG
|
if (DEBUG) assert(isVal(x) && v(x)->refc>0);
|
||||||
assert(isVal(x) && v(x)->refc>0);
|
|
||||||
#endif
|
|
||||||
Value* vx = v(x);
|
Value* vx = v(x);
|
||||||
if(!--vx->refc) value_free(vx);
|
if(!--vx->refc) value_free(vx);
|
||||||
}
|
}
|
||||||
FORCE_INLINE void ptr_decT(Arr* x) { // assumes argument is an array and consists of non-heap-allocated elements
|
FORCE_INLINE void ptr_decT(Arr* x) { // assumes argument is an array and consists of non-heap-allocated elements
|
||||||
#if DEBUG
|
if (DEBUG) assert(x->refc>0);
|
||||||
assert(x->refc>0);
|
|
||||||
#endif
|
|
||||||
if (x->refc==1) TIv(x,freeT)((Value*) x);
|
if (x->refc==1) TIv(x,freeT)((Value*) x);
|
||||||
else x->refc--;
|
else x->refc--;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,9 +95,7 @@ enum {
|
|||||||
void gc_onVisit(Value* x) {
|
void gc_onVisit(Value* x) {
|
||||||
switch (visit_mode) { default: UD;
|
switch (visit_mode) { default: UD;
|
||||||
case GC_DEC_REFC:
|
case GC_DEC_REFC:
|
||||||
#if DEBUG
|
if (DEBUG && x->refc==0) fatal("decrementing refc 0");
|
||||||
if(x->refc==0) fatal("decrementing refc 0");
|
|
||||||
#endif
|
|
||||||
x->refc--;
|
x->refc--;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user