https://github.com/Unipisa/CMM
Tip revision: 55778ad8b99c136e1886959c1f1333c776df14e1 authored by Giuseppe Attardi on 15 May 1997, 06:24:54 UTC
1.8 -
1.8 -
Tip revision: 55778ad
patch-1
diff -c cmm/ChangeLog /project/posso/cmm/cmm/ChangeLog
*** cmm/ChangeLog Sun Dec 15 20:51:13 1996
--- /project/posso/cmm/cmm/ChangeLog Mon Dec 2 09:20:49 1996
***************
*** 1,32 ****
- 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
-
- * machine.h: changed basic types:
- typedef char * Ptr;
- typedef Ptr * GCP;
-
- * msw.cpp: added various fixes by Iglio
-
- Sun Dec 8 13:57:08 1996 Giuseppe Attardi <attardi@omega>
-
- * cmm.cpp (promotePage): added test OUTSIDE_HEAPS before MARK.
- Was causing failure in test4 with new MSW initialization.
-
- * cmm.h: revised mechanism for CmmArray.
- Arrays of CmmObject's can be created and used with the standard
- syntax provided one overloads new[] for the class used for elements.
- Solution is dependent on GCC.
- test7 now works
-
- * test7.cpp (test): revised to use new mechanism.
-
- Tue Dec 3 19:31:53 1996 Giuseppe Attardi <attardi@omega>
-
- * README: added Win32 port
-
Mon Dec 2 09:20:32 1996 Giuseppe Attardi <attardi@omega>
* machine.h:
--- 1,3 ----
diff -c cmm/README /project/posso/cmm/cmm/README
*** cmm/README Tue Dec 3 19:32:22 1996
--- /project/posso/cmm/cmm/README Wed Oct 30 13:39:44 1996
***************
*** 49,58 ****
- SunOS 4.x
- Solaris 2.x
! - Linux 1.x, 2.x
- AIX (RS6000)
- SGI
- - Win32 (Windows 95, Windows NT)
but it should run without changes also on HPUX, NeXTOS and DOS (djgpp).
If you are interest in some other platforms you can send mail to
--- 49,57 ----
- SunOS 4.x
- Solaris 2.x
! - Linux 1.x
- AIX (RS6000)
- SGI
but it should run without changes also on HPUX, NeXTOS and DOS (djgpp).
If you are interest in some other platforms you can send mail to
diff -c cmm/cmm.cpp /project/posso/cmm/cmm/cmm.cpp
*** cmm/cmm.cpp Sun Dec 15 20:10:22 1996
--- /project/posso/cmm/cmm/cmm.cpp Thu Nov 28 09:54:28 1996
***************
*** 56,62 ****
/* Version tag */
! char* Cmm::version = "CMM 1.8.1";
/*---------------------------------------------------------------------------*
*
--- 56,62 ----
/* Version tag */
! char* Cmm::version = "CMM 1.8";
/*---------------------------------------------------------------------------*
*
***************
*** 71,77 ****
static int heapSpanPages; /* # of pages that span the heap */
int freePages; /* # of pages not yet allocated */
static int freeWords = 0; /* # words left on the current page */
! static Ptr *firstFreeWord; /* Ptr to the first free word on the current
page */
page firstFreePage; /* First possible free page */
static page queueHead; /* Head of list of stable set of pages */
--- 71,77 ----
static int heapSpanPages; /* # of pages that span the heap */
int freePages; /* # of pages not yet allocated */
static int freeWords = 0; /* # words left on the current page */
! static long *firstFreeWord; /* Ptr to the first free word on the current
page */
page firstFreePage; /* First possible free page */
static page queueHead; /* Head of list of stable set of pages */
***************
*** 238,248 ****
#if HEADER_SIZE
static int freeSpaceTag = MAKE_TAG(0);
# ifdef DOUBLE_ALIGN
! static Ptr doublepad = MAKE_HEADER(1, MAKE_TAG(1));
#define HEADER_ALIGN(firstFreeWord, freeWords) \
if ((freeWords & 1) == 0 && freeWords) { \
*firstFreeWord++ = doublepad; \
! freeWords--; \
}
# endif // DOUBLE_ALIGN
#endif // HEADER_SIZE
--- 238,248 ----
#if HEADER_SIZE
static int freeSpaceTag = MAKE_TAG(0);
# ifdef DOUBLE_ALIGN
! static int doublepad = MAKE_HEADER(1, MAKE_TAG(1));
#define HEADER_ALIGN(firstFreeWord, freeWords) \
if ((freeWords & 1) == 0 && freeWords) { \
*firstFreeWord++ = doublepad; \
! freeWords = freeWords - 1; \
}
# endif // DOUBLE_ALIGN
#endif // HEADER_SIZE
***************
*** 546,554 ****
"\n****** CMM Unable to allocate %d byte heap\n", Cmm::minHeap);
abort();
}
- #ifdef _WIN32
globalHeapStart = heap;
- #endif
heap = heap + bytesPerPage - 1;
heap -= (long)heap % bytesPerPage;
firstHeapPage = GCPtoPage(heap);
--- 546,552 ----
***************
*** 558,564 ****
pageSpace = (short *)pageToGCP(firstTablePage);
pageGroup = &pageSpace[totalPages];
! pageLink = (page *)&pageGroup[totalPages];
pageHeap = (CmmHeap **)&pageLink[totalPages];
objectMap = (unsigned long *)&pageHeap[totalPages];
# if !HEADER_SIZE || defined(MARKING)
--- 556,562 ----
pageSpace = (short *)pageToGCP(firstTablePage);
pageGroup = &pageSpace[totalPages];
! pageLink = (unsigned *)&pageGroup[totalPages];
pageHeap = (CmmHeap **)&pageLink[totalPages];
objectMap = (unsigned long *)&pageHeap[totalPages];
# if !HEADER_SIZE || defined(MARKING)
***************
*** 771,777 ****
new_pageGroup[i] = pageGroup[i];
}
for (i = WORD_INDEX(firstHeapPage*bytesPerPage);
! i < WORD_INDEX((lastHeapPage + 1)*bytesPerPage); i++)
{
new_objectMap[i] = objectMap[i];
#if !HEADER_SIZE || defined(MARKING)
--- 769,775 ----
new_pageGroup[i] = pageGroup[i];
}
for (i = WORD_INDEX(firstHeapPage*bytesPerPage);
! (unsigned)i < WORD_INDEX((lastHeapPage + 1)*bytesPerPage); i++)
{
new_objectMap[i] = objectMap[i];
#if !HEADER_SIZE || defined(MARKING)
***************
*** 871,884 ****
// Don't promote pages belonging to other heaps.
// (We noticed no benefit by inlining the following test in the caller)
if (page >= firstHeapPage
! && page <= lastHeapPage
&& pageHeap[page] == Cmm::theDefaultHeap)
{
# ifdef MARKING
CmmObject *bp = basePointer(cp);
- unsigned bpp = GCPtoPage(bp);
- if (OUTSIDE_HEAPS(bpp))
- return;
MARK(bp);
# endif
if (inFromSpace(page))
--- 869,879 ----
// Don't promote pages belonging to other heaps.
// (We noticed no benefit by inlining the following test in the caller)
if (page >= firstHeapPage
! && page <= lastHeapPage
&& pageHeap[page] == Cmm::theDefaultHeap)
{
# ifdef MARKING
CmmObject *bp = basePointer(cp);
MARK(bp);
# endif
if (inFromSpace(page))
***************
*** 959,965 ****
int page = GCPtoPage(cp); /* Page number */
GCP np; /* Pointer to the new object */
# if HEADER_SIZE
! Ptr header; /* Object header */
# endif
/* Verify that the object is a valid pointer and decrement ptr cnt */
--- 954,960 ----
int page = GCPtoPage(cp); /* Page number */
GCP np; /* Pointer to the new object */
# if HEADER_SIZE
! int header; /* Object header */
# endif
/* Verify that the object is a valid pointer and decrement ptr cnt */
***************
*** 1017,1023 ****
SET_OBJECTMAP(np);
freeWords = freeWords - words;
# if HEADER_SIZE
! cp[-HEADER_SIZE] = (Ptr)np; // lowest bit 0 means forwarded
words -= HEADER_SIZE;
while (words--) *firstFreeWord++ = *cp++;
# ifdef DOUBLE_ALIGN
--- 1012,1018 ----
SET_OBJECTMAP(np);
freeWords = freeWords - words;
# if HEADER_SIZE
! cp[-HEADER_SIZE] = (int)np; // lowest bit 0 means forwarded
words -= HEADER_SIZE;
while (words--) *firstFreeWord++ = *cp++;
# ifdef DOUBLE_ALIGN
***************
*** 1054,1060 ****
GCP p = (GCP)basePointer((GCP)*loc);
page = GCPtoPage(p);
! if (inside(p)) // in this heap
{
if (inFromSpace(page)) // can be moved
*loc = (CmmObject *)((int)CmmMove(p) + (int)*loc - (int)p);
--- 1049,1055 ----
GCP p = (GCP)basePointer((GCP)*loc);
page = GCPtoPage(p);
! if (inside(p)) // in this heap
{
if (inFromSpace(page)) // can be moved
*loc = (CmmObject *)((int)CmmMove(p) + (int)*loc - (int)p);
***************
*** 1070,1076 ****
)
((CmmObject *)p)->traverse();
}
! # endif // MARKING
}
else if (!OUTSIDE_HEAPS(page)
// if page is OUTSIDE_HEAPS, p must be an ambiguous pointer
--- 1065,1071 ----
)
((CmmObject *)p)->traverse();
}
! # endif // MARKING
}
else if (!OUTSIDE_HEAPS(page)
// if page is OUTSIDE_HEAPS, p must be an ambiguous pointer
***************
*** 1609,1619 ****
{
extern int end;
if (
! # ifdef _WIN32
! printf("in text?\n") &&
! # else
! obj >= (void *)(&end) &&
! # endif
# ifdef STACK_GROWS_DOWNWARD
obj < (void *)(&obj)
# else
--- 1604,1614 ----
{
extern int end;
if (
! # ifdef _WIN32
! printf("in text?\n") &&
! # else
! obj >= (void *)(&end) &&
! # endif
# ifdef STACK_GROWS_DOWNWARD
obj < (void *)(&obj)
# else
***************
*** 1678,1684 ****
{
delete obj;
}
! #endif // _WIN32
/*---------------------------------------------------------------------------*
*
* CmmVarObject::operator new
--- 1673,1679 ----
{
delete obj;
}
! #endif // _WIN32
/*---------------------------------------------------------------------------*
*
* CmmVarObject::operator new
***************
*** 1688,1697 ****
void *
CmmVarObject::operator new(size_t size, size_t extraSize, CmmHeap *heap)
{
! GCP object = heap->alloc(size + extraSize);
! // To avoid problems in GC after new() but during constructor
*object = *((GCP)aCmmVarObject);
return (void *)object;
--- 1683,1693 ----
void *
CmmVarObject::operator new(size_t size, size_t extraSize, CmmHeap *heap)
{
+ size += extraSize;
! GCP object = heap->alloc(size);
! // To avoid problems in GC after new but during constructor
*object = *((GCP)aCmmVarObject);
return (void *)object;
diff -c cmm/cmm.h /project/posso/cmm/cmm/cmm.h
*** cmm/cmm.h Sun Dec 15 19:40:02 1996
--- /project/posso/cmm/cmm/cmm.h Sun Dec 1 11:03:10 1996
***************
*** 381,392 ****
#if HEADER_SIZE
#define MAKE_TAG(index) ((index) << 21 | 1)
! #define MAKE_HEADER(words, tag) (Ptr)((tag) | (words) << 1)
! #define HEADER_TAG(header) ((unsigned long)(header) >> 21 & 0x7FF)
! #define HEADER_WORDS(header) ((unsigned long)(header) >> 1 & 0xFFFFF) // includes HEADER_SIZE
#define maxHeaderWords 0xFFFFF /* 1048575 = 4,194,300 bytes */
! #define FORWARDED(header) (((unsigned long)(header) & 1) == 0)
#else
/* an object is forwarded if it is marked as live and contained in FromSpace */
#define FORWARDED(gcp) ((MARKED(gcp) && inFromSpace(GCPtoPage(gcp))))
--- 381,392 ----
#if HEADER_SIZE
#define MAKE_TAG(index) ((index) << 21 | 1)
! #define MAKE_HEADER(words, tag) ((tag) | (words) << 1)
! #define HEADER_TAG(header) ((header) >> 21 & 0x7FF)
! #define HEADER_WORDS(header) ((header) >> 1 & 0xFFFFF) // includes HEADER_SIZE
#define maxHeaderWords 0xFFFFF /* 1048575 = 4,194,300 bytes */
! #define FORWARDED(header) (((header) & 1) == 0)
#else
/* an object is forwarded if it is marked as live and contained in FromSpace */
#define FORWARDED(gcp) ((MARKED(gcp) && inFromSpace(GCPtoPage(gcp))))
***************
*** 641,647 ****
int stablePages; // # of pages in the stable set
page firstUnusedPage; // where to start looking for unused pages
page firstReservedPage; // first page used by this Heap
! page lastReservedPage; // last page used by this Heap
};
/*---------------------------------------------------------------------------*
--- 641,647 ----
int stablePages; // # of pages in the stable set
page firstUnusedPage; // where to start looking for unused pages
page firstReservedPage; // first page used by this Heap
! page lastReservedPage; // last page used by this Heap
};
/*---------------------------------------------------------------------------*
***************
*** 726,732 ****
#if !HEADER_SIZE
MARK(this);
#endif
! ((GCP)this)[-HEADER_SIZE] = (Ptr)ptr;
}
inline CmmObject *getForward()
{
--- 726,732 ----
#if !HEADER_SIZE
MARK(this);
#endif
! ((GCP)this)[-HEADER_SIZE] = (int)ptr;
}
inline CmmObject *getForward()
{
***************
*** 735,793 ****
inline CmmObject *next() {return (CmmObject *)(((GCP)this) + words()); }
void* operator new(size_t, CmmHeap* = Cmm::heap);
! void operator delete(void*);
#ifndef _WIN32
! void* operator new[](size_t size, CmmHeap* = Cmm::heap);
! void operator delete[](void*);
#endif
};
class CmmVarObject: public CmmObject
{
public:
! void* operator new(size_t, size_t = 0, CmmHeap* = Cmm::heap);
};
/*---------------------------------------------------------------------------*
*
* -- 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];
- *
*---------------------------------------------------------------------------*/
template <class T>
class CmmArray : public CmmObject
{
public:
! void* operator new(size_t s1, size_t s2, CmmHeap* heap = Cmm::heap)
{
! return heap->alloc(s2);
}
~CmmArray()
{
size_t i;
for (i = 1; i < count; ++i)
ptr[i].~T();
}
--- 735,802 ----
inline CmmObject *next() {return (CmmObject *)(((GCP)this) + words()); }
void* operator new(size_t, CmmHeap* = Cmm::heap);
! void operator delete(void *);
#ifndef _WIN32
! void* operator new[](size_t size, CmmHeap *heap = Cmm::heap);
! void operator delete[](void* obj);
#endif
};
class CmmVarObject: public CmmObject
{
public:
! void* operator new(size_t, size_t = (size_t)0, CmmHeap* = Cmm::heap);
};
/*---------------------------------------------------------------------------*
*
* -- Arrays of CmmObjects
*
*---------------------------------------------------------------------------*/
+ // Class CmmArray must be used to create arrays of CmmObject's as follows:
+ //
+ // CmmArray<MyClass> & MyVector = * new (100) CmmArray<MyClass> ;
+ //
+ // Then you can use the [] operator to get CmmObjects as usual.
+ // Ex:
+ // MyVector[i]->print();
+ // or:
+ // MyClass mc = MyVector[3];
+ //
+
template <class T>
class CmmArray : public CmmObject
{
public:
! void * operator new(size_t s1, size_t s2 = 0, CmmHeap* hz = Cmm::heap)
{
! // tito: allocate just s2-1, because the other one
! // is already in s1=sizeof(CmmArray<T>)
! size_t size = s1 + sizeof(T) * (s2-1);
! void* res = new (size, hz) CmmVarObject;
!
! // clear the array so that if collect is called during the execution of
! // this function, traverse will skip empty elements
! bzero((char*) &(((CmmArray<T> *)res)->ptr[0]), s2*sizeof(T));
!
! T* array = (T*)&(((CmmArray<T> *)res)->ptr[0]);
! // tito: array[0] should be already initialized by the compiler:
! // start from i=1.
! for (size_t i = 1; i < s2; i++)
! {
! size_t preserve = (size_t)&(((CmmArray<T> *)res)->ptr[i]);
! ::new (&(((CmmArray<T> *)res)->ptr[i])) T;
! }
! return res;
}
~CmmArray()
{
size_t i;
+ unsigned int count = ((size() - sizeof(CmmArray)) / sizeof(T)) + 1;
for (i = 1; i < count; ++i)
ptr[i].~T();
}
***************
*** 796,830 ****
void traverse()
{
! for (size_t i = 0; i < count; i++)
! ptr[i].traverse();
}
private:
! size_t count; // the __GNUC__ initializes it after new[]
! #ifdef DOUBLE_ALIGN
! size_t padding;
! #endif
! T ptr[0]; // avoid call to T constructor
};
-
- /*
- * This is supposedly correct, but produces
- * Internal compiler error 197
- * in gcc 2.7.2:
- *
- template <class T>
- void*
- T::operator new[](size_t size)
- {
- return sizeof(size_t) + (char*)new(size) CmmArray<T>;
- }
- */
/*---------------------------------------------------------------------------*/
inline void CmmHeap::
! visit(CmmObject* ptr)
{
#ifdef MARKING
if (!ptr->isMarked())
--- 805,824 ----
void traverse()
{
! unsigned int count = ((size() - sizeof(CmmArray)) / sizeof(T)) + 1;
! for (unsigned int i = 0; i < count; i++)
! if (((int*)ptr)[i])
! ptr[i].traverse();
}
private:
! T ptr[1];
};
/*---------------------------------------------------------------------------*/
inline void CmmHeap::
! visit(CmmObject *ptr)
{
#ifdef MARKING
if (!ptr->isMarked())
diff -c cmm/cmm.mak /project/posso/cmm/cmm/cmm.mak
*** cmm/cmm.mak Sun Dec 15 20:57:10 1996
--- /project/posso/cmm/cmm/cmm.mak Thu Nov 28 12:53:22 1996
***************
*** 193,201 ****
CLEAN :
-@erase ".\Release\cmm.lib"
-@erase ".\Release\memory.obj"
-@erase ".\Release\cmm.obj"
-@erase ".\Release\msw.obj"
- -@erase ".\Release\tempheap.obj"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
--- 193,201 ----
CLEAN :
-@erase ".\Release\cmm.lib"
-@erase ".\Release\memory.obj"
+ -@erase ".\Release\tempheap.obj"
-@erase ".\Release\cmm.obj"
-@erase ".\Release\msw.obj"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
***************
*** 237,245 ****
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/cmm.lib"
LIB32_OBJS= \
"$(INTDIR)/memory.obj" \
"$(INTDIR)/cmm.obj" \
! "$(INTDIR)/msw.obj" \
! "$(INTDIR)/tempheap.obj"
"$(OUTDIR)\cmm.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
--- 237,245 ----
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/cmm.lib"
LIB32_OBJS= \
"$(INTDIR)/memory.obj" \
+ "$(INTDIR)/tempheap.obj" \
"$(INTDIR)/cmm.obj" \
! "$(INTDIR)/msw.obj"
"$(OUTDIR)\cmm.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
***************
*** 266,274 ****
CLEAN :
-@erase ".\Debug\cmm.lib"
-@erase ".\Debug\memory.obj"
- -@erase ".\Debug\tempheap.obj"
-@erase ".\Debug\cmm.obj"
-@erase ".\Debug\msw.obj"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
--- 266,274 ----
CLEAN :
-@erase ".\Debug\cmm.lib"
-@erase ".\Debug\memory.obj"
-@erase ".\Debug\cmm.obj"
-@erase ".\Debug\msw.obj"
+ -@erase ".\Debug\tempheap.obj"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
***************
*** 310,318 ****
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/cmm.lib"
LIB32_OBJS= \
"$(INTDIR)/memory.obj" \
- "$(INTDIR)/tempheap.obj" \
"$(INTDIR)/cmm.obj" \
! "$(INTDIR)/msw.obj"
"$(OUTDIR)\cmm.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
--- 310,318 ----
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/cmm.lib"
LIB32_OBJS= \
"$(INTDIR)/memory.obj" \
"$(INTDIR)/cmm.obj" \
! "$(INTDIR)/msw.obj" \
! "$(INTDIR)/tempheap.obj"
"$(OUTDIR)\cmm.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
***************
*** 1424,1429 ****
--- 1424,1432 ----
# Begin Source File
SOURCE=.\test2.cpp
+
+ !IF "$(CFG)" == "test2 - Win32 Release"
+
DEP_CPP_TEST2=\
".\cmm.h"\
".\machine.h"\
***************
*** 1433,1438 ****
--- 1436,1453 ----
"$(INTDIR)\test2.obj" : $(SOURCE) $(DEP_CPP_TEST2) "$(INTDIR)"
+ !ELSEIF "$(CFG)" == "test2 - Win32 Debug"
+
+ DEP_CPP_TEST2=\
+ ".\cmm.h"\
+ ".\machine.h"\
+
+
+ "$(INTDIR)\test2.obj" : $(SOURCE) $(DEP_CPP_TEST2) "$(INTDIR)"
+
+
+ !ENDIF
+
# End Source File
# End Target
################################################################################
***************
*** 1469,1474 ****
--- 1484,1502 ----
# Begin Source File
SOURCE=.\test3.cpp
+
+ !IF "$(CFG)" == "test3 - Win32 Release"
+
+ DEP_CPP_TEST3=\
+ ".\cmm.h"\
+ ".\machine.h"\
+
+
+ "$(INTDIR)\test3.obj" : $(SOURCE) $(DEP_CPP_TEST3) "$(INTDIR)"
+
+
+ !ELSEIF "$(CFG)" == "test3 - Win32 Debug"
+
DEP_CPP_TEST3=\
".\cmm.h"\
".\machine.h"\
***************
*** 1478,1483 ****
--- 1506,1513 ----
"$(INTDIR)\test3.obj" : $(SOURCE) $(DEP_CPP_TEST3) "$(INTDIR)"
+ !ENDIF
+
# End Source File
# End Target
################################################################################
***************
*** 1514,1519 ****
--- 1544,1562 ----
# Begin Source File
SOURCE=.\test4.cpp
+
+ !IF "$(CFG)" == "test4 - Win32 Release"
+
+ DEP_CPP_TEST4=\
+ ".\cmm.h"\
+ ".\machine.h"\
+
+
+ "$(INTDIR)\test4.obj" : $(SOURCE) $(DEP_CPP_TEST4) "$(INTDIR)"
+
+
+ !ELSEIF "$(CFG)" == "test4 - Win32 Debug"
+
DEP_CPP_TEST4=\
".\cmm.h"\
".\machine.h"\
***************
*** 1523,1528 ****
--- 1566,1573 ----
"$(INTDIR)\test4.obj" : $(SOURCE) $(DEP_CPP_TEST4) "$(INTDIR)"
+ !ENDIF
+
# End Source File
# End Target
################################################################################
***************
*** 1559,1564 ****
--- 1604,1612 ----
# Begin Source File
SOURCE=.\test5.cpp
+
+ !IF "$(CFG)" == "test5 - Win32 Release"
+
DEP_CPP_TEST5=\
".\tempheap.h"\
".\cmm.h"\
***************
*** 1569,1574 ****
--- 1617,1635 ----
"$(INTDIR)\test5.obj" : $(SOURCE) $(DEP_CPP_TEST5) "$(INTDIR)"
+ !ELSEIF "$(CFG)" == "test5 - Win32 Debug"
+
+ DEP_CPP_TEST5=\
+ ".\tempheap.h"\
+ ".\cmm.h"\
+ ".\machine.h"\
+
+
+ "$(INTDIR)\test5.obj" : $(SOURCE) $(DEP_CPP_TEST5) "$(INTDIR)"
+
+
+ !ENDIF
+
# End Source File
# End Target
################################################################################
***************
*** 1609,1615 ****
".\tempheap.h"\
".\cmm.h"\
".\machine.h"\
- ".\msw.h"\
"$(INTDIR)\test6.obj" : $(SOURCE) $(DEP_CPP_TEST6) "$(INTDIR)"
--- 1670,1675 ----
Common subdirectories: cmm/doc and /project/posso/cmm/cmm/doc
diff -c cmm/msw.cpp /project/posso/cmm/cmm/msw.cpp
*** cmm/msw.cpp Sun Dec 15 21:59:10 1996
--- /project/posso/cmm/cmm/msw.cpp Sun Dec 1 11:07:27 1996
***************
*** 44,51 ****
* - MSW_CHECK_HEAP: perform automatic heap checking before/after every
* collection and tempHeap destruction.
* - MSW_SERIAL_DEBUG
! * - MSW_TRACE_ONE_PAGE
! * - MSW_DONT_TAG_FREE_MEM: when NDEBUG is on avoid filling with a tag
* each empty/released memory object.
*
* Other macros that can be defined at compile time:
--- 44,51 ----
* - MSW_CHECK_HEAP: perform automatic heap checking before/after every
* collection and tempHeap destruction.
* - MSW_SERIAL_DEBUG
! * - MSW_TRACE_ONE_PAGE
! * - MSW_DONT_TAG_FREE_MEM: when NDEBUG is on avoid filling with a tag
* each empty/released memory object.
*
* Other macros that can be defined at compile time:
***************
*** 196,201 ****
--- 196,202 ----
#define TransparentMask 0xbb
/* Page type: values for the page map */
+ #define PAGE_LONG_Free 0L
#define PAGE_Free 0x0
#define PAGE_Fixed 0x1
***************
*** 220,227 ****
* If there is an attempt of using a free memory object, it should be easy to
* understand if the mem obj has been released during a collection.
*/
! #define EMPTY_MEM_TAG 0xee
! #define RELEASED_MEM_TAG 0xdd
#define PAGE_START(ptr) (Ptr)((Word)(ptr) & ~(bytesPerPage - 1))
--- 221,228 ----
* If there is an attempt of using a free memory object, it should be easy to
* understand if the mem obj has been released during a collection.
*/
! #define EMPTY_MEM_TAG 0xdd
! #define RELEASED_MEM_TAG 0xee
#define PAGE_START(ptr) (Ptr)((Word)(ptr) & ~(bytesPerPage - 1))
***************
*** 255,262 ****
*/
#define pageMap pageLink
- // Max number of pages for a chunk (currently used for debugging only)
- #define MAX_CHUNK_PAGES 50000
/*---------------------------------------------------------------------------*
*
* :: Type Definitions
--- 256,261 ----
***************
*** 495,501 ****
freePage->allocatedObjs += 1;
*freeList = AllocMask;
! *(Byte *)(freeList-1) = TransparentMask;
// Following assignment is needed because subsequent call to
// mswAllocFPage might release completely "freePage".
--- 494,500 ----
freePage->allocatedObjs += 1;
*freeList = AllocMask;
! *(freeList-1) = TransparentMask;
// Following assignment is needed because subsequent call to
// mswAllocFPage might release completely "freePage".
***************
*** 531,537 ****
{
if (size < MaxFixedSize) {
Ptr ret = (Ptr)mswAlloc(size);
! *(Byte *)(ret-2) = OpaqueMask;
return ret;
}
else
--- 530,536 ----
{
if (size < MaxFixedSize) {
Ptr ret = (Ptr)mswAlloc(size);
! *(ret-2) = OpaqueMask;
return ret;
}
else
***************
*** 621,626 ****
--- 620,626 ----
{
Ptr newPages;
+ mswDEBUG(fprintf(gcOut, "Automatic gc call...\n"););
mswCollect();
/* Expand anyway if not found enough free pages */
***************
*** 643,649 ****
mswDEBUG(fprintf(gcOut, "Found enough pages after gc!\n"));
return newPages; /* <----------- */
}
! mswDEBUG(fprintf(gcOut, "[H]"));
return mswExpandHeap(nPages);
}
--- 643,650 ----
mswDEBUG(fprintf(gcOut, "Found enough pages after gc!\n"));
return newPages; /* <----------- */
}
! mswDEBUG(fprintf(gcOut,
! "Not found enough pages after gc! Expanding heap\n"));
return mswExpandHeap(nPages);
}
***************
*** 896,908 ****
PageHeader page;
if (realSize >= size) {
! /* Size of mixed objects must be updated because during
! * the mark phase we traverse only header->objSize bytes.
*/
! if (PAGE_INFO(p) == PAGE_Mixed) {
page = (PageHeader) PAGE_START(p);
page->objSize = size;
- }
return p; /* <---------- */
}
else {
--- 897,908 ----
PageHeader page;
if (realSize >= size) {
! /* Size of mixed objects must be updated because during mark
! * phase we traverse only header->objSize bytes.
*/
! if (PAGE_INFO(p) == PAGE_Mixed)
page = (PageHeader) PAGE_START(p);
page->objSize = size;
return p; /* <---------- */
}
else {
***************
*** 1367,1374 ****
{
int nPages = header->nPages;
- assert(nPages > 0 && nPages < MAX_CHUNK_PAGES);
-
mswPageMapSet((Ptr)header, nPages, PAGE_Free);
assert(tempHeapInfo == NULL);
// if (tempHeapInfo)
--- 1367,1372 ----
***************
*** 1631,1637 ****
assert(*(bp-1) == OpaqueMask ||
*(bp-1) == TransparentMask);
! if (*(Byte *)(bp-1) == OpaqueMask)
continue;
MarkStackPush(pt+1);
--- 1629,1635 ----
assert(*(bp-1) == OpaqueMask ||
*(bp-1) == TransparentMask);
! if (*(bp-1) == OpaqueMask)
continue;
MarkStackPush(pt+1);
***************
*** 1942,1950 ****
Word heapSize = (lastHeapPage - firstHeapPage) * bytesPerPage;
if (heapSize < (Word)Cmm::gcThreshold)
! ; // mswDEBUG(fprintf(gcOut, "heap size < gc threshold: skipping GC\n"));
else {
! mswDEBUG(fprintf(gcOut, "Calling GC...\n"););
mswCollectNow();
}
}
--- 1940,1949 ----
Word heapSize = (lastHeapPage - firstHeapPage) * bytesPerPage;
if (heapSize < (Word)Cmm::gcThreshold)
! mswDEBUG(fprintf(gcOut,
! "heap size < gc threshold: skipping GC\n"));
else {
! mswDEBUG(fprintf(gcOut, "-> GC request ACCEPTED.\n"););
mswCollectNow();
}
}
***************
*** 2084,2090 ****
for (ptr = (long*) obj + 1 + sizeof(Ptr);
ptr < (long*) obj + 1 + size; ptr++)
! promotePage((GCP)ptr);
}
} else if (pageInfo == PAGE_Mixed) {
long* ptr;
--- 2083,2089 ----
for (ptr = (long*) obj + 1 + sizeof(Ptr);
ptr < (long*) obj + 1 + size; ptr++)
! promotePage((GCP) ptr);
}
} else if (pageInfo == PAGE_Mixed) {
long* ptr;
***************
*** 2095,2101 ****
end = (long*) FirstObjOffset + 1 + header->objSize;
for (ptr = (long*) FirstObjOffset + 1; ptr < end; ptr++)
! promotePage((GCP)ptr);
}
}
--- 2094,2100 ----
end = (long*) FirstObjOffset + 1 + header->objSize;
for (ptr = (long*) FirstObjOffset + 1; ptr < end; ptr++)
! promotePage(ptr);
}
}
***************
*** 2335,2341 ****
const int pagesPerLine = 72;
fprintf(gcOut,
! "+++++ (T = Temporary, - = Permanent) ++++");
for (i = base; i < top; i++) {
if (j == 0) {
--- 2334,2340 ----
const int pagesPerLine = 72;
fprintf(gcOut,
! "+++++ (. = Free, # = Fixed, B/b = BigObj, O = Other) ++++");
for (i = base; i < top; i++) {
if (j == 0) {
***************
*** 2811,2841 ****
base = GET_OBJ_BASE(p, page);
fprintf(gcOut, "pointer base: %lx\n", base);
if (base == p) {
! fprintf(gcOut, "WARNING: the pointer points before the beginning of a fixed object!\n");
return;
}
- switch (*base) {
- case AllocMask:
- fprintf(gcOut, "STATE: allocated\n"); break;
- case MarkMask:
- fprintf(gcOut, "STATE: marked\n"); break;
- case FreeMask:
- fprintf(gcOut, "STATE: free\n"); break;
- default:
- fprintf(gcOut,
- "WARNING: STATE is not MarkMask | AllocMask | FreeMask! \n");
- break;
- }
- switch (*(base-1)) {
- case OpaqueMask:
- fprintf(gcOut, "Obj is OPAQUE \n"); break;
- case TransparentMask:
- fprintf(gcOut, "Obj is TRANSPARENT \n"); break;
- default:
- fprintf(gcOut,
- "WARNING: not registred as OPAQUE or TRANSPARENT! \n");
- break;
- }
break;
case PAGE_Next: {
int index;
--- 2810,2818 ----
base = GET_OBJ_BASE(p, page);
fprintf(gcOut, "pointer base: %lx\n", base);
if (base == p) {
! fprintf(gcOut, "WARNING: the pointer points before the start of the object!\n");
return;
}
break;
case PAGE_Next: {
int index;
***************
*** 2853,2859 ****
index -= 1;
assert(index > 0);
}
! p = (Ptr)pageToGCP(index);
goto LAB_PageMixed;
}
case PAGE_Mixed:
--- 2830,2836 ----
index -= 1;
assert(index > 0);
}
! p = pageToGCP(index);
goto LAB_PageMixed;
}
case PAGE_Mixed:
***************
*** 2925,2931 ****
Ptr
pageFromIndex(int index)
{
! return (Ptr)pageToGCP(index);
}
int
--- 2902,2908 ----
Ptr
pageFromIndex(int index)
{
! return pageToGCP(index);
}
int
diff -c cmm/test4.cpp /project/posso/cmm/cmm/test4.cpp
*** cmm/test4.cpp Sat Dec 7 07:03:28 1996
--- /project/posso/cmm/cmm/test4.cpp Sat Nov 23 12:54:44 1996
***************
*** 61,67 ****
Cmm dummy(CMM_MINHEAP, CMM_MAXHEAP, CMM_INCHEAP, 50, 45,
CMM_GCTHRESHOLD, CMM_FLAGS, 0);
!
void
main()
{
--- 61,67 ----
Cmm dummy(CMM_MINHEAP, CMM_MAXHEAP, CMM_INCHEAP, 50, 45,
CMM_GCTHRESHOLD, CMM_FLAGS, 0);
!
void
main()
{
diff -c cmm/test7.cpp /project/posso/cmm/cmm/test7.cpp
*** cmm/test7.cpp Sun Dec 8 16:56:07 1996
--- /project/posso/cmm/cmm/test7.cpp Sat Nov 23 12:54:16 1996
***************
*** 1,39 ****
- /*
- * Test for CmmArray
- */
- #include "cmm.h"
#include <stdio.h>
#include <stdlib.h>
- int count = 0;
! class Item : CmmObject
{
! public:
! Item *car;
! Item *cdr;
int value1;
! char bytes[bytesPerPage+2];
int value2;
! Item() { value1 = ++count; };
! Item(Item* x, Item* y, int v1, int v2);
void traverse();
- void *operator new[](size_t size);
};
! typedef Item* VP;
! void
! Item::traverse()
{
CmmHeap *heap = Cmm::heap;
heap->scavenge((CmmObject **)&car);
heap->scavenge((CmmObject **)&cdr);
}
! Item::Item(Item* x, Item* y, int v1, int v2)
{
car = x;
cdr = y;
--- 1,57 ----
+ #include "cmm.h"
#include <stdio.h>
#include <stdlib.h>
+ #include "tempheap.h"
+
+ struct cell : CmmObject
+ {
+ cell *car;
+ 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)
{
! car = initcar;
! cdr = initcdr;
! value = initvalue;
! }
!
! struct vector : CmmObject
! {
! vector *car;
! vector *cdr;
int value1;
! char bytes[1000];
int value2;
! vector(vector* x, vector* y, int v1, int v2);
void traverse();
};
! typedef vector* VP;
! void vector::traverse()
{
CmmHeap *heap = Cmm::heap;
heap->scavenge((CmmObject **)&car);
heap->scavenge((CmmObject **)&cdr);
}
! vector::vector(vector* x, vector* y, int v1, int v2)
{
car = x;
cdr = y;
***************
*** 41,59 ****
value2 = v2;
}
- void*
- Item::operator new[](size_t size)
- {
- return sizeof(CmmObject) + (char*)new(size) CmmArray<Item>;
- }
! void
! test()
{
int i, j;
VP lp, zp;
! printf("Item test\n");
lp = NULL;
for (i = 0; i <= 100 ; i++)
{
--- 59,71 ----
value2 = v2;
}
! void vectortest()
{
int i, j;
VP lp, zp;
! printf("Vector test\n");
lp = NULL;
for (i = 0; i <= 100 ; i++)
{
***************
*** 61,74 ****
printf("%d ", i);
else
printf("%d\n", i);
! zp = new Item[8];
! zp[0] = Item(NULL, lp, i, i);
lp = zp;
Cmm::heap->collect();
zp = lp;
for (j = i; j >= 0 ; j--)
{
! if ((zp == NULL) || (zp[0].value1 != j) || (zp[0].value2 != j))
printf("LP is not a good list when j = %d\n", j);
zp = zp->cdr;
}
--- 73,85 ----
printf("%d ", i);
else
printf("%d\n", i);
! zp = new vector[10](NULL, lp, i, i);
lp = zp;
Cmm::heap->collect();
zp = lp;
for (j = i; j >= 0 ; j--)
{
! if ((zp == NULL) || (zp->value1 != j) || (zp->value2 != j))
printf("LP is not a good list when j = %d\n", j);
zp = zp->cdr;
}
***************
*** 76,86 ****
printf("\n");
}
! void
main()
{
! /* List of Items > 1 page */
! test();
exit(0);
}
--- 87,97 ----
printf("\n");
}
! void
main()
{
! /* List of vectors > 1 page */
! vectortest();
exit(0);
}