Next update to gc-malloc.c

Bernie Solomon bernard at UG.EDS.COM
Tue Apr 22 08:08:23 PDT 1997


I have tried to build a JIT version of 0.8.4 on Alpha/Digital Unix 4.0
(which seems to work much better than 0.8.3) but somehow its trying to
allocate a ridiculous amount of memory and gc-malloc.c mishandles out of
heap. I have updated my diffs to this file (includes yesterdays) to
cope. At the same time I have suppressed a couple of warnings gcc was
giving owing to 64 bit pointers. 

I'd also say that the algorithm gc-malloc.c is using may be fast but it
can be pretty wasteful of memory.

Bernie

sdlhpp5% diff -c ~/orig-kaffe-0.8.4/kaffe/kaffevm/gc-malloc.c
master/kaffe/kaffevm
*** /users/bernard/orig-kaffe-0.8.4/kaffe/kaffevm/gc-malloc.c   Fri Apr
18 15:58:33 1997
--- master/kaffe/kaffevm/gc-malloc.c    Tue Apr 22 15:40:46 1997
***************
*** 62,68 ****
  #endif
  
  static void morecore();
- static int findbucket();
  
  /*
   * The overhead on a block is at least 4 bytes.  When free, this space
--- 62,67 ----
***************
*** 178,184 ****
        gcHeaptop = gcHeapbase + heapsize;
  
        op = (union overhead *)gcHeapptr;
!       n = n - sizeof (*op) - ((int)op & (n - 1));
        if (n < 0) {
                n += pagesz;
        }
--- 177,183 ----
        gcHeaptop = gcHeapbase + heapsize;
  
        op = (union overhead *)gcHeapptr;
!       n = n - sizeof (*op) - ((unsigned long)op & (n - 1));
        if (n < 0) {
                n += pagesz;
        }
***************
*** 215,221 ****
                amt = 16;       /* size of first bucket */
                bucket = 1;
  #endif
!               n = -(sizeof (*op) + RSLOP);
        } else {
                amt = pagesz;
                bucket = pagebucket;
--- 214,220 ----
                amt = 16;       /* size of first bucket */
                bucket = 1;
  #endif
!               n = -(int)(sizeof (*op) + RSLOP);
        } else {
                amt = pagesz;
                bucket = pagebucket;
***************
*** 287,293 ****
        }
        op = (union overhead *)gcheap_sbrk(amt);
        /* no more room! */
!       if ((int)op == -1)
                return;
        /*
         * Add new memory allocated to that on
--- 286,292 ----
        }
        op = (union overhead *)gcheap_sbrk(amt);
        /* no more room! */
!       if (op == NULL)
                return;
        /*
         * Add new memory allocated to that on
***************
*** 298,303 ****
--- 297,303 ----
                op->ov_next = (union overhead *)((caddr_t)op + sz);
                op = (union overhead *)((caddr_t)op + sz);
        }
+         op->ov_next = NULL;
  }
  
  void
***************
*** 326,353 ****
  #ifdef MSTATS
        nmalloc[size]--;
  #endif
- }
- 
- /*
-  * Search ``srchlen'' elements of each free list for a block whose
-  * header starts at ``freep''.  If srchlen is -1 search the whole
list.
-  * Return bucket number, or -1 if not found.
-  */
- static
- findbucket(union overhead* freep, int srchlen)
- {
-       register union overhead *p;
-       register int i, j;
- 
-       for (i = 0; i < NBUCKETS; i++) {
-               j = 0;
-               for (p = nextf[i]; p && j != srchlen; p = p->ov_next) {
-                       if (p == freep)
-                               return (i);
-                       j++;
-               }
-       }
-       return (-1);
  }
  
  #ifdef MSTATS
--- 326,331 ----
-- 
Bernie Solomon (bernard at edsug.com or Bernard.Solomon at acm.org)
Unigraphics Architecture, EDS-Unigraphics, Cambridge, UK



More information about the kaffe mailing list