swh:1:snp:4ac4ed834489429d51fc0fd004f10ddbf78d807a
Raw File
Tip revision: 55778ad8b99c136e1886959c1f1333c776df14e1 authored by Giuseppe Attardi on 15 May 1997, 06:24:54 UTC
1.8 -
Tip revision: 55778ad
patch-2
diff -c cmm/ChangeLog /project/posso/cmm/cmm/ChangeLog
*** cmm/ChangeLog	Wed Dec 18 20:57:31 1996
--- /project/posso/cmm/cmm/ChangeLog	Wed Dec 18 14:01:55 1996
***************
*** 1,15 ****
- Wed Dec 18 17:07:57 1996  Giuseppe Attardi  <attardi@omega>
- 
- 	* cmm.cpp (CmmInit): heap rounding requires cast to (Word) for
-         usage with mmap.
- 
  Wed Dec 18 12:02:09 1996  Pietro Iglio  <iglio@di.unipi.it>
  
! 	* cmm.cpp (emptyStableSpace): check for empty queue
! 	* test7.cpp (class Item): added public to CmmObject
  
  Sun Dec 15 20:04:45 1996  Giuseppe Attardi  <attardi@omega>
! 
  	* msw.cpp (mswAlloc, mswAllocOpaque): added casts:
  	*(Byte *)(freeList-1) = TransparentMask;
  	*(Byte *)(ret-2) = OpaqueMask
--- 1,10 ----
  Wed Dec 18 12:02:09 1996  Pietro Iglio  <iglio@di.unipi.it>
  
! 	* Fixed bug in cmm.cpp:emptyStableSpace()
! 	* Changed test7.cpp such that it can be compiled with gcc 2.7
  
  Sun Dec 15 20:04:45 1996  Giuseppe Attardi  <attardi@omega>
! 	
  	* msw.cpp (mswAlloc, mswAllocOpaque): added casts:
  	*(Byte *)(freeList-1) = TransparentMask;
  	*(Byte *)(ret-2) = OpaqueMask
diff -c cmm/cmm.cpp /project/posso/cmm/cmm/cmm.cpp
*** cmm/cmm.cpp	Wed Dec 18 21:22:12 1996
--- /project/posso/cmm/cmm/cmm.cpp	Wed Dec 18 13:41:34 1996
***************
*** 550,556 ****
    globalHeapStart = heap;
  #endif
    heap = heap + bytesPerPage - 1;
!   heap -= (Word)heap % bytesPerPage;
    firstHeapPage = GCPtoPage(heap);
    lastHeapPage = firstHeapPage + heapSpanPages - 1;
    firstTablePage = lastHeapPage + 1;
--- 550,556 ----
    globalHeapStart = heap;
  #endif
    heap = heap + bytesPerPage - 1;
!   heap -= (long)heap % bytesPerPage;
    firstHeapPage = GCPtoPage(heap);
    lastHeapPage = firstHeapPage + heapSpanPages - 1;
    firstTablePage = lastHeapPage + 1;
***************
*** 584,589 ****
--- 584,594 ----
    /* Initialize tables */
    for (i = firstHeapPage ; i <= lastHeapPage ; i++)
      pageHeap[i] = NOHEAP;
+ 
+ # ifdef _WIN32
+   pageLink[0] = 0;	// _WIN32 malloc does not clear. Needed for expandHeap
+ # endif
+ 
    fromSpace = UNALLOCATEDSPACE + 1;
    nextSpace = fromSpace;
    firstFreePage = firstHeapPage;
***************
*** 686,692 ****
    inc_heap = ::new char[inc_totalPages*bytesPerPage + bytesPerPage - 1];
    if (inc_heap == NULL) goto fail;
    inc_heap = inc_heap + bytesPerPage - 1;
!   inc_heap -= (Word)inc_heap % bytesPerPage;
    inc_firstHeapPage = GCPtoPage(inc_heap);
    inc_lastHeapPage = inc_firstHeapPage + inc_totalPages - 1;
    new_firstHeapPage = MIN(firstHeapPage,
--- 691,697 ----
    inc_heap = ::new char[inc_totalPages*bytesPerPage + bytesPerPage - 1];
    if (inc_heap == NULL) goto fail;
    inc_heap = inc_heap + bytesPerPage - 1;
!   inc_heap -= (int)inc_heap % bytesPerPage;
    inc_firstHeapPage = GCPtoPage(inc_heap);
    inc_lastHeapPage = inc_firstHeapPage + inc_totalPages - 1;
    new_firstHeapPage = MIN(firstHeapPage,
***************
*** 806,823 ****
   * -- emptyStableSpace
   *
   * Moves the pages in StableSpace, up to end, into the FromSpace.
!  * A total collection is performed by calling this before calling collect().
!  * When generational collection is not desired, this is called after
!  * collection to empty the StableSpace.
   *
   *---------------------------------------------------------------------------*/
  
  static void
  emptyStableSpace(page end)
  {
    page scan;
-   if (queueHead == 0)		// happens in test3
-     return;
    end = pageLink[end];
    while (queueHead != end)
      {
--- 811,828 ----
   * -- emptyStableSpace
   *
   * Moves the pages in StableSpace, up to end, into the FromSpace.
!  * A total collection is performed by calling this before calling
!  * collect().  When generational collection is not desired, this is called
!  * after collection to empty the StableSpace.
   *
   *---------------------------------------------------------------------------*/
  
  static void
  emptyStableSpace(page end)
  {
+   if (queueHead == 0) return;
+ 
    page scan;
    end = pageLink[end];
    while (queueHead != end)
      {
***************
*** 877,884 ****
      {
  #     ifdef MARKING
        CmmObject *bp = basePointer(cp);
!       page = GCPtoPage(bp);
!       if (OUTSIDE_HEAPS(page))
  	return;
        MARK(bp);
  #     endif
--- 882,889 ----
      {
  #     ifdef MARKING
        CmmObject *bp = basePointer(cp);
!       unsigned bpp = GCPtoPage(bp);
!       if (OUTSIDE_HEAPS(bpp))
  	return;
        MARK(bp);
  #     endif
diff -c cmm/cmm.h /project/posso/cmm/cmm/cmm.h
*** cmm/cmm.h	Wed Dec 18 17:35:47 1996
--- /project/posso/cmm/cmm/cmm.h	Sun Dec 15 19:40:02 1996
***************
*** 132,157 ****
  
     Arrays of collected objects
     ---------------------------
!    Class CmmArray can be used to create arrays of CmmObject's as follows.
!    To create an array of objects of class Item, overload the new() operator
!    for class Item:
!   
!   	void*
!   	Item::operator new[](size_t size)
!   	{
!   	  return sizeof(size_t) + (char*)new(size) CmmArray<Item>;
!   	}
!   
!    Then you can create arrays of Item normally, for instance:
!   
!   	Item* anArrayOfItems = new Item[20];
!   
!    The constructor for class Item with no argument will be called for
!    each Item in the array.
!    Such arrays can be used normally, e.g.:
!   
!   	anArrayOfItems[i].print();
!   	Item anItem = anArrayOfItems[3];
  
     Caveats
     -------
--- 132,142 ----
  
     Arrays of collected objects
     ---------------------------
!    Garbage collected arrays of garbage collected objects can be created
!    by using class CmmArray.
!    Such arrays must be always used through references, e.g.:
! 
! 	CmmArray<MyClass> & MyVector = * new (100) CmmArray<MyClass>;
  
     Caveats
     -------
***************
*** 699,705 ****
  
  /*---------------------------------------------------------------------------*
   *
!  * -- CmmObject
   *
   *---------------------------------------------------------------------------*/
  
--- 684,690 ----
  
  /*---------------------------------------------------------------------------*
   *
!  * -- CmmObjects
   *
   *---------------------------------------------------------------------------*/
  
***************
*** 758,771 ****
  #endif
  };
  
- /*---------------------------------------------------------------------------*
-  *
-  * -- CmmVarObject
-  *
-  * Collectable objects of variable size.
-  *
-  *---------------------------------------------------------------------------*/
- 
  class CmmVarObject: public CmmObject
  {
  public:
--- 743,748 ----
***************
*** 775,780 ****
--- 752,777 ----
  /*---------------------------------------------------------------------------*
   *
   * -- Arrays of CmmObjects
+  *
+  * Class CmmArray can be used to create arrays of CmmObject's as follows.
+  * To create an array of objects of class Item, overload the new() operator
+  * for class Item:
+  *
+  *	void*
+  *	Item::operator new[](size_t size)
+  *	{
+  *	  return sizeof(size_t) + (char*)new(size) CmmArray<Item>;
+  *	}
+  *
+  * Then you can create and use array of Item normally, for instance:
+  *
+  *	Item* anArrayOfItems = new Item[20];
+  *
+  * The constructor for class Item with no argument will be called for
+  * each Item in the array.
+  *
+  *	anArrayOfItems[i].print();
+  *	Item anItem = anArrayOfItems[3];
   *
   *---------------------------------------------------------------------------*/
  
Common subdirectories: cmm/doc and /project/posso/cmm/cmm/doc
diff -c cmm/msw.cpp /project/posso/cmm/cmm/msw.cpp
*** cmm/msw.cpp	Wed Dec 18 20:45:17 1996
--- /project/posso/cmm/cmm/msw.cpp	Sun Dec 15 21:59:10 1996
***************
*** 1470,1476 ****
  	    assert(*(bp-1) == OpaqueMask ||
  		   *(bp-1) == TransparentMask);
  
! 	    if (*(Byte *)(bp-1) == OpaqueMask)
  	      continue;
  
  	    mswMarkFromTo((GCP)(bp+1),
--- 1470,1476 ----
  	    assert(*(bp-1) == OpaqueMask ||
  		   *(bp-1) == TransparentMask);
  
! 	    if (*(bp-1) == OpaqueMask)
  	      continue;
  
  	    mswMarkFromTo((GCP)(bp+1),
***************
*** 1547,1553 ****
        assert(*(bp-1) == OpaqueMask ||
  	     *(bp-1) == TransparentMask);
  		
!       if (*(Byte *)(bp-1) == OpaqueMask)
  	continue;
  		
        MarkStackPush((GCP)(bp+1));
--- 1547,1553 ----
        assert(*(bp-1) == OpaqueMask ||
  	     *(bp-1) == TransparentMask);
  		
!       if (*(bp-1) == OpaqueMask)
  	continue;
  		
        MarkStackPush((GCP)(bp+1));
***************
*** 2592,2599 ****
  	firstObjOff = FPagesInfo[size].firstObjOffset;
  
  	for (p = page + firstObjOff; p <= hi; p += size1) {
! 	  assert(*(Byte *)(p-1) == TransparentMask
! 		 || *(Byte *)(p-1) == OpaqueMask);
  	  assert(*p == AllocMask || *p == FreeMask);
  	  if (*p == AllocMask)
  	    allocatedObjs += 1;
--- 2592,2598 ----
  	firstObjOff = FPagesInfo[size].firstObjOffset;
  
  	for (p = page + firstObjOff; p <= hi; p += size1) {
! 	  assert(*(p-1) == TransparentMask || *(p-1) == OpaqueMask);
  	  assert(*p == AllocMask || *p == FreeMask);
  	  if (*p == AllocMask)
  	    allocatedObjs += 1;
diff -c cmm/test2.cpp /project/posso/cmm/cmm/test2.cpp
*** cmm/test2.cpp	Tue Dec 17 11:37:30 1996
--- /project/posso/cmm/cmm/test2.cpp	Sun Nov 24 18:52:34 1996
***************
*** 79,84 ****
  	    abort();
  	  }
  	  cl = cl->next;
! 	}
  	return 0;
  }
--- 79,84 ----
  	    abort();
  	  }
  	  cl = cl->next;
! 	}
  	return 0;
  }
diff -c cmm/test3.cpp /project/posso/cmm/cmm/test3.cpp
*** cmm/test3.cpp	Tue Dec 17 11:37:45 1996
--- /project/posso/cmm/cmm/test3.cpp	Sat Nov 23 21:13:48 1996
***************
*** 42,48 ****
  	    0, 1, CMM_GCTHRESHOLD, CMM_FLAGS, 0);
  }
  
! void
  main(int argc, char* argv[])
  {
  	block  *lp = NULL;
--- 42,48 ----
  	    0, 1, CMM_GCTHRESHOLD, CMM_FLAGS, 0);
  }
  
! void
  main(int argc, char* argv[])
  {
  	block  *lp = NULL;
diff -c cmm/test7.cpp /project/posso/cmm/cmm/test7.cpp
*** cmm/test7.cpp	Wed Dec 18 20:56:47 1996
--- /project/posso/cmm/cmm/test7.cpp	Wed Dec 18 13:41:52 1996
***************
*** 9,15 ****
  
  int count = 0;
  
! class Item : public CmmObject
  {
  public:
    Item  *car;
--- 9,15 ----
  
  int count = 0;
  
! class Item : public CmmObject 
  {
  public:
    Item  *car;
back to top