[Vm-dev] [commit][2678] CogVM source as per VMMaker.oscog-eem.264.

commits at squeakvm.org commits at squeakvm.org
Wed Feb 6 02:55:14 UTC 2013


Revision: 2678
Author:   eliot
Date:     2013-02-05 18:55:12 -0800 (Tue, 05 Feb 2013)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.264.

Fix snapshot primitive failure in the StackVM and Cogit.  The
primitive should fail, not merely return the receiver.  Also if in
Cogit, need to back-up instruction pointer on failure.

Make reportMinimumUnusedHeadroom more informative (also print
available headroom).

Back out of named SerialPlugin primitives (comprehensive
platform support is lacking).

Fix reportStackHeadroom switch testing.  Not applicable to the StackVM.

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/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c
    branches/Cog/platforms/unix/vm/sqUnixMain.c
    branches/Cog/platforms/win32/vm/sqWin32Intel.c
    branches/Cog/src/vm/cogit.c
    branches/Cog/src/vm/cogit.h
    branches/Cog/src/vm/cogmethod.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

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

Modified: branches/Cog/nscogsrc/vm/cogit.c
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/cogit.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGenerator VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	StackToRegisterMappingCogit VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -4356,6 +4356,10 @@
 		return;
 	}
 	methodHeader = headerOf(methodObj);
+	if (hasLinkRegister(backEnd)) {
+		/* begin PushR: */
+		genoperand(PushR, LinkReg);
+	}
 	/* begin PushR: */
 	genoperand(PushR, FPReg);
 	/* begin MoveR:R: */

Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/cogit.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGenerator VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 

Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/cogmethod.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGenerator VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 typedef struct {

Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/cointerp.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
    from
-	CoInterpreter VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CoInterpreter VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1175,7 +1175,6 @@
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
-static void writeImageFile(sqInt imageBytes);
 usqInt youngStartAddress(void);
 
 /*** Variables ***/
@@ -1194,8 +1193,8 @@
 _iss sqInt bytecodeSetSelector;
 _iss usqInt instructionPointer;
 _iss sqInt argumentCount;
+_iss sqInt nilObj;
 _iss usqInt freeStart;
-_iss sqInt nilObj;
 _iss sqInt messageSelector;
 _iss usqInt newMethod;
 _iss usqInt youngStart;
@@ -1940,7 +1939,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.261";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.264";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -21591,7 +21590,8 @@
 		return;
 	}
 	thePage = GIV(stackPage);
-	if (thePage != null) {
+	if ((thePage != null)
+	 && (thePage != 0)) {
 		(thePage->stackLimit = ((char *) (((usqInt) -1))));
 	}
 	GIV(stackLimit) = ((char *) (((usqInt) -1)));
@@ -41536,8 +41536,15 @@
 
 static void
 primitiveSnapshot(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(0);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -41550,8 +41557,15 @@
 
 static void
 primitiveSnapshotEmbedded(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(1);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -47318,7 +47332,7 @@
 void
 reportMinimumUnusedHeadroom(void)
 {
-	printf("stack page size %ld minimum unused stack headroom %ld bytes\n", stackPageByteSize(), minimumUnusedHeadroom());
+	printf("stack page bytes %ld available headroom %ld minimum unused headroom %ld\n", stackPageByteSize(), ((stackPageByteSize()) - (((512 < (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))) ? 512 : (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))))) - ((IFrameSlots + 64) * BytesPerWord), minimumUnusedHeadroom());
 }
 
 
@@ -49335,38 +49349,63 @@
 static void
 snapshot(sqInt embedded)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt activateCogMethod;
     sqInt activeContext;
     sqInt activeProc;
     sqInt chunk;
+    CogMethod *cogMethod;
     sqInt dataSize;
+    sqInt errorCode;
     sqInt fmt;
     sqInt header;
     sqInt header1;
     sqInt header2;
     sqInt i;
     sqInt i1;
+    sqInt i2;
+    usqInt initialIP;
+    sqInt methodHeader;
+    sqInt numArgs;
+    sqInt numTemps;
     sqInt object;
     sqInt object1;
+    sqInt object2;
     sqInt oop;
     sqInt oop1;
     sqInt oop2;
     sqInt oop3;
     sqInt rcvr;
+    sqInt rcvr1;
     void *setMacType;
     char *sp;
     char *sp1;
+    char *sp10;
+    char *sp11;
+    char *sp12;
     char *sp2;
+    char *sp3;
+    char *sp4;
+    char *sp5;
+    char *sp6;
+    char *sp7;
+    char *sp8;
+    char *sp9;
     sqInt stackIndex;
     sqInt sz;
     sqInt sz1;
+    sqInt table;
 
 
-	/* Need to convert all frames into contexts since the snapshot file only holds objects. */
+	/* For nowe the stack munging below doesn't deal with more than omne argument.
+	   It can, and should. */
 
+	if (GIV(argumentCount) != 0) {
+		(GIV(primFailCode) = PrimErrBadNumArgs); return;
+	}
 	/* begin push: */
-	object1 = GIV(instructionPointer);
-	longAtput((sp2 = GIV(stackPointer) - BytesPerWord), object1);
-	GIV(stackPointer) = sp2;
+	object2 = GIV(instructionPointer);
+	longAtput((sp12 = GIV(stackPointer) - BytesPerWord), object2);
+	GIV(stackPointer) = sp12;
 
 	/* update state of active process */
 
@@ -49413,8 +49452,8 @@
 				sz = ((header1 & TypeMask) == HeaderTypeSizeAndClass
 					? (longAt(oop2 - (BytesPerWord * 2))) & LongSizeMask
 					: header1 & SizeMask);
-				for (i = ((lastPointerOf(oop2)) + BytesPerWord); i <= (sz - BaseHeaderSize); i += BytesPerWord) {
-					longAtput(oop2 + i, GIV(nilObj));
+				for (i2 = ((lastPointerOf(oop2)) + BytesPerWord); i2 <= (sz - BaseHeaderSize); i2 += BytesPerWord) {
+					longAtput(oop2 + i2, GIV(nilObj));
 				}
 			}
 			if (fmt >= 12) {
@@ -49475,8 +49514,9 @@
 		stackIndex = (oop >> 1);
 		rcvr = longAt((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord));
 		longAtput((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord), GIV(trueObj));
-		writeImageFile(dataSize);
-		if (!embedded) {
+		writeImageFileIO(dataSize);
+		if ((!GIV(primFailCode))
+		 && (!embedded)) {
 
 			/* set Mac file type and creator; this is a noop on other platforms */
 
@@ -49498,6 +49538,120 @@
 		/* begin push: */
 		longAtput((sp1 = GIV(stackPointer) - BytesPerWord), rcvr);
 		GIV(stackPointer) = sp1;
+		/* begin justActivateNewMethod */
+		VM_LABEL(2justActivateNewMethod);
+		methodHeader = longAt((GIV(newMethod) + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+		if ((activateCogMethod = isCogMethodReference(methodHeader))) {
+			cogMethod = ((CogMethod *) methodHeader);
+			methodHeader = (cogMethod->methodHeader);
+		}
+		numTemps = (((usqInt) methodHeader) >> 19) & 63;
+		numArgs = (((usqInt) methodHeader) >> 25) & 15;
+
+		/* could new rcvr be set at point of send? */
+
+		rcvr1 = longAt(GIV(stackPointer) + (numArgs * BytesPerWord));
+		if (activateCogMethod
+		 && (GIV(instructionPointer) >= (startOfMemory()))) {
+			/* begin iframeSavedIP:put: */
+			assert(!(isMachineCodeFrame(GIV(framePointer))));
+			longAtput(GIV(framePointer) + FoxIFSavedIP, GIV(instructionPointer));
+			GIV(instructionPointer) = ceReturnToInterpreterPC();
+		}
+		/* begin push: */
+		longAtput((sp7 = GIV(stackPointer) - BytesPerWord), GIV(instructionPointer));
+		GIV(stackPointer) = sp7;
+		/* begin push: */
+		longAtput((sp8 = GIV(stackPointer) - BytesPerWord), GIV(framePointer));
+		GIV(stackPointer) = sp8;
+		GIV(framePointer) = GIV(stackPointer);
+		initialIP = (GIV(newMethod) + ((LiteralStart + (((((sqInt) methodHeader)) < 0
+		? (((usqInt) methodHeader) >> 1) & 65535
+		: (((usqInt) methodHeader) >> 10) & 255))) * BytesPerWord)) + BaseHeaderSize;
+		if (activateCogMethod) {
+			/* begin push: */
+			longAtput((sp10 = GIV(stackPointer) - BytesPerWord), ((usqInt)cogMethod));
+			GIV(stackPointer) = sp10;
+			/* begin push: */
+			longAtput((sp11 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp11;
+			GIV(instructionPointer) = (((usqInt)cogMethod)) + ((cogMethod->stackCheckOffset));
+		}
+		else {
+			/* begin push: */
+			longAtput((sp2 = GIV(stackPointer) - BytesPerWord), GIV(newMethod));
+			GIV(stackPointer) = sp2;
+			/* begin setMethod:methodHeader: */
+			GIV(method) = GIV(newMethod);
+			assert(isOopCompiledMethod(GIV(method)));
+			assert((headerOf(GIV(method))) == methodHeader);
+			GIV(bytecodeSetSelector) = ((((sqInt) methodHeader)) < 0
+				? 256
+				: 0);
+
+			/* begin push: */
+			longAtput((sp3 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp3;
+			/* begin push: */
+			object1 = (VMBIGENDIAN
+				? ((1 + (numArgs << ((BytesPerWord * 8) - 8))) + ((0
+	? 1 << ((BytesPerWord * 8) - 16)
+	: 0))) + ((0
+	? 1 << ((BytesPerWord * 8) - 24)
+	: 0))
+				: ((1 + (numArgs << 8)) + ((0
+	? 1 << 16
+	: 0))) + ((0
+	? 1 << 24
+	: 0)));
+			longAtput((sp4 = GIV(stackPointer) - BytesPerWord), object1);
+			GIV(stackPointer) = sp4;
+			/* begin push: */
+			longAtput((sp5 = GIV(stackPointer) - BytesPerWord), 0);
+			GIV(stackPointer) = sp5;
+			GIV(instructionPointer) = initialIP - 1;
+		}
+		/* begin push: */
+		longAtput((sp9 = GIV(stackPointer) - BytesPerWord), rcvr1);
+		GIV(stackPointer) = sp9;
+		for (i = (numArgs + 1); i <= numTemps; i += 1) {
+			/* begin push: */
+			longAtput((sp6 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp6;
+		}
+		if (((((sqInt) methodHeader)) < 0
+						? methodHeader & (65536 << SmallIntegerShift)
+						: (methodHeader & 536871934) != 0)) {
+
+			/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method starts
+			   with a long store temp.  Strictly no need to skip the store because it's effectively a noop. */
+
+			initialIP += ((((sqInt) methodHeader)) < 0
+								? 3
+								: 0);
+			if (!activateCogMethod) {
+				GIV(instructionPointer) = initialIP;
+			}
+			if (GIV(primFailCode) != 0) {
+				if ((byteAt(initialIP + 1)) == (((((sqInt) methodHeader)) < 0
+		? 234
+		: 129))) {
+					/* begin getErrorObjectFromPrimFailCode */
+					if (GIV(primFailCode) > 0) {
+						table = longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (PrimErrTableIndex << ShiftForWord));
+						if (GIV(primFailCode) <= (((sqInt) (lastPointerOf(table)) >> 2))) {
+							errorCode = longAt((table + BaseHeaderSize) + ((GIV(primFailCode) - 1) << ShiftForWord));
+							goto l1;
+						}
+					}
+					errorCode = ((GIV(primFailCode) << 1) | 1);
+				l1:	/* end getErrorObjectFromPrimFailCode */;
+					longAtPointerput(GIV(stackPointer), errorCode);
+				}
+				GIV(primFailCode) = 0;
+			}
+		}
+		methodHeader;
 	}
 }
 
@@ -52303,18 +52457,6 @@
 	sqImageFileClose(f);
 }
 
-static void
-writeImageFile(sqInt imageBytes)
-{
-    void *fn;
-
-	writeImageFileIO(imageBytes);
-	fn = ioLoadFunctionFrom("setMacFileTypeAndCreator", "FilePlugin");
-	if (!(fn == 0)) {
-		((sqInt (*)(char*, char*, char*))fn)(imageName, "STim", "FAST");
-	}
-}
-
 usqInt
 youngStartAddress(void)
 {

Modified: branches/Cog/nscogsrc/vm/cointerp.h
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/cointerp.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 

Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
    from
-	CoInterpreter VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CoInterpreter VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1178,7 +1178,6 @@
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
-static void writeImageFile(sqInt imageBytes);
 usqInt youngStartAddress(void);
 
 /*** Variables ***/
@@ -1197,8 +1196,8 @@
 _iss sqInt bytecodeSetSelector;
 _iss usqInt instructionPointer;
 _iss sqInt argumentCount;
+_iss sqInt nilObj;
 _iss usqInt freeStart;
-_iss sqInt nilObj;
 _iss sqInt messageSelector;
 _iss usqInt newMethod;
 _iss usqInt youngStart;
@@ -1943,7 +1942,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.261";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.264";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -21600,7 +21599,8 @@
 		return;
 	}
 	thePage = GIV(stackPage);
-	if (thePage != null) {
+	if ((thePage != null)
+	 && (thePage != 0)) {
 		(thePage->stackLimit = ((char *) (((usqInt) -1))));
 	}
 	GIV(stackLimit) = ((char *) (((usqInt) -1)));
@@ -41545,8 +41545,15 @@
 
 static void
 primitiveSnapshot(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(0);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -41559,8 +41566,15 @@
 
 static void
 primitiveSnapshotEmbedded(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(1);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -47327,7 +47341,7 @@
 void
 reportMinimumUnusedHeadroom(void)
 {
-	printf("stack page size %ld minimum unused stack headroom %ld bytes\n", stackPageByteSize(), minimumUnusedHeadroom());
+	printf("stack page bytes %ld available headroom %ld minimum unused headroom %ld\n", stackPageByteSize(), ((stackPageByteSize()) - (((512 < (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))) ? 512 : (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))))) - ((IFrameSlots + 64) * BytesPerWord), minimumUnusedHeadroom());
 }
 
 
@@ -49344,38 +49358,63 @@
 static void
 snapshot(sqInt embedded)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt activateCogMethod;
     sqInt activeContext;
     sqInt activeProc;
     sqInt chunk;
+    CogMethod *cogMethod;
     sqInt dataSize;
+    sqInt errorCode;
     sqInt fmt;
     sqInt header;
     sqInt header1;
     sqInt header2;
     sqInt i;
     sqInt i1;
+    sqInt i2;
+    usqInt initialIP;
+    sqInt methodHeader;
+    sqInt numArgs;
+    sqInt numTemps;
     sqInt object;
     sqInt object1;
+    sqInt object2;
     sqInt oop;
     sqInt oop1;
     sqInt oop2;
     sqInt oop3;
     sqInt rcvr;
+    sqInt rcvr1;
     void *setMacType;
     char *sp;
     char *sp1;
+    char *sp10;
+    char *sp11;
+    char *sp12;
     char *sp2;
+    char *sp3;
+    char *sp4;
+    char *sp5;
+    char *sp6;
+    char *sp7;
+    char *sp8;
+    char *sp9;
     sqInt stackIndex;
     sqInt sz;
     sqInt sz1;
+    sqInt table;
 
 
-	/* Need to convert all frames into contexts since the snapshot file only holds objects. */
+	/* For nowe the stack munging below doesn't deal with more than omne argument.
+	   It can, and should. */
 
+	if (GIV(argumentCount) != 0) {
+		(GIV(primFailCode) = PrimErrBadNumArgs); return;
+	}
 	/* begin push: */
-	object1 = GIV(instructionPointer);
-	longAtput((sp2 = GIV(stackPointer) - BytesPerWord), object1);
-	GIV(stackPointer) = sp2;
+	object2 = GIV(instructionPointer);
+	longAtput((sp12 = GIV(stackPointer) - BytesPerWord), object2);
+	GIV(stackPointer) = sp12;
 
 	/* update state of active process */
 
@@ -49422,8 +49461,8 @@
 				sz = ((header1 & TypeMask) == HeaderTypeSizeAndClass
 					? (longAt(oop2 - (BytesPerWord * 2))) & LongSizeMask
 					: header1 & SizeMask);
-				for (i = ((lastPointerOf(oop2)) + BytesPerWord); i <= (sz - BaseHeaderSize); i += BytesPerWord) {
-					longAtput(oop2 + i, GIV(nilObj));
+				for (i2 = ((lastPointerOf(oop2)) + BytesPerWord); i2 <= (sz - BaseHeaderSize); i2 += BytesPerWord) {
+					longAtput(oop2 + i2, GIV(nilObj));
 				}
 			}
 			if (fmt >= 12) {
@@ -49484,8 +49523,9 @@
 		stackIndex = (oop >> 1);
 		rcvr = longAt((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord));
 		longAtput((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord), GIV(trueObj));
-		writeImageFile(dataSize);
-		if (!embedded) {
+		writeImageFileIO(dataSize);
+		if ((!GIV(primFailCode))
+		 && (!embedded)) {
 
 			/* set Mac file type and creator; this is a noop on other platforms */
 
@@ -49507,6 +49547,120 @@
 		/* begin push: */
 		longAtput((sp1 = GIV(stackPointer) - BytesPerWord), rcvr);
 		GIV(stackPointer) = sp1;
+		/* begin justActivateNewMethod */
+		VM_LABEL(2justActivateNewMethod);
+		methodHeader = longAt((GIV(newMethod) + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+		if ((activateCogMethod = isCogMethodReference(methodHeader))) {
+			cogMethod = ((CogMethod *) methodHeader);
+			methodHeader = (cogMethod->methodHeader);
+		}
+		numTemps = (((usqInt) methodHeader) >> 19) & 63;
+		numArgs = (((usqInt) methodHeader) >> 25) & 15;
+
+		/* could new rcvr be set at point of send? */
+
+		rcvr1 = longAt(GIV(stackPointer) + (numArgs * BytesPerWord));
+		if (activateCogMethod
+		 && (GIV(instructionPointer) >= (startOfMemory()))) {
+			/* begin iframeSavedIP:put: */
+			assert(!(isMachineCodeFrame(GIV(framePointer))));
+			longAtput(GIV(framePointer) + FoxIFSavedIP, GIV(instructionPointer));
+			GIV(instructionPointer) = ceReturnToInterpreterPC();
+		}
+		/* begin push: */
+		longAtput((sp7 = GIV(stackPointer) - BytesPerWord), GIV(instructionPointer));
+		GIV(stackPointer) = sp7;
+		/* begin push: */
+		longAtput((sp8 = GIV(stackPointer) - BytesPerWord), GIV(framePointer));
+		GIV(stackPointer) = sp8;
+		GIV(framePointer) = GIV(stackPointer);
+		initialIP = (GIV(newMethod) + ((LiteralStart + (((((sqInt) methodHeader)) < 0
+		? (((usqInt) methodHeader) >> 1) & 65535
+		: (((usqInt) methodHeader) >> 10) & 255))) * BytesPerWord)) + BaseHeaderSize;
+		if (activateCogMethod) {
+			/* begin push: */
+			longAtput((sp10 = GIV(stackPointer) - BytesPerWord), ((usqInt)cogMethod));
+			GIV(stackPointer) = sp10;
+			/* begin push: */
+			longAtput((sp11 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp11;
+			GIV(instructionPointer) = (((usqInt)cogMethod)) + ((cogMethod->stackCheckOffset));
+		}
+		else {
+			/* begin push: */
+			longAtput((sp2 = GIV(stackPointer) - BytesPerWord), GIV(newMethod));
+			GIV(stackPointer) = sp2;
+			/* begin setMethod:methodHeader: */
+			GIV(method) = GIV(newMethod);
+			assert(isOopCompiledMethod(GIV(method)));
+			assert((headerOf(GIV(method))) == methodHeader);
+			GIV(bytecodeSetSelector) = ((((sqInt) methodHeader)) < 0
+				? 256
+				: 0);
+
+			/* begin push: */
+			longAtput((sp3 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp3;
+			/* begin push: */
+			object1 = (VMBIGENDIAN
+				? ((1 + (numArgs << ((BytesPerWord * 8) - 8))) + ((0
+	? 1 << ((BytesPerWord * 8) - 16)
+	: 0))) + ((0
+	? 1 << ((BytesPerWord * 8) - 24)
+	: 0))
+				: ((1 + (numArgs << 8)) + ((0
+	? 1 << 16
+	: 0))) + ((0
+	? 1 << 24
+	: 0)));
+			longAtput((sp4 = GIV(stackPointer) - BytesPerWord), object1);
+			GIV(stackPointer) = sp4;
+			/* begin push: */
+			longAtput((sp5 = GIV(stackPointer) - BytesPerWord), 0);
+			GIV(stackPointer) = sp5;
+			GIV(instructionPointer) = initialIP - 1;
+		}
+		/* begin push: */
+		longAtput((sp9 = GIV(stackPointer) - BytesPerWord), rcvr1);
+		GIV(stackPointer) = sp9;
+		for (i = (numArgs + 1); i <= numTemps; i += 1) {
+			/* begin push: */
+			longAtput((sp6 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp6;
+		}
+		if (((((sqInt) methodHeader)) < 0
+						? methodHeader & (65536 << SmallIntegerShift)
+						: (methodHeader & 536871934) != 0)) {
+
+			/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method starts
+			   with a long store temp.  Strictly no need to skip the store because it's effectively a noop. */
+
+			initialIP += ((((sqInt) methodHeader)) < 0
+								? 3
+								: 0);
+			if (!activateCogMethod) {
+				GIV(instructionPointer) = initialIP;
+			}
+			if (GIV(primFailCode) != 0) {
+				if ((byteAt(initialIP + 1)) == (((((sqInt) methodHeader)) < 0
+		? 234
+		: 129))) {
+					/* begin getErrorObjectFromPrimFailCode */
+					if (GIV(primFailCode) > 0) {
+						table = longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (PrimErrTableIndex << ShiftForWord));
+						if (GIV(primFailCode) <= (((sqInt) (lastPointerOf(table)) >> 2))) {
+							errorCode = longAt((table + BaseHeaderSize) + ((GIV(primFailCode) - 1) << ShiftForWord));
+							goto l1;
+						}
+					}
+					errorCode = ((GIV(primFailCode) << 1) | 1);
+				l1:	/* end getErrorObjectFromPrimFailCode */;
+					longAtPointerput(GIV(stackPointer), errorCode);
+				}
+				GIV(primFailCode) = 0;
+			}
+		}
+		methodHeader;
 	}
 }
 
@@ -52312,18 +52466,6 @@
 	sqImageFileClose(f);
 }
 
-static void
-writeImageFile(sqInt imageBytes)
-{
-    void *fn;
-
-	writeImageFileIO(imageBytes);
-	fn = ioLoadFunctionFrom("setMacFileTypeAndCreator", "FilePlugin");
-	if (!(fn == 0)) {
-		((sqInt (*)(char*, char*, char*))fn)(imageName, "STim", "FAST");
-	}
-}
-
 usqInt
 youngStartAddress(void)
 {

Modified: branches/Cog/nscogsrc/vm/interp.h
===================================================================
--- branches/Cog/nscogsrc/vm/interp.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/interp.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 #define VM_PROXY_MAJOR 1

Modified: branches/Cog/nscogsrc/vm/vmCallback.h
===================================================================
--- branches/Cog/nscogsrc/vm/vmCallback.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/nscogsrc/vm/vmCallback.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 #define VM_CALLBACK_INC 1


Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
   - Thu Jan 31 09:58:48 PST 2013
   + Tue Feb  5 18:53:21 PST 2013

Modified: branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c
===================================================================
--- branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -205,10 +205,6 @@
 		extern sqInt pollpip;
 		pollpip = atoi(argv[1]);	 
 		return 2; }
-      else if (!strcmp(argv[0], "-reportheadroom")) { 
-		extern sqInt reportStackHeadroom;
-		reportStackHeadroom = 1;
-		return 1; }
 #endif /* STACKVM */
 #if COGVM
       else if (!strcmp(argv[0], "-codesize")) { 
@@ -246,6 +242,10 @@
 		extern sqInt minBackwardJumpCountForCompile;
 		minBackwardJumpCountForCompile = strtobkm(argv[1]);	 
 		return 2; }
+      else if (!strcmp(argv[0], "-reportheadroom")) { 
+		extern sqInt reportStackHeadroom;
+		reportStackHeadroom = 1;
+		return 1; }
 #endif /* COGVM */
       else if (!strcmp(argv[0], "-pathenc")) { 
 		setEncodingType(argv[1]); 

Modified: branches/Cog/platforms/unix/vm/sqUnixMain.c
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixMain.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/platforms/unix/vm/sqUnixMain.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1368,10 +1368,6 @@
 		extern sqInt pollpip;
 		pollpip = atoi(argv[1]);	 
 		return 2; }
-      else if (!strcmp(argv[0], "-reportheadroom")) { 
-		extern sqInt reportStackHeadroom;
-		reportStackHeadroom = 1;
-		return 1; }
 #endif /* STACKVM */
 #if COGVM
       else if (!strcmp(argv[0], "-codesize")) { 
@@ -1405,6 +1401,10 @@
 		extern sqInt minBackwardJumpCountForCompile;
 		minBackwardJumpCountForCompile = strtobkm(argv[1]);	 
 		return 2; }
+      else if (!strcmp(argv[0], "-reportheadroom")) { 
+		extern sqInt reportStackHeadroom;
+		reportStackHeadroom = 1;
+		return 1; }
 #endif /* COGVM */
       else if (!strcmp(argv[0], "-textenc"))
 	{

Modified: branches/Cog/platforms/win32/vm/sqWin32Intel.c
===================================================================
--- branches/Cog/platforms/win32/vm/sqWin32Intel.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/platforms/win32/vm/sqWin32Intel.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1688,10 +1688,6 @@
 		extern sqInt suppressHeartbeatFlag;
 		suppressHeartbeatFlag = 1;
 		return 1; }
-    else if (!strcmp(argv[0], "-reportheadroom")) { 
-		extern sqInt reportStackHeadroom;
-		reportStackHeadroom = 1;
-		return 1; }
 #endif /* STACKVM */
 #if COGVM
 	else if (!strcmp(argv[0], "-codesize")) { 
@@ -1737,6 +1733,10 @@
 		extern sqInt minBackwardJumpCountForCompile;
 		minBackwardJumpCountForCompile = strtobkm(argv[0]+13);	 
 		return 2; }
+    else if (!strcmp(argv[0], "-reportheadroom")) { 
+		extern sqInt reportStackHeadroom;
+		reportStackHeadroom = 1;
+		return 1; }
 #endif /* COGVM */
 
   /* NOTE: the following flags are "undocumented" */

Modified: branches/Cog/src/vm/cogit.c
===================================================================
--- branches/Cog/src/vm/cogit.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/src/vm/cogit.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGenerator VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	StackToRegisterMappingCogit VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -3937,6 +3937,10 @@
 		return;
 	}
 	methodHeader = headerOf(methodObj);
+	if (hasLinkRegister(backEnd)) {
+		/* begin PushR: */
+		genoperand(PushR, LinkReg);
+	}
 	/* begin PushR: */
 	genoperand(PushR, FPReg);
 	/* begin MoveR:R: */

Modified: branches/Cog/src/vm/cogit.h
===================================================================
--- branches/Cog/src/vm/cogit.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/src/vm/cogit.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGenerator VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 

Modified: branches/Cog/src/vm/cogmethod.h
===================================================================
--- branches/Cog/src/vm/cogmethod.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/src/vm/cogmethod.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGenerator VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 typedef struct {

Modified: branches/Cog/src/vm/cointerp.c
===================================================================
--- branches/Cog/src/vm/cointerp.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/src/vm/cointerp.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
    from
-	CoInterpreter VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CoInterpreter VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1166,7 +1166,6 @@
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
-static void writeImageFile(sqInt imageBytes);
 usqInt youngStartAddress(void);
 
 /*** Variables ***/
@@ -1183,8 +1182,8 @@
 _iss StackPage * stackPage;
 _iss usqInt freeStart;
 _iss sqInt nilObj;
+_iss usqInt instructionPointer;
 _iss usqInt method;
-_iss usqInt instructionPointer;
 _iss sqInt argumentCount;
 _iss usqInt newMethod;
 _iss StackPage * pages;
@@ -1930,7 +1929,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.261]";
+const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.264]";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -17417,7 +17416,8 @@
 		return;
 	}
 	thePage = GIV(stackPage);
-	if (thePage != null) {
+	if ((thePage != null)
+	 && (thePage != 0)) {
 		(thePage->stackLimit = ((char *) (((usqInt) -1))));
 	}
 	GIV(stackLimit) = ((char *) (((usqInt) -1)));
@@ -37027,8 +37027,15 @@
 
 static void
 primitiveSnapshot(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(0);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -37041,8 +37048,15 @@
 
 static void
 primitiveSnapshotEmbedded(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(1);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -42802,7 +42816,7 @@
 void
 reportMinimumUnusedHeadroom(void)
 {
-	printf("stack page size %ld minimum unused stack headroom %ld bytes\n", stackPageByteSize(), minimumUnusedHeadroom());
+	printf("stack page bytes %ld available headroom %ld minimum unused headroom %ld\n", stackPageByteSize(), ((stackPageByteSize()) - (((512 < (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))) ? 512 : (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))))) - ((IFrameSlots + 64) * BytesPerWord), minimumUnusedHeadroom());
 }
 
 
@@ -44785,38 +44799,63 @@
 static void
 snapshot(sqInt embedded)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt activateCogMethod;
     sqInt activeContext;
     sqInt activeProc;
     sqInt chunk;
+    CogMethod *cogMethod;
     sqInt dataSize;
+    sqInt errorCode;
     sqInt fmt;
     sqInt header;
     sqInt header1;
     sqInt header2;
     sqInt i;
     sqInt i1;
+    sqInt i2;
+    usqInt initialIP;
+    sqInt methodHeader;
+    sqInt numArgs;
+    sqInt numTemps;
     sqInt object;
     sqInt object1;
+    sqInt object2;
     sqInt oop;
     sqInt oop1;
     sqInt oop2;
     sqInt oop3;
     sqInt rcvr;
+    sqInt rcvr1;
     void *setMacType;
     char *sp;
     char *sp1;
+    char *sp10;
+    char *sp11;
+    char *sp12;
     char *sp2;
+    char *sp3;
+    char *sp4;
+    char *sp5;
+    char *sp6;
+    char *sp7;
+    char *sp8;
+    char *sp9;
     sqInt stackIndex;
     sqInt sz;
     sqInt sz1;
+    sqInt table;
 
 
-	/* Need to convert all frames into contexts since the snapshot file only holds objects. */
+	/* For nowe the stack munging below doesn't deal with more than omne argument.
+	   It can, and should. */
 
+	if (GIV(argumentCount) != 0) {
+		(GIV(primFailCode) = PrimErrBadNumArgs); return;
+	}
 	/* begin push: */
-	object1 = GIV(instructionPointer);
-	longAtput((sp2 = GIV(stackPointer) - BytesPerWord), object1);
-	GIV(stackPointer) = sp2;
+	object2 = GIV(instructionPointer);
+	longAtput((sp12 = GIV(stackPointer) - BytesPerWord), object2);
+	GIV(stackPointer) = sp12;
 
 	/* update state of active process */
 
@@ -44863,8 +44902,8 @@
 				sz = ((header1 & TypeMask) == HeaderTypeSizeAndClass
 					? (longAt(oop2 - (BytesPerWord * 2))) & LongSizeMask
 					: header1 & SizeMask);
-				for (i = ((lastPointerOf(oop2)) + BytesPerWord); i <= (sz - BaseHeaderSize); i += BytesPerWord) {
-					longAtput(oop2 + i, GIV(nilObj));
+				for (i2 = ((lastPointerOf(oop2)) + BytesPerWord); i2 <= (sz - BaseHeaderSize); i2 += BytesPerWord) {
+					longAtput(oop2 + i2, GIV(nilObj));
 				}
 			}
 			if (fmt >= 12) {
@@ -44925,8 +44964,9 @@
 		stackIndex = (oop >> 1);
 		rcvr = longAt((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord));
 		longAtput((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord), GIV(trueObj));
-		writeImageFile(dataSize);
-		if (!embedded) {
+		writeImageFileIO(dataSize);
+		if ((!GIV(primFailCode))
+		 && (!embedded)) {
 
 			/* set Mac file type and creator; this is a noop on other platforms */
 
@@ -44948,6 +44988,109 @@
 		/* begin push: */
 		longAtput((sp1 = GIV(stackPointer) - BytesPerWord), rcvr);
 		GIV(stackPointer) = sp1;
+		/* begin justActivateNewMethod */
+		VM_LABEL(2justActivateNewMethod);
+		methodHeader = longAt((GIV(newMethod) + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+		if ((activateCogMethod = isCogMethodReference(methodHeader))) {
+			cogMethod = ((CogMethod *) methodHeader);
+			methodHeader = (cogMethod->methodHeader);
+		}
+		numTemps = (((usqInt) methodHeader) >> 19) & 63;
+		numArgs = (((usqInt) methodHeader) >> 25) & 15;
+
+		/* could new rcvr be set at point of send? */
+
+		rcvr1 = longAt(GIV(stackPointer) + (numArgs * BytesPerWord));
+		if (activateCogMethod
+		 && (GIV(instructionPointer) >= (startOfMemory()))) {
+			/* begin iframeSavedIP:put: */
+			assert(!(isMachineCodeFrame(GIV(framePointer))));
+			longAtput(GIV(framePointer) + FoxIFSavedIP, GIV(instructionPointer));
+			GIV(instructionPointer) = ceReturnToInterpreterPC();
+		}
+		/* begin push: */
+		longAtput((sp7 = GIV(stackPointer) - BytesPerWord), GIV(instructionPointer));
+		GIV(stackPointer) = sp7;
+		/* begin push: */
+		longAtput((sp8 = GIV(stackPointer) - BytesPerWord), GIV(framePointer));
+		GIV(stackPointer) = sp8;
+		GIV(framePointer) = GIV(stackPointer);
+		initialIP = (GIV(newMethod) + ((LiteralStart + ((((usqInt) methodHeader) >> 10) & 255)) * BytesPerWord)) + BaseHeaderSize;
+		if (activateCogMethod) {
+			/* begin push: */
+			longAtput((sp10 = GIV(stackPointer) - BytesPerWord), ((usqInt)cogMethod));
+			GIV(stackPointer) = sp10;
+			/* begin push: */
+			longAtput((sp11 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp11;
+			GIV(instructionPointer) = (((usqInt)cogMethod)) + ((cogMethod->stackCheckOffset));
+		}
+		else {
+			/* begin push: */
+			longAtput((sp2 = GIV(stackPointer) - BytesPerWord), GIV(newMethod));
+			GIV(stackPointer) = sp2;
+			/* begin setMethod:methodHeader: */
+			GIV(method) = GIV(newMethod);
+			assert(isOopCompiledMethod(GIV(method)));
+			assert((headerOf(GIV(method))) == methodHeader);
+			
+			/* begin push: */
+			longAtput((sp3 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp3;
+			/* begin push: */
+			object1 = (VMBIGENDIAN
+				? ((1 + (numArgs << ((BytesPerWord * 8) - 8))) + ((0
+	? 1 << ((BytesPerWord * 8) - 16)
+	: 0))) + ((0
+	? 1 << ((BytesPerWord * 8) - 24)
+	: 0))
+				: ((1 + (numArgs << 8)) + ((0
+	? 1 << 16
+	: 0))) + ((0
+	? 1 << 24
+	: 0)));
+			longAtput((sp4 = GIV(stackPointer) - BytesPerWord), object1);
+			GIV(stackPointer) = sp4;
+			/* begin push: */
+			longAtput((sp5 = GIV(stackPointer) - BytesPerWord), 0);
+			GIV(stackPointer) = sp5;
+			GIV(instructionPointer) = initialIP - 1;
+		}
+		/* begin push: */
+		longAtput((sp9 = GIV(stackPointer) - BytesPerWord), rcvr1);
+		GIV(stackPointer) = sp9;
+		for (i = (numArgs + 1); i <= numTemps; i += 1) {
+			/* begin push: */
+			longAtput((sp6 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp6;
+		}
+		if ((methodHeader & 536871934) != 0) {
+
+			/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method starts
+			   with a long store temp.  Strictly no need to skip the store because it's effectively a noop. */
+
+			initialIP += 0;
+			if (!activateCogMethod) {
+				GIV(instructionPointer) = initialIP;
+			}
+			if (GIV(primFailCode) != 0) {
+				if ((byteAt(initialIP + 1)) == (129)) {
+					/* begin getErrorObjectFromPrimFailCode */
+					if (GIV(primFailCode) > 0) {
+						table = longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (PrimErrTableIndex << ShiftForWord));
+						if (GIV(primFailCode) <= (((sqInt) (lastPointerOf(table)) >> 2))) {
+							errorCode = longAt((table + BaseHeaderSize) + ((GIV(primFailCode) - 1) << ShiftForWord));
+							goto l1;
+						}
+					}
+					errorCode = ((GIV(primFailCode) << 1) | 1);
+				l1:	/* end getErrorObjectFromPrimFailCode */;
+					longAtPointerput(GIV(stackPointer), errorCode);
+				}
+				GIV(primFailCode) = 0;
+			}
+		}
+		methodHeader;
 	}
 }
 
@@ -47727,18 +47870,6 @@
 	sqImageFileClose(f);
 }
 
-static void
-writeImageFile(sqInt imageBytes)
-{
-    void *fn;
-
-	writeImageFileIO(imageBytes);
-	fn = ioLoadFunctionFrom("setMacFileTypeAndCreator", "FilePlugin");
-	if (!(fn == 0)) {
-		((sqInt (*)(char*, char*, char*))fn)(imageName, "STim", "FAST");
-	}
-}
-
 usqInt
 youngStartAddress(void)
 {

Modified: branches/Cog/src/vm/cointerp.h
===================================================================
--- branches/Cog/src/vm/cointerp.h	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/src/vm/cointerp.h	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
 
 

Modified: branches/Cog/src/vm/cointerpmt.c
===================================================================
--- branches/Cog/src/vm/cointerpmt.c	2013-01-31 18:00:18 UTC (rev 2677)
+++ branches/Cog/src/vm/cointerpmt.c	2013-02-06 02:55:12 UTC (rev 2678)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
    from
-	CoInterpreterMT VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623
+	CoInterpreterMT VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d
  */
-static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.261 uuid: eeb310a3-23e0-41f6-8a92-5749b798e623 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.264 uuid: 64e76092-8af7-449f-9188-e65f3bd1f08d " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1248,7 +1248,6 @@
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
-static void writeImageFile(sqInt imageBytes);
 usqInt youngStartAddress(void);
 
 /*** Variables ***/
@@ -2029,7 +2028,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.261]";
+const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.264]";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 sqInt willNotThreadWarnCount;
@@ -18056,7 +18055,8 @@
 		return;
 	}
 	thePage = GIV(stackPage);
-	if (thePage != null) {
+	if ((thePage != null)
+	 && (thePage != 0)) {
 		(thePage->stackLimit = ((char *) (((usqInt) -1))));
 	}
 	GIV(stackLimit) = ((char *) (((usqInt) -1)));
@@ -38358,8 +38358,15 @@
 
 static void
 primitiveSnapshot(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(0);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -38372,8 +38379,15 @@
 
 static void
 primitiveSnapshotEmbedded(void)
-{
+{   DECL_MAYBE_SQ_GLOBAL_STRUCT
 	snapshot(1);
+	if ((iframeMethod(GIV(framePointer))) == GIV(newMethod)) {
+
+		/* snapshot: has reached the end and built a frame.
+		   In the JIT we need to back-up the pc before reentering the interpreter. */
+
+		GIV(instructionPointer) -= 1;
+	}
 	siglongjmp(reenterInterpreter, ReturnToInterpreter);
 }
 
@@ -44197,7 +44211,7 @@
 void
 reportMinimumUnusedHeadroom(void)
 {
-	printf("stack page size %ld minimum unused stack headroom %ld bytes\n", stackPageByteSize(), minimumUnusedHeadroom());
+	printf("stack page bytes %ld available headroom %ld minimum unused headroom %ld\n", stackPageByteSize(), ((stackPageByteSize()) - (((512 < (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))) ? 512 : (((stackPageByteSize()) - ((IFrameSlots + 64) * BytesPerWord)) - (osCogStackPageHeadroom()))))) - ((IFrameSlots + 64) * BytesPerWord), minimumUnusedHeadroom());
 }
 
 
@@ -46235,38 +46249,63 @@
 static void
 snapshot(sqInt embedded)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt activateCogMethod;
     sqInt activeContext;
     sqInt activeProc;
     sqInt chunk;
+    CogMethod *cogMethod;
     sqInt dataSize;
+    sqInt errorCode;
     sqInt fmt;
     sqInt header;
     sqInt header1;
     sqInt header2;
     sqInt i;
     sqInt i1;
+    sqInt i2;
+    usqInt initialIP;
+    sqInt methodHeader;
+    sqInt numArgs;
+    sqInt numTemps;
     sqInt object;
     sqInt object1;
+    sqInt object2;
     sqInt oop;
     sqInt oop1;
     sqInt oop2;
     sqInt oop3;
     sqInt rcvr;
+    sqInt rcvr1;
     void *setMacType;
     char *sp;
     char *sp1;
+    char *sp10;
+    char *sp11;
+    char *sp12;
     char *sp2;
+    char *sp3;
+    char *sp4;
+    char *sp5;
+    char *sp6;
+    char *sp7;
+    char *sp8;
+    char *sp9;
     sqInt stackIndex;
     sqInt sz;
     sqInt sz1;
+    sqInt table;
 
 
-	/* Need to convert all frames into contexts since the snapshot file only holds objects. */
+	/* For nowe the stack munging below doesn't deal with more than omne argument.
+	   It can, and should. */
 
+	if (GIV(argumentCount) != 0) {
+		(GIV(primFailCode) = PrimErrBadNumArgs); return;
+	}
 	/* begin push: */
-	object1 = GIV(instructionPointer);
-	longAtput((sp2 = GIV(stackPointer) - BytesPerWord), object1);
-	GIV(stackPointer) = sp2;
+	object2 = GIV(instructionPointer);
+	longAtput((sp12 = GIV(stackPointer) - BytesPerWord), object2);
+	GIV(stackPointer) = sp12;
 
 	/* update state of active process */
 
@@ -46313,8 +46352,8 @@
 				sz = ((header1 & TypeMask) == HeaderTypeSizeAndClass
 					? (longAt(oop2 - (BytesPerWord * 2))) & LongSizeMask
 					: header1 & SizeMask);
-				for (i = ((lastPointerOf(oop2)) + BytesPerWord); i <= (sz - BaseHeaderSize); i += BytesPerWord) {
-					longAtput(oop2 + i, GIV(nilObj));
+				for (i2 = ((lastPointerOf(oop2)) + BytesPerWord); i2 <= (sz - BaseHeaderSize); i2 += BytesPerWord) {
+					longAtput(oop2 + i2, GIV(nilObj));
 				}
 			}
 			if (fmt >= 12) {
@@ -46375,8 +46414,9 @@
 		stackIndex = (oop >> 1);
 		rcvr = longAt((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord));
 		longAtput((activeContext + BaseHeaderSize) + (((stackIndex + CtxtTempFrameStart) - 1) << ShiftForWord), GIV(trueObj));
-		writeImageFile(dataSize);
-		if (!embedded) {
+		writeImageFileIO(dataSize);
+		if ((!GIV(primFailCode))
+		 && (!embedded)) {
 
 			/* set Mac file type and creator; this is a noop on other platforms */
 
@@ -46398,6 +46438,109 @@
 		/* begin push: */
 		longAtput((sp1 = GIV(stackPointer) - BytesPerWord), rcvr);
 		GIV(stackPointer) = sp1;
+		/* begin justActivateNewMethod */
+		VM_LABEL(2justActivateNewMethod);
+		methodHeader = longAt((GIV(newMethod) + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+		if ((activateCogMethod = isCogMethodReference(methodHeader))) {
+			cogMethod = ((CogMethod *) methodHeader);
+			methodHeader = (cogMethod->methodHeader);
+		}
+		numTemps = (((usqInt) methodHeader) >> 19) & 63;
+		numArgs = (((usqInt) methodHeader) >> 25) & 15;
+
+		/* could new rcvr be set at point of send? */
+
+		rcvr1 = longAt(GIV(stackPointer) + (numArgs * BytesPerWord));
+		if (activateCogMethod
+		 && (GIV(instructionPointer) >= (startOfMemory()))) {
+			/* begin iframeSavedIP:put: */
+			assert(!(isMachineCodeFrame(GIV(framePointer))));
+			longAtput(GIV(framePointer) + FoxIFSavedIP, GIV(instructionPointer));
+			GIV(instructionPointer) = ceReturnToInterpreterPC();
+		}
+		/* begin push: */
+		longAtput((sp7 = GIV(stackPointer) - BytesPerWord), GIV(instructionPointer));
+		GIV(stackPointer) = sp7;
+		/* begin push: */
+		longAtput((sp8 = GIV(stackPointer) - BytesPerWord), GIV(framePointer));
+		GIV(stackPointer) = sp8;
+		GIV(framePointer) = GIV(stackPointer);
+		initialIP = (GIV(newMethod) + ((LiteralStart + ((((usqInt) methodHeader) >> 10) & 255)) * BytesPerWord)) + BaseHeaderSize;
+		if (activateCogMethod) {
+			/* begin push: */
+			longAtput((sp10 = GIV(stackPointer) - BytesPerWord), ((usqInt)cogMethod));
+			GIV(stackPointer) = sp10;
+			/* begin push: */
+			longAtput((sp11 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp11;
+			GIV(instructionPointer) = (((usqInt)cogMethod)) + ((cogMethod->stackCheckOffset));
+		}
+		else {
+			/* begin push: */
+			longAtput((sp2 = GIV(stackPointer) - BytesPerWord), GIV(newMethod));
+			GIV(stackPointer) = sp2;
+			/* begin setMethod:methodHeader: */
+			GIV(method) = GIV(newMethod);
+			assert(isOopCompiledMethod(GIV(method)));
+			assert((headerOf(GIV(method))) == methodHeader);
+			
+			/* begin push: */
+			longAtput((sp3 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp3;
+			/* begin push: */
+			object1 = (VMBIGENDIAN
+				? ((1 + (numArgs << ((BytesPerWord * 8) - 8))) + ((0
+	? 1 << ((BytesPerWord * 8) - 16)
+	: 0))) + ((0
+	? 1 << ((BytesPerWord * 8) - 24)
+	: 0))
+				: ((1 + (numArgs << 8)) + ((0
+	? 1 << 16
+	: 0))) + ((0
+	? 1 << 24
+	: 0)));
+			longAtput((sp4 = GIV(stackPointer) - BytesPerWord), object1);
+			GIV(stackPointer) = sp4;
+			/* begin push: */
+			longAtput((sp5 = GIV(stackPointer) - BytesPerWord), 0);
+			GIV(stackPointer) = sp5;
+			GIV(instructionPointer) = initialIP - 1;
+		}
+		/* begin push: */
+		longAtput((sp9 = GIV(stackPointer) - BytesPerWord), rcvr1);
+		GIV(stackPointer) = sp9;
+		for (i = (numArgs + 1); i <= numTemps; i += 1) {
+			/* begin push: */
+			longAtput((sp6 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
+			GIV(stackPointer) = sp6;
+		}
+		if ((methodHeader & 536871934) != 0) {
+
+			/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method starts

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list