shithub: MicroHs

Download patch

ref: 22433437b17a4da9f0681c8e89afa64caa0d9f21
parent: 342c800869083b1419676b84868021d7c5651937
author: Lennart Augustsson <lennart@augustsson.net>
date: Sat Sep 16 19:45:47 EDT 2023

Turn GCRED back on

--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -8,7 +8,7 @@
 #include <locale.h>
 #include <ctype.h>
 
-#define GCRED    0              /* do some reductions during GC */
+#define GCRED    1              /* do some reductions during GC */
 #define FASTTAGS 1              /* compute tag by pointer subtraction */
 #define UNIONPTR 1              /* use compact (2 pointer) layout */
 #define INTTABLE 1              /* use fixed table of small INT nodes */
@@ -489,6 +489,8 @@
 int red_a, red_k, red_i, red_int;
 #endif
 
+counter_t mark_depth;
+
 /* Mark all used nodes reachable from *np */
 void
 mark(NODEPTR *np)
@@ -498,6 +500,9 @@
   value_t i;
 #endif
 
+  mark_depth++;
+  if (mark_depth % 10000 == 0)
+    printf("mark depth %"PRIcounter"\n", mark_depth);
   top:
   n = *np;
   if (GETTAG(n) == T_IND) {
@@ -522,6 +527,7 @@
     *np = n;
   }
   if (is_marked_used(n)) {
+    mark_depth--;
     return;
   }
   num_marked++;
@@ -565,10 +571,16 @@
 #endif  /* INTTABLE */
 #endif  /* GCRED */
   if (GETTAG(n) == T_AP) {
+#if 1
     mark(&FUN(n));
     //mark(&ARG(n));
     np = &ARG(n);
     goto top;                   /* Avoid tail recursion */
+#else
+    mark(&ARG(n));
+    np = &FUN(n);
+    goto top;                   /* Avoid tail recursion */
+#endif
   }
 }
 
@@ -586,6 +598,7 @@
     fprintf(stderr, "gc mark\n");
   gc_mark_time -= gettime();
   mark_all_free();
+  mark_depth = 0;
   for (stackptr_t i = 0; i <= stack_ptr; i++)
     mark(&stack[i]);
   t = gettime();
--