shithub: MicroHs

Download patch

ref: 489502a3de33da67f5125b21da3ca21098fd83b4
parent: 75709603d6582d9e824d5f5cd85294fc4d2a7375
author: Lennart Augustsson <lennart@augustsson.net>
date: Mon Feb 26 05:44:10 EST 2024

Shortcut some BININT stuff when already evaluated.

--- a/README.md
+++ b/README.md
@@ -138,6 +138,7 @@
 * `-CR` read compilation cache from `.mhscache` at the start of compilation
 * `-C` short for `-CW` and `-CR`
 * `-T` generate dynamic function usage statistics
+* `-z` compress combinator code generated in the `.c` file
 * `-XCPP` run `cpphs` on source files
 * `-Dxxx` passed to `cpphs`
 
--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -2402,7 +2402,14 @@
   case T_UGT:
   case T_UGE:
     n = ARG(TOP(1));
-    PUSH(combBININT2);
+    if (GETTAG(n) == T_INT) {
+      n = ARG(TOP(0));
+      PUSH(combBININT1);
+      if (GETTAG(n) == T_INT)
+        goto binint1;
+    } else {
+      PUSH(combBININT2);
+    }
     goto top;
   case T_NEG:
   case T_INV:
@@ -2636,6 +2643,7 @@
       if (GETTAG(n) != T_INT)
         ERR("BININT 0");
 #endif  /* SANITY */
+    binint1:
       xu = (uvalue_t)GETVALUE(n);
       /* Second argument */
       y = ARG(TOP(2));
--