on master help sign in
Add -DIDRIS_ENABLE_STATS to CodegenC. Add missing #ifdef IDRIS_ENABLED_STATS in rts/idris_gc.c.
035e15bstepcut
config.mk+1
@@ -1,6 +1,7 @@
1CC ?=cc
1CC ?=cc
2CABAL :=cabal
2CABAL :=cabal
3# IDRIS_ENABLE_STATS should not be set in final release
3# IDRIS_ENABLE_STATS should not be set in final release
4+# Any flags defined here which alter the RTS API must also be added to src/IRTS/CodegenC.hs
4CFLAGS :=-O2 -Wall -DHAS_PTHREAD -DIDRIS_ENABLE_STATS $(CFLAGS)
5CFLAGS :=-O2 -Wall -DHAS_PTHREAD -DIDRIS_ENABLE_STATS $(CFLAGS)
5
6
6#CABALFLAGS :=
7#CABALFLAGS :=
rts/idris_gc.c+3−1
@@ -151,7 +151,9 @@ void idris_gcInfo(VM* vm, int doGC) {
151 printf("Final heap use %d\n", (int)(vm->heap.next - vm->heap.heap));
151 printf("Final heap use %d\n", (int)(vm->heap.next - vm->heap.heap));
152 if (doGC) { idris_gc(vm); }
152 if (doGC) { idris_gc(vm); }
153 printf("Final heap use after GC %d\n", (int)(vm->heap.next - vm->heap.heap));
153 printf("Final heap use after GC %d\n", (int)(vm->heap.next - vm->heap.heap));
154−
154+#ifdef IDRIS_ENABLE_STATS
155 printf("Total allocations %d\n", vm->stats.allocations);
155 printf("Total allocations %d\n", vm->stats.allocations);
156+#endif
156 printf("Number of collections %d\n", vm->stats.collections);
157 printf("Number of collections %d\n", vm->stats.collections);
158+
157}
159}
src/IRTS/CodegenC.hs+2−1
@@ -67,7 +67,8 @@ codegenC' defs out exec incs objs libs flags dbg
67 let gcc = comp ++ " " ++
67 let gcc = comp ++ " " ++
68 gccDbg dbg ++ " " ++
68 gccDbg dbg ++ " " ++
69 gccFlags ++
69 gccFlags ++
70+ -- # Any flags defined here which alter the RTS API must also be added to config.mk
70− " -DHAS_PTHREAD " ++
71+ " -DHAS_PTHREAD -DIDRIS_ENABLE_STATS" ++
71 " -I. " ++ objs ++ " -x c " ++
72 " -I. " ++ objs ++ " -x c " ++
72 (if (exec == Executable) then "" else " -c ") ++
73 (if (exec == Executable) then "" else " -c ") ++
73 " " ++ tmpn ++
74 " " ++ tmpn ++