[Vm-dev] [commit][2869] CogVM source as per VMMaker.oscog-eem.620

commits at squeakvm.org commits at squeakvm.org
Thu Feb 20 02:07:01 UTC 2014


Revision: 2869
Author:   eliot
Date:     2014-02-19 18:06:56 -0800 (Wed, 19 Feb 2014)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.620

Make primitiveClone cope with variable args, cloning its last
argument.  This for the Newspeak VMMirror.

Fix an assert fail in findSPOrNilOf:on:startingFrom:.

Spur:
Fix scanClassPostBecome:effects: for the bogus temp classes the
Newspeak bootstrap creates.

Get obj stack swizzling correct.

Update firstFreeChunk correctly when it is allocated in the compaction routines.

Break out of the search loop sooner in allocateOldSpaceChunkOfBytes:suchThat:.

Make Spur snapshot avoid writing trailing free space in each
segment to the image file.

Modified Paths:
--------------
    branches/Cog/nscogsrc/plugins/FilePlugin/FilePlugin.c
    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/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/spursrc/vm/cogit.c
    branches/Cog/spursrc/vm/cogit.h
    branches/Cog/spursrc/vm/cogmethod.h
    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/plugins/FilePlugin/FilePlugin.c
    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/plugins/FilePlugin/FilePlugin.c
===================================================================
--- branches/Cog/nscogsrc/plugins/FilePlugin/FilePlugin.c	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nscogsrc/plugins/FilePlugin/FilePlugin.c	2014-02-20 02:06:56 UTC (rev 2869)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	VMPluginCodeGenerator VMMaker.oscog-eem.580 uuid: 751b08d4-d92e-440a-b3f6-cb2c76f52514
+	VMPluginCodeGenerator VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
    from
-	FilePlugin VMMaker.oscog-eem.580 uuid: 751b08d4-d92e-440a-b3f6-cb2c76f52514
+	FilePlugin VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
-static char __buildInfo[] = "FilePlugin VMMaker.oscog-eem.580 uuid: 751b08d4-d92e-440a-b3f6-cb2c76f52514 " __DATE__ ;
+static char __buildInfo[] = "FilePlugin VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9 " __DATE__ ;
 
 
 
@@ -180,9 +180,9 @@
 struct VirtualMachine* interpreterProxy;
 static const char *moduleName =
 #ifdef SQUEAK_BUILTIN_PLUGIN
-	"FilePlugin VMMaker.oscog-eem.580 (i)"
+	"FilePlugin VMMaker.oscog-eem.620 (i)"
 #else
-	"FilePlugin VMMaker.oscog-eem.580 (e)"
+	"FilePlugin VMMaker.oscog-eem.620 (e)"
 #endif
 ;
 static void * sCCPfn;
@@ -659,16 +659,12 @@
 	typeString = stackValue(1);
 	fileName = stackValue(2);
 	if (!((isBytes(creatorString))
-		 && ((byteSizeOf(creatorString)) == 4))) {
+		 && ((isBytes(typeString))
+		 && ((isBytes(fileName))
+		 && (((byteSizeOf(creatorString)) == 4)
+		 && ((byteSizeOf(typeString)) == 4)))))) {
 		return primitiveFail();
 	}
-	if (!((isBytes(typeString))
-		 && ((byteSizeOf(typeString)) == 4))) {
-		return primitiveFail();
-	}
-	if (!(isBytes(fileName))) {
-		return primitiveFail();
-	}
 	creatorStringIndex = firstIndexableField(creatorString);
 	typeStringIndex = firstIndexableField(typeString);
 	fileNameIndex = firstIndexableField(fileName);
@@ -678,12 +674,12 @@
 
 	fileNameSize = byteSizeOf(fileName);
 	if (sCSFTfn != 0) {
-		okToSet =  ((sqInt (*)(char *, sqInt))sCSFTfn)(fileNameIndex, fileNameSize);
+		okToSet = ((sqInt (*)(char *, sqInt))sCSFTfn)(fileNameIndex, fileNameSize);
 		if (!okToSet) {
 			return primitiveFail();
 		}
 	}
-	if (!(dir_SetMacFileTypeAndCreator(fileNameIndex, fileNameSize,typeStringIndex, creatorStringIndex))) {
+	if (!(dir_SetMacFileTypeAndCreator(fileNameIndex, fileNameSize, typeStringIndex, creatorStringIndex))) {
 		return primitiveFail();
 	}
 	pop(3);

Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nscogsrc/vm/cointerp.c	2014-02-20 02:06:56 UTC (rev 2869)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
    from
-	CoInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CoInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -2032,7 +2032,7 @@
 	/* 574 */ (void (*)(void))0,
 	/* 575 */ (void (*)(void))0,
  0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.612";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.620";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -4826,6 +4826,7 @@
 							GIV(framePointer) = localFP;
 							
 							ceEnterCogCodePopReceiverReg();
+							null;
 							goto l307;
 						}
 						localIP = pointerForOop(longAt(localFP + FoxIFSavedIP));
@@ -4843,7 +4844,7 @@
 					/* begin fetchNextBytecode */
 					currentBytecode = (byteAtPointer(++localIP)) + GIV(bytecodeSetSelector);
 
-					/* return self */
+					null;
 				l307:	/* end baseFrameReturn */;
 					goto l304;
 				}
@@ -21609,17 +21610,15 @@
 findSPOfon(char *theFP, StackPage *thePage)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     char *aFrame;
+    char *prevFrame;
     char *startFrame;
     char *theSP;
-    char *theSP1;
 
 	/* begin findSPOrNilOf:on:startingFrom: */
 	startFrame = (thePage->headFP);
 	assert(!(isFree(thePage)));
-	aFrame = startFrame;
-	theSP1 = (thePage->headSP);
-	if (aFrame == theFP) {
-		if (theSP1 >= aFrame) {
+	if (startFrame == theFP) {
+		if (((thePage->headSP)) >= startFrame) {
 
 			/* If the SP is invalid return the pointer to the receiver field. */
 
@@ -21630,21 +21629,22 @@
 			goto l1;
 		}
 		theSP = (thePage == GIV(stackPage)
-			? theSP1
-			: theSP1 + BytesPerWord);
+			? (thePage->headSP)
+			: ((thePage->headSP)) + BytesPerWord);
 		goto l1;
 	}
+	aFrame = startFrame;
 	while (1) {
-		/* begin frameCallerSP: */
-		assert(!(isBaseFrame(aFrame)));
-		theSP1 = (aFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(aFrame + FoxMethod)))) < (startOfMemory())
-	? ((mframeCogMethod(aFrame))->cmNumArgs)
-	: byteAt((aFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
+		prevFrame = aFrame;
 		/* begin frameCallerFP: */
 		aFrame = pointerForOop(longAt(aFrame + FoxSavedFP));
 		if (!(aFrame != 0)) break;
 		if (theFP == aFrame) {
-			theSP = theSP1;
+			/* begin frameCallerSP: */
+			assert(!(isBaseFrame(prevFrame)));
+			theSP = (prevFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(prevFrame + FoxMethod)))) < (startOfMemory())
+	? ((mframeCogMethod(prevFrame))->cmNumArgs)
+	: byteAt((prevFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
 			goto l1;
 		}
 	}
@@ -32124,7 +32124,7 @@
 		}
 	}
 	/* begin pop:thenPush: */
-	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), newCopy);
+	longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), newCopy);
 	GIV(stackPointer) = sp;
 }
 
@@ -46777,10 +46777,10 @@
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     char *aFrame;
     sqInt index;
+    char *prevFrame;
     char *startFrame;
     StackPage *thePage;
     char *theSP;
-    char *theSP1;
 
 	if (theFP == GIV(framePointer)) {
 		theSP = GIV(stackPointer);
@@ -46811,10 +46811,8 @@
 				? GIV(framePointer)
 				: (thePage->headFP));
 			assert(!(isFree(thePage)));
-			aFrame = startFrame;
-			theSP1 = (thePage->headSP);
-			if (aFrame == theFP) {
-				if (theSP1 >= aFrame) {
+			if (startFrame == theFP) {
+				if (((thePage->headSP)) >= startFrame) {
 
 					/* If the SP is invalid return the pointer to the receiver field. */
 
@@ -46825,21 +46823,22 @@
 					goto l1;
 				}
 				theSP = (thePage == GIV(stackPage)
-					? theSP1
-					: theSP1 + BytesPerWord);
+					? (thePage->headSP)
+					: ((thePage->headSP)) + BytesPerWord);
 				goto l1;
 			}
+			aFrame = startFrame;
 			while (1) {
-				/* begin frameCallerSP: */
-				assert(!(isBaseFrame(aFrame)));
-				theSP1 = (aFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(aFrame + FoxMethod)))) < (startOfMemory())
-	? ((mframeCogMethod(aFrame))->cmNumArgs)
-	: byteAt((aFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
+				prevFrame = aFrame;
 				/* begin frameCallerFP: */
 				aFrame = pointerForOop(longAt(aFrame + FoxSavedFP));
 				if (!(aFrame != 0)) break;
 				if (theFP == aFrame) {
-					theSP = theSP1;
+					/* begin frameCallerSP: */
+					assert(!(isBaseFrame(prevFrame)));
+					theSP = (prevFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(prevFrame + FoxMethod)))) < (startOfMemory())
+	? ((mframeCogMethod(prevFrame))->cmNumArgs)
+	: byteAt((prevFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
 					goto l1;
 				}
 			}
@@ -51939,6 +51938,7 @@
 		}
 		longAtput((activeContext + BaseHeaderSize) + (StackPointerIndex << ShiftForWord), (((stackIndex - 1) << 1) | 1));
 	}
+	/* begin postSnapshot */
 	marryContextInNewStackPageAndInitializeInterpreterRegisters(activeContext);
 	if (!GIV(primFailCode)) {
 		/* begin push: */

Modified: branches/Cog/nscogsrc/vm/cointerp.h
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.h	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nscogsrc/vm/cointerp.h	2014-02-20 02:06:56 UTC (rev 2869)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
 
 

Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2014-02-20 02:06:56 UTC (rev 2869)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
    from
-	CoInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CoInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -2035,7 +2035,7 @@
 	/* 574 */ (void (*)(void))0,
 	/* 575 */ (void (*)(void))0,
  0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.612";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.620";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -4835,6 +4835,7 @@
 							GIV(framePointer) = localFP;
 							
 							ceEnterCogCodePopReceiverReg();
+							null;
 							goto l307;
 						}
 						localIP = pointerForOop(longAt(localFP + FoxIFSavedIP));
@@ -4852,7 +4853,7 @@
 					/* begin fetchNextBytecode */
 					currentBytecode = (byteAtPointer(++localIP)) + GIV(bytecodeSetSelector);
 
-					/* return self */
+					null;
 				l307:	/* end baseFrameReturn */;
 					goto l304;
 				}
@@ -21618,17 +21619,15 @@
 findSPOfon(char *theFP, StackPage *thePage)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     char *aFrame;
+    char *prevFrame;
     char *startFrame;
     char *theSP;
-    char *theSP1;
 
 	/* begin findSPOrNilOf:on:startingFrom: */
 	startFrame = (thePage->headFP);
 	assert(!(isFree(thePage)));
-	aFrame = startFrame;
-	theSP1 = (thePage->headSP);
-	if (aFrame == theFP) {
-		if (theSP1 >= aFrame) {
+	if (startFrame == theFP) {
+		if (((thePage->headSP)) >= startFrame) {
 
 			/* If the SP is invalid return the pointer to the receiver field. */
 
@@ -21639,21 +21638,22 @@
 			goto l1;
 		}
 		theSP = (thePage == GIV(stackPage)
-			? theSP1
-			: theSP1 + BytesPerWord);
+			? (thePage->headSP)
+			: ((thePage->headSP)) + BytesPerWord);
 		goto l1;
 	}
+	aFrame = startFrame;
 	while (1) {
-		/* begin frameCallerSP: */
-		assert(!(isBaseFrame(aFrame)));
-		theSP1 = (aFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(aFrame + FoxMethod)))) < (startOfMemory())
-	? ((mframeCogMethod(aFrame))->cmNumArgs)
-	: byteAt((aFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
+		prevFrame = aFrame;
 		/* begin frameCallerFP: */
 		aFrame = pointerForOop(longAt(aFrame + FoxSavedFP));
 		if (!(aFrame != 0)) break;
 		if (theFP == aFrame) {
-			theSP = theSP1;
+			/* begin frameCallerSP: */
+			assert(!(isBaseFrame(prevFrame)));
+			theSP = (prevFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(prevFrame + FoxMethod)))) < (startOfMemory())
+	? ((mframeCogMethod(prevFrame))->cmNumArgs)
+	: byteAt((prevFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
 			goto l1;
 		}
 	}
@@ -32133,7 +32133,7 @@
 		}
 	}
 	/* begin pop:thenPush: */
-	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), newCopy);
+	longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), newCopy);
 	GIV(stackPointer) = sp;
 }
 
@@ -46786,10 +46786,10 @@
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     char *aFrame;
     sqInt index;
+    char *prevFrame;
     char *startFrame;
     StackPage *thePage;
     char *theSP;
-    char *theSP1;
 
 	if (theFP == GIV(framePointer)) {
 		theSP = GIV(stackPointer);
@@ -46820,10 +46820,8 @@
 				? GIV(framePointer)
 				: (thePage->headFP));
 			assert(!(isFree(thePage)));
-			aFrame = startFrame;
-			theSP1 = (thePage->headSP);
-			if (aFrame == theFP) {
-				if (theSP1 >= aFrame) {
+			if (startFrame == theFP) {
+				if (((thePage->headSP)) >= startFrame) {
 
 					/* If the SP is invalid return the pointer to the receiver field. */
 
@@ -46834,21 +46832,22 @@
 					goto l1;
 				}
 				theSP = (thePage == GIV(stackPage)
-					? theSP1
-					: theSP1 + BytesPerWord);
+					? (thePage->headSP)
+					: ((thePage->headSP)) + BytesPerWord);
 				goto l1;
 			}
+			aFrame = startFrame;
 			while (1) {
-				/* begin frameCallerSP: */
-				assert(!(isBaseFrame(aFrame)));
-				theSP1 = (aFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(aFrame + FoxMethod)))) < (startOfMemory())
-	? ((mframeCogMethod(aFrame))->cmNumArgs)
-	: byteAt((aFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
+				prevFrame = aFrame;
 				/* begin frameCallerFP: */
 				aFrame = pointerForOop(longAt(aFrame + FoxSavedFP));
 				if (!(aFrame != 0)) break;
 				if (theFP == aFrame) {
-					theSP = theSP1;
+					/* begin frameCallerSP: */
+					assert(!(isBaseFrame(prevFrame)));
+					theSP = (prevFrame + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(prevFrame + FoxMethod)))) < (startOfMemory())
+	? ((mframeCogMethod(prevFrame))->cmNumArgs)
+	: byteAt((prevFrame + FoxIFrameFlags) + 1))))) + BytesPerWord;
 					goto l1;
 				}
 			}
@@ -51948,6 +51947,7 @@
 		}
 		longAtput((activeContext + BaseHeaderSize) + (StackPointerIndex << ShiftForWord), (((stackIndex - 1) << 1) | 1));
 	}
+	/* begin postSnapshot */
 	marryContextInNewStackPageAndInitializeInterpreterRegisters(activeContext);
 	if (!GIV(primFailCode)) {
 		/* begin push: */

Modified: branches/Cog/nscogsrc/vm/interp.h
===================================================================
--- branches/Cog/nscogsrc/vm/interp.h	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nscogsrc/vm/interp.h	2014-02-20 02:06:56 UTC (rev 2869)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
 
 #define VM_PROXY_MAJOR 1

Modified: branches/Cog/nscogsrc/vm/vmCallback.h
===================================================================
--- branches/Cog/nscogsrc/vm/vmCallback.h	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nscogsrc/vm/vmCallback.h	2014-02-20 02:06:56 UTC (rev 2869)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
 
 #define VM_CALLBACK_INC 1

Modified: branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c
===================================================================
--- branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c	2014-02-20 02:06:56 UTC (rev 2869)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
    from
-	StackInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	StackInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
-static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3 " __DATE__ ;
+static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -74,6 +74,8 @@
 	usqInt	segSize;
 	sqInt	swizzle;
 	usqInt	containsPinned;
+	usqInt	savedSegSize;
+	usqInt	lastFreeObject;
  } SpurSegmentInfo;
 
 
@@ -483,7 +485,7 @@
 static sqInt fetchPointerofFreeChunk(sqInt fieldIndex, sqInt objOop);
 sqInt fetchPointerofObject(sqInt fieldIndex, sqInt objOop);
 static sqInt fetchStackPointerOf(sqInt aContext);
-static void fillHighestObjectsWithMovableObjectsFromupTo(sqInt startObj, sqInt limitObj);
+static void fillHighestObjectsWithMovableObjectsFromFirstFreeChunkUpTo(sqInt limitObj);
 static sqInt findApplicationOfTargetMixinstartingAtBehavior(sqInt targetMixin, sqInt aBehavior);
 static sqInt findClassContainingMethodstartingAt(sqInt meth, sqInt classObj);
 sqInt findClassOfMethodforReceiver(sqInt meth, sqInt rcvr);
@@ -608,6 +610,7 @@
 static sqInt isContextHeader(sqInt aHeader);
 static sqInt isContextNonImm(sqInt oop);
 static sqInt isContext(sqInt oop);
+static sqInt isEmptyObjStack(sqInt objStack);
 static sqInt isEnumerableObjectNoAssert(sqInt objOop);
 static sqInt isEnumerableObject(sqInt objOop);
 static sqInt isEphemeron(sqInt objOop);
@@ -651,6 +654,7 @@
 static sqInt isScavengeSurvivor(sqInt oop);
 static sqInt isSegmentBridge(sqInt objOop);
 static sqInt isSingleContext(sqInt aContext);
+static sqInt isValidClassIndex(sqInt classIndex);
 static sqInt isValidFreeObject(sqInt objOop);
 static sqInt isValidObjStackAt(sqInt objStackRootIndex);
 static sqInt isValidObjStackPagemyIndex(sqInt objStackPage, sqInt myx);
@@ -1213,8 +1217,8 @@
 _iss sqInt primFailCode;
 _iss sqInt specialObjectsOop;
 _iss usqInt method;
+_iss sqInt nilObj;
 _iss StackPage * stackPage;
-_iss sqInt nilObj;
 _iss sqInt bytecodeSetSelector;
 _iss char * framePointer;
 _iss sqInt argumentCount;
@@ -1230,24 +1234,24 @@
 _iss sqInt trueObj;
 _iss sqInt falseObj;
 _iss sqInt remapBufferCount;
+_iss SpurSegmentInfo * segments;
 _iss sqInt * freeLists;
 _iss StackPage * pages;
-_iss SpurSegmentInfo * segments;
 _iss usqInt freeListsMask;
 _iss usqInt pastSpaceStart;
+_iss sqInt numSegments;
 _iss char * stackMemory;
+_iss sqInt firstFreeChunk;
 _iss char * stackLimit;
+_iss sqInt weaklingStack;
 _iss sqInt bytesPerPage;
 _iss sqInt rememberedSetSize;
 _iss SpurNewSpaceSpace pastSpace;
-_iss sqInt weaklingStack;
 _iss SpurContiguousObjStack unscannedEphemerons;
 _iss SpurNewSpaceSpace futureSpace;
-_iss sqInt numSegments;
 _iss StackPage * mostRecentlyUsedPage;
 _iss sqInt classTableFirstPage;
 _iss usqInt newSpaceStart;
-_iss sqInt firstFreeChunk;
 _iss sqInt futureSurvivorStart;
 _iss usqInt oldSpaceStart;
 _iss sqInt jmpDepth;
@@ -1267,8 +1271,10 @@
 _iss sqInt profileProcess;
 _iss sqInt extraRootCount;
 _iss sqInt invalidObjStackPage;
+_iss sqInt lastSubdividedFreeChunk;
 _iss sqInt previousRememberedSetSize;
 _iss unsigned char * classTableBitmap;
+_iss usqInt freeOldSpaceStart;
 _iss sqInt longRunningPrimitiveCheckMethod;
 _iss sqInt longRunningPrimitiveCheckSemaphore;
 _iss sqInt profileMethod;
@@ -1281,12 +1287,10 @@
 _iss sqInt profileSemaphore;
 _iss sqInt classTableIndex;
 _iss sqInt highestRunnableProcessPriority;
-_iss sqInt lastSubdividedFreeChunk;
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
 _iss sqInt numSegInfos;
 _iss sqInt statCheckForEvents;
-_iss usqInt freeOldSpaceStart;
 _iss usqInt lowSpaceThreshold;
 _iss usqLong statGCEndUsecs;
 _iss sqInt externalPrimitiveTableFirstFreeIndex;
@@ -1297,13 +1301,13 @@
 _iss sqInt weakList;
 _iss sqInt firstSegmentSize;
 _iss usqLong gcStartUsecs;
+_iss sqInt lastHash;
 _iss usqInt memory;
 _iss usqInt scavengeThreshold;
 _iss sqInt statCompactPassCount;
 _iss sqInt thisClassIndex;
 _iss sqInt fullScreenFlag;
 _iss sqInt interruptPending;
-_iss sqInt lastHash;
 _iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt marking;
 _iss sqInt methodDictLinearSearchLimit;
@@ -1970,7 +1974,7 @@
  0 };
 char * breakSelector;
 sqInt breakSelectorLength = -1;
-const char *interpreterVersion = "Newspeak Virtual Machine StackInterpreter_VMMaker.oscog-eem.612";
+const char *interpreterVersion = "Newspeak Virtual Machine StackInterpreter_VMMaker.oscog-eem.620";
 volatile int sendTrace;
 sqInt suppressHeartbeatFlag;
 
@@ -18666,7 +18670,12 @@
 static void
 compact(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+	assert((GIV(firstFreeChunk) == 0)
+	 || (isFreeObject(GIV(firstFreeChunk))));
 	exactFitCompact();
+	assert((GIV(firstFreeChunk) == 0)
+	 || ((isFreeObject(GIV(firstFreeChunk)))
+	 || (isValidClassIndex(classIndexOf(GIV(firstFreeChunk))))));
 	if ((usedSize(&GIV(highestObjects))) > 0) {
 		firstFitCompact();
 	}
@@ -20705,6 +20714,7 @@
     sqInt fieldIndex1;
     sqInt fieldIndex2;
     sqInt first;
+    sqInt fo;
     sqInt freeObj;
     sqInt freeObj1;
     sqInt freeObj2;
@@ -20881,7 +20891,22 @@
 								longAtput(misfits, longAt(ptr));
 							}
 							else {
+
+								/* here's a wrinkle; if the firstFreeChunk is allocated to a small object and the firstFreeChunk
+								   is a large chunk then firstFreeChunk will no longer point to an object header.  So check and
+								   adjust firstFreeChunk if it is assigned to. */
+
 								nfits += 1;
+								/* begin objectStartingAt: */
+								/* begin rawNumSlotsOf: */
+								flag("endianness");
+								numSlots = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
+								fo = (numSlots == 0xFF
+									? f + (BaseHeaderSize)
+									: f);
+								if (fo == GIV(firstFreeChunk)) {
+									GIV(firstFreeChunk) = objectAfter(fo);
+								}
 								/* begin copyAndForward:withBytes:toFreeChunk: */
 								startOfObj = ((rawNumSlotsOf(longAt(ptr))) == 0xFF
 									? (longAt(ptr)) - (BaseHeaderSize)
@@ -20921,15 +20946,6 @@
 									}
 								}
 								longAtput(((longAt(ptr)) + (BaseHeaderSize)) + (0 << 2), freeObj);
-								if (f == GIV(firstFreeChunk)) {
-									/* begin objectStartingAt: */
-									/* begin rawNumSlotsOf: */
-									flag("endianness");
-									numSlots = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
-									GIV(firstFreeChunk) = (numSlots == 0xFF
-										? f + (BaseHeaderSize)
-										: f);
-								}
 							}
 						}
 
@@ -21068,7 +21084,22 @@
 								longAtput(misfits, longAt(ptr));
 							}
 							else {
+
+								/* here's a wrinkle; if the firstFreeChunk is allocated to a small object and the firstFreeChunk
+								   is a large chunk then firstFreeChunk will no longer point to an object header.  So check and
+								   adjust firstFreeChunk if it is assigned to. */
+
 								nfits += 1;
+								/* begin objectStartingAt: */
+								/* begin rawNumSlotsOf: */
+								flag("endianness");
+								numSlots = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
+								fo = (numSlots == 0xFF
+									? f + (BaseHeaderSize)
+									: f);
+								if (fo == GIV(firstFreeChunk)) {
+									GIV(firstFreeChunk) = objectAfter(fo);
+								}
 								/* begin copyAndForward:withBytes:toFreeChunk: */
 								startOfObj1 = ((rawNumSlotsOf(longAt(ptr))) == 0xFF
 									? (longAt(ptr)) - (BaseHeaderSize)
@@ -21108,15 +21139,6 @@
 									}
 								}
 								longAtput(((longAt(ptr)) + (BaseHeaderSize)) + (0 << 2), freeObj1);
-								if (f == GIV(firstFreeChunk)) {
-									/* begin objectStartingAt: */
-									/* begin rawNumSlotsOf: */
-									flag("endianness");
-									numSlots = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
-									GIV(firstFreeChunk) = (numSlots == 0xFF
-										? f + (BaseHeaderSize)
-										: f);
-								}
 							}
 						}
 
@@ -21247,7 +21269,22 @@
 							longAtput(misfits, longAt(ptr));
 						}
 						else {
+
+							/* here's a wrinkle; if the firstFreeChunk is allocated to a small object and the firstFreeChunk
+							   is a large chunk then firstFreeChunk will no longer point to an object header.  So check and
+							   adjust firstFreeChunk if it is assigned to. */
+
 							nfits += 1;
+							/* begin objectStartingAt: */
+							/* begin rawNumSlotsOf: */
+							flag("endianness");
+							numSlots = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
+							fo = (numSlots == 0xFF
+								? f + (BaseHeaderSize)
+								: f);
+							if (fo == GIV(firstFreeChunk)) {
+								GIV(firstFreeChunk) = objectAfter(fo);
+							}
 							/* begin copyAndForward:withBytes:toFreeChunk: */
 							startOfObj2 = ((rawNumSlotsOf(longAt(ptr))) == 0xFF
 								? (longAt(ptr)) - (BaseHeaderSize)
@@ -21287,15 +21324,6 @@
 								}
 							}
 							longAtput(((longAt(ptr)) + (BaseHeaderSize)) + (0 << 2), freeObj2);
-							if (f == GIV(firstFreeChunk)) {
-								/* begin objectStartingAt: */
-								/* begin rawNumSlotsOf: */
-								flag("endianness");
-								numSlots = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
-								GIV(firstFreeChunk) = (numSlots == 0xFF
-									? f + (BaseHeaderSize)
-									: f);
-							}
 						}
 					}
 
@@ -21341,7 +21369,7 @@
 		memmove(((void *)(oldLimit - bytesToMove)), ((void *)((GIV(highestObjects).start))), bytesToMove);
 		savedLimit = oldLimit;
 	l2:	/* end moveMisfitsToTopOfHighestObjects: */;
-		fillHighestObjectsWithMovableObjectsFromupTo(GIV(firstFreeChunk), first);
+		fillHighestObjectsWithMovableObjectsFromFirstFreeChunkUpTo(first);
 		/* begin moveMisfitsInHighestObjectsBack: */
 		if (savedLimit == ((GIV(highestObjects).limit))) {
 			misfits = (GIV(highestObjects).last);
@@ -22130,12 +22158,10 @@
 
 
 /*	Refill highestObjects with movable objects up to, but not including
-	limitObj. c.f. the loop in
-	freeUnmarkedObjectsNilUnmarkedWeaklingSlotsAndSortAndCoalesceFreeSpace. 
- */
+	limitObj. c.f. the loop in freeUnmarkedObjectsAndSortAndCoalesceFreeSpace. */
 
 static void
-fillHighestObjectsWithMovableObjectsFromupTo(sqInt startObj, sqInt limitObj)
+fillHighestObjectsWithMovableObjectsFromFirstFreeChunkUpTo(sqInt limitObj)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt firstFree;
     sqInt highestObjectsWraps;
@@ -22145,6 +22171,9 @@
     sqInt prevObj;
     sqInt prevPrevObj;
 
+	assert((GIV(firstFreeChunk) == 0)
+	 || ((isFreeObject(GIV(firstFreeChunk)))
+	 || (isValidClassIndex(classIndexOf(GIV(firstFreeChunk))))));
 	/* begin resetAsEmpty */
 	(GIV(highestObjects).first) = (GIV(highestObjects).start);
 	(GIV(highestObjects).last) = ((GIV(highestObjects).start)) - (wordSize());
@@ -22153,16 +22182,17 @@
 	highestObjectsWraps = (firstFree = 0);
 	/* begin allOldSpaceEntitiesFrom:do: */
 	prevPrevObj = (prevObj = null);
-	objOop = startObj;
+	objOop = GIV(firstFreeChunk);
 	while (1) {
 		assert((objOop % (allocationUnit())) == 0);
 		if (!((((usqInt) objOop)) < (((usqInt) GIV(endOfMemory))))) break;
 		assert((longLongAt(objOop)) != 0);
 		if ((((usqInt) objOop)) >= (((usqInt) limitObj))) {
 			(GIV(highestObjects).last = lastHighest);
-			if ((firstFree != 0)
-			 && (!(((longAt(GIV(firstFreeChunk))) & 0x3FFFFF) == 0))) {
-				GIV(firstFreeChunk) = firstFree;
+			if (!(((longAt(GIV(firstFreeChunk))) & 0x3FFFFF) == 0)) {
+				GIV(firstFreeChunk) = (firstFree == 0
+					? limitObj
+					: firstFree);
 			}
 			return;
 		}
@@ -22196,10 +22226,14 @@
 	
 	
 	(GIV(highestObjects).last = lastHighest);
-	if ((firstFree != 0)
-	 && (!(((longAt(GIV(firstFreeChunk))) & 0x3FFFFF) == 0))) {
-		GIV(firstFreeChunk) = firstFree;
+	if (!(((longAt(GIV(firstFreeChunk))) & 0x3FFFFF) == 0)) {
+		GIV(firstFreeChunk) = (firstFree == 0
+			? limitObj
+			: firstFree);
 	}
+	assert((GIV(firstFreeChunk) == 0)
+	 || ((isFreeObject(GIV(firstFreeChunk)))
+	 || (isValidClassIndex(classIndexOf(GIV(firstFreeChunk))))));
 }
 
 
@@ -22683,17 +22717,15 @@
 findSPOfon(char *theFP, StackPage *thePage)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     char *aFrame;
+    char *prevFrame;
     char *startFrame;
     char *theSP;
-    char *theSP1;
 
 	/* begin findSPOrNilOf:on:startingFrom: */
 	startFrame = (thePage->headFP);
 	assert(!(isFree(thePage)));
-	aFrame = startFrame;
-	theSP1 = (thePage->headSP);
-	if (aFrame == theFP) {
-		if (theSP1 >= aFrame) {
+	if (startFrame == theFP) {
+		if (((thePage->headSP)) >= startFrame) {
 
 			/* If the SP is invalid return the pointer to the receiver field. */
 
@@ -22702,19 +22734,20 @@
 			goto l1;
 		}
 		theSP = (thePage == GIV(stackPage)
-			? theSP1
-			: theSP1 + BytesPerWord);
+			? (thePage->headSP)
+			: ((thePage->headSP)) + BytesPerWord);
 		goto l1;
 	}
+	aFrame = startFrame;
 	while (1) {
-		/* begin frameCallerSP: */
-		assert(!(isBaseFrame(aFrame)));
-		theSP1 = (aFrame + ((FoxCallerSavedIP + BytesPerWord) + ((byteAt((aFrame + FoxFrameFlags) + 1)) << ShiftForWord))) + BytesPerWord;
+		prevFrame = aFrame;
 		/* begin frameCallerFP: */
 		aFrame = pointerForOop(longAt(aFrame + FoxSavedFP));
 		if (!(aFrame != 0)) break;
 		if (theFP == aFrame) {
-			theSP = theSP1;
+			/* begin frameCallerSP: */
+			assert(!(isBaseFrame(prevFrame)));
+			theSP = (prevFrame + ((FoxCallerSavedIP + BytesPerWord) + ((byteAt((prevFrame + FoxFrameFlags) + 1)) << ShiftForWord))) + BytesPerWord;
 			goto l1;
 		}
 	}
@@ -23041,6 +23074,7 @@
     usqLong childBytes;
     sqInt f;
     sqInt first;
+    sqInt fo;
     sqInt freeObj;
     sqInt index;
     sqInt initialIndex;
@@ -23049,6 +23083,7 @@
     sqInt nmisses;
     sqInt node;
     usqInt numSlots;
+    usqInt numSlots1;
     sqInt o;
     sqInt prev;
     usqInt ptr;
@@ -23077,6 +23112,9 @@
  && (ptr <= ((GIV(highestObjects).last))))
 						 || ((((GIV(highestObjects).first)) <= ptr)
 						 && (ptr <= ((GIV(highestObjects).limit))))));
+				assert((GIV(firstFreeChunk) == 0)
+				 || ((isFreeObject(GIV(firstFreeChunk)))
+				 || (isValidClassIndex(classIndexOf(GIV(firstFreeChunk))))));
 				if ((((usqInt) (longAt(ptr)))) <= (((usqInt) GIV(firstFreeChunk)))) {
 					print("firstFitCompact fits: ");
 					printNum(nhits);
@@ -23261,25 +23299,30 @@
 							}
 							else {
 								flag("we can do better here; preferentially choosing the lowest node. That would be a form of best-fit since we are trying to compact down");
+								node = child;
+								child = longAt((node + (BaseHeaderSize)) + (3 << 2));
 								if (acceptedNode == 0) {
 
 									/* first search the list. */
 
-									acceptedChunk = child;
+									acceptedChunk = node;
 									do {
 										acceptedChunk = longAt((acceptedChunk + (BaseHeaderSize)) + (0 << 2));
 										if ((acceptedChunk != 0)
 										 && (acceptedChunk < (longAt(ptr)))) {
-											acceptedNode = child;
+											acceptedNode = node;
 										}
 									} while((acceptedChunk != 0)
  && (acceptedNode == 0));
 									if ((acceptedNode == 0)
-									 && (child < (longAt(ptr)))) {
-										acceptedNode = child;
+									 && (node < (longAt(ptr)))) {
+										acceptedNode = node;
+
+										/* break out of loop now we have an acceptedNode */
+
+										child = 0;
 									}
 								}
-								child = longAt((child + (BaseHeaderSize)) + (3 << 2));
 							}
 						}
 					}
@@ -23336,7 +23379,30 @@
 						nmisses += 1;
 					}
 					else {
+
+						/* here's a wrinkle; if the firstFreeChunk is allocated to a small object and the firstFreeChunk
+						   is a large chunk then firstFreeChunk will no longer point to an object header.  So check and
+						   adjust firstFreeChunk if it is assigned to. */
+
 						nhits += 1;
+						/* begin objectStartingAt: */
+						/* begin rawNumSlotsOf: */
+						flag("endianness");
+						numSlots1 = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
+						fo = (numSlots1 == 0xFF
+							? f + (BaseHeaderSize)
+							: f);
+						if (fo == GIV(firstFreeChunk)) {
+							GIV(firstFreeChunk) = (GIV(lastSubdividedFreeChunk) == 0
+								? objectAfter(fo)
+								: (/* begin objectStartingAt: */
+									/* begin rawNumSlotsOf: */
+									flag("endianness"),
+									(numSlots = ((usqInt) (((usqInt)(longAt(GIV(lastSubdividedFreeChunk) + 4))))) >> 24),
+									(numSlots == 0xFF
+											? GIV(lastSubdividedFreeChunk) + (BaseHeaderSize)
+											: GIV(lastSubdividedFreeChunk))));
+						}
 						/* begin copyAndForward:withBytes:toFreeChunk: */
 						startOfObj = ((rawNumSlotsOf(longAt(ptr))) == 0xFF
 							? (longAt(ptr)) - (BaseHeaderSize)
@@ -23376,15 +23442,6 @@
 							}
 						}
 						longAtput(((longAt(ptr)) + (BaseHeaderSize)) + (0 << 2), freeObj);
-						if (f == GIV(firstFreeChunk)) {
-							/* begin objectStartingAt: */
-							/* begin rawNumSlotsOf: */
-							flag("endianness");
-							numSlots = ((usqInt) (((usqInt)(longAt(f + 4))))) >> 24;
-							GIV(firstFreeChunk) = (numSlots == 0xFF
-								? f + (BaseHeaderSize)
-								: f);
-						}
 						assert((GIV(lastSubdividedFreeChunk) == 0)
 						 || ((addressAfter(objectStartingAt(f))) == GIV(lastSubdividedFreeChunk)));
 					}
@@ -23406,7 +23463,7 @@
 		assert(GIV(totalFreeOldSpace) == (totalFreeListBytes()));
 		first = longAt((GIV(highestObjects).first));
 		assert(oopisGreaterThan(first, GIV(firstFreeChunk)));
-		fillHighestObjectsWithMovableObjectsFromupTo(GIV(firstFreeChunk), first);
+		fillHighestObjectsWithMovableObjectsFromFirstFreeChunkUpTo(first);
 	} while((usedSize(&GIV(highestObjects))) > 0);
 	print("firstFitCompact fits: ");
 	printNum(nhits);
@@ -24619,6 +24676,8 @@
 		/* begin rawNumSlotsOf: */
 		flag("endianness");
 		rawNumSlots = ((usqInt) (((usqInt)(longAt(objOop + 4))))) >> 24;
+		assert((GIV(firstFreeChunk) == 0)
+		 || (isFreeObject(GIV(firstFreeChunk))));
 		if (isMarked(objOop)) {
 
 			/* forwarders should have been followed in markAndTrace: */
@@ -24709,9 +24768,6 @@
 			l2:	/* end coalesce:and: */;
 				next = objectAfterlimit(here, limit);
 			}
-			if (GIV(firstFreeChunk) == 0) {
-				GIV(firstFreeChunk) = here;
-			}
 			if ((((sqInt) (bytesInObject(here)) >> 3)) >= 32) {
 				/* begin setFree: */
 				long32Atput(here, 0);
@@ -24752,6 +24808,10 @@
 				longAtput((here + (BaseHeaderSize)) + (0 << 2), GIV(freeLists)[index1]);
 				GIV(freeLists)[index1] = here;
 			}
+			if (GIV(firstFreeChunk) == 0) {
+				assert(isFreeObject(here));
+				GIV(firstFreeChunk) = here;
+			}
 		}
 
 		/* begin rawNumSlotsOf: */
@@ -24916,6 +24976,7 @@
 	compact();
 	eliminateAndFreeForwarders();
 	assert(validObjStacks());
+	assert(isEmptyObjStack(GIV(weaklingStack)));
 	assert(allObjectsUnmarked());
 	/* begin runLeakCheckerForFullGC: */
 	runLeakCheckerForFullGCexcludeUnmarkedNewSpaceObjs(1, 0);
@@ -26258,6 +26319,8 @@
 	GIV(markStack) = swizzleObjStackAt(MarkStackRootIndex);
 	GIV(weaklingStack) = swizzleObjStackAt(WeaklingStackRootIndex);
 	GIV(ephemeronQueue) = swizzleObjStackAt(EphemeronQueueRootIndex);
+	assert(validObjStacks());
+	assert(isEmptyObjStack(GIV(weaklingStack)));
 	/* begin initializeFreeSpacePostLoad: */
 	assert((numSlotsOf(freeListObj)) == (numFreeLists()));
 	assert((formatOf(freeListObj)) == (firstLongFormat()));
@@ -26780,7 +26843,18 @@
 	 && (((longAt(oop)) & 0x3FFFFF) == ClassMethodContextCompactIndex);
 }
 
+static sqInt
+isEmptyObjStack(sqInt objStack)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+	if (objStack == GIV(nilObj)) {
+		return 1;
+	}
+	assert(isValidObjStack(objStack));
+	return (0 == (longAt((objStack + (BaseHeaderSize)) + (ObjStackTopx << 2))))
+	 && (0 == (longAt((objStack + (BaseHeaderSize)) + (ObjStackNextx << 2))));
+}
 
+
 /*	Answer if objOop should be included in an allObjects...Do: enumeration.
 	Non-objects should be excluded; these are bridges and free chunks. */
 
@@ -27240,6 +27314,31 @@
 }
 
 static sqInt
+isValidClassIndex(sqInt classIndex)
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt classTablePage;
+
+	if (classIndex <= 0) {
+		return 0;
+	}
+	if (!((classIndex <= 3)
+		 || (classIndex >= 16))) {
+		return 0;
+	}
+	if (classIndex >= (1 << 22)) {
+		return 0;
+	}
+	classTablePage = longAt((GIV(hiddenRootsObj) + (BaseHeaderSize)) + ((((usqInt) classIndex) >> 10) << 2));
+	if (classTablePage == GIV(nilObj)) {
+		return 0;
+	}
+	if (!(addressCouldBeObj(classTablePage))) {
+		0;
+	}
+	return addressCouldBeClassObj(longAt((classTablePage + (BaseHeaderSize)) + ((classIndex & ((1 << 10) - 1)) << 2)));
+}
+
+static sqInt
 isValidFreeObject(sqInt objOop)
 {
     sqInt chunk;
@@ -30711,18 +30810,15 @@
 }
 
 
-/*	Use simple algorithm by D.H. Lehmer from 1951, for now. */
+/*	Use a slight variation on D.H. Lehmer's linear congruential generator from
+	1951. See e.g. http://en.wikipedia.org/wiki/Linear_congruential_generator. */
 
 static sqInt
 newObjectHash(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
-
-	/* 7 raisedTo: 5 */
-	/* (2 raisedTo: 31) - 1 */
-
-	GIV(lastHash) = (GIV(lastHash) * 16807) % 2147483645;
+	GIV(lastHash) = GIV(lastHash) * 16807;
 	assert(GIV(lastHash) != 0);
-	return GIV(lastHash);
+	return GIV(lastHash) + (((usqInt) GIV(lastHash)) >> 8);
 }
 
 static sqInt
@@ -30777,6 +30873,9 @@
     sqInt topIndex;
     sqInt weakling;
 
+	if (GIV(weaklingStack) == GIV(nilObj)) {
+		return;
+	}
 	/* begin objStack:from:do: */
 	size = longAt((GIV(weaklingStack) + (BaseHeaderSize)) + (ObjStackTopx << 2));
 	objStackPage = longAt((GIV(weaklingStack) + (BaseHeaderSize)) + (ObjStackNextx << 2));
@@ -30804,6 +30903,9 @@
 	}
 	size;
 	/* begin emptyObjStack: */
+	if (GIV(weaklingStack) == GIV(nilObj)) {
+		goto l1;
+	}
 	assert(isValidObjStack(GIV(weaklingStack)));
 	/* begin storePointer:ofObject:withValue: */
 	assert(!(isForwarded(GIV(weaklingStack))));
@@ -30845,6 +30947,7 @@
 	null;
 	longAtput((GIV(weaklingStack) + (BaseHeaderSize)) + (ObjStackNextx << 2), 0);
 	assert(isValidObjStack(GIV(weaklingStack)));
+l1:	/* end emptyObjStack: */;
 }
 
 
@@ -34234,7 +34337,7 @@
 		}
 	}
 	/* begin pop:thenPush: */
-	longAtput((sp = GIV(stackPointer) + ((1 - 1) * BytesPerWord)), newCopy);
+	longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), newCopy);
 	GIV(stackPointer) = sp;
 }
 
@@ -49216,10 +49319,10 @@
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     char *aFrame;
     sqInt index;
+    char *prevFrame;
     char *startFrame;
     StackPage *thePage;
     char *theSP;
-    char *theSP1;
 
 	if (theFP == GIV(framePointer)) {
 		theSP = GIV(stackPointer);
@@ -49243,10 +49346,8 @@
 			? GIV(framePointer)
 			: (thePage->headFP));
 		assert(!(isFree(thePage)));
-		aFrame = startFrame;
-		theSP1 = (thePage->headSP);
-		if (aFrame == theFP) {
-			if (theSP1 >= aFrame) {
+		if (startFrame == theFP) {
+			if (((thePage->headSP)) >= startFrame) {
 
 				/* If the SP is invalid return the pointer to the receiver field. */
 
@@ -49255,19 +49356,20 @@
 				goto l1;
 			}
 			theSP = (thePage == GIV(stackPage)
-				? theSP1
-				: theSP1 + BytesPerWord);
+				? (thePage->headSP)
+				: ((thePage->headSP)) + BytesPerWord);
 			goto l1;
 		}
+		aFrame = startFrame;
 		while (1) {
-			/* begin frameCallerSP: */
-			assert(!(isBaseFrame(aFrame)));
-			theSP1 = (aFrame + ((FoxCallerSavedIP + BytesPerWord) + ((byteAt((aFrame + FoxFrameFlags) + 1)) << ShiftForWord))) + BytesPerWord;
+			prevFrame = aFrame;
 			/* begin frameCallerFP: */
 			aFrame = pointerForOop(longAt(aFrame + FoxSavedFP));
 			if (!(aFrame != 0)) break;
 			if (theFP == aFrame) {
-				theSP = theSP1;
+				/* begin frameCallerSP: */
+				assert(!(isBaseFrame(prevFrame)));
+				theSP = (prevFrame + ((FoxCallerSavedIP + BytesPerWord) + ((byteAt((prevFrame + FoxFrameFlags) + 1)) << ShiftForWord))) + BytesPerWord;
 				goto l1;
 			}
 		}
@@ -53228,6 +53330,11 @@
 	assert(becomeEffects & BecamePointerObjectFlag);
 	classObj = startClassObj;
 	while (1) {
+		if (!((((classObj & 3) == 0)
+ && (((((usqInt) (longAt(classObj))) >> 24) & 0x1F) <= 5))
+			 && ((numSlotsOf(classObj)) > MethodDictionaryIndex))) {
+			return;
+		}
 		/* begin followObjField:ofObject: */
 		objOop1 = longAt((classObj + (BaseHeaderSize)) + (MethodDictionaryIndex << 2));
 		assert(isNonImmediate(objOop1));
@@ -55077,9 +55184,22 @@
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt activeContext;
     sqInt activeProc;
+    sqInt address;
+    sqInt bytes;
+    sqInt cameFrom;
+    SpurSegmentInfo * cascade0;
     sqInt errorCode;
+    usqInt freeChunk;
+    usqInt freeChunk1;
     sqInt i;
+    sqInt i1;
+    sqInt i2;
+    sqInt i3;
+    sqInt largeChild;
     sqInt methodHeader;
+    sqInt newEndOfMemory;
+    sqInt newEndOfMemory1;
+    sqInt next;
     sqInt numArgs;
     sqInt numTemps;
     sqInt object;
@@ -55087,7 +55207,9 @@
     sqInt rcvr;
     sqInt rcvr1;
     sqInt savedTenuringThreshold;
+    SpurSegmentInfo *seg;
     void *setMacType;
+    sqInt smallChild;
     char *sp;
     char *sp1;
     char *sp11;
@@ -55100,6 +55222,7 @@
     char *sp8;
     sqInt stackIndex;
     sqInt table;
+    sqInt treeNode;
 
 
 	/* For now the stack munging below doesn't deal with more than one argument.
@@ -55147,6 +55270,82 @@
 	assert(GIV(pastSpaceStart) == (((pastSpace()).start)));
 	assert(GIV(freeStart) == (((eden()).start)));
 	fullGC();
+	/* begin prepareForSnapshot */
+	for (i2 = 0; i2 < GIV(numSegments); i2 += 1) {
+		cascade0 = (&(GIV(segments)[i2]));
+		(cascade0->savedSegSize = ((GIV(segments)[i2]).segSize));
+		(cascade0->lastFreeObject = null);
+	}
+	/* begin freeTreeNodesDo: */
+	treeNode = GIV(freeLists)[0];
+	if (treeNode == 0) {
+		goto l2;
+	}
+	cameFrom = -1;
+	do {
+		smallChild = longAt((treeNode + (BaseHeaderSize)) + (3 << 2));
+		largeChild = longAt((treeNode + (BaseHeaderSize)) + (4 << 2));
+		assert((smallChild == 0)
+		 || (treeNode == (fetchPointerofFreeChunk(freeChunkParentIndex(), smallChild))));
+		assert((largeChild == 0)
+		 || (treeNode == (fetchPointerofFreeChunk(freeChunkParentIndex(), largeChild))));
+		if (((smallChild == 0)
+ && (largeChild == 0))
+		 || ((largeChild == 0
+			? cameFrom == smallChild
+			: cameFrom == largeChild))) {
+
+			/* and since we've applied we must move on up */
+
+			next = objectAfterlimit(treeNode, endOfMemory());
+			if (((longAt(next)) & 0x3FFFFF) == 3) {
+				/* begin segmentContainingObj: */
+				for (i1 = (GIV(numSegments) - 1); i1 >= 0; i1 += -1) {
+					if (treeNode >= (((GIV(segments)[i1]).segStart))) {
+						seg = (&(GIV(segments)[i1]));
+						goto l4;
+					}
+				}
+				seg = null;
+			l4:	/* end segmentContainingObj: */;
+				(seg->lastFreeObject = treeNode);
+			}
+			treeNode = treeNode;
+
+			cameFrom = treeNode;
+			treeNode = longAt((treeNode + (BaseHeaderSize)) + (2 << 2));
+		}
+		else {
+			if ((smallChild != 0)
+			 && (cameFrom != smallChild)) {
+				treeNode = smallChild;
+			}
+			else {
+				assert(largeChild != 0);
+				treeNode = largeChild;
+			}
+			cameFrom = -1;
+		}
+	} while(treeNode != 0);
+l2:	/* end freeTreeNodesDo: */;
+	for (i2 = 0; i2 < GIV(numSegments); i2 += 1) {
+		freeChunk = ((GIV(segments)[i2]).lastFreeObject);
+		if (!(freeChunk == null)) {
+			detachFreeObject(freeChunk);
+			((GIV(segments)[i2]).segSize = ((((rawNumSlotsOf(freeChunk)) == 0xFF
+	? freeChunk - (BaseHeaderSize)
+	: freeChunk)) + (2 * (BaseHeaderSize))) - (((GIV(segments)[i2]).segStart)));
+			bridgeFromto((&(GIV(segments)[i2])), (i2 < (GIV(numSegments) - 1)
+				? (&(GIV(segments)[i2 + 1]))
+				: 0));
+		}
+	}
+	/* begin setEndOfMemory: */
+	newEndOfMemory = ((((GIV(segments)[GIV(numSegments) - 1]).segSize)) + (((GIV(segments)[GIV(numSegments) - 1]).segStart))) - (2 * (BaseHeaderSize));
+	GIV(endOfMemory) = newEndOfMemory;
+	if (GIV(freeOldSpaceStart) > newEndOfMemory) {
+		GIV(freeOldSpaceStart) = newEndOfMemory;
+	}
 	activeContext = GIV(tempOop);
 	GIV(tempOop) = 0;
 	if (!GIV(primFailCode)) {
@@ -55179,6 +55378,27 @@
 		assert(!(isForwarded(activeContext)));
 		longAtput((activeContext + (BaseHeaderSize)) + (StackPointerIndex << 2), (((stackIndex - 1) << 1) | 1));
 	}
+	/* begin postSnapshot */
+	for (i3 = (GIV(numSegments) - 1); i3 >= 0; i3 += -1) {
+		freeChunk1 = ((GIV(segments)[i3]).lastFreeObject);
+		if (!(freeChunk1 == null)) {
+			address = ((((GIV(segments)[i3]).segSize)) + (((GIV(segments)[i3]).segStart))) - (2 * (BaseHeaderSize));
+			((GIV(segments)[i3]).segSize = ((GIV(segments)[i3]).savedSegSize));
+			bridgeFromto((&(GIV(segments)[i3])), (i3 < (GIV(numSegments) - 1)
+				? (&(GIV(segments)[i3 + 1]))
+				: 0));
+			/* begin addFreeChunkWithBytes:at: */
+			bytes = (((((GIV(segments)[i3]).segSize)) + (((GIV(segments)[i3]).segStart))) - address) - (2 * (BaseHeaderSize));
+			freeChunkWithBytesat(bytes, address);
+			GIV(totalFreeOldSpace) += bytes;
+		}
+	}
+	/* begin setEndOfMemory: */
+	newEndOfMemory1 = ((((GIV(segments)[GIV(numSegments) - 1]).segSize)) + (((GIV(segments)[GIV(numSegments) - 1]).segStart))) - (2 * (BaseHeaderSize));
+	GIV(endOfMemory) = newEndOfMemory1;
+	if (GIV(freeOldSpaceStart) > newEndOfMemory1) {
+		GIV(freeOldSpaceStart) = newEndOfMemory1;
+	}
 	marryContextInNewStackPageAndInitializeInterpreterRegisters(activeContext);
 	if (!GIV(primFailCode)) {
 		/* begin push: */
@@ -56322,7 +56542,7 @@
 		assert((numSlotsOfAny(stackOrNil)) == ObjStackPageSlots);
 		assert((fetchPointerofObject(ObjStackMyx, stackOrNil)) == objStackRootIndex);
 
-		/* swizzle fields including ObjStackNextx and leave field containing the next link. */
+		/* swizzle fields including ObjStackNextx, excluding ObjStackFreex and leave field containing the next link. */
 
 		index = (longAt((stackOrNil + (BaseHeaderSize)) + (ObjStackTopx << 2))) + ObjStackNextx;
 		do {
@@ -56335,32 +56555,19 @@
 				null;
 				longAtput((stackOrNil + (BaseHeaderSize)) + (index << 2), field);
 			}
-		} while(((index -= 1)) > ObjStackMyx);
+		} while(((index -= 1)) >= ObjStackNextx);
 	} while(((stackOrNil = field)) != 0);
 	if (((stackOrNil = longAt((firstPage + (BaseHeaderSize)) + (ObjStackFreex << 2)))) != 0) {
-		while (1) {
-			page = longAt((stackOrNil + (BaseHeaderSize)) + (ObjStackFreex << 2));
-			if (!(page != 0)) break;
-			field = swizzleObj(page);
+		page = firstPage;
+		do {
+			stackOrNil = swizzleObj(stackOrNil);
 			/* begin storePointer:ofObjStack:withValue: */
-			assert((formatOf(stackOrNil)) == (wordIndexableFormat()));
+			assert((formatOf(page)) == (wordIndexableFormat()));
 			null;
-			longAtput((stackOrNil + (BaseHeaderSize)) + (ObjStackFreex << 2), field);
-			stackOrNil = field;
-		}
+			longAtput((page + (BaseHeaderSize)) + (ObjStackFreex << 2), stackOrNil);
+			page = stackOrNil;
+		} while(((stackOrNil = longAt((page + (BaseHeaderSize)) + (ObjStackFreex << 2)))) != 0);
 	}
-	if (((stackOrNil = longAt((firstPage + (BaseHeaderSize)) + (ObjStackNextx << 2)))) != 0) {
-		while (1) {
-			page = longAt((stackOrNil + (BaseHeaderSize)) + (ObjStackNextx << 2));
-			if (!(page != 0)) break;
-			field = swizzleObj(page);
-			/* begin storePointer:ofObjStack:withValue: */
-			assert((formatOf(stackOrNil)) == (wordIndexableFormat()));
-			null;
-			longAtput((stackOrNil + (BaseHeaderSize)) + (ObjStackNextx << 2), field);
-			stackOrNil = field;
-		}
-	}
 	assert(isValidObjStackAt(objStackRootIndex));
 	return longAt((GIV(hiddenRootsObj) + (BaseHeaderSize)) + (objStackRootIndex << 2));
 }

Modified: branches/Cog/nsspurstacksrc/vm/interp.c
===================================================================
--- branches/Cog/nsspurstacksrc/vm/interp.c	2014-02-18 00:00:50 UTC (rev 2868)
+++ branches/Cog/nsspurstacksrc/vm/interp.c	2014-02-20 02:06:56 UTC (rev 2869)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
    from
-	StackInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3
+	StackInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9
  */
-static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.612 uuid: 54335642-7834-48fb-936d-b567fb9857b3 " __DATE__ ;
+static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.620 uuid: 0c6991e0-acb5-4250-84d8-cdeebfac41e9 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -71,6 +71,8 @@
 	usqInt	segSize;
 	sqInt	swizzle;
 	usqInt	containsPinned;
+	usqInt	savedSegSize;
+	usqInt	lastFreeObject;
  } SpurSegmentInfo;
 
 
@@ -480,7 +482,7 @@
 static sqInt fetchPointerofFreeChunk(sqInt fieldIndex, sqInt objOop);
 sqInt fetchPointerofObject(sqInt fieldIndex, sqInt objOop);
 static sqInt fetchStackPointerOf(sqInt aContext);
-static void fillHighestObjectsWithMovableObjectsFromupTo(sqInt startObj, sqInt limitObj);
+static void fillHighestObjectsWithMovableObjectsFromFirstFreeChunkUpTo(sqInt limitObj);
 static sqInt findApplicationOfTargetMixinstartingAtBehavior(sqInt targetMixin, sqInt aBehavior);
 static sqInt findClassContainingMethodstartingAt(sqInt meth, sqInt classObj);
 sqInt findClassOfMethodforReceiver(sqInt meth, sqInt rcvr);
@@ -605,6 +607,7 @@
 static sqInt isContextHeader(sqInt aHeader);
 static sqInt isContextNonImm(sqInt oop);
 static sqInt isContext(sqInt oop);
+static sqInt isEmptyObjStack(sqInt objStack);
 static sqInt isEnumerableObjectNoAssert(sqInt objOop);
 static sqInt isEnumerableObject(sqInt objOop);
 static sqInt isEphemeron(sqInt objOop);
@@ -648,6 +651,7 @@
 static sqInt isScavengeSurvivor(sqInt oop);
 static sqInt isSegmentBridge(sqInt objOop);
 static sqInt isSingleContext(sqInt aContext);
+static sqInt isValidClassIndex(sqInt classIndex);
 static sqInt isValidFreeObject(sqInt objOop);
 static sqInt isValidObjStackAt(sqInt objStackRootIndex);
 static sqInt isValidObjStackPagemyIndex(sqInt objStackPage, sqInt myx);
@@ -1210,8 +1214,8 @@
 _iss sqInt primFailCode;
 _iss sqInt specialObjectsOop;
 _iss usqInt method;
+_iss sqInt nilObj;
 _iss StackPage * stackPage;
-_iss sqInt nilObj;
 _iss sqInt bytecodeSetSelector;
 _iss char * framePointer;
 _iss sqInt argumentCount;
@@ -1227,24 +1231,24 @@
 _iss sqInt trueObj;
 _iss sqInt falseObj;
 _iss sqInt remapBufferCount;
+_iss SpurSegmentInfo * segments;
 _iss sqInt * freeLists;
 _iss StackPage * pages;
-_iss SpurSegmentInfo * segments;
 _iss usqInt freeListsMask;
 _iss usqInt pastSpaceStart;
+_iss sqInt numSegments;
 _iss char * stackMemory;
+_iss sqInt firstFreeChunk;
 _iss char * stackLimit;
+_iss sqInt weaklingStack;
 _iss sqInt bytesPerPage;
 _iss sqInt rememberedSetSize;
 _iss SpurNewSpaceSpace pastSpace;
-_iss sqInt weaklingStack;
 _iss SpurContiguousObjStack unscannedEphemerons;
 _iss SpurNewSpaceSpace futureSpace;
-_iss sqInt numSegments;
 _iss StackPage * mostRecentlyUsedPage;
 _iss sqInt classTableFirstPage;
 _iss usqInt newSpaceStart;
-_iss sqInt firstFreeChunk;
 _iss sqInt futureSurvivorStart;
 _iss usqInt oldSpaceStart;
 _iss sqInt jmpDepth;
@@ -1264,8 +1268,10 @@
 _iss sqInt profileProcess;
 _iss sqInt extraRootCount;
 _iss sqInt invalidObjStackPage;
+_iss sqInt lastSubdividedFreeChunk;
 _iss sqInt previousRememberedSetSize;
 _iss unsigned char * classTableBitmap;
+_iss usqInt freeOldSpaceStart;
 _iss sqInt longRunningPrimitiveCheckMethod;
 _iss sqInt longRunningPrimitiveCheckSemaphore;
 _iss sqInt profileMethod;
@@ -1278,12 +1284,10 @@
 _iss sqInt profileSemaphore;
 _iss sqInt classTableIndex;

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list