[Vm-dev] [commit][2877] CogVM source as per VMMaker.oscog-eem.638

commits at squeakvm.org commits at squeakvm.org
Wed Mar 12 02:12:17 UTC 2014


Revision: 2877
Author:   eliot
Date:     2014-03-11 19:12:10 -0700 (Tue, 11 Mar 2014)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.638

Add primitiveAllInstances and modify primitiveAllObjects so that
both will grow memory to guarantee their results.
Modify Objectmemory/SpurMemoryManager>>allObjects &
allInstancesOf: to answer the count of objects when they run out of
space so that the primitives can grow and retry.

Change the time primtiives to access the time now, not the time as
updated by the heartbeat (but /don't/ change the time basis for
event checking.  This for performance because use of gettimeofday
in e.g. stack overflow can be a signficant performance overhead.
Move the simulated time implementations (ioSeconds et al) up to
StackInterpreter to reduce duplication.  Add ioSecondsNow et al to
the platform code to support this.

Spur:
Assert that the markStack and weaklingStack are empty at system
startup and at start of GC (allInstancesOf: et al went though a buggy
phase where weaklingStack was left full).

Fix assert in popObjStack: now that isValidObjStack: checks slots in
hiddenRootsObj.

Modified Paths:
--------------
    branches/Cog/nscogsrc/vm/cogit.c
    branches/Cog/nscogsrc/vm/cogit.h
    branches/Cog/nscogsrc/vm/cogmethod.h
    branches/Cog/nscogsrc/vm/cointerp.c
    branches/Cog/nscogsrc/vm/cointerp.h
    branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
    branches/Cog/nscogsrc/vm/interp.h
    branches/Cog/nscogsrc/vm/vmCallback.h
    branches/Cog/nsspursrc/vm/cointerp.c
    branches/Cog/nsspursrc/vm/cointerp.h
    branches/Cog/nsspursrc/vm/gcc3x-cointerp.c
    branches/Cog/nsspursrc/vm/interp.h
    branches/Cog/nsspursrc/vm/vmCallback.h
    branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c
    branches/Cog/nsspurstacksrc/vm/interp.c
    branches/Cog/nsspurstacksrc/vm/interp.h
    branches/Cog/nsspurstacksrc/vm/vmCallback.h
    branches/Cog/platforms/Cross/vm/sq.h
    branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c
    branches/Cog/platforms/unix/vm/sqUnixITimerHeartbeat.c
    branches/Cog/platforms/unix/vm/sqUnixITimerTickerHeartbeat.c
    branches/Cog/platforms/win32/vm/sqWin32Heartbeat.c
    branches/Cog/spursrc/vm/cointerp.c
    branches/Cog/spursrc/vm/cointerp.h
    branches/Cog/spursrc/vm/gcc3x-cointerp.c
    branches/Cog/spursrc/vm/interp.h
    branches/Cog/spursrc/vm/vmCallback.h
    branches/Cog/spurstacksrc/vm/gcc3x-interp.c
    branches/Cog/spurstacksrc/vm/interp.c
    branches/Cog/spurstacksrc/vm/interp.h
    branches/Cog/spurstacksrc/vm/vmCallback.h
    branches/Cog/src/vm/cointerp.c
    branches/Cog/src/vm/cointerp.h
    branches/Cog/src/vm/cointerpmt.c
    branches/Cog/src/vm/cointerpmt.h
    branches/Cog/src/vm/gcc3x-cointerp.c
    branches/Cog/src/vm/gcc3x-cointerpmt.c
    branches/Cog/src/vm/interp.h
    branches/Cog/src/vm/vmCallback.h
    branches/Cog/stacksrc/vm/gcc3x-interp.c
    branches/Cog/stacksrc/vm/interp.c
    branches/Cog/stacksrc/vm/interp.h
    branches/Cog/stacksrc/vm/vmCallback.h

Property Changed:
----------------
    branches/Cog/platforms/Cross/vm/sqSCCSVersion.h

Modified: branches/Cog/nscogsrc/vm/cogit.c
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.c	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/cogit.c	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.624 uuid: 7671143a-d3d3-45cb-b481-210d4d0c4073
+	CCodeGenerator VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.624 uuid: 7671143a-d3d3-45cb-b481-210d4d0c4073
+	StackToRegisterMappingCogit VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.624 uuid: 7671143a-d3d3-45cb-b481-210d4d0c4073 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -15040,6 +15040,7 @@
     AbstractInstruction *jumpCond;
     AbstractInstruction *jumpDouble;
     AbstractInstruction *jumpFail;
+    AbstractInstruction *jumpNonInt;
     AbstractInstruction *jumpTrue;
     sqInt quickConstant;
 
@@ -15056,6 +15057,7 @@
 	/* begin RetN: */
 	genoperand(RetN, 0);
 	jmpTarget(jumpDouble, gLabel());
+	
 	genGetCompactClassIndexNonImmOfinto(Arg0Reg, SendNumArgsReg);
 	/* begin CmpCq:R: */
 	quickConstant = classFloatCompactIndex();
@@ -15079,6 +15081,7 @@
 	/* begin RetN: */
 	genoperand(RetN, 0);
 	jmpTarget(jumpFail, gLabel());
+
 	return 0;
 }
 

Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/cogit.h	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.624 uuid: 7671143a-d3d3-45cb-b481-210d4d0c4073
+	CCodeGenerator VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
 
 

Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/cogmethod.h	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.624 uuid: 7671143a-d3d3-45cb-b481-210d4d0c4073
+	CCodeGenerator VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
 
 typedef struct {

Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/cointerp.c	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
    from
-	CoInterpreter VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CoInterpreter VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -365,6 +365,8 @@
 sqInt addressCouldBeOop(sqInt address);
 static sqInt addressIsInPage(StackPage * self_in_addressIsInPage, char *address);
 static sqInt adjustAllOopsBy(sqInt bytesToShift);
+static sqInt allInstancesOf(sqInt aBehavior);
+static sqInt allObjects(void);
 static char * allocateMemoryminimumimageFileheaderSize(sqInt heapSize, sqInt minimumMemory, sqImageFile fileStream, sqInt headerSize);
 static sqInt allYoungand(sqInt array1, sqInt array2);
 usqInt argumentCountAddress(void);
@@ -823,7 +825,8 @@
 static void primitiveAdd(void);
 EXPORT(void) primitiveAddLargeIntegers(void);
 static void primitiveAdoptInstance(void);
-EXPORT(sqInt) primitiveAllObjects(void);
+EXPORT(void) primitiveAllInstances(void);
+EXPORT(void) primitiveAllObjects(void);
 static void primitiveArctan(void);
 static void primitiveArrayBecome(void);
 static void primitiveArrayBecomeOneWay(void);
@@ -1146,7 +1149,7 @@
 static void rewriteMethodCacheEntryForExternalPrimitiveToFunction(void (*localPrimAddress)(void));
 static sqInt roomToPushNArgs(sqInt n);
 static void runLeakCheckerForFullGC(sqInt fullGCFlag);
-static usqInt safeObjectAfter(sqInt oop);
+static sqInt safeObjectAfter(sqInt oop);
 static sqInt safePrintStringOf(sqInt oop);
 usqInt scavengeThresholdAddress(void);
 EXPORT(sqInt) sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext);
@@ -1273,8 +1276,8 @@
 _iss usqInt method;
 _iss StackPage * stackPage;
 _iss sqInt bytecodeSetSelector;
+_iss usqInt freeStart;
 _iss usqInt instructionPointer;
-_iss usqInt freeStart;
 _iss sqInt argumentCount;
 _iss sqInt nilObj;
 _iss usqInt newMethod;
@@ -1287,11 +1290,11 @@
 _iss sqInt falseObj;
 _iss sqInt traceLogIndex;
 _iss sqInt bytesPerPage;
+_iss usqInt reserveStart;
 _iss char * stackLimit;
-_iss usqInt reserveStart;
 _iss sqInt rootTableCount;
+_iss usqInt memoryLimit;
 _iss usqInt endOfMemory;
-_iss usqInt memoryLimit;
 _iss StackPage * mostRecentlyUsedPage;
 _iss unsigned char primTraceLogIndex;
 _iss usqInt scavengeThreshold;
@@ -1307,12 +1310,13 @@
 _iss sqInt extraRootCount;
 _iss sqInt profileProcess;
 _iss sqInt classNameIndex;
+_iss sqInt statGrowMemory;
 _iss sqInt weakRootCount;
+_iss sqInt growHeadroom;
 _iss sqInt longRunningPrimitiveCheckMethod;
 _iss sqInt profileMethod;
 _iss sqInt lastMethodCacheProbeWrite;
 _iss sqInt backwardJumpCount;
-_iss sqInt growHeadroom;
 _iss sqInt lkupClass;
 _iss usqLong nextWakeupUsecs;
 _iss sqInt preemptionYields;
@@ -1322,7 +1326,6 @@
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
 _iss usqLong statCheckForEvents;
-_iss sqInt statGrowMemory;
 _iss sqInt statMarkCount;
 _iss sqInt lastCoggableInterpretedBlockMethod;
 _iss sqInt lastUncoggableInterpretedBlockMethod;
@@ -1633,8 +1636,8 @@
 	/* 174 */ (void (*)(void))0,
 	/* 175 */ primitiveBehaviorHash,
 	/* 176 */ primitiveMaxIdentityHash,
-	/* 177 */ (void (*)(void))0,
-	/* 178 */ (void (*)(void))0,
+	/* 177 */ primitiveAllInstances,
+	/* 178 */ primitiveAllObjects,
 	/* 179 */ (void (*)(void))0,
 	/* 180 */ (void (*)(void))0,
 	/* 181 */ (void (*)(void))0,
@@ -2033,7 +2036,7 @@
 	/* 574 */ (void (*)(void))0,
 	/* 575 */ (void (*)(void))0,
  0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.636";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.638";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -13564,6 +13567,212 @@
 }
 
 
+/*	Attempt to answer all instances of aBehavior, failing if there is not
+	enough room.
+ */
+/*	Allocate a large header Array of sufficient size to require a large
+	header. Reset its size later. */
+
+static sqInt
+allInstancesOf(sqInt aBehavior)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt afterPreAllocatedObject;
+    sqInt byteSize;
+    sqInt ccIndex;
+    sqInt chunk;
+    sqInt container;
+    sqInt count;
+    sqInt fillPointer;
+    sqInt header;
+    sqInt header1;
+    usqInt i;
+    usqInt i1;
+    sqInt obj;
+    sqInt obj1;
+    sqInt sz;
+    sqInt sz1;
+
+	container = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), 256);
+	/* begin sizeHeader:putBodySize: */
+	assert((0 % 4) == 0);
+	longAtput(container - (BytesPerWord * 2), ((0 + BytesPerWord) & LongSizeMask) | ((((longAt(container - (BytesPerWord * 2))) | LongSizeMask) - LongSizeMask)));
+	afterPreAllocatedObject = GIV(freeStart);
+	GIV(freeStart) = (fillPointer = ((sqInt)(firstFixedField(container))));
+	count = 0;
+	/* begin oopFromChunk: */
+	chunk = startOfMemory();
+	obj = chunk + (headerTypeBytes[(longAt(chunk)) & TypeMask]);
+	while ((((usqInt) obj)) < (((usqInt) container))) {
+		if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+			if (((((ccIndex = (((usqInt) (longAt(obj))) >> 12) & 0x1F)) == 0
+	? (longAt(obj - BaseHeaderSize)) & AllButTypeMask
+	: longAt(((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (CompactClasses << ShiftForWord))) + BaseHeaderSize) + ((ccIndex - 1) << ShiftForWord)))) == aBehavior) {
+				count += 1;
+				if (fillPointer < GIV(reserveStart)) {
+					longAtput(fillPointer, obj);
+					fillPointer += BytesPerOop;
+				}
+			}
+		}
+		/* begin accessibleObjectAfter: */
+		/* begin objectAfter: */
+		if (!(asserta(oopisLessThan(obj, GIV(freeStart))))) {
+			error("no objects after the end of memory");
+		}
+		if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+			sz1 = (longAt(obj)) & AllButTypeMask;
+		}
+		else {
+			/* begin sizeBitsOf: */
+			header1 = longAt(obj);
+			sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+				? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+				: header1 & SizeMask);
+		}
+		obj1 = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+		while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+			if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+				obj = obj1;
+				goto l1;
+			}
+			/* begin objectAfter: */
+			if (!(asserta(oopisLessThan(obj1, GIV(freeStart))))) {
+				error("no objects after the end of memory");
+			}
+			if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+				sz = (longAt(obj1)) & AllButTypeMask;
+			}
+			else {
+				/* begin sizeBitsOf: */
+				header = longAt(obj1);
+				sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+					? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+					: header & SizeMask);
+			}
+			obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+		}
+		obj = null;
+	l1:	/* end accessibleObjectAfter: */;
+	}
+	if (fillPointer >= GIV(reserveStart)) {
+
+		/* didn't fit.  refill with allocation check pattern and answer count. */
+
+		/* begin maybeFillWithAllocationCheckFillerFrom:to: */
+		for (i = GIV(freeStart); i <= fillPointer; i += BytesPerWord) {
+			longAtput(i, i);
+		}
+
+		return ((count << 1) | 1);
+	}
+	byteSize = fillPointer - (((sqInt)(firstFixedField(container))));
+	/* begin sizeHeader:putBodySize: */
+	assert((byteSize % 4) == 0);
+	longAtput(container - (BytesPerWord * 2), ((byteSize + BytesPerWord) & LongSizeMask) | ((((longAt(container - (BytesPerWord * 2))) | LongSizeMask) - LongSizeMask)));
+	if (fillPointer < afterPreAllocatedObject) {
+		/* begin maybeFillWithAllocationCheckFillerFrom:to: */
+		for (i1 = fillPointer; i1 <= afterPreAllocatedObject; i1 += BytesPerWord) {
+			longAtput(i1, i1);
+		}
+
+	}
+	GIV(freeStart) = fillPointer;
+	return container;
+}
+
+
+/*	Attempt to answer an array of all objects, excluding those that may
+	be garbage collected as a side effect of allocating the result array.
+	If no memory is available answer the number of objects as a SmallInteger.
+	Since objects are at least 4 bytes big, and the largest SmallInteger
+	covers 1/4 of the address space, the count can never overflow. */
+/*	Count the currently accessible objects */
+
+static sqInt
+allObjects(void)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt chunk;
+    sqInt chunk1;
+    sqInt count;
+    sqInt header;
+    sqInt header1;
+    sqInt ign;
+    sqInt newCount;
+    sqInt obj;
+    sqInt oop;
+    sqInt resultArray;
+    sqInt sz;
+    sqInt sz1;
+
+	count = 0;
+	/* begin allObjectsDo: */
+	/* begin oopFromChunk: */
+	chunk1 = startOfMemory();
+	oop = chunk1 + (headerTypeBytes[(longAt(chunk1)) & TypeMask]);
+	while (oop < GIV(freeStart)) {
+		if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
+			count += 1;
+
+		}
+		/* begin objectAfter: */
+		if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
+			error("no objects after the end of memory");
+		}
+		if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+			sz = (longAt(oop)) & AllButTypeMask;
+		}
+		else {
+			/* begin sizeBitsOf: */
+			header = longAt(oop);
+			sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+				? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+				: header & SizeMask);
+		}
+		oop = (oop + sz) + (headerTypeBytes[(longAt(oop + sz)) & TypeMask]);
+	}
+
+	/* Store all objects in result array, excluding any reference to the result array itself,
+	   as may happen if garbage collection occurred during allocation of the array. No store
+	   check is necessary; the result array will be the last object in memory and hence new. */
+
+	resultArray = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), count);
+	newCount = 0;
+	/* begin oopFromChunk: */
+	chunk = startOfMemory();
+	obj = chunk + (headerTypeBytes[(longAt(chunk)) & TypeMask]);
+	while (obj < resultArray) {
+		if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+			newCount += 1;
+			if (!(resultArray == null)) {
+				longAtput((resultArray + BaseHeaderSize) + (newCount << ShiftForWord), obj);
+			}
+		}
+		/* begin objectAfter: */
+		if (!(asserta(oopisLessThan(obj, GIV(freeStart))))) {
+			error("no objects after the end of memory");
+		}
+		if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+			sz1 = (longAt(obj)) & AllButTypeMask;
+		}
+		else {
+			/* begin sizeBitsOf: */
+			header1 = longAt(obj);
+			sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+				? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+				: header1 & SizeMask);
+		}
+		obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+	}
+	if (resultArray == null) {
+		return ((count << 1) | 1);
+	}
+	if (newCount < count) {
+		shortentoIndexableSize(resultArray, newCount);
+	}
+	return resultArray;
+}
+
+
 /*	Translate to C function call with (case sensitive) camelCase. The purpose
 	of this
 	method is to document the translation.
@@ -23734,15 +23943,17 @@
     sqInt header1;
     sqInt header2;
     sqInt header3;
+    sqInt header4;
     usqInt lastWord;
     sqInt newFreeChunk;
     sqInt newOop;
-    usqInt next;
+    sqInt next;
     sqInt oop;
     sqInt realHeader;
     sqInt sz;
     sqInt sz1;
     sqInt sz2;
+    sqInt sz3;
     sqInt target;
     usqInt w;
 
@@ -23753,7 +23964,21 @@
 		/* begin objectAfterWhileForwarding: */
 		header2 = longAt(oop);
 		if ((header2 & MarkBit) == 0) {
-			next = ((sqInt) (objectAfter(oop)));
+			/* begin objectAfter: */
+			if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
+				error("no objects after the end of memory");
+			}
+			if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+				sz2 = (longAt(oop)) & AllButTypeMask;
+			}
+			else {
+				/* begin sizeBitsOf: */
+				header3 = longAt(oop);
+				sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
+					? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+					: header3 & SizeMask);
+			}
+			next = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
 			goto l1;
 		}
 		fwdBlock1 = (header2 & AllButMarkBitAndTypeMask) << 1;
@@ -23768,7 +23993,7 @@
 		else {
 			sz1 = realHeader & SizeMask;
 		}
-		next = ((sqInt) ((oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask])));
+		next = (oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask]);
 	l1:	/* end objectAfterWhileForwarding: */;
 		if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
 
@@ -23822,18 +24047,18 @@
 	}
 	/* begin safeObjectAfter: */
 	if (((longAt(newFreeChunk)) & TypeMask) == HeaderTypeFree) {
-		sz2 = (longAt(newFreeChunk)) & AllButTypeMask;
+		sz3 = (longAt(newFreeChunk)) & AllButTypeMask;
 	}
 	else {
 		/* begin sizeBitsOf: */
-		header3 = longAt(newFreeChunk);
-		sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
+		header4 = longAt(newFreeChunk);
+		sz3 = ((header4 & TypeMask) == HeaderTypeSizeAndClass
 			? (longAt(newFreeChunk - (BytesPerWord * 2))) & LongSizeMask
-			: header3 & SizeMask);
+			: header4 & SizeMask);
 	}
-	next = ((newFreeChunk + sz2) >= GIV(freeStart)
+	next = ((newFreeChunk + sz3) >= GIV(freeStart)
 		? GIV(freeStart)
-		: (newFreeChunk + sz2) + (headerTypeBytes[(longAt(newFreeChunk + sz2)) & TypeMask]));
+		: (newFreeChunk + sz3) + (headerTypeBytes[(longAt(newFreeChunk + sz3)) & TypeMask]));
 	assert((next == GIV(freeStart))
 	 || (next == (oopFromChunk(GIV(compEnd)))));
 	if (next == GIV(freeStart)) {
@@ -30424,93 +30649,76 @@
 }
 
 
+/*	Answer an array of all instances of the receiver that exist
+	when the primitive is called, excluding any that may be
+	garbage collected as a side effect of allocating the result array. */
+
+EXPORT(void)
+primitiveAllInstances(void)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt delta;
+    sqInt limit;
+    sqInt result;
+    char *sp;
+
+	result = allInstancesOf(longAt(GIV(stackPointer)));
+	if ((result & 1)) {
+		/* begin growToAccomodateContainerWithNumSlots: */
+		delta = (((((sqInt) (headerTypeBytes[HeaderTypeSizeAndClass]) >> 2)) + 1) + ((result >> 1))) * BytesPerOop;
+		/* begin growObjectMemory: */
+		GIV(statGrowMemory) += 1;
+		limit = sqGrowMemoryBy(GIV(memoryLimit), ((GIV(growHeadroom) < delta) ? delta : GIV(growHeadroom)));
+		if (!(limit == GIV(memoryLimit))) {
+			/* begin setMemoryLimit: */
+			assert(((limit - 24) & (BytesPerWord - 1)) == 0);
+			GIV(memoryLimit) = limit - 24;
+			initializeMemoryFirstFree(GIV(freeStart));
+			sqMakeMemoryNotExecutableFromTo(startOfMemory(), GIV(memoryLimit));
+		}
+		result = allInstancesOf(longAt(GIV(stackPointer)));
+		if ((result & 1)) {
+			(GIV(primFailCode) = PrimErrNoMemory);
+			return;
+		}
+	}
+	/* begin pop:thenPush: */
+	longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), result);
+	GIV(stackPointer) = sp;
+}
+
+
 /*	Answer an array of all objects that exist when the primitive
 	is called, excluding those that may be garbage collected as
 	a side effect of allocating the result array. */
 
-EXPORT(sqInt)
+EXPORT(void)
 primitiveAllObjects(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
-    sqInt chunk;
-    sqInt chunk1;
-    sqInt count;
-    sqInt header;
-    sqInt header1;
-    sqInt ign;
-    sqInt newCount;
-    sqInt obj;
-    sqInt oop;
+    sqInt delta;
+    sqInt limit;
     sqInt result;
-    sqInt resultArray;
     char *sp;
-    sqInt sz;
-    sqInt sz1;
 
-	/* begin allObjects */
-	count = 0;
-	/* begin allObjectsDo: */
-	/* begin oopFromChunk: */
-	chunk = startOfMemory();
-	oop = chunk + (headerTypeBytes[(longAt(chunk)) & TypeMask]);
-	while (oop < GIV(freeStart)) {
-		if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
-			count += 1;
-
+	result = allObjects();
+	if ((result & 1)) {
+		/* begin growToAccomodateContainerWithNumSlots: */
+		delta = (((((sqInt) (headerTypeBytes[HeaderTypeSizeAndClass]) >> 2)) + 1) + ((result >> 1))) * BytesPerOop;
+		/* begin growObjectMemory: */
+		GIV(statGrowMemory) += 1;
+		limit = sqGrowMemoryBy(GIV(memoryLimit), ((GIV(growHeadroom) < delta) ? delta : GIV(growHeadroom)));
+		if (!(limit == GIV(memoryLimit))) {
+			/* begin setMemoryLimit: */
+			assert(((limit - 24) & (BytesPerWord - 1)) == 0);
+			GIV(memoryLimit) = limit - 24;
+			initializeMemoryFirstFree(GIV(freeStart));
+			sqMakeMemoryNotExecutableFromTo(startOfMemory(), GIV(memoryLimit));
 		}
-		/* begin objectAfter: */
-		if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
-			error("no objects after the end of memory");
+		result = allObjects();
+		if ((result & 1)) {
+			(GIV(primFailCode) = PrimErrNoMemory);
+			return;
 		}
-		if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
-			sz1 = (longAt(oop)) & AllButTypeMask;
-		}
-		else {
-			/* begin sizeBitsOf: */
-			header1 = longAt(oop);
-			sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
-				? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
-				: header1 & SizeMask);
-		}
-		oop = (oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask]);
 	}
-	resultArray = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), count);
-	if (resultArray == null) {
-		result = 0;
-		goto l1;
-	}
-	newCount = 0;
-	/* begin oopFromChunk: */
-	chunk1 = startOfMemory();
-	obj = chunk1 + (headerTypeBytes[(longAt(chunk1)) & TypeMask]);
-	while (obj < resultArray) {
-		if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
-			newCount += 1;
-			longAtput((resultArray + BaseHeaderSize) + (newCount << ShiftForWord), obj);
-		}
-		/* begin objectAfter: */
-		if (!(asserta(oopisLessThan(obj, GIV(freeStart))))) {
-			error("no objects after the end of memory");
-		}
-		if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
-			sz = (longAt(obj)) & AllButTypeMask;
-		}
-		else {
-			/* begin sizeBitsOf: */
-			header = longAt(obj);
-			sz = ((header & TypeMask) == HeaderTypeSizeAndClass
-				? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
-				: header & SizeMask);
-		}
-		obj = (obj + sz) + (headerTypeBytes[(longAt(obj + sz)) & TypeMask]);
-	}
-	if (newCount < count) {
-		shortentoIndexableSize(resultArray, newCount);
-	}
-	result = resultArray;
-l1:	/* end allObjects */;
-	if (result == 0) {
-		return (GIV(primFailCode) = PrimErrNoMemory);
-	}
 	/* begin pop:thenPush: */
 	longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), result);
 	GIV(stackPointer) = sp;
@@ -39022,7 +39230,7 @@
     char *sp;
 
 	/* begin pop:thenPush: */
-	oop = positive64BitIntegerFor(ioLocalMicroseconds());
+	oop = positive64BitIntegerFor(ioLocalMicrosecondsNow());
 	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), oop);
 	GIV(stackPointer) = sp;
 }
@@ -41806,7 +42014,7 @@
     char *sp;
 
 	/* begin pop:thenPush: */
-	oop = positive32BitIntegerFor(ioSeconds());
+	oop = positive32BitIntegerFor(ioSecondsNow());
 	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), oop);
 	GIV(stackPointer) = sp;
 }
@@ -44778,7 +44986,7 @@
     char *sp;
 
 	/* begin pop:thenPush: */
-	oop = positive64BitIntegerFor(ioUTCMicroseconds());
+	oop = positive64BitIntegerFor(ioUTCMicrosecondsNow());
 	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), oop);
 	GIV(stackPointer) = sp;
 }
@@ -44802,7 +45010,7 @@
 	/* 2177452800000000 = '1/1/1970' asDate asSeconds - '1/1/1901' asDate asSeconds * 1,000,000 */
 
 	/* begin pushRemappableOop: */
-	oop = positive64BitIntegerFor((ioUTCMicroseconds()) - 2177452800000000ULL);
+	oop = positive64BitIntegerFor((ioUTCMicrosecondsNow()) - 2177452800000000ULL);
 	assert(addressCouldBeOop(oop));
 	GIV(remapBuffer)[(GIV(remapBufferCount) += 1)] = oop;
 	if (!(GIV(remapBufferCount) <= RemapBufferSize)) {
@@ -50248,7 +50456,7 @@
 	given object or free chunk in memory. Return freeStart when
 	enumeration is complete. This is for assertion checking only. */
 
-static usqInt
+static sqInt
 safeObjectAfter(sqInt oop)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt header;
@@ -55125,6 +55333,7 @@
 	{"", "dumpImage", (void*)dumpImage},
 	{"", "moduleUnloaded", (void*)moduleUnloaded},
 	{"", "primitiveAddLargeIntegers", (void*)primitiveAddLargeIntegers},
+	{"", "primitiveAllInstances", (void*)primitiveAllInstances},
 	{"", "primitiveAllObjects", (void*)primitiveAllObjects},
 	{"", "primitiveBitAndLargeIntegers", (void*)primitiveBitAndLargeIntegers},
 	{"", "primitiveBitOrLargeIntegers", (void*)primitiveBitOrLargeIntegers},

Modified: branches/Cog/nscogsrc/vm/cointerp.h
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.h	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/cointerp.h	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
 
 

Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2014-03-12 02:12:10 UTC (rev 2877)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
    from
-	CoInterpreter VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CoInterpreter VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -368,6 +368,8 @@
 sqInt addressCouldBeOop(sqInt address);
 static sqInt addressIsInPage(StackPage * self_in_addressIsInPage, char *address);
 static sqInt adjustAllOopsBy(sqInt bytesToShift);
+static sqInt allInstancesOf(sqInt aBehavior);
+static sqInt allObjects(void);
 static char * allocateMemoryminimumimageFileheaderSize(sqInt heapSize, sqInt minimumMemory, sqImageFile fileStream, sqInt headerSize);
 static sqInt allYoungand(sqInt array1, sqInt array2);
 usqInt argumentCountAddress(void);
@@ -826,7 +828,8 @@
 static void primitiveAdd(void);
 EXPORT(void) primitiveAddLargeIntegers(void);
 static void primitiveAdoptInstance(void);
-EXPORT(sqInt) primitiveAllObjects(void);
+EXPORT(void) primitiveAllInstances(void);
+EXPORT(void) primitiveAllObjects(void);
 static void primitiveArctan(void);
 static void primitiveArrayBecome(void);
 static void primitiveArrayBecomeOneWay(void);
@@ -1149,7 +1152,7 @@
 static void rewriteMethodCacheEntryForExternalPrimitiveToFunction(void (*localPrimAddress)(void));
 static sqInt roomToPushNArgs(sqInt n);
 static void runLeakCheckerForFullGC(sqInt fullGCFlag);
-static usqInt safeObjectAfter(sqInt oop);
+static sqInt safeObjectAfter(sqInt oop);
 static sqInt safePrintStringOf(sqInt oop);
 usqInt scavengeThresholdAddress(void);
 EXPORT(sqInt) sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext);
@@ -1276,8 +1279,8 @@
 _iss usqInt method;
 _iss StackPage * stackPage;
 _iss sqInt bytecodeSetSelector;
+_iss usqInt freeStart;
 _iss usqInt instructionPointer;
-_iss usqInt freeStart;
 _iss sqInt argumentCount;
 _iss sqInt nilObj;
 _iss usqInt newMethod;
@@ -1290,11 +1293,11 @@
 _iss sqInt falseObj;
 _iss sqInt traceLogIndex;
 _iss sqInt bytesPerPage;
+_iss usqInt reserveStart;
 _iss char * stackLimit;
-_iss usqInt reserveStart;
 _iss sqInt rootTableCount;
+_iss usqInt memoryLimit;
 _iss usqInt endOfMemory;
-_iss usqInt memoryLimit;
 _iss StackPage * mostRecentlyUsedPage;
 _iss unsigned char primTraceLogIndex;
 _iss usqInt scavengeThreshold;
@@ -1310,12 +1313,13 @@
 _iss sqInt extraRootCount;
 _iss sqInt profileProcess;
 _iss sqInt classNameIndex;
+_iss sqInt statGrowMemory;
 _iss sqInt weakRootCount;
+_iss sqInt growHeadroom;
 _iss sqInt longRunningPrimitiveCheckMethod;
 _iss sqInt profileMethod;
 _iss sqInt lastMethodCacheProbeWrite;
 _iss sqInt backwardJumpCount;
-_iss sqInt growHeadroom;
 _iss sqInt lkupClass;
 _iss usqLong nextWakeupUsecs;
 _iss sqInt preemptionYields;
@@ -1325,7 +1329,6 @@
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
 _iss usqLong statCheckForEvents;
-_iss sqInt statGrowMemory;
 _iss sqInt statMarkCount;
 _iss sqInt lastCoggableInterpretedBlockMethod;
 _iss sqInt lastUncoggableInterpretedBlockMethod;
@@ -1636,8 +1639,8 @@
 	/* 174 */ (void (*)(void))0,
 	/* 175 */ primitiveBehaviorHash,
 	/* 176 */ primitiveMaxIdentityHash,
-	/* 177 */ (void (*)(void))0,
-	/* 178 */ (void (*)(void))0,
+	/* 177 */ primitiveAllInstances,
+	/* 178 */ primitiveAllObjects,
 	/* 179 */ (void (*)(void))0,
 	/* 180 */ (void (*)(void))0,
 	/* 181 */ (void (*)(void))0,
@@ -2036,7 +2039,7 @@
 	/* 574 */ (void (*)(void))0,
 	/* 575 */ (void (*)(void))0,
  0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.636";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.638";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -13573,6 +13576,212 @@
 }
 
 
+/*	Attempt to answer all instances of aBehavior, failing if there is not
+	enough room.
+ */
+/*	Allocate a large header Array of sufficient size to require a large
+	header. Reset its size later. */
+
+static sqInt
+allInstancesOf(sqInt aBehavior)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt afterPreAllocatedObject;
+    sqInt byteSize;
+    sqInt ccIndex;
+    sqInt chunk;
+    sqInt container;
+    sqInt count;
+    sqInt fillPointer;
+    sqInt header;
+    sqInt header1;
+    usqInt i;
+    usqInt i1;
+    sqInt obj;
+    sqInt obj1;
+    sqInt sz;
+    sqInt sz1;
+
+	container = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), 256);
+	/* begin sizeHeader:putBodySize: */
+	assert((0 % 4) == 0);
+	longAtput(container - (BytesPerWord * 2), ((0 + BytesPerWord) & LongSizeMask) | ((((longAt(container - (BytesPerWord * 2))) | LongSizeMask) - LongSizeMask)));
+	afterPreAllocatedObject = GIV(freeStart);
+	GIV(freeStart) = (fillPointer = ((sqInt)(firstFixedField(container))));
+	count = 0;
+	/* begin oopFromChunk: */
+	chunk = startOfMemory();
+	obj = chunk + (headerTypeBytes[(longAt(chunk)) & TypeMask]);
+	while ((((usqInt) obj)) < (((usqInt) container))) {
+		if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+			if (((((ccIndex = (((usqInt) (longAt(obj))) >> 12) & 0x1F)) == 0
+	? (longAt(obj - BaseHeaderSize)) & AllButTypeMask
+	: longAt(((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (CompactClasses << ShiftForWord))) + BaseHeaderSize) + ((ccIndex - 1) << ShiftForWord)))) == aBehavior) {
+				count += 1;
+				if (fillPointer < GIV(reserveStart)) {
+					longAtput(fillPointer, obj);
+					fillPointer += BytesPerOop;
+				}
+			}
+		}
+		/* begin accessibleObjectAfter: */
+		/* begin objectAfter: */
+		if (!(asserta(oopisLessThan(obj, GIV(freeStart))))) {
+			error("no objects after the end of memory");
+		}
+		if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+			sz1 = (longAt(obj)) & AllButTypeMask;
+		}
+		else {
+			/* begin sizeBitsOf: */
+			header1 = longAt(obj);
+			sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+				? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+				: header1 & SizeMask);
+		}
+		obj1 = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+		while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+			if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+				obj = obj1;
+				goto l1;
+			}
+			/* begin objectAfter: */
+			if (!(asserta(oopisLessThan(obj1, GIV(freeStart))))) {
+				error("no objects after the end of memory");
+			}
+			if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+				sz = (longAt(obj1)) & AllButTypeMask;
+			}
+			else {
+				/* begin sizeBitsOf: */
+				header = longAt(obj1);
+				sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+					? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+					: header & SizeMask);
+			}
+			obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+		}
+		obj = null;
+	l1:	/* end accessibleObjectAfter: */;
+	}
+	if (fillPointer >= GIV(reserveStart)) {
+
+		/* didn't fit.  refill with allocation check pattern and answer count. */
+
+		/* begin maybeFillWithAllocationCheckFillerFrom:to: */
+		for (i = GIV(freeStart); i <= fillPointer; i += BytesPerWord) {
+			longAtput(i, i);
+		}
+
+		return ((count << 1) | 1);
+	}
+	byteSize = fillPointer - (((sqInt)(firstFixedField(container))));
+	/* begin sizeHeader:putBodySize: */
+	assert((byteSize % 4) == 0);
+	longAtput(container - (BytesPerWord * 2), ((byteSize + BytesPerWord) & LongSizeMask) | ((((longAt(container - (BytesPerWord * 2))) | LongSizeMask) - LongSizeMask)));
+	if (fillPointer < afterPreAllocatedObject) {
+		/* begin maybeFillWithAllocationCheckFillerFrom:to: */
+		for (i1 = fillPointer; i1 <= afterPreAllocatedObject; i1 += BytesPerWord) {
+			longAtput(i1, i1);
+		}
+
+	}
+	GIV(freeStart) = fillPointer;
+	return container;
+}
+
+
+/*	Attempt to answer an array of all objects, excluding those that may
+	be garbage collected as a side effect of allocating the result array.
+	If no memory is available answer the number of objects as a SmallInteger.
+	Since objects are at least 4 bytes big, and the largest SmallInteger
+	covers 1/4 of the address space, the count can never overflow. */
+/*	Count the currently accessible objects */
+
+static sqInt
+allObjects(void)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt chunk;
+    sqInt chunk1;
+    sqInt count;
+    sqInt header;
+    sqInt header1;
+    sqInt ign;
+    sqInt newCount;
+    sqInt obj;
+    sqInt oop;
+    sqInt resultArray;
+    sqInt sz;
+    sqInt sz1;
+
+	count = 0;
+	/* begin allObjectsDo: */
+	/* begin oopFromChunk: */
+	chunk1 = startOfMemory();
+	oop = chunk1 + (headerTypeBytes[(longAt(chunk1)) & TypeMask]);
+	while (oop < GIV(freeStart)) {
+		if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
+			count += 1;
+
+		}
+		/* begin objectAfter: */
+		if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
+			error("no objects after the end of memory");
+		}
+		if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+			sz = (longAt(oop)) & AllButTypeMask;
+		}
+		else {
+			/* begin sizeBitsOf: */
+			header = longAt(oop);
+			sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+				? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+				: header & SizeMask);
+		}
+		oop = (oop + sz) + (headerTypeBytes[(longAt(oop + sz)) & TypeMask]);
+	}
+
+	/* Store all objects in result array, excluding any reference to the result array itself,
+	   as may happen if garbage collection occurred during allocation of the array. No store
+	   check is necessary; the result array will be the last object in memory and hence new. */
+
+	resultArray = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), count);
+	newCount = 0;
+	/* begin oopFromChunk: */
+	chunk = startOfMemory();
+	obj = chunk + (headerTypeBytes[(longAt(chunk)) & TypeMask]);
+	while (obj < resultArray) {
+		if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+			newCount += 1;
+			if (!(resultArray == null)) {
+				longAtput((resultArray + BaseHeaderSize) + (newCount << ShiftForWord), obj);
+			}
+		}
+		/* begin objectAfter: */
+		if (!(asserta(oopisLessThan(obj, GIV(freeStart))))) {
+			error("no objects after the end of memory");
+		}
+		if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+			sz1 = (longAt(obj)) & AllButTypeMask;
+		}
+		else {
+			/* begin sizeBitsOf: */
+			header1 = longAt(obj);
+			sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+				? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+				: header1 & SizeMask);
+		}
+		obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+	}
+	if (resultArray == null) {
+		return ((count << 1) | 1);
+	}
+	if (newCount < count) {
+		shortentoIndexableSize(resultArray, newCount);
+	}
+	return resultArray;
+}
+
+
 /*	Translate to C function call with (case sensitive) camelCase. The purpose
 	of this
 	method is to document the translation.
@@ -23743,15 +23952,17 @@
     sqInt header1;
     sqInt header2;
     sqInt header3;
+    sqInt header4;
     usqInt lastWord;
     sqInt newFreeChunk;
     sqInt newOop;
-    usqInt next;
+    sqInt next;
     sqInt oop;
     sqInt realHeader;
     sqInt sz;
     sqInt sz1;
     sqInt sz2;
+    sqInt sz3;
     sqInt target;
     usqInt w;
 
@@ -23762,7 +23973,21 @@
 		/* begin objectAfterWhileForwarding: */
 		header2 = longAt(oop);
 		if ((header2 & MarkBit) == 0) {
-			next = ((sqInt) (objectAfter(oop)));
+			/* begin objectAfter: */
+			if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
+				error("no objects after the end of memory");
+			}
+			if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+				sz2 = (longAt(oop)) & AllButTypeMask;
+			}
+			else {
+				/* begin sizeBitsOf: */
+				header3 = longAt(oop);
+				sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
+					? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+					: header3 & SizeMask);
+			}
+			next = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
 			goto l1;
 		}
 		fwdBlock1 = (header2 & AllButMarkBitAndTypeMask) << 1;
@@ -23777,7 +24002,7 @@
 		else {
 			sz1 = realHeader & SizeMask;
 		}
-		next = ((sqInt) ((oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask])));
+		next = (oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask]);
 	l1:	/* end objectAfterWhileForwarding: */;
 		if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
 
@@ -23831,18 +24056,18 @@
 	}
 	/* begin safeObjectAfter: */
 	if (((longAt(newFreeChunk)) & TypeMask) == HeaderTypeFree) {
-		sz2 = (longAt(newFreeChunk)) & AllButTypeMask;
+		sz3 = (longAt(newFreeChunk)) & AllButTypeMask;
 	}
 	else {
 		/* begin sizeBitsOf: */
-		header3 = longAt(newFreeChunk);
-		sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
+		header4 = longAt(newFreeChunk);
+		sz3 = ((header4 & TypeMask) == HeaderTypeSizeAndClass
 			? (longAt(newFreeChunk - (BytesPerWord * 2))) & LongSizeMask
-			: header3 & SizeMask);
+			: header4 & SizeMask);
 	}
-	next = ((newFreeChunk + sz2) >= GIV(freeStart)
+	next = ((newFreeChunk + sz3) >= GIV(freeStart)
 		? GIV(freeStart)
-		: (newFreeChunk + sz2) + (headerTypeBytes[(longAt(newFreeChunk + sz2)) & TypeMask]));
+		: (newFreeChunk + sz3) + (headerTypeBytes[(longAt(newFreeChunk + sz3)) & TypeMask]));
 	assert((next == GIV(freeStart))
 	 || (next == (oopFromChunk(GIV(compEnd)))));
 	if (next == GIV(freeStart)) {
@@ -30433,93 +30658,76 @@
 }
 
 
+/*	Answer an array of all instances of the receiver that exist
+	when the primitive is called, excluding any that may be
+	garbage collected as a side effect of allocating the result array. */
+
+EXPORT(void)
+primitiveAllInstances(void)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt delta;
+    sqInt limit;
+    sqInt result;
+    char *sp;
+
+	result = allInstancesOf(longAt(GIV(stackPointer)));
+	if ((result & 1)) {
+		/* begin growToAccomodateContainerWithNumSlots: */
+		delta = (((((sqInt) (headerTypeBytes[HeaderTypeSizeAndClass]) >> 2)) + 1) + ((result >> 1))) * BytesPerOop;
+		/* begin growObjectMemory: */
+		GIV(statGrowMemory) += 1;
+		limit = sqGrowMemoryBy(GIV(memoryLimit), ((GIV(growHeadroom) < delta) ? delta : GIV(growHeadroom)));
+		if (!(limit == GIV(memoryLimit))) {
+			/* begin setMemoryLimit: */
+			assert(((limit - 24) & (BytesPerWord - 1)) == 0);
+			GIV(memoryLimit) = limit - 24;
+			initializeMemoryFirstFree(GIV(freeStart));
+			sqMakeMemoryNotExecutableFromTo(startOfMemory(), GIV(memoryLimit));
+		}
+		result = allInstancesOf(longAt(GIV(stackPointer)));
+		if ((result & 1)) {
+			(GIV(primFailCode) = PrimErrNoMemory);
+			return;
+		}
+	}
+	/* begin pop:thenPush: */
+	longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), result);
+	GIV(stackPointer) = sp;
+}
+
+
 /*	Answer an array of all objects that exist when the primitive
 	is called, excluding those that may be garbage collected as
 	a side effect of allocating the result array. */
 
-EXPORT(sqInt)
+EXPORT(void)
 primitiveAllObjects(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
-    sqInt chunk;
-    sqInt chunk1;
-    sqInt count;
-    sqInt header;
-    sqInt header1;
-    sqInt ign;
-    sqInt newCount;
-    sqInt obj;
-    sqInt oop;
+    sqInt delta;
+    sqInt limit;
     sqInt result;
-    sqInt resultArray;
     char *sp;
-    sqInt sz;
-    sqInt sz1;
 
-	/* begin allObjects */
-	count = 0;
-	/* begin allObjectsDo: */
-	/* begin oopFromChunk: */
-	chunk = startOfMemory();
-	oop = chunk + (headerTypeBytes[(longAt(chunk)) & TypeMask]);
-	while (oop < GIV(freeStart)) {
-		if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
-			count += 1;
-
+	result = allObjects();
+	if ((result & 1)) {
+		/* begin growToAccomodateContainerWithNumSlots: */
+		delta = (((((sqInt) (headerTypeBytes[HeaderTypeSizeAndClass]) >> 2)) + 1) + ((result >> 1))) * BytesPerOop;
+		/* begin growObjectMemory: */
+		GIV(statGrowMemory) += 1;
+		limit = sqGrowMemoryBy(GIV(memoryLimit), ((GIV(growHeadroom) < delta) ? delta : GIV(growHeadroom)));
+		if (!(limit == GIV(memoryLimit))) {
+			/* begin setMemoryLimit: */
+			assert(((limit - 24) & (BytesPerWord - 1)) == 0);
+			GIV(memoryLimit) = limit - 24;
+			initializeMemoryFirstFree(GIV(freeStart));
+			sqMakeMemoryNotExecutableFromTo(startOfMemory(), GIV(memoryLimit));
 		}
-		/* begin objectAfter: */
-		if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
-			error("no objects after the end of memory");
+		result = allObjects();
+		if ((result & 1)) {
+			(GIV(primFailCode) = PrimErrNoMemory);
+			return;
 		}
-		if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
-			sz1 = (longAt(oop)) & AllButTypeMask;
-		}
-		else {
-			/* begin sizeBitsOf: */
-			header1 = longAt(oop);
-			sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
-				? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
-				: header1 & SizeMask);
-		}
-		oop = (oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask]);
 	}
-	resultArray = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), count);
-	if (resultArray == null) {
-		result = 0;
-		goto l1;
-	}
-	newCount = 0;
-	/* begin oopFromChunk: */
-	chunk1 = startOfMemory();
-	obj = chunk1 + (headerTypeBytes[(longAt(chunk1)) & TypeMask]);
-	while (obj < resultArray) {
-		if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
-			newCount += 1;
-			longAtput((resultArray + BaseHeaderSize) + (newCount << ShiftForWord), obj);
-		}
-		/* begin objectAfter: */
-		if (!(asserta(oopisLessThan(obj, GIV(freeStart))))) {
-			error("no objects after the end of memory");
-		}
-		if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
-			sz = (longAt(obj)) & AllButTypeMask;
-		}
-		else {
-			/* begin sizeBitsOf: */
-			header = longAt(obj);
-			sz = ((header & TypeMask) == HeaderTypeSizeAndClass
-				? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
-				: header & SizeMask);
-		}
-		obj = (obj + sz) + (headerTypeBytes[(longAt(obj + sz)) & TypeMask]);
-	}
-	if (newCount < count) {
-		shortentoIndexableSize(resultArray, newCount);
-	}
-	result = resultArray;
-l1:	/* end allObjects */;
-	if (result == 0) {
-		return (GIV(primFailCode) = PrimErrNoMemory);
-	}
 	/* begin pop:thenPush: */
 	longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), result);
 	GIV(stackPointer) = sp;
@@ -39031,7 +39239,7 @@
     char *sp;
 
 	/* begin pop:thenPush: */
-	oop = positive64BitIntegerFor(ioLocalMicroseconds());
+	oop = positive64BitIntegerFor(ioLocalMicrosecondsNow());
 	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), oop);
 	GIV(stackPointer) = sp;
 }
@@ -41815,7 +42023,7 @@
     char *sp;
 
 	/* begin pop:thenPush: */
-	oop = positive32BitIntegerFor(ioSeconds());
+	oop = positive32BitIntegerFor(ioSecondsNow());
 	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), oop);
 	GIV(stackPointer) = sp;
 }
@@ -44787,7 +44995,7 @@
     char *sp;
 
 	/* begin pop:thenPush: */
-	oop = positive64BitIntegerFor(ioUTCMicroseconds());
+	oop = positive64BitIntegerFor(ioUTCMicrosecondsNow());
 	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), oop);
 	GIV(stackPointer) = sp;
 }
@@ -44811,7 +45019,7 @@
 	/* 2177452800000000 = '1/1/1970' asDate asSeconds - '1/1/1901' asDate asSeconds * 1,000,000 */
 
 	/* begin pushRemappableOop: */
-	oop = positive64BitIntegerFor((ioUTCMicroseconds()) - 2177452800000000ULL);
+	oop = positive64BitIntegerFor((ioUTCMicrosecondsNow()) - 2177452800000000ULL);
 	assert(addressCouldBeOop(oop));
 	GIV(remapBuffer)[(GIV(remapBufferCount) += 1)] = oop;
 	if (!(GIV(remapBufferCount) <= RemapBufferSize)) {
@@ -50257,7 +50465,7 @@
 	given object or free chunk in memory. Return freeStart when
 	enumeration is complete. This is for assertion checking only. */
 
-static usqInt
+static sqInt
 safeObjectAfter(sqInt oop)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt header;
@@ -55134,6 +55342,7 @@
 	{"", "dumpImage", (void*)dumpImage},
 	{"", "moduleUnloaded", (void*)moduleUnloaded},
 	{"", "primitiveAddLargeIntegers", (void*)primitiveAddLargeIntegers},
+	{"", "primitiveAllInstances", (void*)primitiveAllInstances},
 	{"", "primitiveAllObjects", (void*)primitiveAllObjects},
 	{"", "primitiveBitAndLargeIntegers", (void*)primitiveBitAndLargeIntegers},
 	{"", "primitiveBitOrLargeIntegers", (void*)primitiveBitOrLargeIntegers},

Modified: branches/Cog/nscogsrc/vm/interp.h
===================================================================
--- branches/Cog/nscogsrc/vm/interp.h	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/interp.h	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
 
 #define VM_PROXY_MAJOR 1

Modified: branches/Cog/nscogsrc/vm/vmCallback.h
===================================================================
--- branches/Cog/nscogsrc/vm/vmCallback.h	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nscogsrc/vm/vmCallback.h	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
 
 #define VM_CALLBACK_INC 1

Modified: branches/Cog/nsspursrc/vm/cointerp.c
===================================================================
--- branches/Cog/nsspursrc/vm/cointerp.c	2014-03-10 23:54:08 UTC (rev 2876)
+++ branches/Cog/nsspursrc/vm/cointerp.c	2014-03-12 02:12:10 UTC (rev 2877)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
    from
-	CoInterpreter VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9
+	CoInterpreter VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.636 uuid: 97945106-afaf-4c50-be03-a1806625c3b9 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.638 uuid: 4c01acdf-1273-4319-aef5-fd3591c3dbe9 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -374,6 +374,8 @@
 static void addToWeakList(sqInt weakCorpse);
 static void adjustSegmentSwizzlesBy(sqInt firstSegmentShift);
 static sqInt allBridgesMarked(void);
+static sqInt allInstancesOf(sqInt aClass);
+static sqInt allObjects(void);
 static sqInt allObjectsUnmarked(void);
 static sqInt allocateBytesclassIndex(sqInt numBytes, sqInt classIndex);
 static char * allocateMemoryminimumimageFileheaderSize(sqInt heapSize, sqInt minimumMemory, sqImageFile fileStream, sqInt headerSize);
@@ -551,6 +553,7 @@
 void dumpTraceLog(void);
 sqInt eeInstantiateClassIndexformatnumSlots(sqInt knownClassIndex, sqInt objFormat, sqInt numSlots);
 static void eliminateAndFreeForwarders(void);
+static void emptyObjStack(sqInt objStack);
 static void ensureAdequateClassTableBitmap(void);
 static sqInt ensureBehaviorHash(sqInt aBehavior);
 static sqInt ensureCallerContext(char *theFP);
@@ -940,7 +943,8 @@
 static void primitiveAdd(void);
 EXPORT(void) primitiveAddLargeIntegers(void);
 static void primitiveAdoptInstance(void);
-EXPORT(sqInt) primitiveAllObjects(void);
+EXPORT(void) primitiveAllInstances(void);
+EXPORT(void) primitiveAllObjects(void);
 static void primitiveArctan(void);
 static void primitiveArrayBecome(void);
 static void primitiveArrayBecomeOneWay(void);
@@ -1426,13 +1430,13 @@
 _iss sqInt hiddenRootsObj;
 _iss char * stackBasePlus1;
 _iss SpurCircularBuffer highestObjects;
+_iss sqInt totalFreeOldSpace;
 _iss usqInt endOfMemory;
-_iss sqInt totalFreeOldSpace;
 _iss sqInt trueObj;
 _iss SpurSegmentInfo * segments;
 _iss sqInt falseObj;
+_iss sqInt needGCFlag;
 _iss sqInt remapBufferCount;
-_iss sqInt needGCFlag;
 _iss sqInt traceLogIndex;
 _iss sqInt bytesPerPage;
 _iss sqInt * freeLists;
@@ -1442,7 +1446,6 @@
 _iss sqInt numSegments;
 _iss sqInt firstFreeChunk;
 _iss usqInt scavengeThreshold;
-_iss sqInt weaklingStack;
 _iss sqInt rememberedSetSize;
 _iss SpurNewSpaceSpace pastSpace;
 _iss SpurContiguousObjStack unscannedEphemerons;
@@ -1452,13 +1455,14 @@
 _iss usqInt newSpaceStart;
 _iss unsigned char primTraceLogIndex;
 _iss sqInt numStackPages;
+_iss sqInt markStack;
 _iss usqInt oldSpaceStart;
+_iss sqInt weaklingStack;
 _iss sqInt futureSurvivorStart;
 _iss sqInt jmpDepth;
 _iss sqLong nextProfileTick;
 _iss sqInt numRememberedEphemerons;
 _iss sqInt classNameIndex;
-_iss sqInt markStack;
 _iss sqInt numClassTablePages;
 _iss sqInt longRunningPrimitiveCheckSemaphore;
 _iss sqInt tempOop;
@@ -1478,6 +1482,7 @@
 _iss sqInt profileMethod;
 _iss sqInt classTableIndex;
 _iss sqInt ephemeronQueue;
+_iss sqInt growHeadroom;
 _iss sqInt lastMethodCacheProbeWrite;
 _iss sqInt lkupClass;
 _iss sqInt backwardJumpCount;
@@ -1485,7 +1490,6 @@
 _iss usqLong nextWakeupUsecs;
 _iss sqInt preemptionYields;
 _iss sqInt cogCompiledCodeCompactionCalledFor;
-_iss sqInt growHeadroom;
 _iss sqInt highestRunnableProcessPriority;
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
@@ -1790,8 +1794,8 @@
 	/* 174 */ (void (*)(void))0,
 	/* 175 */ primitiveBehaviorHash,
 	/* 176 */ primitiveMaxIdentityHash,
-	/* 177 */ (void (*)(void))0,
-	/* 178 */ (void (*)(void))0,
+	/* 177 */ primitiveAllInstances,
+	/* 178 */ primitiveAllObjects,
 	/* 179 */ (void (*)(void))0,
 	/* 180 */ primitiveGrowMemoryByAtLeast,
 	/* 181 */ primitiveSizeInBytesOfInstance,
@@ -2191,7 +2195,7 @@
 	/* 575 */ (void (*)(void))0,
  0 };
 usqInt heapBase;
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.636";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.638";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -15818,7 +15822,555 @@
 	return 1;
 }
 
+
+/*	Attempt to answer an array of all objects, excluding those that may
+	be garbage collected as a side effect of allocating the result array.
+	If no memory is available answer the number of instances as a
+	SmallInteger. Since objects are at least 16 bytes big, and the largest
+	SmallInteger covers
+	1/4 of the address space, the count can never overflow. */
+
 static sqInt
+allInstancesOf(sqInt aClass)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt address;
+    sqInt address1;
+    sqInt bytes;
+    usqLong bytes1;
+    sqInt classIndex;
+    sqInt count;
+    sqInt freeChunk;
+    sqInt freeChunk1;
+    sqInt i;
+    sqInt limit;

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list