[Vm-dev] [commit][2697] iCogVM source as per VMMaker.oscog-eem.270

commits at squeakvm.org commits at squeakvm.org
Sat Mar 2 01:22:09 UTC 2013


Revision: 2697
Author:   eliot
Date:     2013-03-01 17:22:06 -0800 (Fri, 01 Mar 2013)
Log Message:
-----------
iCogVM source as per VMMaker.oscog-eem.270

Fix the become issue where methods that are identical are failing
the code test because their penultimate literals are different objects.
Add a flag "cmUsesPenultimateLit" to jitted methods, stealing bits
from stackCheckOffset (which was way larger than needed).
Shrink stackCheckOffset to 12 bits (still an order of magnitude larger
than needed) and add an error check on assigning it.
Also add a check for max method size (2^16-1 bytes) and refuse to
jit a method that generates too much code.
When comparing code, use the cmUsesPenultimateLit flag to decide
if comparison includes penultimate lit or not.

This is mildly insane, but the VM really doesn't know about the
penultimate literal and it shouldn't depend on knowing it can be
ignored.  Note that the CoInterpreter knows about the last literal;
it uses this in supersends.  With this hack, Pharo's condenseSources
works.

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/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

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

Modified: branches/Cog/nscogsrc/vm/cogit.c
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/cogit.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	CCodeGenerator VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	StackToRegisterMappingCogit VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -173,7 +173,7 @@
 #define ECX 1
 #define EDI 7
 #define EDX 2
-#define EncounteredUnknownBytecode -4
+#define EncounteredUnknownBytecode -6
 #define ESI 6
 #define ESP 4
 #define Fill16 5
@@ -251,16 +251,19 @@
 #define LongSizeMask 0xFFFFFFFCUL
 #define MapEnd 0
 #define MaxCompiledPrimitiveIndex 222
-#define MaxNegativeErrorCode -4
+#define MaxMethodSize 65535
+#define MaxNegativeErrorCode -6
 #define MaxNumArgs 15
+#define MaxStackCheckOffset 0xFFF
 #define MaxUnitDisplacement 31
-#define MaxUnreportableError -3
+#define MaxUnreportableError -5
 #define MaxX2NDisplacement 992
 #define MethodCacheClass 2
 #define MethodCacheMask 0xFFC
 #define MethodCacheMethod 3
 #define MethodCacheSelector 1
 #define MethodIndex 3
+#define MethodTooBig -4
 #define MFENCE 108
 #define MFMethodFlagHasContextFlag 1
 #define MFMethodFlagIsBlockFlag 2
@@ -346,7 +349,7 @@
 #define XMM7L 14
 #define XorCwR 94
 #define XorRR 80
-#define YoungSelectorInPIC -3
+#define YoungSelectorInPIC -5
 
 
 /*** Function Prototypes ***/
@@ -806,6 +809,7 @@
 static AbstractInstruction * genoperandoperandoperand(sqInt opcode, sqInt operandOne, sqInt operandTwo, sqInt operandThree);
 static sqInt getInlineCacheClassTagFrominto(sqInt sourceReg, sqInt destReg);
 static AbstractInstruction * getJmpTarget(AbstractInstruction * self_in_getJmpTarget);
+static sqInt getLiteral(sqInt litIndex);
 static sqInt hasDoublePrecisionFloatingPointSupport(AbstractInstruction * self_in_hasDoublePrecisionFloatingPointSupport);
 static sqInt hasLinkRegister(AbstractInstruction * self_in_hasLinkRegister);
 static sqInt hasPCDependentInstructions(AbstractInstruction * self_in_hasPCDependentInstructions);
@@ -907,7 +911,7 @@
 static sqInt methodAbortTrampolineFor(sqInt numArgs);
 static CogMethod * methodAfter(CogMethod *cogMethod);
 CogMethod * methodFor(void *address);
-static sqInt methodhasSameCodeAs(sqInt methodA, sqInt methodB);
+static sqInt methodhasSameCodeAscheckPenultimate(sqInt methodA, sqInt methodB, sqInt comparePenultimateLiteral);
 sqInt minCogMethodAddress(void);
 sqInt mnuOffset(void);
 static sqInt modRMRO(AbstractInstruction * self_in_modRMRO, sqInt mod, sqInt regMode, sqInt regOpcode);
@@ -1666,6 +1670,7 @@
 static int labelCounter;
 static sqInt lastSend;
 static usqInt limitAddress;
+static sqInt maxLitIndex;
 static CogBlockMethod * maxMethodBefore;
 static sqInt methodAbortTrampolines[4];
 static sqInt methodBytesFreedSinceLastCompaction;
@@ -4158,6 +4163,7 @@
 	inBlock = 0;
 	primInvokeLabel = null;
 	postCompileHook = null;
+	maxLitIndex = -1;
 	extra = ((((primitiveIndex = primitiveIndexOf(methodObj))) > 0)
 	 && (!(isQuickPrimitiveIndex(primitiveIndex)))
 		? 30
@@ -7555,10 +7561,10 @@
 
 	opType = ((usqInt) byte1) >> 5;
 	if (opType == 0) {
-		return genSendnumArgs(literalofMethod(byte2, methodObj), byte1 & 31);
+		return genSendnumArgs(getLiteral(byte2), byte1 & 31);
 	}
 	if (opType == 1) {
-		return genSendSupernumArgs(literalofMethod(byte2, methodObj), byte1 & 31);
+		return genSendSupernumArgs(getLiteral(byte2), byte1 & 31);
 	}
 	
 	switch (opType) {
@@ -8012,9 +8018,15 @@
 	}
 	(method->cmUsageCount = initialMethodUsageCount());
 	(method->cpicHasMNUCase = 0);
+	(method->cmUsesPenultimateLit = maxLitIndex >= ((literalCountOfHeader(methodHeader)) - 2));
 	(method->blockEntryOffset = (blockEntryLabel != null
 		? ((blockEntryLabel->address)) - (((sqInt)method))
 		: 0));
+	if (needsFrame) {
+		if (!((((stackCheckLabel->address)) - (((sqInt)method))) <= MaxStackCheckOffset)) {
+			error("too much code for stack check offset");
+		}
+	}
 	(method->stackCheckOffset = (needsFrame
 		? ((stackCheckLabel->address)) - (((sqInt)method))
 		: 0));
@@ -8657,7 +8669,7 @@
 static sqInt
 genDynamicSuperSendBytecode(void)
 {
-	return genSendDynamicSupernumArgs(literalofMethod(byte2, methodObj), byte1);
+	return genSendDynamicSupernumArgs(getLiteral(byte2), byte1);
 }
 
 
@@ -8816,13 +8828,13 @@
 static sqInt
 genExtendedSendBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte1 & 31, methodObj), ((usqInt) byte1) >> 5);
+	return genSendnumArgs(getLiteral(byte1 & 31), ((usqInt) byte1) >> 5);
 }
 
 static sqInt
 genExtendedSuperBytecode(void)
 {
-	return genSendSupernumArgs(literalofMethod(byte1 & 31, methodObj), ((usqInt) byte1) >> 5);
+	return genSendSupernumArgs(getLiteral(byte1 & 31), ((usqInt) byte1) >> 5);
 }
 
 
@@ -9072,7 +9084,7 @@
 	extA = 0;
 	nArgs = (byte1 & 7) + (extB << 3);
 	extB = 0;
-	return genSendAbsentDynamicSupernumArgs(literalofMethod(litIndex, methodObj), nArgs);
+	return genSendAbsentDynamicSupernumArgs(getLiteral(litIndex), nArgs);
 }
 
 
@@ -9090,7 +9102,7 @@
 	extA = 0;
 	nArgs = (byte1 & 7) + (extB << 3);
 	extB = 0;
-	return genSendAbsentImplicitnumArgs(literalofMethod(litIndex, methodObj), nArgs);
+	return genSendAbsentImplicitnumArgs(getLiteral(litIndex), nArgs);
 }
 
 
@@ -9108,7 +9120,7 @@
 	extA = 0;
 	nArgs = (byte1 & 7) + (extB << 3);
 	extB = 0;
-	return genSendnumArgs(literalofMethod(litIndex, methodObj), nArgs);
+	return genSendnumArgs(getLiteral(litIndex), nArgs);
 }
 
 
@@ -9126,7 +9138,7 @@
 	extA = 0;
 	nArgs = (byte1 & 7) + (extB << 3);
 	extB = 0;
-	return genSendSupernumArgs(literalofMethod(litIndex, methodObj), nArgs);
+	return genSendSupernumArgs(getLiteral(litIndex), nArgs);
 }
 
 
@@ -9361,6 +9373,9 @@
 	codeSize = generateInstructionsAt(((methodLabel->address)) + headerSize);
 	mapSize = generateMapAtstart(0, ((methodLabel->address)) + cmNoCheckEntryOffset);
 	totalSize = roundUpLength((headerSize + codeSize) + mapSize);
+	if (totalSize > MaxMethodSize) {
+		return ((CogMethod *) MethodTooBig);
+	}
 	startAddress = allocate(totalSize);
 	if (startAddress == 0) {
 		return ((CogMethod *) InsufficientCodeSpace);
@@ -11929,7 +11944,7 @@
 {
     sqInt levelOop;
 
-	levelOop = literalofMethod(byte1, methodObj);
+	levelOop = getLiteral(byte1);
 	assert((levelOop & 1));
 	return genPushExplicitOuterSendReceiver((levelOop >> 1));
 }
@@ -11954,7 +11969,7 @@
 {
     sqInt result;
 
-	result = genGetImplicitReceiverFor(literalofMethod(byte1, methodObj));
+	result = genGetImplicitReceiverFor(getLiteral(byte1));
 	if (result != 0) {
 		return result;
 	}
@@ -11975,7 +11990,7 @@
 {
     sqInt literal;
 
-	literal = literalofMethod(literalIndex, methodObj);
+	literal = getLiteral(literalIndex);
 	return genPushLiteral(literal);
 }
 
@@ -12006,7 +12021,7 @@
 	/* So far descriptors are not rich enough to describe the entire dereference so generate the register
 	   load but don't push the result.  There is an order-or-evaluation issue if we defer the dereference. */
 
-	association = literalofMethod(literalIndex, methodObj);
+	association = getLiteral(literalIndex);
 	annotateobjRef(gMoveCwR(association, TempReg), association);
 	genLoadSlotsourceRegdestReg(ValueIndex, TempReg, freeReg);
 	ssPushRegister(freeReg);
@@ -12509,7 +12524,7 @@
 static sqInt
 genSecondExtendedSendBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte1 & 63, methodObj), ((usqInt) byte1) >> 6);
+	return genSendnumArgs(getLiteral(byte1 & 63), ((usqInt) byte1) >> 6);
 }
 
 
@@ -12540,7 +12555,7 @@
 static sqInt
 genSendAbsentImplicit0ArgsBytecode(void)
 {
-	return genSendAbsentImplicitnumArgs(literalofMethod(byte0 & 15, methodObj), 0);
+	return genSendAbsentImplicitnumArgs(getLiteral(byte0 & 15), 0);
 }
 
 
@@ -12570,19 +12585,19 @@
 static sqInt
 genSendLiteralSelector0ArgsBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte0 & 15, methodObj), 0);
+	return genSendnumArgs(getLiteral(byte0 & 15), 0);
 }
 
 static sqInt
 genSendLiteralSelector1ArgBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte0 & 15, methodObj), 1);
+	return genSendnumArgs(getLiteral(byte0 & 15), 1);
 }
 
 static sqInt
 genSendLiteralSelector2ArgsBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte0 & 15, methodObj), 2);
+	return genSendnumArgs(getLiteral(byte0 & 15), 2);
 }
 
 static sqInt
@@ -13206,7 +13221,7 @@
 	flag("with better register allocation this wouldn't need a frame.  e.g. use SendNumArgs instead of ReceiverResultReg");
 	assert(needsFrame);
 	(optStatus.isReceiverResultRegLive = 0);
-	association = literalofMethod(litVarIndex, methodObj);
+	association = getLiteral(litVarIndex);
 
 	/* Avoid store check for immediate values */
 
@@ -13724,7 +13739,16 @@
 	return ((AbstractInstruction *) (((self_in_getJmpTarget->operands))[0]));
 }
 
+static sqInt
+getLiteral(sqInt litIndex)
+{
+	if (maxLitIndex < litIndex) {
+		maxLitIndex = litIndex;
+	}
+	return literalofMethod(litIndex, methodObj);
+}
 
+
 /*	We can generate dpfp support if the processor has SSE2 instructions. */
 
 static sqInt
@@ -14982,7 +15006,7 @@
 						if (methodHasCogMethod(remappedMethod)) {
 							error("attempt to become two cogged methods");
 						}
-						if (!(withoutForwardingOnandsendToCogit((cogMethod->methodObject), remappedMethod, methodhasSameCodeAs))) {
+						if (!(withoutForwardingOnandwithsendToCogit((cogMethod->methodObject), remappedMethod, (cogMethod->cmUsesPenultimateLit), methodhasSameCodeAscheckPenultimate))) {
 							error("attempt to become cogged method into different method");
 						}
 						rawHeaderOfput((cogMethod->methodObject), (cogMethod->methodHeader));
@@ -15887,7 +15911,7 @@
 	flags can differ. */
 
 static sqInt
-methodhasSameCodeAs(sqInt methodA, sqInt methodB)
+methodhasSameCodeAscheckPenultimate(sqInt methodA, sqInt methodB, sqInt comparePenultimateLiteral)
 {
     sqInt bi;
     sqInt endPCA;
@@ -15909,7 +15933,10 @@
 	}
 	for (li = 1; li <= (numLitsA - 1); li += 1) {
 		if ((fetchPointerofObject(li, methodA)) != (fetchPointerofObject(li, methodB))) {
-			return 0;
+			if ((li < (numLitsA - 1))
+			 || (comparePenultimateLiteral)) {
+				return 0;
+			}
 		}
 	}
 	for (bi = (startPCOfMethod(methodA)); bi <= endPCA; bi += 1) {

Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/cogit.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	CCodeGenerator VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 

Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/cogmethod.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	CCodeGenerator VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 typedef struct {
@@ -10,7 +10,9 @@
 	unsigned		cmRefersToYoung : 1;
 	unsigned		cpicHasMNUCase : 1;
 	unsigned		cmUsageCount : 3;
-	unsigned		stackCheckOffset : 16;
+	unsigned		cmUsesPenultimateLit : 1;
+	unsigned		cmUnusedFlags : 3;
+	unsigned		stackCheckOffset : 12;
  } CogBlockMethod;
 
 typedef struct {
@@ -20,7 +22,9 @@
 	unsigned		cmRefersToYoung : 1;
 	unsigned		cpicHasMNUCase : 1;
 	unsigned		cmUsageCount : 3;
-	unsigned		stackCheckOffset : 16;
+	unsigned		cmUsesPenultimateLit : 1;
+	unsigned		cmUnusedFlags : 3;
+	unsigned		stackCheckOffset : 12;
 	unsigned short	blockSize;
 	unsigned short	blockEntryOffset;
 	sqInt	methodObject;

Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/cointerp.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1181,6 +1181,7 @@
 static sqInt voidVMStateForSnapshot(void);
 static sqInt wakeHighestPriority(void);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
@@ -1949,7 +1950,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_*_VMMaker.oscog-eem.269";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.270";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -52670,6 +52671,61 @@
 	return result;
 }
 
+
+/*	For the purposes of become: send selector to the cogit with obj1 and obj2
+	and answer the result. Undo forwarding for the selector, but redo
+	forwarding after since
+	become:'s restoreHeadersAfter*Become* methods expect to be able to
+	restore. 
+ */
+
+sqInt
+withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt))
+{
+    sqInt aWord;
+    sqInt aWord1;
+    sqInt fwdBlock;
+    sqInt fwdBlock1;
+    sqInt header;
+    sqInt header1;
+    sqInt result;
+    sqInt savedHeaderA;
+    sqInt savedHeaderB;
+
+	savedHeaderA = longAt(obj1);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header = longAt(obj1);
+	if ((header & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock = (header & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock));
+		header = longAt(fwdBlock + BytesPerWord);
+	}
+	aWord = header;
+	longAtput(obj1, aWord);
+	savedHeaderB = longAt(obj2);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header1 = longAt(obj2);
+	if ((header1 & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock1 = (header1 & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock1));
+		header1 = longAt(fwdBlock1 + BytesPerWord);
+	}
+	aWord1 = header1;
+	longAtput(obj2, aWord1);
+	result = selector(obj1, obj2, aBool);
+	longAtput(obj1, savedHeaderA);
+	longAtput(obj2, savedHeaderB);
+	return result;
+}
+
 static sqInt
 withSmallIntegerTags(char *value)
 {

Modified: branches/Cog/nscogsrc/vm/cointerp.h
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/cointerp.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 
@@ -207,6 +207,7 @@
 void updateStackZoneReferencesToCompiledCodePreCompaction(void);
 extern void warning(char *s);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 usqInt youngStartAddress(void);
 
 

Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1184,6 +1184,7 @@
 static sqInt voidVMStateForSnapshot(void);
 static sqInt wakeHighestPriority(void);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
@@ -1952,7 +1953,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_*_VMMaker.oscog-eem.269";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.270";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -52679,6 +52680,61 @@
 	return result;
 }
 
+
+/*	For the purposes of become: send selector to the cogit with obj1 and obj2
+	and answer the result. Undo forwarding for the selector, but redo
+	forwarding after since
+	become:'s restoreHeadersAfter*Become* methods expect to be able to
+	restore. 
+ */
+
+sqInt
+withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt))
+{
+    sqInt aWord;
+    sqInt aWord1;
+    sqInt fwdBlock;
+    sqInt fwdBlock1;
+    sqInt header;
+    sqInt header1;
+    sqInt result;
+    sqInt savedHeaderA;
+    sqInt savedHeaderB;
+
+	savedHeaderA = longAt(obj1);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header = longAt(obj1);
+	if ((header & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock = (header & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock));
+		header = longAt(fwdBlock + BytesPerWord);
+	}
+	aWord = header;
+	longAtput(obj1, aWord);
+	savedHeaderB = longAt(obj2);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header1 = longAt(obj2);
+	if ((header1 & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock1 = (header1 & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock1));
+		header1 = longAt(fwdBlock1 + BytesPerWord);
+	}
+	aWord1 = header1;
+	longAtput(obj2, aWord1);
+	result = selector(obj1, obj2, aBool);
+	longAtput(obj1, savedHeaderA);
+	longAtput(obj2, savedHeaderB);
+	return result;
+}
+
 static sqInt
 withSmallIntegerTags(char *value)
 {

Modified: branches/Cog/nscogsrc/vm/interp.h
===================================================================
--- branches/Cog/nscogsrc/vm/interp.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/interp.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.267 uuid: 8b17ccab-cf2b-4810-8e9a-ac9571eafef5
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 #define VM_PROXY_MAJOR 1

Modified: branches/Cog/nscogsrc/vm/vmCallback.h
===================================================================
--- branches/Cog/nscogsrc/vm/vmCallback.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/nscogsrc/vm/vmCallback.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.267 uuid: 8b17ccab-cf2b-4810-8e9a-ac9571eafef5
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 #define VM_CALLBACK_INC 1


Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
   - Thu Feb 28 15:41:57 PST 2013
   + Fri Mar  1 17:20:58 PST 2013

Modified: branches/Cog/src/vm/cogit.c
===================================================================
--- branches/Cog/src/vm/cogit.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/cogit.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	CCodeGenerator VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	StackToRegisterMappingCogit VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -173,7 +173,7 @@
 #define ECX 1
 #define EDI 7
 #define EDX 2
-#define EncounteredUnknownBytecode -4
+#define EncounteredUnknownBytecode -6
 #define ESI 6
 #define ESP 4
 #define Fill16 5
@@ -251,16 +251,19 @@
 #define LongSizeMask 0xFFFFFFFCUL
 #define MapEnd 0
 #define MaxCompiledPrimitiveIndex 222
-#define MaxNegativeErrorCode -4
+#define MaxMethodSize 65535
+#define MaxNegativeErrorCode -6
 #define MaxNumArgs 15
+#define MaxStackCheckOffset 0xFFF
 #define MaxUnitDisplacement 31
-#define MaxUnreportableError -3
+#define MaxUnreportableError -5
 #define MaxX2NDisplacement 992
 #define MethodCacheClass 2
 #define MethodCacheMask 0xFFC
 #define MethodCacheMethod 3
 #define MethodCacheSelector 1
 #define MethodIndex 3
+#define MethodTooBig -4
 #define MFENCE 108
 #define MFMethodFlagHasContextFlag 1
 #define MFMethodFlagIsBlockFlag 2
@@ -346,7 +349,7 @@
 #define XMM7L 14
 #define XorCwR 94
 #define XorRR 80
-#define YoungSelectorInPIC -3
+#define YoungSelectorInPIC -5
 
 
 /*** Function Prototypes ***/
@@ -764,6 +767,7 @@
 static AbstractInstruction * genoperandoperandoperand(sqInt opcode, sqInt operandOne, sqInt operandTwo, sqInt operandThree);
 static sqInt getInlineCacheClassTagFrominto(sqInt sourceReg, sqInt destReg);
 static AbstractInstruction * getJmpTarget(AbstractInstruction * self_in_getJmpTarget);
+static sqInt getLiteral(sqInt litIndex);
 static sqInt hasDoublePrecisionFloatingPointSupport(AbstractInstruction * self_in_hasDoublePrecisionFloatingPointSupport);
 static sqInt hasLinkRegister(AbstractInstruction * self_in_hasLinkRegister);
 static sqInt hasPCDependentInstructions(AbstractInstruction * self_in_hasPCDependentInstructions);
@@ -862,7 +866,7 @@
 static sqInt methodAbortTrampolineFor(sqInt numArgs);
 static CogMethod * methodAfter(CogMethod *cogMethod);
 CogMethod * methodFor(void *address);
-static sqInt methodhasSameCodeAs(sqInt methodA, sqInt methodB);
+static sqInt methodhasSameCodeAscheckPenultimate(sqInt methodA, sqInt methodB, sqInt comparePenultimateLiteral);
 sqInt minCogMethodAddress(void);
 sqInt mnuOffset(void);
 static sqInt modRMRO(AbstractInstruction * self_in_modRMRO, sqInt mod, sqInt regMode, sqInt regOpcode);
@@ -1353,6 +1357,7 @@
 static int labelCounter;
 static sqInt lastSend;
 static usqInt limitAddress;
+static sqInt maxLitIndex;
 static CogBlockMethod * maxMethodBefore;
 static sqInt methodAbortTrampolines[4];
 static sqInt methodBytesFreedSinceLastCompaction;
@@ -3741,6 +3746,7 @@
 	inBlock = 0;
 	primInvokeLabel = null;
 	postCompileHook = null;
+	maxLitIndex = -1;
 	extra = ((((primitiveIndex = primitiveIndexOf(methodObj))) > 0)
 	 && (!(isQuickPrimitiveIndex(primitiveIndex)))
 		? 30
@@ -7129,10 +7135,10 @@
 
 	opType = ((usqInt) byte1) >> 5;
 	if (opType == 0) {
-		return genSendnumArgs(literalofMethod(byte2, methodObj), byte1 & 31);
+		return genSendnumArgs(getLiteral(byte2), byte1 & 31);
 	}
 	if (opType == 1) {
-		return genSendSupernumArgs(literalofMethod(byte2, methodObj), byte1 & 31);
+		return genSendSupernumArgs(getLiteral(byte2), byte1 & 31);
 	}
 	
 	switch (opType) {
@@ -7561,9 +7567,15 @@
 	}
 	(method->cmUsageCount = initialMethodUsageCount());
 	(method->cpicHasMNUCase = 0);
+	(method->cmUsesPenultimateLit = maxLitIndex >= ((literalCountOfHeader(methodHeader)) - 2));
 	(method->blockEntryOffset = (blockEntryLabel != null
 		? ((blockEntryLabel->address)) - (((sqInt)method))
 		: 0));
+	if (needsFrame) {
+		if (!((((stackCheckLabel->address)) - (((sqInt)method))) <= MaxStackCheckOffset)) {
+			error("too much code for stack check offset");
+		}
+	}
 	(method->stackCheckOffset = (needsFrame
 		? ((stackCheckLabel->address)) - (((sqInt)method))
 		: 0));
@@ -8359,13 +8371,13 @@
 static sqInt
 genExtendedSendBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte1 & 31, methodObj), ((usqInt) byte1) >> 5);
+	return genSendnumArgs(getLiteral(byte1 & 31), ((usqInt) byte1) >> 5);
 }
 
 static sqInt
 genExtendedSuperBytecode(void)
 {
-	return genSendSupernumArgs(literalofMethod(byte1 & 31, methodObj), ((usqInt) byte1) >> 5);
+	return genSendSupernumArgs(getLiteral(byte1 & 31), ((usqInt) byte1) >> 5);
 }
 
 
@@ -8533,6 +8545,9 @@
 	codeSize = generateInstructionsAt(((methodLabel->address)) + headerSize);
 	mapSize = generateMapAtstart(0, ((methodLabel->address)) + cmNoCheckEntryOffset);
 	totalSize = roundUpLength((headerSize + codeSize) + mapSize);
+	if (totalSize > MaxMethodSize) {
+		return ((CogMethod *) MethodTooBig);
+	}
 	startAddress = allocate(totalSize);
 	if (startAddress == 0) {
 		return ((CogMethod *) InsufficientCodeSpace);
@@ -10940,7 +10955,7 @@
 {
     sqInt literal;
 
-	literal = literalofMethod(literalIndex, methodObj);
+	literal = getLiteral(literalIndex);
 	return genPushLiteral(literal);
 }
 
@@ -10962,7 +10977,7 @@
 	/* So far descriptors are not rich enough to describe the entire dereference so generate the register
 	   load but don't push the result.  There is an order-or-evaluation issue if we defer the dereference. */
 
-	association = literalofMethod(literalIndex, methodObj);
+	association = getLiteral(literalIndex);
 	annotateobjRef(gMoveCwR(association, TempReg), association);
 	genLoadSlotsourceRegdestReg(ValueIndex, TempReg, freeReg);
 	ssPushRegister(freeReg);
@@ -11465,25 +11480,25 @@
 static sqInt
 genSecondExtendedSendBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte1 & 63, methodObj), ((usqInt) byte1) >> 6);
+	return genSendnumArgs(getLiteral(byte1 & 63), ((usqInt) byte1) >> 6);
 }
 
 static sqInt
 genSendLiteralSelector0ArgsBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte0 & 15, methodObj), 0);
+	return genSendnumArgs(getLiteral(byte0 & 15), 0);
 }
 
 static sqInt
 genSendLiteralSelector1ArgBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte0 & 15, methodObj), 1);
+	return genSendnumArgs(getLiteral(byte0 & 15), 1);
 }
 
 static sqInt
 genSendLiteralSelector2ArgsBytecode(void)
 {
-	return genSendnumArgs(literalofMethod(byte0 & 15, methodObj), 2);
+	return genSendnumArgs(getLiteral(byte0 & 15), 2);
 }
 
 static sqInt
@@ -12090,7 +12105,7 @@
 	flag("with better register allocation this wouldn't need a frame.  e.g. use SendNumArgs instead of ReceiverResultReg");
 	assert(needsFrame);
 	(optStatus.isReceiverResultRegLive = 0);
-	association = literalofMethod(litVarIndex, methodObj);
+	association = getLiteral(litVarIndex);
 
 	/* Avoid store check for immediate values */
 
@@ -12608,7 +12623,16 @@
 	return ((AbstractInstruction *) (((self_in_getJmpTarget->operands))[0]));
 }
 
+static sqInt
+getLiteral(sqInt litIndex)
+{
+	if (maxLitIndex < litIndex) {
+		maxLitIndex = litIndex;
+	}
+	return literalofMethod(litIndex, methodObj);
+}
 
+
 /*	We can generate dpfp support if the processor has SSE2 instructions. */
 
 static sqInt
@@ -13849,7 +13873,7 @@
 						if (methodHasCogMethod(remappedMethod)) {
 							error("attempt to become two cogged methods");
 						}
-						if (!(withoutForwardingOnandsendToCogit((cogMethod->methodObject), remappedMethod, methodhasSameCodeAs))) {
+						if (!(withoutForwardingOnandwithsendToCogit((cogMethod->methodObject), remappedMethod, (cogMethod->cmUsesPenultimateLit), methodhasSameCodeAscheckPenultimate))) {
 							error("attempt to become cogged method into different method");
 						}
 						rawHeaderOfput((cogMethod->methodObject), (cogMethod->methodHeader));
@@ -14545,7 +14569,7 @@
 	flags can differ. */
 
 static sqInt
-methodhasSameCodeAs(sqInt methodA, sqInt methodB)
+methodhasSameCodeAscheckPenultimate(sqInt methodA, sqInt methodB, sqInt comparePenultimateLiteral)
 {
     sqInt bi;
     sqInt endPCA;
@@ -14567,7 +14591,10 @@
 	}
 	for (li = 1; li <= (numLitsA - 1); li += 1) {
 		if ((fetchPointerofObject(li, methodA)) != (fetchPointerofObject(li, methodB))) {
-			return 0;
+			if ((li < (numLitsA - 1))
+			 || (comparePenultimateLiteral)) {
+				return 0;
+			}
 		}
 	}
 	for (bi = (startPCOfMethod(methodA)); bi <= endPCA; bi += 1) {

Modified: branches/Cog/src/vm/cogit.h
===================================================================
--- branches/Cog/src/vm/cogit.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/cogit.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	CCodeGenerator VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 

Modified: branches/Cog/src/vm/cogmethod.h
===================================================================
--- branches/Cog/src/vm/cogmethod.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/cogmethod.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.266 uuid: ee4e0b6e-91a8-432c-847b-132d682bc79b
+	CCodeGenerator VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 typedef struct {
@@ -10,7 +10,9 @@
 	unsigned		cmRefersToYoung : 1;
 	unsigned		cpicHasMNUCase : 1;
 	unsigned		cmUsageCount : 3;
-	unsigned		stackCheckOffset : 16;
+	unsigned		cmUsesPenultimateLit : 1;
+	unsigned		cmUnusedFlags : 3;
+	unsigned		stackCheckOffset : 12;
  } CogBlockMethod;
 
 typedef struct {
@@ -20,7 +22,9 @@
 	unsigned		cmRefersToYoung : 1;
 	unsigned		cpicHasMNUCase : 1;
 	unsigned		cmUsageCount : 3;
-	unsigned		stackCheckOffset : 16;
+	unsigned		cmUsesPenultimateLit : 1;
+	unsigned		cmUnusedFlags : 3;
+	unsigned		stackCheckOffset : 12;
 	unsigned short	blockSize;
 	unsigned short	blockEntryOffset;
 	sqInt	methodObject;

Modified: branches/Cog/src/vm/cointerp.c
===================================================================
--- branches/Cog/src/vm/cointerp.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/cointerp.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1172,6 +1172,7 @@
 static sqInt voidVMStateForSnapshot(void);
 static sqInt wakeHighestPriority(void);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
@@ -1939,7 +1940,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.269]";
+const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.270]";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -48079,6 +48080,61 @@
 	return result;
 }
 
+
+/*	For the purposes of become: send selector to the cogit with obj1 and obj2
+	and answer the result. Undo forwarding for the selector, but redo
+	forwarding after since
+	become:'s restoreHeadersAfter*Become* methods expect to be able to
+	restore. 
+ */
+
+sqInt
+withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt))
+{
+    sqInt aWord;
+    sqInt aWord1;
+    sqInt fwdBlock;
+    sqInt fwdBlock1;
+    sqInt header;
+    sqInt header1;
+    sqInt result;
+    sqInt savedHeaderA;
+    sqInt savedHeaderB;
+
+	savedHeaderA = longAt(obj1);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header = longAt(obj1);
+	if ((header & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock = (header & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock));
+		header = longAt(fwdBlock + BytesPerWord);
+	}
+	aWord = header;
+	longAtput(obj1, aWord);
+	savedHeaderB = longAt(obj2);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header1 = longAt(obj2);
+	if ((header1 & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock1 = (header1 & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock1));
+		header1 = longAt(fwdBlock1 + BytesPerWord);
+	}
+	aWord1 = header1;
+	longAtput(obj2, aWord1);
+	result = selector(obj1, obj2, aBool);
+	longAtput(obj1, savedHeaderA);
+	longAtput(obj2, savedHeaderB);
+	return result;
+}
+
 static sqInt
 withSmallIntegerTags(char *value)
 {

Modified: branches/Cog/src/vm/cointerp.h
===================================================================
--- branches/Cog/src/vm/cointerp.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/cointerp.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 
@@ -207,6 +207,7 @@
 void updateStackZoneReferencesToCompiledCodePreCompaction(void);
 extern void warning(char *s);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 usqInt youngStartAddress(void);
 
 

Modified: branches/Cog/src/vm/cointerpmt.c
===================================================================
--- branches/Cog/src/vm/cointerpmt.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/cointerpmt.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	CoInterpreterMT VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CoInterpreterMT VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1254,6 +1254,7 @@
 static void wakeVMThreadFor(sqInt index);
 static CogVMThread * willingVMThread(void);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
@@ -2038,7 +2039,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.269]";
+const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.270]";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 sqInt willNotThreadWarnCount;
@@ -49928,6 +49929,61 @@
 	return result;
 }
 
+
+/*	For the purposes of become: send selector to the cogit with obj1 and obj2
+	and answer the result. Undo forwarding for the selector, but redo
+	forwarding after since
+	become:'s restoreHeadersAfter*Become* methods expect to be able to
+	restore. 
+ */
+
+sqInt
+withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt))
+{
+    sqInt aWord;
+    sqInt aWord1;
+    sqInt fwdBlock;
+    sqInt fwdBlock1;
+    sqInt header;
+    sqInt header1;
+    sqInt result;
+    sqInt savedHeaderA;
+    sqInt savedHeaderB;
+
+	savedHeaderA = longAt(obj1);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header = longAt(obj1);
+	if ((header & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock = (header & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock));
+		header = longAt(fwdBlock + BytesPerWord);
+	}
+	aWord = header;
+	longAtput(obj1, aWord);
+	savedHeaderB = longAt(obj2);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header1 = longAt(obj2);
+	if ((header1 & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock1 = (header1 & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock1));
+		header1 = longAt(fwdBlock1 + BytesPerWord);
+	}
+	aWord1 = header1;
+	longAtput(obj2, aWord1);
+	result = selector(obj1, obj2, aBool);
+	longAtput(obj1, savedHeaderA);
+	longAtput(obj2, savedHeaderB);
+	return result;
+}
+
 static sqInt
 withSmallIntegerTags(char *value)
 {

Modified: branches/Cog/src/vm/cointerpmt.h
===================================================================
--- branches/Cog/src/vm/cointerpmt.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/cointerpmt.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 
@@ -211,6 +211,7 @@
 usqInt vmOwnerLockAddress(void);
 extern void warning(char *s);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 usqInt youngStartAddress(void);
 
 

Modified: branches/Cog/src/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/src/vm/gcc3x-cointerp.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/gcc3x-cointerp.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1175,6 +1175,7 @@
 static sqInt voidVMStateForSnapshot(void);
 static sqInt wakeHighestPriority(void);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
@@ -1942,7 +1943,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.269]";
+const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.270]";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -48088,6 +48089,61 @@
 	return result;
 }
 
+
+/*	For the purposes of become: send selector to the cogit with obj1 and obj2
+	and answer the result. Undo forwarding for the selector, but redo
+	forwarding after since
+	become:'s restoreHeadersAfter*Become* methods expect to be able to
+	restore. 
+ */
+
+sqInt
+withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt))
+{
+    sqInt aWord;
+    sqInt aWord1;
+    sqInt fwdBlock;
+    sqInt fwdBlock1;
+    sqInt header;
+    sqInt header1;
+    sqInt result;
+    sqInt savedHeaderA;
+    sqInt savedHeaderB;
+
+	savedHeaderA = longAt(obj1);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header = longAt(obj1);
+	if ((header & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock = (header & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock));
+		header = longAt(fwdBlock + BytesPerWord);
+	}
+	aWord = header;
+	longAtput(obj1, aWord);
+	savedHeaderB = longAt(obj2);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header1 = longAt(obj2);
+	if ((header1 & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock1 = (header1 & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock1));
+		header1 = longAt(fwdBlock1 + BytesPerWord);
+	}
+	aWord1 = header1;
+	longAtput(obj2, aWord1);
+	result = selector(obj1, obj2, aBool);
+	longAtput(obj1, savedHeaderA);
+	longAtput(obj2, savedHeaderB);
+	return result;
+}
+
 static sqInt
 withSmallIntegerTags(char *value)
 {

Modified: branches/Cog/src/vm/gcc3x-cointerpmt.c
===================================================================
--- branches/Cog/src/vm/gcc3x-cointerpmt.c	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/gcc3x-cointerpmt.c	2013-03-02 01:22:06 UTC (rev 2697)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
    from
-	CoInterpreterMT VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CoInterpreterMT VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
-static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1257,6 +1257,7 @@
 static void wakeVMThreadFor(sqInt index);
 static CogVMThread * willingVMThread(void);
 sqInt withoutForwardingOnandsendToCogit(sqInt obj1, sqInt obj2, sqInt (*selector)(sqInt,sqInt));
+sqInt withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt));
 static sqInt withSmallIntegerTags(char *value);
 static sqInt wordSwapped(sqInt w);
 static void writeImageFileIO(sqInt imageBytes);
@@ -2041,7 +2042,7 @@
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
 static usqInt heapBase;
-const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.269]";
+const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.270]";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 sqInt willNotThreadWarnCount;
@@ -49937,6 +49938,61 @@
 	return result;
 }
 
+
+/*	For the purposes of become: send selector to the cogit with obj1 and obj2
+	and answer the result. Undo forwarding for the selector, but redo
+	forwarding after since
+	become:'s restoreHeadersAfter*Become* methods expect to be able to
+	restore. 
+ */
+
+sqInt
+withoutForwardingOnandwithsendToCogit(sqInt obj1, sqInt obj2, sqInt aBool, sqInt (*selector)(sqInt,sqInt,sqInt))
+{
+    sqInt aWord;
+    sqInt aWord1;
+    sqInt fwdBlock;
+    sqInt fwdBlock1;
+    sqInt header;
+    sqInt header1;
+    sqInt result;
+    sqInt savedHeaderA;
+    sqInt savedHeaderB;
+
+	savedHeaderA = longAt(obj1);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header = longAt(obj1);
+	if ((header & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock = (header & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock));
+		header = longAt(fwdBlock + BytesPerWord);
+	}
+	aWord = header;
+	longAtput(obj1, aWord);
+	savedHeaderB = longAt(obj2);
+	/* begin baseHeader:put: */
+	/* begin headerWhileForwardingOf: */
+	header1 = longAt(obj2);
+	if ((header1 & MarkBit) != 0) {
+
+		/* oop is forwarded; get its real header from its forwarding table entry */
+
+		fwdBlock1 = (header1 & AllButMarkBitAndTypeMask) << 1;
+		assert(fwdBlockValid(fwdBlock1));
+		header1 = longAt(fwdBlock1 + BytesPerWord);
+	}
+	aWord1 = header1;
+	longAtput(obj2, aWord1);
+	result = selector(obj1, obj2, aBool);
+	longAtput(obj1, savedHeaderA);
+	longAtput(obj2, savedHeaderB);
+	return result;
+}
+
 static sqInt
 withSmallIntegerTags(char *value)
 {

Modified: branches/Cog/src/vm/interp.h
===================================================================
--- branches/Cog/src/vm/interp.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/interp.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.269 uuid: 49173296-5145-4de1-a2d9-defc8579acc6
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 #define VM_PROXY_MAJOR 1

Modified: branches/Cog/src/vm/vmCallback.h
===================================================================
--- branches/Cog/src/vm/vmCallback.h	2013-02-28 23:46:24 UTC (rev 2696)
+++ branches/Cog/src/vm/vmCallback.h	2013-03-02 01:22:06 UTC (rev 2697)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.267 uuid: 8b17ccab-cf2b-4810-8e9a-ac9571eafef5
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.270 uuid: 014f0153-bb02-49b7-b544-d8f3ac2deef6
  */
 
 #define VM_CALLBACK_INC 1



More information about the Vm-dev mailing list