Raw File
patch-5
diff -c /home/omega/attardi/posso/cmm/ChangeLog /project/posso/cmm/curr/cmm/ChangeLog
*** /home/omega/attardi/posso/cmm/ChangeLog	Fri Nov  7 19:45:55 1997
--- /project/posso/cmm/curr/cmm/ChangeLog	Thu Nov  6 12:29:15 1997
***************
*** 1,22 ****
- Fri Nov  7 10:40:42 1997  Giuseppe Attardi  <attardi@omega>
- 
- 	* cmm.cpp (verifyHeader): fixed to deal with SCANNED pages.
- 
- 	* cmm.cpp (promotionPhase): scan only objects in pages in transparent
- 	heaps; scan every address in opaque heaps.
- 
- 	* cmm.cpp (logRoot): use basePointer() instead of nextObject().
- 
- 	* test1.cpp, test5.cpp: added version using FIELDTABLE
- 
- 	* cmm.h, cmm.cpp, machine.h: port to MacIntosh for Metrowerks C++
- 	contributed by Patrick C. Beard <beard@apple.com>
- 
- 	* cmm.prj: project file for MacIntosh for Metrowerks CodeWarrior Pro
- 
- 	* cmm.cpp (traverse): version based on FieldTable contributed by
- 	Patrick C. Beard
- 
  Wed Nov  5 10:17:36 1997  Giuseppe Attardi  <attardi@omega>
  
  	* msw.cpp: unsigned long -> size_t
--- 1,3 ----
diff -c /home/omega/attardi/posso/cmm/Copyright /project/posso/cmm/curr/cmm/Copyright
*** /home/omega/attardi/posso/cmm/Copyright	Fri Nov  7 10:40:22 1997
--- /project/posso/cmm/curr/cmm/Copyright	Mon Sep  8 12:17:20 1997
***************
*** 51,58 ****
  
  Contributors:
  
! 	Uttam M. Narsu	  <narsu@styx.hks.com>
! 	Pietro Iglio	  <iglio@di.unipi.it>
! 	Hans J. Boehm	  <boehm@mti.sgi.com>
! 	Christian Heckler <chh@plato.uni-paderborn.de>
! 	Patrick C. Beard  <beard@apple.com>
--- 51,57 ----
  
  Contributors:
  
! 	Uttam M. Narsu	<narsu@styx.hks.com>
! 	Pietro Iglio	<iglio@di.unipi.it>
! 	Hans J. Boehm	<boehm@mti.sgi.com>
! 	Christian Heckler <chh@plato.uni-paderborn.de>
\ No newline at end of file
Only in /home/omega/attardi/posso/cmm: Parallel
diff -c /home/omega/attardi/posso/cmm/README /project/posso/cmm/curr/cmm/README
*** /home/omega/attardi/posso/cmm/README	Fri Nov  7 10:39:52 1997
--- /project/posso/cmm/curr/cmm/README	Tue Dec  3 19:32:22 1996
***************
*** 265,276 ****
  Tito Flagella,	tito@di.unipi.it
  Pietro Iglio, iglio@di.unipi.it
  
- Patrick C. Beard <beard@apple.com> contributed the MacIntosh port.
- Hans J. Boehm <boehm@mti.sgi.com> provided useful suggestion and some machine
- specific code from his collector.
- Christian Heckler <chh@plato.uni-paderborn.de> contributed the parallel version
- for Solaris threads as well as various bug fixes.
- Uttam M. Narsu <narsu@styx.hks.com> contributed the SGI port.
- 
  Carlo Traverso and John Abbott contributed useful hints.
  Joachim Hollman gave precious feedback on the first implementation of CMM.
--- 265,269 ----
diff -c /home/omega/attardi/posso/cmm/cmm.cpp /project/posso/cmm/curr/cmm/cmm.cpp
*** /home/omega/attardi/posso/cmm/cmm.cpp	Fri Nov  7 19:52:54 1997
--- /project/posso/cmm/curr/cmm/cmm.cpp	Thu Nov  6 10:35:37 1997
***************
*** 54,60 ****
  
  /* Version tag */
  
! char*  Cmm::version = "CMM 1.9e";
  
  /*---------------------------------------------------------------------------*
   *
--- 54,60 ----
  
  /* Version tag */
  
! char*  Cmm::version = "CMM 1.9d";
  
  /*---------------------------------------------------------------------------*
   *
***************
*** 283,289 ****
   * --  Roots
   *
   * Roots explicitely registered with the garbage collector are contained in
!  * the following structure, allocated from the uncollected heap.
   *
   *---------------------------------------------------------------------------*/
  
--- 283,289 ----
   * --  Roots
   *
   * Roots explicitely registered with the garbage collector are contained in
!  * the following structure, allocated from the non-garbage collected heap.
   *
   *---------------------------------------------------------------------------*/
  
***************
*** 406,433 ****
      return false;
  }
  
- #ifdef FIELDTABLE
- void
- CmmObject::traverse()
- {
-   CmmHeap* heap = Cmm::heap;
-   CmmFieldTable& table = getFieldTable();
-   int count = table.count;
-   CmmFieldPtr* fields = table.fields;
-   for (int i = 0; i < count; i++)
-     {
-       CmmFieldPtr fp = fields[i];
-       heap->scavenge(&(this->*fp));
-     }
- }
- 
- CmmFieldTable&
- CmmObject::getFieldTable()
- {
-   static CmmFieldTable emptyTable = { 0, NULL };
-   return emptyTable;
- }
- #endif
  
  #if !HEADER_SIZE
  /*
--- 406,411 ----
***************
*** 553,559 ****
    if (stackBottom == 0)
      {
        CmmSetStackBottom((Word)&i);
! #     ifdef SBRK
        /* Determine start of system heap				*/
        globalHeapStart = sbrk(0);
  #     endif
--- 531,537 ----
    if (stackBottom == 0)
      {
        CmmSetStackBottom((Word)&i);
! #     ifndef _WIN32
        /* Determine start of system heap				*/
        globalHeapStart = sbrk(0);
  #     endif
***************
*** 623,629 ****
    objectIDmax = ID_INC;
    stats = ::new char[objectIDmax];
    bzero(stats, objectIDmax);
! #endif // CMM_ID
  
    /* Log actual heap parameters if from environment or logging */
    if ((environmentValue("CMM_MINHEAP", Cmm::minHeap)
--- 601,607 ----
    objectIDmax = ID_INC;
    stats = ::new char[objectIDmax];
    bzero(stats, objectIDmax);
! #endif CMM_ID
  
    /* Log actual heap parameters if from environment or logging */
    if ((environmentValue("CMM_MINHEAP", Cmm::minHeap)
***************
*** 1369,1394 ****
       collected heap for possible pointers */
    WHEN_VERBOSE (CMM_ROOTLOG, fprintf(stderr, "stack roots:\n"));
  
!   void CmmExamineArea(GCP, GCP);
  
    /* Examine the stack:		*/
    register GCP fp;
    Word sp;
  
  # ifdef STACK_GROWS_DOWNWARD
!   CmmExamineArea((GCP)&sp+1, (GCP)stackBottom);
  # else
!   CmmExamineArea((GCP)stackBottom, (GCP)&sp-1);
  # endif
  
    /* Examine the static areas:		*/
    WHEN_VERBOSE (CMM_ROOTLOG,
  		fprintf(stderr, "Static and registered roots:\n"));
  
!   CmmExamineStaticAreas(CmmExamineArea);
  
    /* Examine registered roots:		*/
-   /* Actually shouldn't these be just scavenged? Beppe */
    RootArea* ra;
    for (roots.begin(); ra = roots.get(); )
      {
--- 1347,1375 ----
       collected heap for possible pointers */
    WHEN_VERBOSE (CMM_ROOTLOG, fprintf(stderr, "stack roots:\n"));
  
!   void CmmExamineStaticArea(GCP, GCP);
  
    /* Examine the stack:		*/
    register GCP fp;
    Word sp;
  
  # ifdef STACK_GROWS_DOWNWARD
!   for (fp = (GCP)(&sp+1); fp < (GCP)stackBottom; fp++)
  # else
!     for (fp = (GCP)(&sp-1); fp > (GCP)stackBottom; fp--)
  # endif
+       {
+ 	WHEN_VERBOSE (CMM_ROOTLOG, logRoot(fp));
+ 	promotePage((GCP)*fp);
+       }
  
    /* Examine the static areas:		*/
    WHEN_VERBOSE (CMM_ROOTLOG,
  		fprintf(stderr, "Static and registered roots:\n"));
  
!   CmmExamineStaticAreas(CmmExamineStaticArea);
  
    /* Examine registered roots:		*/
    RootArea* ra;
    for (roots.begin(); ra = roots.get(); )
      {
***************
*** 1397,1403 ****
  	promotePage((GCP)*fp++);
      }
  
!   /* Examine the uncollected and other heaps:		*/
    if (Cmm::flags & CMM_HEAPROOTS)
      {
        WHEN_VERBOSE (CMM_HEAPLOG,
--- 1378,1385 ----
  	promotePage((GCP)*fp++);
      }
  
!   /* Examine the uncollected heap:		*/
!   /* Should scan all opaque heaps		*/
    if (Cmm::flags & CMM_HEAPROOTS)
      {
        WHEN_VERBOSE (CMM_HEAPLOG,
***************
*** 1406,1443 ****
        fp = (GCP)globalHeapStart;
        while (fp < globalHeapEnd)
  	{
! 	  if (inside((GCP)fp))
! 	    fp = fp + wordsPerPage; // skip page
! 	  else
  	    {
! 	      Page page = GCPtoPage(fp);
! 	      if (!OUTSIDE_HEAPS(page)
! 		  && !pageHeap[page]->isOpaque()
! 		  && IS_OBJECT(fp))
! 		{
! 		  // page belongs to a transparent heap,
! 		  // scan only objects in that page
! 		  for (int n = ((CmmObject*)fp)->words(); n > 0; n--)
! 		    promotePage((GCP)*fp++);
! 		}
! 	      else
! 		{
! 		  WHEN_VERBOSE (CMM_HEAPLOG, logRoot(fp));
! 		  promotePage((GCP)*fp);
! 		  fp++;
! 		}
  	    }
  	}
      }
  }
  
  void
! CmmExamineArea(GCP base, GCP limit)
  {
    register GCP fp;
    for (fp = base ; fp < limit ; fp++)
      {
!       WHEN_VERBOSE (CMM_ROOTLOG, if (*fp) logRoot(fp));
        promotePage((GCP)*fp);
      }
  }
--- 1388,1412 ----
        fp = (GCP)globalHeapStart;
        while (fp < globalHeapEnd)
  	{
! 	  if (!inside((GCP)fp))
  	    {
! 	      WHEN_VERBOSE (CMM_HEAPLOG, logRoot(fp));
! 	      promotePage((GCP)*fp);
! 	      fp++;
  	    }
+ 	  else
+ 	    fp = fp + wordsPerPage; // skip page
  	}
      }
  }
  
  void
! CmmExamineStaticArea(GCP base, GCP limit)
  {
    register GCP fp;
    for (fp = base ; fp < limit ; fp++)
      {
!       WHEN_VERBOSE (CMM_ROOTLOG, logRoot(fp));
        promotePage((GCP)*fp);
      }
  }
***************
*** 2012,2029 ****
      int  pages = HEADER_PAGES(cp[-HEADER_SIZE]);
  #   else
      int pages = pageGroup[page];
  #   endif
      Page pagex = pagen;
-     short space = pageSpace[pagen+1];
- #   ifdef MARKING
-     if (pageSpace[pagen] != space && !SCANNED(pagen))
-       goto fail;
- #   endif
      while (--pages)  {
        pagex++;
        if (pagex > lastHeapPage  ||
  	  pageGroup[pagex] > 0  ||
! 	  pageSpace[pagex] != space)
  	goto fail;
      }
    }
--- 1981,1994 ----
      int  pages = HEADER_PAGES(cp[-HEADER_SIZE]);
  #   else
      int pages = pageGroup[page];
+     if (pages < 0) pages = pageGroup[page+pages];
  #   endif
      Page pagex = pagen;
      while (--pages)  {
        pagex++;
        if (pagex > lastHeapPage  ||
  	  pageGroup[pagex] > 0  ||
! 	  pageSpace[pagex] != pageSpace[pagen])
  	goto fail;
      }
    }
***************
*** 2058,2075 ****
        || inFreeSpace(page))
      return;
  
!   GCP bp = (GCP)basePointer((GCP)*fp);
!   page = GCPtoPage(bp);
!   if (!OUTSIDE_HEAPS(page))
!     fprintf(stderr,
! 	    "***** DefaultHeap::alloc  root&: 0x%x  object&: 0x%x  %s\n",
! 	    fp, bp,
  # if HEADER_SIZE
! 	    HEADER_TAG(*bp)
  # else
! 	    *bp
  # endif
! 	    );
  }
  
  /* Output a newline to stderr if logging is enabled. */
--- 2023,2047 ----
        || inFreeSpace(page))
      return;
  
!   int pages = pageGroup[page];
! 
!   if (pages < 0) page += pages;
! 
!   GCP  p1, p2 = pageToGCP(page);
! 
!   while (p2 < (GCP)fp)
!     {
!       p1 = p2;
!       p2 = nextObject(p2);
!     }
!   fprintf(stderr, "***** DefaultHeap::alloc  root&: 0x%x  object&: 0x%x  %s\n",
! 	  fp, p1,
  # if HEADER_SIZE
! 	  HEADER_TAG(*p1)
  # else
! 	  *p1
  # endif
! 	  );
  }
  
  /* Output a newline to stderr if logging is enabled. */
diff -c /home/omega/attardi/posso/cmm/cmm.h /project/posso/cmm/curr/cmm/cmm.h
*** /home/omega/attardi/posso/cmm/cmm.h	Fri Nov  7 10:10:10 1997
--- /project/posso/cmm/curr/cmm/cmm.h	Sat Oct 18 23:10:24 1997
***************
*** 672,679 ****
    Page lastReservedPage;	// last page used by this Heap
  
  private:
!   void promotionPhase();
!   void compactionPhase();
    static GCP move(GCP);
  
  #ifndef NO_SCAN_OPT
--- 672,679 ----
    Page lastReservedPage;	// last page used by this Heap
  
  private:
!   void DefaultHeap::promotionPhase();
!   void DefaultHeap::compactionPhase();
    static GCP move(GCP);
  
  #ifndef NO_SCAN_OPT
***************
*** 715,740 ****
   *
   *---------------------------------------------------------------------------*/
  
- #ifdef FIELDTABLE
- typedef CmmObject* (CmmObject::*CmmFieldPtr);
- 
- struct CmmFieldTable {
- 	int count;
- 	CmmFieldPtr* fields;
- };
- #endif
- 
  class CmmObject
  {
  public:
  
! # ifdef FIELDTABLE
!   virtual CmmFieldTable& getFieldTable();
!   virtual void traverse();
! #else
!   virtual void traverse() {};
! # endif
!   virtual ~CmmObject() {};
  
    CmmHeap *heap() { return pageHeap[GCPtoPage(this)]; }
  
--- 715,727 ----
   *
   *---------------------------------------------------------------------------*/
  
  class CmmObject
  {
  public:
  
!   virtual void traverse() {} ;
! 
!   virtual ~CmmObject() {} ;
  
    CmmHeap *heap() { return pageHeap[GCPtoPage(this)]; }
  
Only in /home/omega/attardi/posso/cmm: cmm.prj
Common subdirectories: /home/omega/attardi/posso/cmm/doc and /project/posso/cmm/curr/cmm/doc
diff -c /home/omega/attardi/posso/cmm/machine.h /project/posso/cmm/curr/cmm/machine.h
*** /home/omega/attardi/posso/cmm/machine.h	Fri Nov  7 09:51:58 1997
--- /project/posso/cmm/curr/cmm/machine.h	Sun Oct 19 12:38:08 1997
***************
*** 86,104 ****
  # define MAX(a,b) (((a)>(b))?(a):(b))
  #endif
  
! #if defined(__svr4__) || defined(_WIN32) || defined(macintosh)
  # define _setjmp(x)  setjmp(x)
  # define _longjmp(x,y) longjmp(x,y)
  #endif
  
! #if !defined(__BORLANDC__) && !defined(_WIN32) && !defined(macintosh)
  # include <unistd.h>	// extern C_LANG void* sbrk(int);
  #endif
  
- #if !defined(_WIN32) && !defined(macintosh)
- # define SBRK
- #endif
- 
  /*---------------------------------------------------------------------------*
   *
   * Stack growth
--- 86,100 ----
  # define MAX(a,b) (((a)>(b))?(a):(b))
  #endif
  
! #if defined(__svr4__) || defined(_WIN32)
  # define _setjmp(x)  setjmp(x)
  # define _longjmp(x,y) longjmp(x,y)
  #endif
  
! #if !defined(__BORLANDC__) && !defined(_WIN32)
  # include <unistd.h>	// extern C_LANG void* sbrk(int);
  #endif
  
  /*---------------------------------------------------------------------------*
   *
   * Stack growth
***************
*** 208,218 ****
  	 */
  #   define DATASTART ((((unsigned long)(&etext)) + 0x3fffff) & ~0x3fffff) \
  		      + ((unsigned long)&etext & 0x1fff)
- #elif defined(macintosh)
- 	// etc. etc.
- #	include <LowMem.h>
- #	define STACKBOTTOM ((unsigned long) LMGetCurStackBase())
- #	define CMM_VERBOSE
  #else
      /* The default case works only for contiguous text and data, such as
       * on a Vax.                                                           */
--- 204,209 ----
diff -c /home/omega/attardi/posso/cmm/memory.cpp /project/posso/cmm/curr/cmm/memory.cpp
*** /home/omega/attardi/posso/cmm/memory.cpp	Fri Nov  7 09:53:55 1997
--- /project/posso/cmm/curr/cmm/memory.cpp	Mon Sep  8 12:09:00 1997
***************
*** 239,262 ****
      (*ExamineArea)((GCP)base, (GCP)limit);
  }
  
- #elif defined(macintosh)
- 
- #include <Memory.h>
- 
- void *
- getGlobalHeapEnd()
- {
- 	/* PCB:  this is an upper limit. */
- 	THz applicationHeap = ApplicationZone();
- 	return (void*)applicationHeap->bkLim;		/* PCB:  end of the application heap is as far as it goes. */
- }
- 
- void CmmExamineStaticAreas(void (*ExamineArea)(GCP, GCP))
- {
- 	extern char __data_start__[], __data_end__[];
- 	(*ExamineArea)((GCP)&__data_start__, (GCP)&__data_end__);
- }
- 
  #else
  
  void *
--- 239,244 ----
diff -c /home/omega/attardi/posso/cmm/msw.cpp /project/posso/cmm/curr/cmm/msw.cpp
*** /home/omega/attardi/posso/cmm/msw.cpp	Fri Nov  7 17:26:13 1997
--- /project/posso/cmm/curr/cmm/msw.cpp	Thu Nov  6 12:36:19 1997
***************
*** 1519,1524 ****
--- 1519,1525 ----
  	  case PAGE_Fixed:
  
  	    header = (PageHeader) PAGE_START(p);
+ 
  	    bp = GET_OBJ_BASE(p, header);
  
  	    /* Consider only allocated objs not marked. */
diff -c /home/omega/attardi/posso/cmm/test1.cpp /project/posso/cmm/curr/cmm/test1.cpp
*** /home/omega/attardi/posso/cmm/test1.cpp	Fri Nov  7 10:18:50 1997
--- /project/posso/cmm/curr/cmm/test1.cpp	Sun Oct 19 11:56:18 1997
***************
*** 3,8 ****
--- 3,9 ----
  /* Externals */
  
  #include <stdio.h>
+ #include <stdlib.h>
  #include "cmm.h"
  
  #define	VECT_SIZE	1000
***************
*** 13,37 ****
    cell  *cdr;
    int  value;
    cell(cell *initcar, cell *initcdr, int initvalue);
! #ifdef FIELDTABLE
!   CmmFieldTable& getFieldTable()
!     {
!       static CmmFieldPtr fields[] = { CmmFieldPtr(&cell::car),
! 				      CmmFieldPtr(&cell::cdr) };
!       static CmmFieldTable table = { 2, fields };
!       return table;
!     }
! #else
!   void traverse()
!     {
!       CmmHeap *heap = Cmm::heap;
!       heap->scavenge((CmmObject **)&car);
!       heap->scavenge((CmmObject **)&cdr);
!     }
! #endif
  };
  
  typedef  cell* CP;
  
  cell::cell(cell *initcar, cell *initcdr, int initvalue)
  {
--- 14,31 ----
    cell  *cdr;
    int  value;
    cell(cell *initcar, cell *initcdr, int initvalue);
!   void traverse();
  };
  
  typedef  cell* CP;
+ 
+ void cell::traverse()  
+ {
+   CmmHeap *heap = Cmm::heap;
+   heap->scavenge((CmmObject **)&car);
+   heap->scavenge((CmmObject **)&cdr);
+ }
+ 
  
  cell::cell(cell *initcar, cell *initcdr, int initvalue)
  {
diff -c /home/omega/attardi/posso/cmm/test5.cpp /project/posso/cmm/curr/cmm/test5.cpp
*** /home/omega/attardi/posso/cmm/test5.cpp	Fri Nov  7 12:19:27 1997
--- /project/posso/cmm/curr/cmm/test5.cpp	Wed Sep 17 18:14:44 1997
***************
*** 17,40 ****
    int  value;
    cell();
    cell(cell *initcar, cell *initcdr, int initvalue);
! #ifdef FIELDTABLE
!   CmmFieldTable& getFieldTable()
!     {
!       static CmmFieldPtr fields[] = { CmmFieldPtr(&cell::car),
!                                       CmmFieldPtr(&cell::cdr) };
!       static CmmFieldTable table = { 2, fields };
!       return table;
!     }
! #else
!   void traverse()
!     {
!       CmmHeap *heap = Cmm::heap;
!       heap->scavenge(CmmRefLoc(cell, car));
!       heap->scavenge(CmmRefLoc(cell, cdr));
!     }
! #endif
  };
  
  
  cell::cell(cell *initcar, cell *initcdr, int initvalue)
    : car(*initcar), cdr(*initcdr), value(initvalue)
--- 17,31 ----
    int  value;
    cell();
    cell(cell *initcar, cell *initcdr, int initvalue);
!   void traverse();
  };
  
+ void cell::traverse()  
+ {
+   CmmHeap *heap = Cmm::heap;
+   heap->scavenge(CmmRefLoc(cell, car));
+   heap->scavenge(CmmRefLoc(cell, cdr));
+ }
  
  cell::cell(cell *initcar, cell *initcdr, int initvalue)
    : car(*initcar), cdr(*initcdr), value(initvalue)
back to top