shithub: MicroHs

Download patch

ref: be3a0829300690150ee2aa9b1a448308df7ad485
parent: 0125e893e3b551c7bb47b91599d682e7bc7fd9ad
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Mon Jan 22 06:30:34 EST 2024

Change how AP and INDIR are counted.  Use a macro for stats counters.

--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -115,6 +115,10 @@
 #define NORETURN __attribute__ ((noreturn))
 #endif /* !defined(NORETURN) */
 
+#if !defined(COUNT)
+#define COUNT(n) ++(n)
+#endif
+
 value_t
 iswindows(void)
 {
@@ -270,7 +274,7 @@
 struct ioarray *array_root = 0;
 
 counter_t num_reductions = 0;
-counter_t num_alloc;
+counter_t num_alloc = 0;
 counter_t num_gc = 0;
 uintptr_t gc_mark_time = 0;
 uintptr_t run_time = 0;
@@ -476,7 +480,7 @@
   next_scan_index = pos;
 
   SETTAG(n, t);
-  num_alloc++;
+  COUNT(num_alloc);
   num_free--;
   return n;
 }
@@ -2192,7 +2196,7 @@
     int sz;
     char *res;
 
-    num_reductions++;
+    COUNT(num_reductions);
 #if FASTTAGS
     l = LABEL(n);
     tag = l < T_IO_BIND ? l : GETTAG(n);
@@ -2201,11 +2205,9 @@
 #endif  /* FASTTAGS */
     switch (tag) {
     ind:
-      num_reductions++;
     case T_IND:  n = INDIR(n); break;
 
     ap:
-      num_reductions++;
     case T_AP:   PUSH(n); n = FUN(n); break;
 
     case T_STR:  RET;
@@ -2567,7 +2569,7 @@
  execute:
   PUSH(n);
   for(;;) {
-    num_reductions++;
+    COUNT(num_reductions);
     //printf("execute switch %s\n", tag_names[GETTAG(n)]);
     switch (GETTAG(n)) {
     case T_IND:
--