made bittable dynamic
authorceriel <none@none>
Thu, 16 Jun 1988 13:24:10 +0000 (13:24 +0000)
committerceriel <none@none>
Thu, 16 Jun 1988 13:24:10 +0000 (13:24 +0000)
mach/proto/as/comm0.h
mach/proto/as/comm1.h
mach/proto/as/comm4.c
mach/proto/as/comm7.c

index d828685..10b223e 100644 (file)
@@ -26,7 +26,6 @@
 
 /* table sizes */
 #define        STRINGMAX       200     /* <= 256 */
-#define        BITMAX          2000    /* for short or long branches */
 #define        SECTMAX         64
 #define        NAMEMAX         80
 #define        MEMINCR         2048
index f917bde..1a2029b 100644 (file)
@@ -78,9 +78,11 @@ extern short hashindex;      /* see item_search() */
 extern item_t  *fb_ptr[4*FB_SIZE];
 
 #ifdef THREE_PASS
-extern char    bittab[BITMAX>>3];
-                               /* one bit per small-large decision */
-extern long    nbits;          /* number of decisions so far */
+#define BITCHUNK       (8 * MEMINCR)
+extern int     nbits;
+extern int     bitindex;       /* bitindex * MEMINCR * 8 + nbits gives
+                                  number of decisions so far
+                               */
 #endif
 
 #ifdef LISTING
index 802f694..cc1a68b 100644 (file)
@@ -139,6 +139,11 @@ char **argv;
        register nfile = 0;
 #endif
 
+#ifdef THREE_PASS
+       bitindex = -1;
+       nbits = BITCHUNK;
+#endif
+
        tempfile = fftemp(temppath, "asTXXXXXX");
 #ifdef LISTING
        listmode = dflag;
@@ -384,7 +389,8 @@ pass_23(n)
        listeoln = 1;
 #endif
 #ifdef THREE_PASS
-       nbits = 0;
+       bitindex = -1;
+       nbits = BITCHUNK;
 #endif
        for (i = 0; i < FB_SIZE; i++)
                fb_ptr[FB_FORW+i] = fb_ptr[FB_HEAD+i];
index 774b022..8c854fb 100644 (file)
@@ -172,6 +172,9 @@ listline(textline)
 /* ---------- code optimization ---------- */
 
 #ifdef THREE_PASS
+#define PBITTABSZ      128
+static char *pbittab[PBITTABSZ];
+
 small(fitsmall, gain)
 {
        register bit;
@@ -181,16 +184,32 @@ small(fitsmall, gain)
                nosect();
        if (bflag)
                return(0);
-       if (nbits == BITMAX) {
-               static int w_given;
-               if (pass == PASS_1 && ! w_given) {
-                       w_given = 1;
-                       warning("bit table overflow");
+       if (nbits == BITCHUNK) {
+               bitindex++;
+               nbits = 0;
+               if (bitindex == PBITTABSZ) {
+                       static int w_given;
+                       if (pass == PASS_1 && ! w_given) {
+                               w_given = 1;
+                               warning("bit table overflow");
+                       }
+                       return(0);
                }
-               return(0);
+               if (pbittab[bitindex] == 0 && pass == PASS_1) {
+                       if ((pbittab[bitindex] = malloc(MEMINCR)) == 0) {
+                               static int w2_given;
+
+                               if (!w2_given) {
+                                       w2_given = 1;
+                                       warning("out of space for bit table");
+                               }
+                       }
+               }
+               if (pbittab[bitindex] == 0)
+                       return (0);
        }
-       p = &bittab[(int) (nbits>>3)];
-       bit = 1 << ((int)nbits&7);
+       bit = 1 << (nbits&7);
+       p = pbittab[bitindex]+(nbits>>3);
        nbits++;
        switch (pass) {
        case PASS_1: