[Vm-dev] [commit][3351] CogVM source as per VMMaker.oscog-eem.1317

commits at squeakvm.org commits at squeakvm.org
Thu May 21 05:06:27 UTC 2015


Revision: 3351
Author:   eliot
Date:     2015-05-20 22:06:22 -0700 (Wed, 20 May 2015)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.1317

Cogit:
Fix the performance regression on x86 in r3308 VMMaker.oscog-eem.1178 through
the use of the XCHG instruction in CogIA32Compiler>>genPushRegisterArgsForNumArgs:.
Since SendNumArgsReg is not live with small arity sends it can be used instead
of TempReg.

Replace uses of the magic constant 2 with NumSendTrampolines - 2 (actually <= 2
=> < (NumSendTrampolines - 1)) where appropriate. Hence NumSendTrampolines moved
to CogCompilationConstants.

Fix bug on ARM with pc-relative addressing. pc-relative addressing can only be
used within a method because of relocation.  The old code would use pc-relative
addressing to access trampolines for methods close to the trampolines and then
not for methods further away, causing changes in the code generated by
compileInterpreterPrimitive:.

To support this, rationalize the PIC compilation code, being sure to initialize
and concretize methodLabel at the start of each PIC.  Don't bother to pass PIC
size as a parameter given we have PIC-specific header-filling routines now.

Spur:
Firm up the checkTraversableSortedFreeList assert routine to
check that the list is traversable from lastFreeChunk, not just firstFreeChunk.

Slang:
Make promoteArithmeticTypes:and: obey C99's promotion rules more closely in an
effort to generate more stable sources.  Types were flipping between sqInt &
usqInt for variables that were assigned both types, so that one generation
would produce one type and a subsequent one another (Set/Dictionary hashing?).

Modified Paths:
--------------
    branches/Cog/nsspursrc/vm/cogit.h
    branches/Cog/nsspursrc/vm/cogitARMv5.c
    branches/Cog/nsspursrc/vm/cogitIA32.c
    branches/Cog/nsspursrc/vm/cointerp.c
    branches/Cog/nsspursrc/vm/cointerp.h
    branches/Cog/nsspursrc/vm/gcc3x-cointerp.c
    branches/Cog/nsspurstack64src/vm/gcc3x-interp.c
    branches/Cog/nsspurstack64src/vm/interp.c
    branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c
    branches/Cog/nsspurstacksrc/vm/interp.c
    branches/Cog/spursistasrc/vm/cogit.h
    branches/Cog/spursistasrc/vm/cogitARMv5.c
    branches/Cog/spursistasrc/vm/cogitIA32.c
    branches/Cog/spursistasrc/vm/cointerp.c
    branches/Cog/spursistasrc/vm/cointerp.h
    branches/Cog/spursistasrc/vm/gcc3x-cointerp.c
    branches/Cog/spursrc/vm/cogit.h
    branches/Cog/spursrc/vm/cogitARMv5.c
    branches/Cog/spursrc/vm/cogitIA32.c
    branches/Cog/spursrc/vm/cointerp.c
    branches/Cog/spursrc/vm/cointerp.h
    branches/Cog/spursrc/vm/gcc3x-cointerp.c
    branches/Cog/spurstack64src/vm/gcc3x-interp.c
    branches/Cog/spurstack64src/vm/interp.c
    branches/Cog/spurstacksrc/vm/gcc3x-interp.c
    branches/Cog/spurstacksrc/vm/interp.c
    branches/Cog/src/vm/cogit.h
    branches/Cog/src/vm/cogitARMv5.c
    branches/Cog/src/vm/cogitIA32.c
    branches/Cog/src/vm/cointerp.c
    branches/Cog/src/vm/cointerp.h
    branches/Cog/src/vm/cointerpmt.c
    branches/Cog/src/vm/cointerpmt.h
    branches/Cog/src/vm/gcc3x-cointerp.c
    branches/Cog/src/vm/gcc3x-cointerpmt.c

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

Modified: branches/Cog/nsspursrc/vm/cogit.h
===================================================================
--- branches/Cog/nsspursrc/vm/cogit.h	2015-05-19 01:13:54 UTC (rev 3350)
+++ branches/Cog/nsspursrc/vm/cogit.h	2015-05-21 05:06:22 UTC (rev 3351)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710
+	CCodeGenerator VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440
  */
 
 

Modified: branches/Cog/nsspursrc/vm/cogitARMv5.c
===================================================================
--- branches/Cog/nsspursrc/vm/cogitARMv5.c	2015-05-19 01:13:54 UTC (rev 3350)
+++ branches/Cog/nsspursrc/vm/cogitARMv5.c	2015-05-21 05:06:22 UTC (rev 3351)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710
+	CCodeGenerator VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710
+	StackToRegisterMappingCogit VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -556,7 +556,7 @@
 sqInt abortOffset(void);
 static void addCleanBlockStarts(void);
 void addCogMethodsToHeapMap(void);
-static sqInt addressIsInCodeZone(sqInt address) NoDbgRegParms;
+static sqInt addressIsInCurrentCompilation(sqInt address) NoDbgRegParms;
 static sqInt addressIsInFixups(AbstractInstruction *address) NoDbgRegParms;
 static sqInt addressIsInInstructions(AbstractInstruction *address) NoDbgRegParms;
 static sqInt addressOfEndOfCaseinCPIC(sqInt n, CogMethod *cPIC) NoDbgRegParms;
@@ -624,9 +624,7 @@
 static sqInt extABytecode(void);
 static sqInt extBBytecode(void);
 static sqInt fillInBlockHeadersAt(sqInt startAddress) NoDbgRegParms;
-static CogMethod * fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt numCases, sqInt hasMNUCase, sqInt selector) NoDbgRegParms;
 static CogMethod * fillInMethodHeadersizeselector(CogMethod *method, sqInt size, sqInt selector) NoDbgRegParms;
-static CogMethod * fillInOPICHeadersizenumArgsselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt selector) NoDbgRegParms;
 static usqInt findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc) NoDbgRegParms;
 static sqInt findMapLocationForMcpcinMethod(sqInt targetMcpc, CogMethod *cogMethod) NoDbgRegParms;
 CogBlockMethod * findMethodForStartBcpcinHomeMethod(sqInt startbcpc, CogMethod *cogMethod);
@@ -1900,6 +1898,7 @@
 #define halt() warning("halt")
 #define haltmsg(msg) warning("halt: " msg)
 #define interpretOffset() missOffset
+#define methodLabel() methodLabel
 #define methodZoneBase() methodZoneBase
 #define minCallAddress() minValidCallAddress
 #define noCheckEntryOffset() cmNoCheckEntryOffset
@@ -6651,7 +6650,7 @@
 	/* First try and encode as a pc-relative reference... */
 
 	operand = ((self_in_loadCwInto->operands))[0];
-	if (addressIsInCodeZone(operand)) {
+	if (addressIsInCurrentCompilation(operand)) {
 		distance = operand - (((self_in_loadCwInto->address)) + 8);
 		/* begin rotateable8bitImmediate:ifTrue:ifFalse: */
 		if ((distance & 0xFF) == distance) {
@@ -7475,18 +7474,11 @@
 	}
 }
 
-
-/*	N.B. We /don't/ write this as address between: codeBase and: methodZone
-	limitZony in case we're
-	testing an address in a method whose code has yet to be allocated and is
-	hence >= methodZone limitZony
- */
-
 static sqInt
-addressIsInCodeZone(sqInt address)
+addressIsInCurrentCompilation(sqInt address)
 {
-	return ((((usqInt)address)) >= codeBase)
-	 && (address < (youngReferrers()));
+	return ((((usqInt)address)) >= ((methodLabel->address)))
+	 && (address < (((methodLabel->address)) + (1 << 16)));
 }
 
 static sqInt
@@ -8860,7 +8852,7 @@
 cogMNUPICSelectorreceivermethodOperandnumArgs(sqInt selector, sqInt rcvr, sqInt methodOperand, sqInt numArgs)
 {
     sqInt end;
-    sqInt headerSize;
+    CogMethod *pic;
     sqInt size;
     sqInt startAddress;
 
@@ -8880,15 +8872,37 @@
 	allocateOpcodesbytecodes(numPICCases * 7, 0);
 	compileMNUCPICmethodOperandnumArgs(((CogMethod *) startAddress), methodOperand, numArgs);
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
-	size = generateInstructionsAt(startAddress + headerSize);
+	concretizeAt(methodLabel, startAddress);
+	size = generateInstructionsAt(startAddress + (sizeof(CogMethod)));
 
 	/* The missOffset is the same as the interpretOffset. On RISCs it includes an additional instruction. */
 
-	end = outputInstructionsAt(startAddress + headerSize);
+	end = outputInstructionsAt(startAddress + (sizeof(CogMethod)));
 	assert(missOffset == ((((callInstructionByteSize(backEnd)) + ((picInterpretAbort->address))) + ((picInterpretAbort->machineCodeSize))) - startAddress));
 	assert((startAddress + cmEntryOffset) == ((entry->address)));
-	return fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(((CogMethod *) startAddress), closedPICSize, numArgs, 1, 1, selector);
+	/* begin fillInCPICHeader:numArgs:numCases:hasMNUCase:selector: */
+	pic = ((CogMethod *) startAddress);
+	assert(!(isYoung(selector)));
+	(pic->cmType = CMClosedPIC);
+	(pic->objectHeader = 0);
+	(pic->blockSize = closedPICSize);
+	(pic->methodObject = 0);
+	(pic->methodHeader = 0);
+	(pic->selector = selector);
+	(pic->cmNumArgs = numArgs);
+	(pic->cmRefersToYoung = 0);
+	(pic->cmUsageCount = initialClosedPICUsageCount());
+	(pic->cpicHasMNUCase = 1);
+	(pic->cPICNumCases = 1);
+	(pic->blockEntryOffset = 0);
+	assert(((pic->cmType)) == CMClosedPIC);
+	assert(((pic->selector)) == selector);
+	assert(((pic->cmNumArgs)) == numArgs);
+	assert(((pic->cPICNumCases)) == 1);
+	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
+	assert(closedPICSize == (roundUpLength(closedPICSize)));
+	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + closedPICSize);
+	return pic;
 }
 
 
@@ -8902,8 +8916,8 @@
 {
     sqInt codeSize;
     sqInt end;
-    sqInt headerSize;
     sqInt mapSize;
+    CogMethod *pic;
     sqInt startAddress;
 
 	compilationBreakpointisMNUCase(selector, numBytesOf(selector), 0);
@@ -8917,13 +8931,34 @@
 	compileOpenPICnumArgs(selector, numArgs);
 	computeMaximumSizes();
 	concretizeAt(methodLabel, startAddress);
-	headerSize = sizeof(CogMethod);
-	codeSize = generateInstructionsAt(startAddress + headerSize);
+	codeSize = generateInstructionsAt(startAddress + (sizeof(CogMethod)));
 	mapSize = generateMapAtstart((startAddress + openPICSize) - 1, startAddress + cmNoCheckEntryOffset);
 	assert((((entry->address)) - startAddress) == cmEntryOffset);
-	assert(((headerSize + codeSize) + mapSize) <= openPICSize);
-	end = outputInstructionsAt(startAddress + headerSize);
-	return fillInOPICHeadersizenumArgsselector(((CogMethod *) startAddress), openPICSize, numArgs, selector);
+	assert(((roundUpLength((sizeof(CogMethod)) + codeSize)) + (roundUpLength(mapSize))) <= openPICSize);
+	end = outputInstructionsAt(startAddress + (sizeof(CogMethod)));
+	/* begin fillInOPICHeader:numArgs:selector: */
+	pic = ((CogMethod *) startAddress);
+	(pic->cmType = CMOpenPIC);
+	(pic->objectHeader = 0);
+	(pic->blockSize = openPICSize);
+	addToOpenPICList(pic);
+	(pic->methodHeader = 0);
+	(pic->selector = selector);
+	(pic->cmNumArgs = numArgs);
+	if ((pic->cmRefersToYoung = isYoung(selector))) {
+		addToYoungReferrers(pic);
+	}
+	(pic->cmUsageCount = initialOpenPICUsageCount());
+	(pic->cpicHasMNUCase = 0);
+	(pic->cPICNumCases = 0);
+	(pic->blockEntryOffset = 0);
+	assert(((pic->cmType)) == CMOpenPIC);
+	assert(((pic->selector)) == selector);
+	assert(((pic->cmNumArgs)) == numArgs);
+	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
+	assert(openPICSize == (roundUpLength(openPICSize)));
+	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + openPICSize);
+	return pic;
 }
 
 
@@ -8939,7 +8974,7 @@
 cogPICSelectornumArgsCase0MethodCase1MethodtagisMNUCase(sqInt selector, sqInt numArgs, CogMethod *case0CogMethod, sqInt case1MethodOrNil, sqInt case1Tag, sqInt isMNUCase)
 {
     sqInt end;
-    sqInt headerSize;
+    CogMethod *pic;
     sqInt size;
     sqInt startAddress;
 
@@ -8956,17 +8991,39 @@
 	allocateOpcodesbytecodes(numPICCases * 7, 0);
 	compileCPICCase0Case1MethodtagisMNUCasenumArgs(((CogMethod *) startAddress), case0CogMethod, case1MethodOrNil, case1Tag, isMNUCase, numArgs);
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
-	size = generateInstructionsAt(startAddress + headerSize);
+	concretizeAt(methodLabel, startAddress);
+	size = generateInstructionsAt(startAddress + (sizeof(CogMethod)));
 
 	/* The missOffset is the same as the interpretOffset. On RISCs it includes an additional instruction. */
 
-	end = outputInstructionsAt(startAddress + headerSize);
+	end = outputInstructionsAt(startAddress + (sizeof(CogMethod)));
 	assert(missOffset == ((((callInstructionByteSize(backEnd)) + ((picInterpretAbort->address))) + ((picInterpretAbort->machineCodeSize))) - startAddress));
 	assert((startAddress + cmEntryOffset) == ((entry->address)));
 	assert(((endCPICCase0->address)) == (startAddress + firstCPICCaseOffset));
 	assert(((endCPICCase1->address)) == ((startAddress + firstCPICCaseOffset) + cPICCaseSize));
-	return fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(((CogMethod *) startAddress), closedPICSize, numArgs, 2, isMNUCase, selector);
+	/* begin fillInCPICHeader:numArgs:numCases:hasMNUCase:selector: */
+	pic = ((CogMethod *) startAddress);
+	assert(!(isYoung(selector)));
+	(pic->cmType = CMClosedPIC);
+	(pic->objectHeader = 0);
+	(pic->blockSize = closedPICSize);
+	(pic->methodObject = 0);
+	(pic->methodHeader = 0);
+	(pic->selector = selector);
+	(pic->cmNumArgs = numArgs);
+	(pic->cmRefersToYoung = 0);
+	(pic->cmUsageCount = initialClosedPICUsageCount());
+	(pic->cpicHasMNUCase = isMNUCase);
+	(pic->cPICNumCases = 2);
+	(pic->blockEntryOffset = 0);
+	assert(((pic->cmType)) == CMClosedPIC);
+	assert(((pic->selector)) == selector);
+	assert(((pic->cmNumArgs)) == numArgs);
+	assert(((pic->cPICNumCases)) == 2);
+	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
+	assert(closedPICSize == (roundUpLength(closedPICSize)));
+	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + closedPICSize);
+	return pic;
 }
 
 
@@ -9807,32 +9864,6 @@
 }
 
 static CogMethod *
-fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt numCases, sqInt hasMNUCase, sqInt selector)
-{
-	assert(!(isYoung(selector)));
-	(pic->cmType = CMClosedPIC);
-	(pic->objectHeader = 0);
-	(pic->blockSize = size);
-	(pic->methodObject = 0);
-	(pic->methodHeader = 0);
-	(pic->selector = selector);
-	(pic->cmNumArgs = numArgs);
-	(pic->cmRefersToYoung = 0);
-	(pic->cmUsageCount = initialClosedPICUsageCount());
-	(pic->cpicHasMNUCase = hasMNUCase);
-	(pic->cPICNumCases = numCases);
-	(pic->blockEntryOffset = 0);
-	assert(((pic->cmType)) == CMClosedPIC);
-	assert(((pic->selector)) == selector);
-	assert(((pic->cmNumArgs)) == numArgs);
-	assert(((pic->cPICNumCases)) == numCases);
-	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
-	assert(size == (roundUpLength(size)));
-	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + size);
-	return pic;
-}
-
-static CogMethod *
 fillInMethodHeadersizeselector(CogMethod *method, sqInt size, sqInt selector)
 {
     sqInt methodHeader;
@@ -9885,32 +9916,6 @@
 	return method;
 }
 
-static CogMethod *
-fillInOPICHeadersizenumArgsselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt selector)
-{
-	(pic->cmType = CMOpenPIC);
-	(pic->objectHeader = 0);
-	(pic->blockSize = size);
-	addToOpenPICList(pic);
-	(pic->methodHeader = 0);
-	(pic->selector = selector);
-	(pic->cmNumArgs = numArgs);
-	if ((pic->cmRefersToYoung = isYoung(selector))) {
-		addToYoungReferrers(pic);
-	}
-	(pic->cmUsageCount = initialOpenPICUsageCount());
-	(pic->cpicHasMNUCase = 0);
-	(pic->cPICNumCases = 0);
-	(pic->blockEntryOffset = 0);
-	assert(((pic->cmType)) == CMOpenPIC);
-	assert(((pic->selector)) == selector);
-	assert(((pic->cmNumArgs)) == numArgs);
-	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
-	assert(size == (roundUpLength(size)));
-	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + size);
-	return pic;
-}
-
 static usqInt
 findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc)
 {
@@ -10323,9 +10328,7 @@
 static void
 generateClosedPICPrototype(void)
 {
-    sqInt headerSize;
 
-
 	/* stack allocate the various collections so that they
 	   are effectively garbage collected on return. */
 
@@ -10333,8 +10336,8 @@
 	allocateOpcodesbytecodes(numPICCases * 7, 0);
 	compileClosedPICPrototype();
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
-	closedPICSize = headerSize + (generateInstructionsAt(methodZoneBase + headerSize));
+	concretizeAt(methodLabel, methodZoneBase);
+	closedPICSize = (sizeof(CogMethod)) + (generateInstructionsAt(methodZoneBase + (sizeof(CogMethod))));
 	firstCPICCaseOffset = ((endCPICCase0->address)) - methodZoneBase;
 	cPICCaseSize = ((endCPICCase1->address)) - ((endCPICCase0->address));
 	cPICEndSize = closedPICSize - (((numPICCases - 1) * cPICCaseSize) + firstCPICCaseOffset);
@@ -10464,7 +10467,7 @@
     unsigned long delta;
     sqInt i;
     sqInt length;
-    sqInt location;
+    unsigned long location;
     unsigned long mapEntry;
     sqInt maxDelta;
     unsigned long mcpc;
@@ -10532,17 +10535,17 @@
 generateOpenPICPrototype(void)
 {
     sqInt codeSize;
-    sqInt headerSize;
     sqInt mapSize;
 
 	allocateOpcodesbytecodes(100, 0);
+	(methodLabel->address = methodZoneBase);
+	(methodLabel->dependent = null);
 	compileOpenPICnumArgs(specialSelector(0), 2);
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
 	concretizeAt(methodLabel, methodZoneBase);
-	codeSize = generateInstructionsAt(methodZoneBase + headerSize);
+	codeSize = generateInstructionsAt(methodZoneBase + (sizeof(CogMethod)));
 	mapSize = generateMapAtstart(null, methodZoneBase + cmNoCheckEntryOffset);
-	openPICSize = (roundUpLength(headerSize + codeSize)) + (roundUpLength(mapSize));
+	openPICSize = (roundUpLength((sizeof(CogMethod)) + codeSize)) + (roundUpLength(mapSize));
 }
 
 
@@ -10609,6 +10612,7 @@
     sqInt methodZoneStart;
 
 	methodZoneStart = methodZoneBase;
+	(methodLabel->address = methodZoneStart);
 	allocateOpcodesbytecodes(80, 0);
 	initialPC = 0;
 	endPC = numAbstractOpcodes - 1;
@@ -22153,7 +22157,7 @@
 	 || (0)) {
 		genEnsureOopInRegNotForwardedscratchReg(ReceiverResultReg, TempReg);
 	}
-	if (numArgs > 2) {
+	if (numArgs >= (NumSendTrampolines - 1)) {
 		/* begin MoveCq:R: */
 		genoperandoperand(MoveCqR, numArgs, SendNumArgsReg);
 	}

Modified: branches/Cog/nsspursrc/vm/cogitIA32.c
===================================================================
--- branches/Cog/nsspursrc/vm/cogitIA32.c	2015-05-19 01:13:54 UTC (rev 3350)
+++ branches/Cog/nsspursrc/vm/cogitIA32.c	2015-05-21 05:06:22 UTC (rev 3351)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710
+	CCodeGenerator VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710
+	StackToRegisterMappingCogit VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -567,9 +567,7 @@
 static sqInt extABytecode(void);
 static sqInt extBBytecode(void);
 static sqInt fillInBlockHeadersAt(sqInt startAddress) NoDbgRegParms;
-static CogMethod * fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt numCases, sqInt hasMNUCase, sqInt selector) NoDbgRegParms;
 static CogMethod * fillInMethodHeadersizeselector(CogMethod *method, sqInt size, sqInt selector) NoDbgRegParms;
-static CogMethod * fillInOPICHeadersizenumArgsselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt selector) NoDbgRegParms;
 static usqInt findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc) NoDbgRegParms;
 static sqInt findMapLocationForMcpcinMethod(sqInt targetMcpc, CogMethod *cogMethod) NoDbgRegParms;
 CogBlockMethod * findMethodForStartBcpcinHomeMethod(sqInt startbcpc, CogMethod *cogMethod);
@@ -1846,6 +1844,7 @@
 #define halt() warning("halt")
 #define haltmsg(msg) warning("halt: " msg)
 #define interpretOffset() missOffset
+#define methodLabel() methodLabel
 #define methodZoneBase() methodZoneBase
 #define minCallAddress() minValidCallAddress
 #define noCheckEntryOffset() cmNoCheckEntryOffset
@@ -5364,18 +5363,34 @@
 
 
 /*	Ensure that the register args are pushed before the retpc for arity <=
-	self numRegArgs.
- */
-/*	This won't be as clumsy on a RISC. But putting the receiver and
-	args above the return address means the CoInterpreter has a
-	single machine-code frame format which saves us a lot of work. */
+	self numRegArgs. This
+	won't be as clumsy on a RISC. But putting the receiver and args above the
+	return address
+	means the CoInterpreter has a single machine-code frame format which saves
+	us a lot of work.
+	N.B. Take great care to /not/ smash TempReg, which is used in directed
+	send marshalling.
+	We could use XCHG to swap the ReceiverResultReg and top-of-stack return
+	address, pushing the
+	the ret pc (now in ReceiverResultReg) later, but XCHG is very slow. We can
+	use SendNumArgsReg
+	because it is only live in sends of arity >= (NumSendTrampolines - 1). */
 
 static AbstractInstruction *
 genPushRegisterArgsForNumArgs(AbstractInstruction * self_in_genPushRegisterArgsForNumArgs, sqInt numArgs)
 {
+	assert((numRegArgs()) < (NumSendTrampolines - 1));
 	if (numArgs <= 2) {
 		assert((numRegArgs()) <= 2);
-		genoperandoperandoperand(XCHGMwrR, 0, SPReg, ReceiverResultReg);
+		
+		/* a.k.a.
+		   cogit gen: XCHGMwrR operand: 0 operand: SPReg operand: ReceiverResultReg.
+		   but XCHG is slow. */
+
+		/* begin MoveMw:r:R: */
+		genoperandoperandoperand(MoveMwrR, 0, SPReg, SendNumArgsReg);
+		/* begin MoveR:Mw:r: */
+		genoperandoperandoperand(MoveRMwr, ReceiverResultReg, 0, SPReg);
 		if (numArgs > 0) {
 			/* begin PushR: */
 			genoperand(PushR, Arg0Reg);
@@ -5385,9 +5400,8 @@
 			}
 		}
 		/* begin PushR: */
-		genoperand(PushR, ReceiverResultReg);
-		/* begin MoveMw:r:R: */
-		genoperandoperandoperand(MoveMwrR, (numArgs + 1) * BytesPerWord, SPReg, ReceiverResultReg);
+		genoperand(PushR, SendNumArgsReg);
+
 	}
 	return self_in_genPushRegisterArgsForNumArgs;
 }
@@ -7647,7 +7661,7 @@
 cogMNUPICSelectorreceivermethodOperandnumArgs(sqInt selector, sqInt rcvr, sqInt methodOperand, sqInt numArgs)
 {
     sqInt end;
-    sqInt headerSize;
+    CogMethod *pic;
     sqInt size;
     sqInt startAddress;
 
@@ -7667,15 +7681,37 @@
 	allocateOpcodesbytecodes(numPICCases * 7, 0);
 	compileMNUCPICmethodOperandnumArgs(((CogMethod *) startAddress), methodOperand, numArgs);
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
-	size = generateInstructionsAt(startAddress + headerSize);
+	concretizeAt(methodLabel, startAddress);
+	size = generateInstructionsAt(startAddress + (sizeof(CogMethod)));
 
 	/* The missOffset is the same as the interpretOffset. On RISCs it includes an additional instruction. */
 
-	end = outputInstructionsAt(startAddress + headerSize);
+	end = outputInstructionsAt(startAddress + (sizeof(CogMethod)));
 	assert(missOffset == ((((0) + ((picInterpretAbort->address))) + ((picInterpretAbort->machineCodeSize))) - startAddress));
 	assert((startAddress + cmEntryOffset) == ((entry->address)));
-	return fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(((CogMethod *) startAddress), closedPICSize, numArgs, 1, 1, selector);
+	/* begin fillInCPICHeader:numArgs:numCases:hasMNUCase:selector: */
+	pic = ((CogMethod *) startAddress);
+	assert(!(isYoung(selector)));
+	(pic->cmType = CMClosedPIC);
+	(pic->objectHeader = 0);
+	(pic->blockSize = closedPICSize);
+	(pic->methodObject = 0);
+	(pic->methodHeader = 0);
+	(pic->selector = selector);
+	(pic->cmNumArgs = numArgs);
+	(pic->cmRefersToYoung = 0);
+	(pic->cmUsageCount = initialClosedPICUsageCount());
+	(pic->cpicHasMNUCase = 1);
+	(pic->cPICNumCases = 1);
+	(pic->blockEntryOffset = 0);
+	assert(((pic->cmType)) == CMClosedPIC);
+	assert(((pic->selector)) == selector);
+	assert(((pic->cmNumArgs)) == numArgs);
+	assert(((pic->cPICNumCases)) == 1);
+	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
+	assert(closedPICSize == (roundUpLength(closedPICSize)));
+	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + closedPICSize);
+	return pic;
 }
 
 
@@ -7689,8 +7725,8 @@
 {
     sqInt codeSize;
     sqInt end;
-    sqInt headerSize;
     sqInt mapSize;
+    CogMethod *pic;
     sqInt startAddress;
 
 	compilationBreakpointisMNUCase(selector, numBytesOf(selector), 0);
@@ -7704,13 +7740,34 @@
 	compileOpenPICnumArgs(selector, numArgs);
 	computeMaximumSizes();
 	concretizeAt(methodLabel, startAddress);
-	headerSize = sizeof(CogMethod);
-	codeSize = generateInstructionsAt(startAddress + headerSize);
+	codeSize = generateInstructionsAt(startAddress + (sizeof(CogMethod)));
 	mapSize = generateMapAtstart((startAddress + openPICSize) - 1, startAddress + cmNoCheckEntryOffset);
 	assert((((entry->address)) - startAddress) == cmEntryOffset);
-	assert(((headerSize + codeSize) + mapSize) <= openPICSize);
-	end = outputInstructionsAt(startAddress + headerSize);
-	return fillInOPICHeadersizenumArgsselector(((CogMethod *) startAddress), openPICSize, numArgs, selector);
+	assert(((roundUpLength((sizeof(CogMethod)) + codeSize)) + (roundUpLength(mapSize))) <= openPICSize);
+	end = outputInstructionsAt(startAddress + (sizeof(CogMethod)));
+	/* begin fillInOPICHeader:numArgs:selector: */
+	pic = ((CogMethod *) startAddress);
+	(pic->cmType = CMOpenPIC);
+	(pic->objectHeader = 0);
+	(pic->blockSize = openPICSize);
+	addToOpenPICList(pic);
+	(pic->methodHeader = 0);
+	(pic->selector = selector);
+	(pic->cmNumArgs = numArgs);
+	if ((pic->cmRefersToYoung = isYoung(selector))) {
+		addToYoungReferrers(pic);
+	}
+	(pic->cmUsageCount = initialOpenPICUsageCount());
+	(pic->cpicHasMNUCase = 0);
+	(pic->cPICNumCases = 0);
+	(pic->blockEntryOffset = 0);
+	assert(((pic->cmType)) == CMOpenPIC);
+	assert(((pic->selector)) == selector);
+	assert(((pic->cmNumArgs)) == numArgs);
+	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
+	assert(openPICSize == (roundUpLength(openPICSize)));
+	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + openPICSize);
+	return pic;
 }
 
 
@@ -7726,7 +7783,7 @@
 cogPICSelectornumArgsCase0MethodCase1MethodtagisMNUCase(sqInt selector, sqInt numArgs, CogMethod *case0CogMethod, sqInt case1MethodOrNil, sqInt case1Tag, sqInt isMNUCase)
 {
     sqInt end;
-    sqInt headerSize;
+    CogMethod *pic;
     sqInt size;
     sqInt startAddress;
 
@@ -7743,17 +7800,39 @@
 	allocateOpcodesbytecodes(numPICCases * 7, 0);
 	compileCPICCase0Case1MethodtagisMNUCasenumArgs(((CogMethod *) startAddress), case0CogMethod, case1MethodOrNil, case1Tag, isMNUCase, numArgs);
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
-	size = generateInstructionsAt(startAddress + headerSize);
+	concretizeAt(methodLabel, startAddress);
+	size = generateInstructionsAt(startAddress + (sizeof(CogMethod)));
 
 	/* The missOffset is the same as the interpretOffset. On RISCs it includes an additional instruction. */
 
-	end = outputInstructionsAt(startAddress + headerSize);
+	end = outputInstructionsAt(startAddress + (sizeof(CogMethod)));
 	assert(missOffset == ((((0) + ((picInterpretAbort->address))) + ((picInterpretAbort->machineCodeSize))) - startAddress));
 	assert((startAddress + cmEntryOffset) == ((entry->address)));
 	assert(((endCPICCase0->address)) == (startAddress + firstCPICCaseOffset));
 	assert(((endCPICCase1->address)) == ((startAddress + firstCPICCaseOffset) + cPICCaseSize));
-	return fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(((CogMethod *) startAddress), closedPICSize, numArgs, 2, isMNUCase, selector);
+	/* begin fillInCPICHeader:numArgs:numCases:hasMNUCase:selector: */
+	pic = ((CogMethod *) startAddress);
+	assert(!(isYoung(selector)));
+	(pic->cmType = CMClosedPIC);
+	(pic->objectHeader = 0);
+	(pic->blockSize = closedPICSize);
+	(pic->methodObject = 0);
+	(pic->methodHeader = 0);
+	(pic->selector = selector);
+	(pic->cmNumArgs = numArgs);
+	(pic->cmRefersToYoung = 0);
+	(pic->cmUsageCount = initialClosedPICUsageCount());
+	(pic->cpicHasMNUCase = isMNUCase);
+	(pic->cPICNumCases = 2);
+	(pic->blockEntryOffset = 0);
+	assert(((pic->cmType)) == CMClosedPIC);
+	assert(((pic->selector)) == selector);
+	assert(((pic->cmNumArgs)) == numArgs);
+	assert(((pic->cPICNumCases)) == 2);
+	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
+	assert(closedPICSize == (roundUpLength(closedPICSize)));
+	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + closedPICSize);
+	return pic;
 }
 
 
@@ -8568,32 +8647,6 @@
 }
 
 static CogMethod *
-fillInCPICHeadersizenumArgsnumCaseshasMNUCaseselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt numCases, sqInt hasMNUCase, sqInt selector)
-{
-	assert(!(isYoung(selector)));
-	(pic->cmType = CMClosedPIC);
-	(pic->objectHeader = 0);
-	(pic->blockSize = size);
-	(pic->methodObject = 0);
-	(pic->methodHeader = 0);
-	(pic->selector = selector);
-	(pic->cmNumArgs = numArgs);
-	(pic->cmRefersToYoung = 0);
-	(pic->cmUsageCount = initialClosedPICUsageCount());
-	(pic->cpicHasMNUCase = hasMNUCase);
-	(pic->cPICNumCases = numCases);
-	(pic->blockEntryOffset = 0);
-	assert(((pic->cmType)) == CMClosedPIC);
-	assert(((pic->selector)) == selector);
-	assert(((pic->cmNumArgs)) == numArgs);
-	assert(((pic->cPICNumCases)) == numCases);
-	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
-	assert(size == (roundUpLength(size)));
-	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + size);
-	return pic;
-}
-
-static CogMethod *
 fillInMethodHeadersizeselector(CogMethod *method, sqInt size, sqInt selector)
 {
     sqInt methodHeader;
@@ -8646,32 +8699,6 @@
 	return method;
 }
 
-static CogMethod *
-fillInOPICHeadersizenumArgsselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt selector)
-{
-	(pic->cmType = CMOpenPIC);
-	(pic->objectHeader = 0);
-	(pic->blockSize = size);
-	addToOpenPICList(pic);
-	(pic->methodHeader = 0);
-	(pic->selector = selector);
-	(pic->cmNumArgs = numArgs);
-	if ((pic->cmRefersToYoung = isYoung(selector))) {
-		addToYoungReferrers(pic);
-	}
-	(pic->cmUsageCount = initialOpenPICUsageCount());
-	(pic->cpicHasMNUCase = 0);
-	(pic->cPICNumCases = 0);
-	(pic->blockEntryOffset = 0);
-	assert(((pic->cmType)) == CMOpenPIC);
-	assert(((pic->selector)) == selector);
-	assert(((pic->cmNumArgs)) == numArgs);
-	assert((callTargetFromReturnAddress(backEnd, (((sqInt)pic)) + missOffset)) == (picAbortTrampolineFor(numArgs)));
-	assert(size == (roundUpLength(size)));
-	flushICacheFromto(processor, ((usqInt)pic), (((usqInt)pic)) + size);
-	return pic;
-}
-
 static usqInt
 findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc)
 {
@@ -9080,9 +9107,7 @@
 static void
 generateClosedPICPrototype(void)
 {
-    sqInt headerSize;
 
-
 	/* stack allocate the various collections so that they
 	   are effectively garbage collected on return. */
 
@@ -9090,8 +9115,8 @@
 	allocateOpcodesbytecodes(numPICCases * 7, 0);
 	compileClosedPICPrototype();
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
-	closedPICSize = headerSize + (generateInstructionsAt(methodZoneBase + headerSize));
+	concretizeAt(methodLabel, methodZoneBase);
+	closedPICSize = (sizeof(CogMethod)) + (generateInstructionsAt(methodZoneBase + (sizeof(CogMethod))));
 	firstCPICCaseOffset = ((endCPICCase0->address)) - methodZoneBase;
 	cPICCaseSize = ((endCPICCase1->address)) - ((endCPICCase0->address));
 	cPICEndSize = closedPICSize - (((numPICCases - 1) * cPICCaseSize) + firstCPICCaseOffset);
@@ -9221,7 +9246,7 @@
     unsigned long delta;
     sqInt i;
     sqInt length;
-    sqInt location;
+    unsigned long location;
     unsigned long mapEntry;
     sqInt maxDelta;
     unsigned long mcpc;
@@ -9289,17 +9314,17 @@
 generateOpenPICPrototype(void)
 {
     sqInt codeSize;
-    sqInt headerSize;
     sqInt mapSize;
 
 	allocateOpcodesbytecodes(100, 0);
+	(methodLabel->address = methodZoneBase);
+	(methodLabel->dependent = null);
 	compileOpenPICnumArgs(specialSelector(0), 2);
 	computeMaximumSizes();
-	headerSize = sizeof(CogMethod);
 	concretizeAt(methodLabel, methodZoneBase);
-	codeSize = generateInstructionsAt(methodZoneBase + headerSize);
+	codeSize = generateInstructionsAt(methodZoneBase + (sizeof(CogMethod)));
 	mapSize = generateMapAtstart(null, methodZoneBase + cmNoCheckEntryOffset);
-	openPICSize = (roundUpLength(headerSize + codeSize)) + (roundUpLength(mapSize));
+	openPICSize = (roundUpLength((sizeof(CogMethod)) + codeSize)) + (roundUpLength(mapSize));
 }
 
 
@@ -9366,6 +9391,7 @@
     sqInt methodZoneStart;
 
 	methodZoneStart = methodZoneBase;
+	(methodLabel->address = methodZoneStart);
 	allocateOpcodesbytecodes(80, 0);
 	initialPC = 0;
 	endPC = numAbstractOpcodes - 1;
@@ -20910,7 +20936,7 @@
 	 || (0)) {
 		genEnsureOopInRegNotForwardedscratchReg(ReceiverResultReg, TempReg);
 	}
-	if (numArgs > 2) {
+	if (numArgs >= (NumSendTrampolines - 1)) {
 		/* begin MoveCq:R: */
 		genoperandoperand(MoveCqR, numArgs, SendNumArgsReg);
 	}

Modified: branches/Cog/nsspursrc/vm/cointerp.c
===================================================================
--- branches/Cog/nsspursrc/vm/cointerp.c	2015-05-19 01:13:54 UTC (rev 3350)
+++ branches/Cog/nsspursrc/vm/cointerp.c	2015-05-21 05:06:22 UTC (rev 3351)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440
    from
-	CoInterpreter VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710
+	CoInterpreter VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.1315 uuid: a8172799-131a-401c-861e-55a1d2c21710 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.1317 uuid: a7e082b5-1ad8-42ef-84cc-0079605c8440 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -1191,13 +1191,13 @@
 static sqInt storeImageSegmentIntooutPointersroots(sqInt segmentWordArray, sqInt outPointerArray, sqInt arrayOfRoots) NoDbgRegParms;
 sqInt storePointerUncheckedofObjectwithValue(sqInt fieldIndex, sqInt objOop, sqInt valuePointer);
 sqInt storePointerofObjectwithValue(sqInt fieldIndex, sqInt objOop, sqInt valuePointer);
-usqInt stringForCString(const char *aCString);
+sqInt stringForCString(const char *aCString);
 static sqInt sufficientSpaceAfterGC(sqInt numBytes) NoDbgRegParms;
 static sqInt swizzleObjStackAt(sqInt objStackRootIndex) NoDbgRegParms;
 void tenuringIncrementalGC(void);
 static sqInt topOfObjStack(sqInt objStack) NoDbgRegParms;
 sqInt topRemappableOop(void);
-static sqInt totalFreeListBytes(void);
+static usqInt totalFreeListBytes(void);
 sqInt trueObject(void);
 static void unlinkSolitaryFreeTreeNode(sqInt freeTreeNode) NoDbgRegParms;
 sqInt unpinObject(sqInt objOop);
@@ -1612,8 +1612,8 @@
 _iss SpurNewSpaceSpace eden;
 _iss sqInt becomeEffectsFlags;
 _iss sqInt futureSurvivorStart;
+_iss usqInt lastFreeChunk;
 _iss char * objStackInvalidBecause;
-_iss usqInt lastFreeChunk;
 _iss sqInt ephemeronList;
 _iss usqInt freeOldSpaceStart;
 _iss sqInt tenureThreshold;
@@ -2380,7 +2380,7 @@
 /*560*/	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0,-1,-1
 	};
 char expensiveAsserts = 0;
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.1315";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.1317";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */;
 volatile int sendTrace;
 
@@ -18325,7 +18325,7 @@
     sqInt i;
     sqInt methodField;
     sqInt ok;
-    sqInt oop;
+    usqInt oop;
     char *theFP;
     StackPage *thePage;
     char *theSP;
@@ -19205,8 +19205,8 @@
     sqInt i;
     sqInt newOop;
     sqInt numArgs;
-    sqInt offset;
-    sqInt oop;
+    usqInt offset;
+    usqInt oop;
     sqInt referent;
     sqInt referent1;
     sqInt referent2;
@@ -20420,7 +20420,7 @@
     sqInt i;
     sqInt oop;
     char *theFP;
-    sqInt theIP;
+    usqInt theIP;
     char *theIPPtr;
     StackPage *thePage;
     char *theSP;
@@ -23551,7 +23551,7 @@
 moveFramesInthroughtoPage(StackPage *oldPage, char *theFP, StackPage *newPage)
 {
     char *callerFP;
-    sqInt callerIP;
+    usqInt callerIP;
     int delta;
     char *fpInNewPage;
     char *newFP;
@@ -24219,10 +24219,10 @@
     sqInt header2;
     CogMethod *homeMethod;
     usqInt i;
-    int index;
+    usqInt index;
     sqInt methodField;
     usqInt numArgs;
-    sqInt numTemps;
+    usqInt numTemps;
     char *rcvrAddress;
     sqInt rcvrOrClosure;
     sqInt theMethod;
@@ -24939,9 +24939,9 @@
 	? 0
 	: allocationReserve));
 	bit = (((highBit(heapSize1)) - 1) * 3) / 4;
-	heapSize = (heapSize1 & ((1 << bit) - 1)
-		? (((heapSize1 | ((1 << bit) - 1)) - ((1 << bit) - 1))) + (1 << bit)
-		: heapSize1);
+	heapSize = ((sqInt) ((heapSize1 & ((1 << bit) - 1)
+	? (((heapSize1 | ((1 << bit) - 1)) - ((1 << bit) - 1))) + (1 << bit)
+	: heapSize1)));
 
 	/* begin memory: */
 	aValue = ((usqInt)(allocateMemoryminimumimageFileheaderSize(heapSize, minimumMemory, f, headerSize)));
@@ -25039,9 +25039,9 @@
 	flag("endianness");
 	assert((classIndexOf(classArrayClass)) > (isForwardedObjectClassIndexPun()));
 	numSlots = byteAt(classArrayClass + 7);
-	GIV(metaclassNumSlots) = ((usqInt) ((numSlots == 0xFF
-	? longAt(classArrayClass - BaseHeaderSize)
-	: numSlots)));
+	GIV(metaclassNumSlots) = (numSlots == 0xFF
+		? longAt(classArrayClass - BaseHeaderSize)
+		: numSlots);
 
 	/* default */
 
@@ -31817,7 +31817,7 @@
     usqInt newObj;
     usqInt numBytes;
     sqInt numSlots;
-    sqInt s;
+    usqInt s;
     char *sp;
     sqInt sz;
 
@@ -31866,7 +31866,7 @@
 				GIV(needGCFlag) = 1;
 				forceInterruptCheck();
 			}
-			s = ((usqInt) (allocateSlotsInOldSpacebytesformatclassIndex(numSlots, numBytes, formatField, ClassByteStringCompactIndex)));
+			s = allocateSlotsInOldSpacebytesformatclassIndex(numSlots, numBytes, formatField, ClassByteStringCompactIndex);
 			goto l1;
 		}
 		if (numSlots >= 0xFF) {
@@ -33186,7 +33186,7 @@
     sqInt arg;
     sqInt fmt;
     sqInt i;
-    sqInt length;
+    usqInt length;
     usqInt numBytes;
     usqInt numSlots;
     usqInt numSlots1;
@@ -33227,18 +33227,18 @@
 
 			/* bytes (the common case), including CompiledMethod */
 
-			length = numBytes - (fmt & 7);
+			length = ((sqInt) (numBytes - (fmt & 7)));
 			goto l1;
 		}
 		if (fmt <= 9) {
-			length = numBytes;
+			length = ((sqInt) numBytes);
 			goto l1;
 		}
 		if (fmt >= 12) {
-			length = numBytes - ((fmt & 3) << 1);
+			length = ((sqInt) (numBytes - ((fmt & 3) << 1)));
 			goto l1;
 		}
-		length = numBytes - ((fmt & 1) << 2);
+		length = ((sqInt) (numBytes - ((fmt & 1) << 2)));
 	l1:	/* end numBytesOf: */;
 		if (!((((((usqInt) (longAt(rcvr))) >> 24) & 0x1F) == ((((usqInt) (longAt(arg))) >> 24) & 0x1F))
 			 && (length == (numBytesOf(arg))))) {
@@ -33256,9 +33256,9 @@
 		flag("endianness");
 		assert((classIndexOf(rcvr)) > (isForwardedObjectClassIndexPun()));
 		numSlots1 = byteAt(rcvr + 7);
-		length = ((usqInt) ((numSlots1 == 0xFF
-	? longAt(rcvr - BaseHeaderSize)
-	: numSlots1)));
+		length = (numSlots1 == 0xFF
+			? longAt(rcvr - BaseHeaderSize)
+			: numSlots1);
 		if (!((isAppropriateForCopyObject(arg))
 			 && (length == (lengthOfformat(arg, (((usqInt) (longAt(arg))) >> 24) & 0x1F))))) {
 			(GIV(primFailCode) = PrimErrBadArgument);
@@ -37384,7 +37384,7 @@
     sqInt hash;
     sqInt header;
     sqInt i;
-    sqInt instSpec;
+    usqInt instSpec;
     sqInt literalCount;
     usqInt newObj;
     usqInt newObj1;
@@ -43204,7 +43204,7 @@
     sqInt err;
     sqInt fillValue;
     sqInt hash;
-    sqInt instSpec;
+    usqInt instSpec;
     usqInt newObj;
     usqInt newObj1;
     usqInt numBytes;
@@ -44049,9 +44049,9 @@
 	flag("endianness");
 	assert((classIndexOf(newObj)) > (isForwardedObjectClassIndexPun()));
 	numSlots2 = byteAt(newObj + 7);
-	GIV(rememberedSetLimit) = ((usqInt) ((numSlots2 == 0xFF
-	? longAt(newObj - BaseHeaderSize)
-	: numSlots2)));
+	GIV(rememberedSetLimit) = (numSlots2 == 0xFF
+		? longAt(newObj - BaseHeaderSize)
+		: numSlots2);
 	/* begin setRememberedSetRedZone */
 	fudge = ((((GIV(eden).limit)) - ((GIV(eden).start))) / BytesPerWord) / 1024;
 	GIV(rememberedSetRedZone) = ((((GIV(rememberedSetLimit) * 3) / 4) < fudge) ? fudge : ((GIV(rememberedSetLimit) * 3) / 4));
@@ -45329,7 +45329,7 @@
     sqInt ptr2;
     sqInt slotBytes;
     usqInt smallObj;
-    sqInt start;
+    usqInt start;
 
 	classIndex = (long32At(aClass + 4)) & 0x3FFFFF;
 	if (classIndex == 0) {
@@ -46494,7 +46494,7 @@
     sqInt referent2;
     sqInt referent3;
     sqInt referent4;
-    sqInt size;
+    usqInt size;
     sqInt sp;
     sqInt temp1;
     sqInt temp2;
@@ -47788,9 +47788,10 @@
     sqInt objOop1;
     usqInt prevFree;
     sqInt prevObj;
+    usqInt prevPrevFree;
     sqInt prevPrevObj;
 
-	prevFree = 0;
+	prevFree = (prevPrevFree = 0);
 	freeChunk = GIV(firstFreeChunk);
 	/* begin allOldSpaceEntitiesDo: */
 	/* begin allOldSpaceEntitiesFrom:do: */
@@ -47814,6 +47815,7 @@
 			while (oopisLessThan((objOop = objectAfter(objOop)), limit)) {
 				assert(!(isFreeObject(objOop)));
 			}
+			prevPrevFree = prevFree;
 			prevFree = freeChunk;
 			freeChunk = next;
 		}
@@ -47825,6 +47827,7 @@
 	
 	
 	assert(prevFree == GIV(lastFreeChunk));
+	assert((nextInSortedFreeListLinkgiven(GIV(lastFreeChunk), 0)) == prevPrevFree);
 	assert(freeChunk == 0);
 	return 1;
 }
@@ -50461,6 +50464,7 @@
 sqInt
 freeObject(sqInt objOop)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt address;
     usqInt bytes;
     sqInt index;
     sqInt next;
@@ -50492,10 +50496,11 @@
 		? objOop - BaseHeaderSize
 		: objOop);
 	/* begin objectStartingAt: */
-	numSlots = byteAt((start + bytes) + 7);
+	address = start + bytes;
+	numSlots = byteAt(address + 7);
 	next = (numSlots == 0xFF
-		? (start + bytes) + BaseHeaderSize
-		: start + bytes);
+		? address + BaseHeaderSize
+		: address);
 	if (((longAt(next)) & 0x3FFFFF) == 0) {
 		detachFreeObject(next);
 		bytes += bytesInObject(next);
@@ -51146,9 +51151,9 @@
 	flag("endianness");
 	assert((classIndexOf(classTableRoot)) > (isForwardedObjectClassIndexPun()));
 	numSlots2 = byteAt(classTableRoot + 7);
-	GIV(numClassTablePages) = ((usqInt) ((numSlots2 == 0xFF
-	? longAt(classTableRoot - BaseHeaderSize)
-	: numSlots2)));
+	GIV(numClassTablePages) = (numSlots2 == 0xFF
+		? longAt(classTableRoot - BaseHeaderSize)
+		: numSlots2);
 	assert(GIV(numClassTablePages) == ((classTableRootSlots()) + (hiddenRootSlots())));
 	for (i2 = 2; i2 < GIV(numClassTablePages); i2 += 1) {
 		if ((longAt((classTableRoot + BaseHeaderSize) + (i2 << (shiftForWord())))) == nilObjPreSwizzle) {
@@ -51313,9 +51318,9 @@
 	flag("endianness");
 	assert((classIndexOf(obj)) > (isForwardedObjectClassIndexPun()));
 	numSlots = byteAt(obj + 7);
-	GIV(rememberedSetLimit) = ((usqInt) ((numSlots == 0xFF
-	? longAt(obj - BaseHeaderSize)
-	: numSlots)));
+	GIV(rememberedSetLimit) = (numSlots == 0xFF
+		? longAt(obj - BaseHeaderSize)
+		: numSlots);
 	/* begin setRememberedSetRedZone */
 	fudge = ((((GIV(eden).limit)) - ((GIV(eden).start))) / BytesPerWord) / 1024;
 	GIV(rememberedSetRedZone) = ((((GIV(rememberedSetLimit) * 3) / 4) < fudge) ? fudge : ((GIV(rememberedSetLimit) * 3) / 4));
@@ -52842,9 +52847,9 @@
 					flag("endianness");
 					assert((classIndexOf(objOop1)) > (isForwardedObjectClassIndexPun()));
 					numSlots = byteAt(objOop1 + 7);
-					i = ((usqInt) ((numSlots == 0xFF
-	? longAt(objOop1 - BaseHeaderSize)
-	: numSlots)));
+					i = (numSlots == 0xFF
+						? longAt(objOop1 - BaseHeaderSize)
+						: numSlots);
 				}
 			}
 			while (((i -= 1)) >= 0) {
@@ -52891,9 +52896,9 @@
 					flag("endianness");
 					assert((classIndexOf(objOop1)) > (isForwardedObjectClassIndexPun()));
 					numSlots1 = byteAt(objOop1 + 7);
-					i = ((usqInt) ((numSlots1 == 0xFF
-	? longAt(objOop1 - BaseHeaderSize)
-	: numSlots1)));
+					i = (numSlots1 == 0xFF
+						? longAt(objOop1 - BaseHeaderSize)
+						: numSlots1);
 				}
 			}
 			while (((i -= 1)) >= 0) {
@@ -52945,9 +52950,9 @@
 						flag("endianness");
 						assert((classIndexOf(objOop11)) > (isForwardedObjectClassIndexPun()));
 						numSlots2 = byteAt(objOop11 + 7);
-						i = ((usqInt) ((numSlots2 == 0xFF
-	? longAt(objOop11 - BaseHeaderSize)
-	: numSlots2)));
+						i = (numSlots2 == 0xFF
+							? longAt(objOop11 - BaseHeaderSize)
+							: numSlots2);
 					}
 				}
 				while (((i -= 1)) >= 0) {
@@ -53009,9 +53014,9 @@
 	flag("endianness");
 	assert((classIndexOf(outPointerArray)) > (isForwardedObjectClassIndexPun()));
 	numSlots2 = byteAt(outPointerArray + 7);
-	numSlots = ((usqInt) ((numSlots2 == 0xFF
-	? longAt(outPointerArray - BaseHeaderSize)
-	: numSlots2)));
+	numSlots = (numSlots2 == 0xFF
+		? longAt(outPointerArray - BaseHeaderSize)
+		: numSlots2);
 	assert(oopisLessThan(((outPointerArray + BaseHeaderSize) + (numSlots * BytesPerOop)) - 1, addressAfter(outPointerArray)));
 	for (p = (((usqInt)(outPointerArray + BaseHeaderSize))); p <= (((usqInt)(((outPointerArray + BaseHeaderSize) + (numSlots * BytesPerOop)) - 1))); p += 8) {
 		longAtput(p, GIV(nilObj));
@@ -54324,7 +54329,7 @@
     sqInt objToScan7;
     sqInt objToScan8;
     sqInt oop;
-    sqInt oop1;
+    usqInt oop1;
     sqInt referent;
     sqInt referent1;
     sqInt referent2;
@@ -59353,7 +59358,7 @@
     usqInt prevFree;
     usqInt prevFreeChunk;
     usqInt prevPrevFree;
-    usqInt prevPrevFreeChunk;
+    sqInt prevPrevFreeChunk;
     sqInt slotBytes;
     sqInt slotBytes1;
     usqInt there;
@@ -60061,9 +60066,9 @@
 		flag("endianness");
 		assert((classIndexOf(objOop)) > (isForwardedObjectClassIndexPun()));
 		numSlots = byteAt(objOop + 7);
-		return ((usqInt) ((numSlots == 0xFF
-	? longAt(objOop - BaseHeaderSize)
-	: numSlots)));
+		return (numSlots == 0xFF
+			? longAt(objOop - BaseHeaderSize)
+			: numSlots);
 	}
 	if (fmt == 7) {
 		return 1;
@@ -61004,9 +61009,9 @@
 		/* begin printHexnp: */
 		/* begin numSlotsOfAny: */
 		numSlots = byteAt((objOop - 8) + 7);
-		n = ((usqInt) ((numSlots == 0xFF
-	? longAt((objOop - 8) - BaseHeaderSize)
-	: numSlots)));
+		n = (numSlots == 0xFF
+			? longAt((objOop - 8) - BaseHeaderSize)
+			: numSlots);
 		printf("0x%lx", ((unsigned long) n));
 		print(" slotc ");
 		/* begin printHexnp: */
@@ -61020,9 +61025,9 @@
 		/* begin printHexnp: */
 		/* begin numSlotsOfAny: */
 		numSlots1 = byteAt(objOop + 7);
-		n1 = ((usqInt) ((numSlots1 == 0xFF
-	? longAt(objOop - BaseHeaderSize)
-	: numSlots1)));
+		n1 = (numSlots1 == 0xFF
+			? longAt(objOop - BaseHeaderSize)
+			: numSlots1);
 		printf("0x%lx", ((unsigned long) n1));
 	}
 	/* begin space */
@@ -61721,9 +61726,9 @@
 			flag("endianness");
 			assert((classIndexOf(objOop1)) > (isForwardedObjectClassIndexPun()));
 			numSlots2 = byteAt(objOop1 + 7);
-			i = ((usqInt) ((numSlots2 == 0xFF
-	? longAt(objOop1 - BaseHeaderSize)
-	: numSlots2)));
+			i = (numSlots2 == 0xFF
+				? longAt(objOop1 - BaseHeaderSize)
+				: numSlots2);
 			goto l8;
 		}
 		if (fmt == 7) {
@@ -61802,9 +61807,9 @@
 			flag("endianness");
 			assert((classIndexOf(objOop1)) > (isForwardedObjectClassIndexPun()));
 			numSlots3 = byteAt(objOop1 + 7);
-			i = ((usqInt) ((numSlots3 == 0xFF
-	? longAt(objOop1 - BaseHeaderSize)
-	: numSlots3)));
+			i = (numSlots3 == 0xFF
+				? longAt(objOop1 - BaseHeaderSize)
+				: numSlots3);
 			goto l10;
 		}
 		if (fmt1 == 7) {
@@ -61888,9 +61893,9 @@
 				flag("endianness");
 				assert((classIndexOf(objOop11)) > (isForwardedObjectClassIndexPun()));
 				numSlots4 = byteAt(objOop11 + 7);
-				i = ((usqInt) ((numSlots4 == 0xFF
-	? longAt(objOop11 - BaseHeaderSize)
-	: numSlots4)));
+				i = (numSlots4 == 0xFF
+					? longAt(objOop11 - BaseHeaderSize)
+					: numSlots4);
 				goto l12;
 			}
 			if (fmt2 == 7) {
@@ -62900,9 +62905,9 @@
 	flag("endianness");
 	assert((classIndexOf(savedInHashes)) > (isForwardedObjectClassIndexPun()));
 	numSlots4 = byteAt(savedInHashes + 7);
-	numSlots = ((usqInt) ((numSlots4 == 0xFF
-	? longAt(savedInHashes - BaseHeaderSize)
-	: numSlots4)));
+	numSlots = (numSlots4 == 0xFF
+		? longAt(savedInHashes - BaseHeaderSize)
+		: numSlots4);
 	assert(oopisLessThan(((savedInHashes + BaseHeaderSize) + (numSlots * BytesPerOop)) - 1, addressAfter(savedInHashes)));
 	for (p = (((usqInt)(savedInHashes + BaseHeaderSize))); p <= (((usqInt)(((savedInHashes + BaseHeaderSize) + (numSlots * BytesPerOop)) - 1))); p += 8) {
 		longAtput(p, fillValue);
@@ -62913,9 +62918,9 @@
 	flag("endianness");
 	assert((classIndexOf(savedOutHashes)) > (isForwardedObjectClassIndexPun()));
 	numSlots5 = byteAt(savedOutHashes + 7);
-	numSlots1 = ((usqInt) ((numSlots5 == 0xFF
-	? longAt(savedOutHashes - BaseHeaderSize)
-	: numSlots5)));
+	numSlots1 = (numSlots5 == 0xFF
+		? longAt(savedOutHashes - BaseHeaderSize)
+		: numSlots5);
 	assert(oopisLessThan(((savedOutHashes + BaseHeaderSize) + (numSlots1 * BytesPerOop)) - 1, addressAfter(savedOutHashes)));
 	for (p1 = (((usqInt)(savedOutHashes + BaseHeaderSize))); p1 <= (((usqInt)(((savedOutHashes + BaseHeaderSize) + (numSlots1 * BytesPerOop)) - 1))); p1 += 8) {
 		longAtput(p1, fillValue);
@@ -63053,7 +63058,7 @@
 /*	Answer a new String copied from a null-terminated C string,
 	or nil if out of memory. */
 
-usqInt
+sqInt
 stringForCString(const char *aCString)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt formatField;
@@ -63252,10 +63257,10 @@
 	on the free lists/tree, and checks that the tree is valid. It is used
 	mainly by checkFreeSpace. */
 
-static sqInt
+static usqInt
 totalFreeListBytes(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
-    sqInt bytesInChunk;
+    usqInt bytesInChunk;
     sqInt cameFrom;
     sqInt i;
     sqInt iLimiT;
@@ -63263,7 +63268,7 @@
     sqInt listNode;
     sqInt nextNode;
     sqInt smallChild;
-    sqInt totalFreeBytes;
+    usqInt totalFreeBytes;
     sqInt treeNode;
     sqInt treeNode1;
 
@@ -63744,7 +63749,7 @@
 static void
 bridgeFromto(SpurSegmentInfo *aSegment, SpurSegmentInfo *nextSegmentOrNil)
 {
-    sqInt bridgeSpan;
+    usqInt bridgeSpan;
     usqInt clifton;
     usqInt segEnd;
 
@@ -63976,7 +63981,7 @@
     sqInt largeChild;
     sqInt newEndOfMemory;
     sqInt next;
-    sqInt node;
+    usqInt node;
     SpurSegmentInfo *seg;
     sqInt smallChild;
     sqInt treeNode;
@@ -64080,12 +64085,12 @@
 readHeapFromImageFiledataBytes(sqImageFile f, sqInt numBytes)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt bridge;
-    sqInt bridgehead;
-    sqInt bridgeSpan;
+    usqInt bridgehead;
+    usqInt bridgeSpan;
     sqInt bytesRead;
     usqInt newBase;
     usqInt nextSegmentSize;
-    sqInt oldBase;
+    usqInt oldBase;
     SpurSegmentInfo *segInfo;
     sqInt totalBytesRead;
 
@@ -69829,11 +69834,14 @@
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt closureOrNil;
     CogMethod *cogMethod;
+    sqInt fieldIndex;
+    sqInt fieldIndex1;
+    sqInt fieldIndex2;
     sqInt frameNumArgs;
     sqInt frameNumArgs1;
     sqInt frameNumArgs2;
     sqInt frameNumArgs3;
-    sqInt i;
+    usqInt i;
     sqInt methodFieldOrObj;
     usqInt numArgs;
     sqInt numSlots;
@@ -69920,6 +69928,7 @@
 	longAtput((theContext + BaseHeaderSize) + (ReceiverIndex << (shiftForWord())), rcvr);
 	for (i = 1; i <= numArgs; i += 1) {
 		/* begin storePointerUnchecked:ofObject:withValue: */
+		fieldIndex = ReceiverIndex + i;
 		valuePointer = ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())
 			? ((i - 1) < ((frameNumArgs = ((mframeCogMethod(theFP))->cmNumArgs)))
 					? longAt((theFP + FoxCallerSavedIP) + ((frameNumArgs - (i - 1)) * BytesPerWord))
@@ -69928,13 +69937,14 @@
 					? longAt((theFP + FoxCallerSavedIP) + ((frameNumArgs2 - (i - 1)) * BytesPerWord))
 					: longAt(((theFP + FoxIFReceiver) - BytesPerWord) + ((frameNumArgs2 - (i - 1)) * BytesPerWord))));
 		assert(!(isForwarded(theContext)));
-		longAtput((theContext + BaseHeaderSize) + ((ReceiverIndex + i) << (shiftForWord())), valuePointer);
+		longAtput((theContext + BaseHeaderSize) + (fieldIndex << (shiftForWord())), valuePointer);
 	}
 	
 	for (i = (numArgs + 1); i <= numStack; i += 1) {
 		/* begin storePointerUnchecked:ofObject:withValue: */
+		fieldIndex2 = ReceiverIndex + i;
 		assert(!(isForwarded(theContext)));
-		longAtput((theContext + BaseHeaderSize) + ((ReceiverIndex + i) << (shiftForWord())), GIV(nilObj));
+		longAtput((theContext + BaseHeaderSize) + (fieldIndex2 << (shiftForWord())), GIV(nilObj));
 	}
 	assert(frameHasContext(theFP));
 	assert((frameOfMarriedContext(theContext)) == theFP);
@@ -75981,9 +75991,9 @@
 		flag("endianness");
 		assert((classIndexOf(schedLists)) > (isForwardedObjectClassIndexPun()));
 		numSlots = byteAt(schedLists + 7);
-		p = ((usqInt) ((numSlots == 0xFF
-	? longAt(schedLists - BaseHeaderSize)
-	: numSlots)));
+		p = (numSlots == 0xFF
+			? longAt(schedLists - BaseHeaderSize)
+			: numSlots);
 	}
 	else {
 		p = GIV(highestRunnableProcessPriority);
@@ -76028,11 +76038,11 @@
     sqInt headerSize;
     squeakFileOffsetType headerStart;
     sqInt i;
-    sqInt imageBytes;
+    usqInt imageBytes;
     extern char imageName[];
     sqInt okToWrite;
     void *sCWIfn;
-    sqInt total;
+    usqInt total;
 
 	null;
 	sCWIfn = ioLoadFunctionFrom("secCanWriteImage", "SecurityPlugin");
@@ -78791,7 +78801,7 @@
     sqInt header1;
     sqInt i;
     sqInt methodHeader;
-    sqInt numSlots;
+    usqInt numSlots;
     usqInt numSlots1;
     sqInt rcvr;
     char *sp;
@@ -78847,9 +78857,9 @@
 			flag("endianness");
 			assert((classIndexOf(rcvr)) > (isForwardedObjectClassIndexPun()));
 			numSlots1 = byteAt(rcvr + 7);
-			numSlots = ((usqInt) ((numSlots1 == 0xFF
-	? longAt(rcvr - BaseHeaderSize)
-	: numSlots1)));
+			numSlots = (numSlots1 == 0xFF

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list