[Vm-dev] [commit][2761] CogVM source as per VMMaker.oscog-eem.317

commits at squeakvm.org commits at squeakvm.org
Thu Aug 1 21:59:29 UTC 2013


Revision: 2761
Author:   eliot
Date:     2013-08-01 14:59:19 -0700 (Thu, 01 Aug 2013)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.317

Correct several uses of literalCountOf:, using LiteralStart instead
of 1, and BytesPerOop instead of BytesPerWord.

Copy 314 transferTo:from: fix to CoInterpreterMT.

Fix become for cog methods that are not paired with their
bytecoded methods (e.g. Newspeak accessors).

Eliminate dead code around contextInstructionPointer:context:.

Eliminate duplicate methodClass asserts in ce*(Send: and simplify
some in code compaction & code freeing.

Don't inline freeStackPage:

Revise the inlining change.  Global vars passed as parameters must
not be read after any non-trivial call.

Use CCodeGenerator>>isAssertSelector: to check for all assert: calls
(these are not inlined).  hence fix assert:l: uses.

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-07-29 22:32:45 UTC (rev 2760)
+++ branches/Cog/nscogsrc/vm/cogit.c	2013-08-01 21:59:19 UTC (rev 2761)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.309 uuid: 2ee24067-8c61-4855-b4b3-4bb419b4fe7f
+	CCodeGenerator VMMaker.oscog-eem.315 uuid: edf4f6ec-fb34-404f-a50a-f3690c4f6dbb
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.309 uuid: 2ee24067-8c61-4855-b4b3-4bb419b4fe7f
+	StackToRegisterMappingCogit VMMaker.oscog-eem.315 uuid: edf4f6ec-fb34-404f-a50a-f3690c4f6dbb
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.309 uuid: 2ee24067-8c61-4855-b4b3-4bb419b4fe7f " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.315 uuid: edf4f6ec-fb34-404f-a50a-f3690c4f6dbb " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -557,12 +557,10 @@
 static CogMethod * fillInMethodHeadersizeselector(CogMethod *method, sqInt size, sqInt selector);
 static CogMethod * fillInOPICHeadersizenumArgsselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt selector);
 static usqInt findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc);
-CogBlockMethod * findEnclosingMethodForinHomeMethod(sqInt mcpc, CogMethod *cogMethod);
 static sqInt findMapLocationForMcpcinMethod(sqInt targetMcpc, CogMethod *cogMethod);
 static sqInt findMcpcBcpcMatchingBcpc(char *mcpc, sqInt bcpc, void *targetBcpc);
 static sqInt findMcpcBcpcMatchingMcpc(char *mcpc, sqInt bcpc, void *targetMcpc);
 CogBlockMethod * findMethodForStartBcpcinHomeMethod(sqInt startbcpc, CogMethod *cogMethod);
-static usqInt findMinAndMaxMethodsPCaround(sqInt blockEntryPC, sqInt mcpc);
 static CogMethod * findPreviouslyCompiledVersionOfwith(sqInt aMethodObj, sqInt aSelectorOop);
 static sqInt frameOffsetOfTemporary(sqInt index);
 static void freeMethod(CogMethod *cogMethod);
@@ -3693,14 +3691,16 @@
 			(dest->objectHeader = objectHeaderValue);
 			if (((dest->cmType)) == CMMethod) {
 
-				/* For non-Newspeak there should ne a one-to-one mapping metween bytecoded and
-				   cog methods. For Newspeak not necessarily, but only for anonymous accessors. */
+				/* For non-Newspeak there should be a one-to-one mapping metween bytecoded and
+				   cog methods.  For Newspeak not necessarily, but only for anonymous accessors. */
+				/* Only update the original method's header if it is referring to this CogMethod. */
 
-				assert(((((sqInt)(rawHeaderOf((dest->methodObject))))) == (((sqInt)source)))
-				 || ((noAssertMethodClassAssociationOf((dest->methodObject))) == (nilObject())));
 				if ((((sqInt)(rawHeaderOf((dest->methodObject))))) == (((sqInt)source))) {
 					rawHeaderOfput((dest->methodObject), ((sqInt)dest));
 				}
+				else {
+					assert((noAssertMethodClassAssociationOf((dest->methodObject))) == (nilObject()));
+				}
 			}
 			else {
 				if (((dest->cmType)) == CMOpenPIC) {
@@ -3711,11 +3711,11 @@
 			if (((dest->cmUsageCount)) > 0) {
 				(dest->cmUsageCount = ((sqInt) ((dest->cmUsageCount)) >> 1));
 			}
-			dest = ((CogMethod *) ((((sqInt)dest)) + bytes));
+			dest = ((CogMethod *) ((((usqInt)dest)) + bytes));
 		}
-		source = ((CogMethod *) ((((sqInt)source)) + bytes));
+		source = ((CogMethod *) ((((usqInt)source)) + bytes));
 	}
-	mzFreeStart = ((sqInt)dest);
+	mzFreeStart = ((usqInt)dest);
 	methodBytesFreedSinceLastCompaction = 0;
 }
 
@@ -8081,23 +8081,6 @@
 	return 0;
 }
 
-
-/*	Find the CMMethod or CMBlock that encloses mcpc.
-	If the method contains blocks then, because block dispatch is not in
-	order, enumerate the block dispatch and find the nearest preceeding entry. */
-
-CogBlockMethod *
-findEnclosingMethodForinHomeMethod(sqInt mcpc, CogMethod *cogMethod)
-{
-	assert(((cogMethod->cmType)) == CMMethod);
-	if (((cogMethod->blockEntryOffset)) == 0) {
-		return ((CogBlockMethod *) cogMethod);
-	}
-	maxMethodBefore = ((CogBlockMethod *) cogMethod);
-	blockDispatchTargetsForperformarg(cogMethod, findMinAndMaxMethodsPCaround, mcpc);
-	return maxMethodBefore;
-}
-
 static sqInt
 findMapLocationForMcpcinMethod(sqInt targetMcpc, CogMethod *cogMethod)
 {
@@ -8160,16 +8143,32 @@
 	return ((CogBlockMethod *) (blockDispatchTargetsForperformarg(cogMethod, findBlockMethodWithEntrystartBcpc, startbcpc)));
 }
 
-static usqInt
-findMinAndMaxMethodsPCaround(sqInt blockEntryPC, sqInt mcpc)
-{
-	if (((((usqInt)blockEntryPC)) <= (((usqInt)mcpc)))
-	 && ((((usqInt)blockEntryPC)) > (((usqInt)maxMethodBefore)))) {
-		maxMethodBefore = ((CogBlockMethod *) (blockEntryPC - (sizeof(CogBlockMethod))));
-	}
-	return 0;
-}
 
+/*	Newspeak uses a set of methods to implement accessors, a setter and a
+	getter for
+	each inst var offset (e.g. 0 to 255). These accessors are installed under
+	the relevant
+	selectors in different method dictionaries as required. These methods
+	effectively have multiple selectors. The current inline cache design
+	stores the selector of a
+	linked send in the header of the target method. So this requires a
+	one-to-many mapping of bytecoded method to cog method, with the bytecoded
+	method referring
+	directly to only one cog method, which will have a specific selector, not
+	necessarily the right one. It is therefore worth-while searching for a cog
+	method on this method
+	that has the right selector.
+	We could revisit this:
+	- a send site could have two loads, one for the selector and one for the
+	class, eliminating the need to store the selector in the header of a cog
+	method (although it would still be needed in a PIC, because open PICs are
+	shared) - a set of unpaired cog methods could be maintained to speed up
+	the search. since
+	the methodHeader field is effectively unused in an unpaired method the
+	list could
+	link through this field (c.f. the openPICList linked through the
+	methodObject field). */
+
 static CogMethod *
 findPreviouslyCompiledVersionOfwith(sqInt aMethodObj, sqInt aSelectorOop)
 {
@@ -8206,13 +8205,15 @@
 	if (((cogMethod->cmType)) == CMMethod) {
 
 		/* For non-Newspeak there should ne a one-to-one mapping between bytecoded and
-		   cog methods. For Newspeak not necessarily, but only for anonymous accessors. */
+		   cog methods.  For Newspeak not necessarily, but only for anonymous accessors. */
+		/* Only reset the original method's header if it is referring to this CogMethod. */
 
-		assert(((((sqInt)(rawHeaderOf((cogMethod->methodObject))))) == (((sqInt)cogMethod)))
-		 || ((noAssertMethodClassAssociationOf((cogMethod->methodObject))) == (nilObject())));
 		if ((((sqInt)(rawHeaderOf((cogMethod->methodObject))))) == (((sqInt)cogMethod))) {
 			rawHeaderOfput((cogMethod->methodObject), (cogMethod->methodHeader));
 		}
+		else {
+			assert((noAssertMethodClassAssociationOf((cogMethod->methodObject))) == (nilObject()));
+		}
 		(cogMethod->cmRefersToYoung = 0);
 	}
 	if (((cogMethod->cmType)) == CMOpenPIC) {
@@ -15017,8 +15018,6 @@
 				}
 				if (((cogMethod->cmType)) == CMMethod) {
 					assert(((cogMethod->objectHeader)) == (nullHeaderForMachineCodeMethod()));
-					assert(((rawHeaderOf((cogMethod->methodObject))) == (((sqInt)cogMethod)))
-					 || ((noAssertMethodClassAssociationOf((cogMethod->methodObject))) == (nilObject())));
 					remappedMethod = remapOop((cogMethod->methodObject));
 					if (remappedMethod != ((cogMethod->methodObject))) {
 						if (methodHasCogMethod(remappedMethod)) {
@@ -15027,10 +15026,17 @@
 						if (!(withoutForwardingOnandwithsendToCogit((cogMethod->methodObject), remappedMethod, (cogMethod->cmUsesPenultimateLit), methodhasSameCodeAscheckPenultimate))) {
 							error("attempt to become cogged method into different method");
 						}
-						rawHeaderOfput((cogMethod->methodObject), (cogMethod->methodHeader));
-						(cogMethod->methodHeader = rawHeaderOf(remappedMethod));
-						(cogMethod->methodObject = remappedMethod);
-						rawHeaderOfput(remappedMethod, ((sqInt)cogMethod));
+						if ((rawHeaderOf((cogMethod->methodObject))) == (((sqInt)cogMethod))) {
+							rawHeaderOfput((cogMethod->methodObject), (cogMethod->methodHeader));
+							(cogMethod->methodHeader = rawHeaderOf(remappedMethod));
+							(cogMethod->methodObject = remappedMethod);
+							rawHeaderOfput(remappedMethod, ((sqInt)cogMethod));
+						}
+						else {
+							assert((noAssertMethodClassAssociationOf((cogMethod->methodObject))) == (nilObject()));
+							(cogMethod->methodHeader = rawHeaderOf(remappedMethod));
+							(cogMethod->methodObject = remappedMethod);
+						}
 					}
 					if (isYoung((cogMethod->methodObject))) {
 						hasYoungObj = 1;

Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h	2013-07-29 22:32:45 UTC (rev 2760)
+++ branches/Cog/nscogsrc/vm/cogit.h	2013-08-01 21:59:19 UTC (rev 2761)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.309 uuid: 2ee24067-8c61-4855-b4b3-4bb419b4fe7f
+	CCodeGenerator VMMaker.oscog-eem.315 uuid: edf4f6ec-fb34-404f-a50a-f3690c4f6dbb
  */
 
 
@@ -33,7 +33,6 @@
 void enterCogCodePopReceiverAndClassRegs(void);
 void enterCogCodePopReceiverArg0Regs(void);
 void enterCogCodePopReceiverArg1Arg0Regs(void);
-CogBlockMethod * findEnclosingMethodForinHomeMethod(sqInt mcpc, CogMethod *cogMethod);
 CogBlockMethod * findMethodForStartBcpcinHomeMethod(sqInt startbcpc, CogMethod *cogMethod);
 sqInt genQuickReturnConst(void);
 sqInt genQuickReturnInstVar(void);

Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h	2013-07-29 22:32:45 UTC (rev 2760)
+++ branches/Cog/nscogsrc/vm/cogmethod.h	2013-08-01 21:59:19 UTC (rev 2761)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.309 uuid: 2ee24067-8c61-4855-b4b3-4bb419b4fe7f
+	CCodeGenerator VMMaker.oscog-eem.315 uuid: edf4f6ec-fb34-404f-a50a-f3690c4f6dbb
  */
 
 typedef struct {

Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c	2013-07-29 22:32:45 UTC (rev 2760)
+++ branches/Cog/nscogsrc/vm/cointerp.c	2013-08-01 21:59:19 UTC (rev 2761)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.314 uuid: e8cba0d1-78b9-4058-820f-62d6e02e180b
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.317 uuid: 18267235-d270-4acf-8626-28095c535f32
    from
-	CoInterpreter VMMaker.oscog-eem.314 uuid: e8cba0d1-78b9-4058-820f-62d6e02e180b
+	CoInterpreter VMMaker.oscog-eem.317 uuid: 18267235-d270-4acf-8626-28095c535f32
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.314 uuid: e8cba0d1-78b9-4058-820f-62d6e02e180b " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.317 uuid: 18267235-d270-4acf-8626-28095c535f32 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -505,7 +505,6 @@
 sqInt eeInstantiateClassindexableSize(sqInt classPointer, sqInt size);
 static sqInt eeInstantiateMethodContextByteSize(sqInt sizeInBytes);
 static sqInt eeInstantiateSmallClasssizeInBytes(sqInt classPointer, sqInt sizeInBytes);
-static sqInt encodedNativePCOfcogMethod(sqInt mcpc, CogBlockMethod *cogMethod);
 static sqInt ensureCallerContext(char *theFP);
 static void ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext);
 static void ensureImageFormatIsUpToDate(sqInt swapBytes);
@@ -576,6 +575,7 @@
 static sqInt frameStackedReceiverOffsetNumArgs(sqInt numArgs);
 static sqInt frameStackedReceiverOffset(char *theFP);
 static void freeStackPageNoAssert(StackPage *aPage);
+static sqInt freeStackPage(StackPage *aPage);
 usqInt freeStartAddress(void);
 sqInt fullDisplayUpdate(void);
 void fullGC(void);
@@ -604,7 +604,9 @@
 sqInt headerOf(sqInt methodPointer);
 static sqInt headerWhileForwardingOf(sqInt oop);
 sqInt highBit(usqInt anUnsignedValue);
+static sqInt iframeIsBlockActivation(char *theFP);
 static usqInt iframeMethod(char *theFP);
+static sqInt iframeReceiver(char *theFP);
 static sqInt iframeSavedIP(char *theFP);
 void ifValidWriteBackStackPointersSaveTo(void *theCFP, void *theCSP, char **savedFPP, char **savedSPP);
 static sqInt imageSegmentVersion(void);
@@ -740,6 +742,8 @@
 static CogBlockMethod * mframeCogMethod(char *theFP);
 CogMethod * mframeHomeMethodExport(void);
 CogMethod * mframeHomeMethod(char *theFP);
+static sqInt mframeIsBlockActivation(char *theFP);
+static sqInt mframeReceiver(char *theFP);
 static sqInt minimumUnusedHeadroom(void);
 sqInt mMethodClass(void);
 static sqInt mnuMethodOrNilFor(sqInt rcvr);
@@ -757,7 +761,6 @@
 static sqInt noInlineTemporaryin(sqInt offset, char *theFP);
 static sqInt noInlineTemporaryinput(sqInt offset, char *theFP, sqInt valueOop);
 static sqInt noMarkedContextsOnPage(StackPage *thePage);
-static sqInt nonWeakFieldsOf(sqInt oop);
 sqInt nullHeaderForMachineCodeMethod(void);
 static sqInt numStkPages(void);
 sqInt objectAfter(sqInt oop);
@@ -1076,6 +1079,7 @@
 void print(char *s);
 static void pruneStackstackp(sqInt stack, sqInt stackp);
 void pushBool(sqInt trueOrFalse);
+static sqInt pushedReceiverOrClosureOfFrame(char *theFP);
 void pushFloat(double f);
 sqInt pushInteger(sqInt integerValue);
 void pushRemappableOop(sqInt oop);
@@ -1985,7 +1989,7 @@
 	/* 575 */ (void (*)(void))0,
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.314";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.317";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -4370,9 +4374,7 @@
 					 || (isContext(callerContextOrNil2)));
 					currentCtx = callerContextOrNil2;
 					assert(isContext(currentCtx));
-					/* begin freeStackPage: */
-					freeStackPageNoAssert(GIV(stackPage));
-					assert(pageListIsWellFormed());
+					freeStackPage(GIV(stackPage));
 					while (!((((longAt((currentCtx + BaseHeaderSize) + (SenderIndex << ShiftForWord))) & 1))
 					 && ((stackPageFor((theFP = frameOfMarriedContext(currentCtx)))) == newPage))) {
 						if (((longAt((currentCtx + BaseHeaderSize) + (SenderIndex << ShiftForWord))) & 1)) {
@@ -4402,9 +4404,7 @@
 							assert((callerContextOrNil1 == (nilObject()))
 							 || (isContext(callerContextOrNil1)));
 							currentCtx = callerContextOrNil1;
-							/* begin freeStackPage: */
-							freeStackPageNoAssert(thePage);
-							assert(pageListIsWellFormed());
+							freeStackPage(thePage);
 						}
 						else {
 							nextCntx = longAt((currentCtx + BaseHeaderSize) + (SenderIndex << ShiftForWord));
@@ -8202,7 +8202,7 @@
 							}
 							else {
 								if ((fmt < 12)
-								 || (((index >> 1)) >= ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerWord) + 1))) {
+								 || (((index >> 1)) >= ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerOop) + 1))) {
 									result = (((byteAt((rcvr + BaseHeaderSize) + (((index >> 1)) - 1))) << 1) | 1);
 									goto l112;
 								}
@@ -8342,7 +8342,7 @@
 							}
 							else {
 								if ((fmt >= 12)
-								 && (((index >> 1)) < ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerWord) + 1))) {
+								 && (((index >> 1)) < ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerOop) + 1))) {
 
 									/* CompiledMethod */
 
@@ -10970,7 +10970,7 @@
 							}
 							else {
 								if ((fmt < 12)
-								 || (((index >> 1)) >= ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerWord) + 1))) {
+								 || (((index >> 1)) >= ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerOop) + 1))) {
 									result = (((byteAt((rcvr + BaseHeaderSize) + (((index >> 1)) - 1))) << 1) | 1);
 									goto l235;
 								}
@@ -11110,7 +11110,7 @@
 							}
 							else {
 								if ((fmt >= 12)
-								 && (((index >> 1)) < ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerWord) + 1))) {
+								 && (((index >> 1)) < ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerOop) + 1))) {
 
 									/* CompiledMethod */
 
@@ -13265,7 +13265,7 @@
 			assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(array1)));
 			contextSize = (sp >> 1);
 		l1:	/* end fetchStackPointerOf: */;
-			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 			goto l2;
 		}
 		fieldOffset = (sizeBitsOfSafe(array1)) - BaseHeaderSize;
@@ -13285,7 +13285,7 @@
 	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
-	fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
+	fieldOffset = (numLiterals + LiteralStart) * BytesPerOop;
 l2:	/* end lastPointerOf: */;
 	while (fieldOffset >= BaseHeaderSize) {
 		if ((((usqInt) (longAt(array1 + fieldOffset)))) < (((usqInt) GIV(youngStart)))) {
@@ -13417,13 +13417,13 @@
 	assertl(lifp < ((GIV(stackPage)->baseAddress)), ln);
 	assertl(lisp < lifp, ln);
 	assertl(lifp > lisp, ln);
-	assertl(lisp >= (((GIV(stackPage)->realStackLimit)) - ((IFrameSlots + 64) * BytesPerWord)), ln);
+	assertl(lisp >= (((GIV(stackPage)->realStackLimit)) - (stackLimitOffset())), ln);
 	assertl((lifp - lisp) < LargeContextSize, ln);
 	methodField = longAt(lifp + FoxMethod);
 	if (inInterpreter) {
-		assertl(!((((usqInt)(longAt(lifp + FoxMethod)))) < (startOfMemory())), ln);
+		assertl(!(isMachineCodeFrame(lifp)), ln);
 		assertl(GIV(method) == methodField, ln);
-		assertl((headerIndicatesAlternateBytecodeSet(headerOf(GIV(method)))) == (GIV(bytecodeSetSelector) == 256), ln);
+		assertl((methodUsesAlternateBytecodeSet(GIV(method))) == (GIV(bytecodeSetSelector) == 256), ln);
 
 		if ((assertal((((usqInt)methodField)) > (startOfMemory()), ln))
 		 && (assertal((((usqInt)methodField)) < (freeStart()), ln))) {
@@ -13437,13 +13437,11 @@
 				 && (lip < ((methodField + (byteLengthOf(methodField))) + BaseHeaderSize)), ln);
 			}
 		}
-		assertl(((byteAt((lifp + FoxIFrameFlags) + 3)) != 0)
-		 || ((longAt(lifp + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(lifp + FoxMethod)))) < (startOfMemory())
-	? (mframeCogMethod(lifp)->cmNumArgs)
-	: byteAt((lifp + FoxIFrameFlags) + 1)))))) == (longAt(lifp + FoxIFReceiver))), ln);
+		assertl((iframeIsBlockActivation(lifp))
+		 || ((pushedReceiverOrClosureOfFrame(lifp)) == (iframeReceiver(lifp))), ln);
 	}
 	else {
-		assertl((((usqInt)(longAt(lifp + FoxMethod)))) < (startOfMemory()), ln);
+		assertl(isMachineCodeFrame(lifp), ln);
 		if ((assertal((((usqInt)methodField)) >= (minCogMethodAddress()), ln))
 		 && (assertal((((usqInt)methodField)) < (maxCogMethodAddress()), ln))) {
 			/* begin mframeHomeMethod: */
@@ -13454,21 +13452,17 @@
 			}
 			cogMethod = ((CogMethod *) (methodField1 & MFMethodMask));
 		l1:	/* end mframeHomeMethod: */;
-			assertl((lip > (methodField + ((((longAt(lifp + FoxMethod)) & MFMethodFlagIsBlockFlag) != 0
+			assertl((lip > (methodField + ((mframeIsBlockActivation(lifp)
 	? sizeof(CogBlockMethod)
 	: sizeof(CogMethod)))))
 			 && (lip < (methodField + ((cogMethod->blockSize)))), ln);
 		}
-		assertl((((longAt(lifp + FoxMethod)) & MFMethodFlagIsBlockFlag) != 0)
-		 || ((longAt(lifp + (frameStackedReceiverOffsetNumArgs(((((usqInt)(longAt(lifp + FoxMethod)))) < (startOfMemory())
-	? (mframeCogMethod(lifp)->cmNumArgs)
-	: byteAt((lifp + FoxIFrameFlags) + 1)))))) == (longAt(lifp + FoxMFReceiver))), ln);
+		assertl((mframeIsBlockActivation(lifp))
+		 || ((pushedReceiverOrClosureOfFrame(lifp)) == (mframeReceiver(lifp))), ln);
 	}
 	if ((longAt(lifp + FoxSavedFP)) == 0) {
-		assertl(((((usqInt)(longAt(lifp + FoxMethod)))) < (startOfMemory())
-			? ((longAt(lifp + FoxMethod)) & MFMethodFlagHasContextFlag) != 0
-			: (byteAt((lifp + FoxIFrameFlags) + 2)) != 0), ln);
-		assertl((longAt(lifp + FoxThisContext)) == (longAt(((GIV(stackPage)->baseAddress)) - BytesPerWord)), ln);
+		assertl(frameHasContext(lifp), ln);
+		assertl((frameContext(lifp)) == (longAt(((GIV(stackPage)->baseAddress)) - BytesPerWord)), ln);
 	}
 }
 
@@ -13823,7 +13817,7 @@
 				assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(array1)));
 				contextSize = (sp >> 1);
 			l2:	/* end fetchStackPointerOf: */;
-				fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+				fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 				goto l3;
 			}
 			fieldOffset = (sizeBitsOfSafe(array1)) - BaseHeaderSize;
@@ -13843,7 +13837,7 @@
 		numLiterals = ((((sqInt) headerPointer)) < 0
 						? (((usqInt) headerPointer) >> 1) & 65535
 						: (((usqInt) headerPointer) >> 10) & 255);
-		fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
+		fieldOffset = (numLiterals + LiteralStart) * BytesPerOop;
 	l3:	/* end lastPointerOf: */;
 		while (fieldOffset >= BaseHeaderSize) {
 			oop1 = longAt(array1 + fieldOffset);
@@ -14440,6 +14434,7 @@
     char *sp1;
     char *sp2;
     char *sp3;
+    char *theFP;
     StackPage *thePage;
     sqInt value;
 
@@ -14489,13 +14484,14 @@
 			   Make the interior frame the top frame. */
 
 			/* begin findFrameAbove:inPage: */
+			theFP = GIV(framePointer);
 			fp = (thePage->headFP);
-			if (fp == GIV(framePointer)) {
+			if (fp == theFP) {
 				frameAbove = 0;
 				goto l1;
 			}
 			while (((callerFP = frameCallerFP(fp))) != 0) {
-				if (callerFP == GIV(framePointer)) {
+				if (callerFP == theFP) {
 					frameAbove = fp;
 					goto l1;
 				}
@@ -14796,15 +14792,19 @@
 		if (((cogMethod->selector)) == GIV(nilObj)) {
 			setSelectorOfto(cogMethod, selector);
 		}
-		if (((cogMethod->selector)) != selector) {
-			assert((methodClassAssociationOf(GIV(newMethod))) == (nilObject()));
-			newCogMethod = cogselector(GIV(newMethod), selector);
-			if (newCogMethod == null) {
-				null;
+		else {
+
+			/* Deal with anonymous accessors, e.g. in Newspeak.  The cogMethod may not have the correct
+			   selector.  If not, try and compile a new method with the correct selector. */
+
+			if (((cogMethod->selector)) != selector) {
+				if (((newCogMethod = cogselector(GIV(newMethod), selector))) == null) {
+					null;
+				}
+				else {
+					cogMethod = newCogMethod;
+				}
 			}
-			else {
-				cogMethod = newCogMethod;
-			}
 		}
 		if ((((cogMethod->selector)) == selector)
 		 && (canLinkCacheTag)) {
@@ -15201,9 +15201,7 @@
 		 || (isContext(callerContextOrNil2)));
 		currentCtx = callerContextOrNil2;
 		assert(isContext(currentCtx));
-		/* begin freeStackPage: */
-		freeStackPageNoAssert(GIV(stackPage));
-		assert(pageListIsWellFormed());
+		freeStackPage(GIV(stackPage));
 			while (1) {
 			assert(isContext(currentCtx));
 			if ((((longAt((currentCtx + BaseHeaderSize) + (SenderIndex << ShiftForWord))) & 1))
@@ -15229,9 +15227,7 @@
 				assert((callerContextOrNil1 == (nilObject()))
 				 || (isContext(callerContextOrNil1)));
 				currentCtx = callerContextOrNil1;
-				/* begin freeStackPage: */
-				freeStackPageNoAssert(thePage);
-				assert(pageListIsWellFormed());
+				freeStackPage(thePage);
 			}
 			else {
 				nextCntx = longAt((currentCtx + BaseHeaderSize) + (SenderIndex << ShiftForWord));
@@ -15291,16 +15287,18 @@
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt aMethodObj;
     char *sp;
+    StackPage *thePage;
 
 	assert(((anOop & 1))
 	 || (addressCouldBeObj(anOop)));
 	flag("are you really sure setStackPageAndLimit: is needed?");
 	/* begin setStackPageAndLimit: */
-	GIV(stackPage) = GIV(stackPage);
+	thePage = GIV(stackPage);
+	GIV(stackPage) = thePage;
 	if (GIV(stackLimit) != (((char *) (((usqInt) -1))))) {
 		GIV(stackLimit) = (GIV(stackPage)->stackLimit);
 	}
-	markStackPageMostRecentlyUsed(GIV(stackPage));
+	markStackPageMostRecentlyUsed(thePage);
 	assert(!(isMachineCodeFrame(GIV(framePointer))));
 	/* begin setMethod: */
 	/* begin iframeMethod: */
@@ -15630,15 +15628,19 @@
 		if (((cogMethod->selector)) == GIV(nilObj)) {
 			setSelectorOfto(cogMethod, selector);
 		}
-		if (((cogMethod->selector)) != selector) {
-			assert((methodClassAssociationOf(GIV(newMethod))) == (nilObject()));
-			newCogMethod = cogselector(GIV(newMethod), selector);
-			if (newCogMethod == null) {
-				null;
+		else {
+
+			/* Deal with anonymous accessors, e.g. in Newspeak.  The cogMethod may not have the
+			   correct selector.  If not, try and compile a new method with the correct selector. */
+
+			if (((cogMethod->selector)) != selector) {
+				if (((newCogMethod = cogselector(GIV(newMethod), selector))) == null) {
+					null;
+				}
+				else {
+					cogMethod = newCogMethod;
+				}
 			}
-			else {
-				cogMethod = newCogMethod;
-			}
 		}
 		if ((((cogMethod->selector)) == selector)
 		 && (canLinkCacheTag)) {
@@ -16318,10 +16320,7 @@
 			if ((fmt <= 4)
 			 || (fmt >= 12)) {
 				if (fmt >= 12) {
-
-					/* + 1 = methodHeader slot */
-
-					fi = (literalCountOfHeader(headerOf(obj))) + 1;
+					fi = (literalCountOfHeader(headerOf(obj))) + LiteralStart;
 				}
 				else {
 					if ((fmt == 3)
@@ -16665,18 +16664,18 @@
 	if (!(checkOopHasOkayClass(oop))) {
 		return 0;
 	}
+	if (!((((((usqInt) (longAt(oop))) >> 8) & 15) <= 4)
+		 || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12))) {
+		return 1;
+	}
 	/* begin isYoung: */
 	oop1 = (((ccIndex = (((usqInt) (longAt(oop))) >> 12) & 31)) == 0
 		? (longAt(oop - BaseHeaderSize)) & AllButTypeMask
 		: longAt(((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (CompactClasses << ShiftForWord))) + BaseHeaderSize) + ((ccIndex - 1) << ShiftForWord)));
 	hasYoung = ((oop1 & 1) == 0)
 	 && ((((usqInt) oop1)) >= (((usqInt) GIV(youngStart))));
-	if (!((((((usqInt) (longAt(oop))) >> 8) & 15) <= 4)
-		 || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12))) {
-		return 1;
-	}
 	if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
-		i = (literalCountOfHeader(headerOf(oop))) - 1;
+		i = ((literalCountOfHeader(headerOf(oop))) + LiteralStart) - 1;
 	}
 	else {
 		if (((oop & 1) == 0)
@@ -17728,7 +17727,7 @@
 				}
 				else {
 					if ((fmt >= 12)
-					 && (index < ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerWord) + 1))) {
+					 && (index < ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerOop) + 1))) {
 
 						/* CompiledMethod */
 
@@ -17872,7 +17871,7 @@
 				}
 				else {
 					if ((fmt < 12)
-					 || (index >= ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerWord) + 1))) {
+					 || (index >= ((((literalCountOfHeader(headerOf(rcvr))) + LiteralStart) * BytesPerOop) + 1))) {
 						result = (((byteAt((rcvr + BaseHeaderSize) + (index - 1))) << 1) | 1);
 						goto l1;
 					}
@@ -17984,7 +17983,7 @@
 			assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(array)));
 			contextSize = (sp >> 1);
 		l1:	/* end fetchStackPointerOf: */;
-			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 			goto l2;
 		}
 		fieldOffset = (sizeBitsOfSafe(array)) - BaseHeaderSize;
@@ -18004,7 +18003,7 @@
 	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
-	fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
+	fieldOffset = (numLiterals + LiteralStart) * BytesPerOop;
 l2:	/* end lastPointerOf: */;
 	while (fieldOffset >= BaseHeaderSize) {
 		if (((longAt(array + fieldOffset)) & 1)) {
@@ -18049,7 +18048,7 @@
 			assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(array1)));
 			contextSize = (sp >> 1);
 		l1:	/* end fetchStackPointerOf: */;
-			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 			goto l2;
 		}
 		fieldOffset = (sizeBitsOfSafe(array1)) - BaseHeaderSize;
@@ -18069,7 +18068,7 @@
 	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
-	fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
+	fieldOffset = (numLiterals + LiteralStart) * BytesPerOop;
 l2:	/* end lastPointerOf: */;
 	while (fieldOffset >= BaseHeaderSize) {
 		if (((longAt(array1 + fieldOffset)) & 1)) {
@@ -18111,9 +18110,25 @@
 static sqInt
 contextInstructionPointerframe(sqInt theIP, char *theFP)
 {
+    sqInt blockOffset;
+    CogBlockMethod *cogMethod;
+    CogMethod *homeMethod;
+
 	assert(validInstructionPointerinFrame(theIP, theFP));
 	if ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())) {
-		return encodedNativePCOfcogMethod(theIP, mframeCogMethod(theFP));
+		/* begin encodedNativePCOf:cogMethod: */
+		VM_LABEL(0encodedNativePCOfcogMethod);
+		/* begin mframeCogMethod: */
+		cogMethod = ((CogBlockMethod *) ((longAt(theFP + FoxMethod)) & MFMethodMask));
+		if (theIP == (ceCannotResumePC())) {
+			return HasBeenReturnedFromMCPC;
+		}
+		if (((cogMethod->cmType)) == CMMethod) {
+			return ((((((sqInt)cogMethod)) - theIP) << 1) | 1);
+		}
+		homeMethod = cmHomeMethod(cogMethod);
+		blockOffset = ((((sqInt)homeMethod)) - (((sqInt)cogMethod))) / (sizeof(CogBlockMethod));
+		return ((((((usqInt) blockOffset << 16)) | (((((sqInt)cogMethod)) - theIP) & 65535)) << 1) | 1);
 	}
 	return (((((((theIP == (ceReturnToInterpreterPC())
 	? longAt(theFP + FoxIFSavedIP)
@@ -18304,12 +18319,10 @@
     sqInt i;
     sqInt newClosure;
     sqInt newClosure1;
-    char *theSP;
 
 	assert(isMachineCodeFrame(GIV(framePointer)));
 	/* begin ensureFrameIsMarried:SP: */
 	VM_LABEL(13ensureFrameIsMarriedSP);
-	theSP = GIV(stackPointer) + ((1 + numCopied) * BytesPerWord);
 	if (((((usqInt)(longAt(GIV(framePointer) + FoxMethod)))) < (startOfMemory())
 		? ((longAt(GIV(framePointer) + FoxMethod)) & MFMethodFlagHasContextFlag) != 0
 		: (byteAt((GIV(framePointer) + FoxIFrameFlags) + 2)) != 0)) {
@@ -18317,7 +18330,7 @@
 		context = longAt(GIV(framePointer) + FoxThisContext);
 		goto l1;
 	}
-	context = marryFrameSP(GIV(framePointer), theSP);
+	context = marryFrameSP(GIV(framePointer), GIV(stackPointer) + ((1 + numCopied) * BytesPerWord));
 l1:	/* end ensureFrameIsMarried:SP: */;
 	/* begin closureIn:numArgs:instructionPointer:numCopiedValues: */
 	VM_LABEL(2closureInnumArgsinstructionPointernumCopiedValues);
@@ -19599,41 +19612,6 @@
 }
 
 
-/*	Encode the mcpc in cogMethod as a value that can be stashed in a context.
-	Mapping native pcs to bytecode pcs is quite expensive, requiring a search
-	through the method map. We mitigate this cost by deferring mapping until
-	we really have to, which is when a context's instruction pointer is
-	accessed by Smalltalk code. But to defer mapping we have to be able to
-	distinguish machine code from bytecode pcs, which we do by using negative
-	values for
-	machine code pcs.
-	
-	As a whorish performance hack we also include the block method offset in
-	the pc of a block. The least significant 16 bits are the native pc and the
-	most significant 15 bits are the block start, in block alignment units. So
-	when mapping back we can find the start of the block.
-	
-	See mustMapMachineCodePC:context: for the code that does the actual
-	mapping.  */
-
-static sqInt
-encodedNativePCOfcogMethod(sqInt mcpc, CogBlockMethod *cogMethod)
-{
-    sqInt blockOffset;
-    CogMethod *homeMethod;
-
-	if (mcpc == (ceCannotResumePC())) {
-		return HasBeenReturnedFromMCPC;
-	}
-	if (((cogMethod->cmType)) == CMMethod) {
-		return ((((((sqInt)cogMethod)) - mcpc) << 1) | 1);
-	}
-	homeMethod = cmHomeMethod(cogMethod);
-	blockOffset = ((((sqInt)homeMethod)) - (((sqInt)cogMethod))) / (sizeof(CogBlockMethod));
-	return ((((((usqInt) blockOffset << 16)) | (((((sqInt)cogMethod)) - mcpc) & 65535)) << 1) | 1);
-}
-
-
 /*	Answerr the caller context for a frame. If the frame has a caller
 	frame that doesn't have a context, then marry the caller frame. */
 
@@ -20377,9 +20355,7 @@
 
 		/* theFP is a base frame; it is now alone; free the entire page */
 
-		/* begin freeStackPage: */
-		freeStackPageNoAssert(thePage);
-		assert(pageListIsWellFormed());
+		freeStackPage(thePage);
 	}
 	else {
 		callerIP = oopForPointer(frameCallerSavedIP(theFP));
@@ -21019,16 +20995,19 @@
 }
 
 
-/*	During sweep phase we have encountered a weak reference. 
-	Check if its object has gone away (or is about to) and if so, signal a 
-	semaphore. */
-/*	Do *not* inline this in sweepPhase - it is quite an unlikely 
-	case to run into a weak reference */
+/*	During sweep phase we have encountered a weak reference. Check if its
+	object has gone away (or is about to) and if so, signal a semaphore. Do
+	*not* inline
+	this in sweepPhase - it is quite an unlikely case to run into a weak
+	reference  */
 
 static void
 finalizeReference(usqInt oop)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt ccIndex;
     sqInt chunk;
+    sqInt class;
+    sqInt classFormat;
     sqInt contextSize;
     sqInt firstField;
     sqInt fmt;
@@ -21037,12 +21016,21 @@
     sqInt i;
     sqInt lastField;
     sqInt methodHeader;
+    sqInt numFields;
     sqInt numLiterals;
     sqInt oopGone;
     sqInt sp;
     usqInt weakOop;
 
-	firstField = BaseHeaderSize + ((nonWeakFieldsOf(oop)) << ShiftForWord);
+	/* begin nonWeakFieldsOf: */
+	VM_LABEL(0nonWeakFieldsOf);
+	assert(isWeakNonInt(oop));
+	class = (((ccIndex = (((usqInt) (longAt(oop))) >> 12) & 31)) == 0
+		? (longAt(oop - BaseHeaderSize)) & AllButTypeMask
+		: longAt(((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (CompactClasses << ShiftForWord))) + BaseHeaderSize) + ((ccIndex - 1) << ShiftForWord)));
+	classFormat = (longAt((class + BaseHeaderSize) + (InstanceSpecificationIndex << ShiftForWord))) - 1;
+	numFields = (((((usqInt) classFormat) >> 11) & 192) + ((((usqInt) classFormat) >> 2) & 63)) - 1;
+	firstField = BaseHeaderSize + (numFields << ShiftForWord);
 	/* begin lastPointerOf: */
 	header = longAt(oop);
 	fmt = (((usqInt) header) >> 8) & 15;
@@ -21061,7 +21049,7 @@
 			assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(oop)));
 			contextSize = (sp >> 1);
 		l1:	/* end fetchStackPointerOf: */;
-			lastField = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+			lastField = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 			goto l2;
 		}
 		lastField = (sizeBitsOfSafe(oop)) - BaseHeaderSize;
@@ -21081,7 +21069,7 @@
 	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
-	lastField = (numLiterals * BytesPerWord) + BaseHeaderSize;
+	lastField = (numLiterals + LiteralStart) * BytesPerOop;
 l2:	/* end lastPointerOf: */;
 	for (i = firstField; i <= lastField; i += BytesPerWord) {
 
@@ -22235,6 +22223,21 @@
 	(GIV(mostRecentlyUsedPage)->nextPage = aPage);
 }
 
+
+/*	<InterpreterStackPage> */
+/*	MRUP-->used page<->used page<->used page<->used page<--LRUP
+	^ <-next-prev-> ^
+	| |
+	v <-prev-next-> v
+	free page<->free page<->free page<->free page */
+
+static sqInt
+freeStackPage(StackPage *aPage)
+{
+	freeStackPageNoAssert(aPage);
+	assert(pageListIsWellFormed());
+}
+
 usqInt
 freeStartAddress(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
@@ -23038,6 +23041,15 @@
 	return bitNo + shifted;
 }
 
+
+/*	<Integer> */
+
+static sqInt
+iframeIsBlockActivation(char *theFP)
+{
+	return (byteAt((theFP + FoxIFrameFlags) + 3)) != 0;
+}
+
 static usqInt
 iframeMethod(char *theFP)
 {
@@ -23045,6 +23057,12 @@
 }
 
 static sqInt
+iframeReceiver(char *theFP)
+{
+	return longAt(theFP + FoxIFReceiver);
+}
+
+static sqInt
 iframeSavedIP(char *theFP)
 {
 	return longAt(theFP + FoxIFSavedIP);
@@ -25404,7 +25422,7 @@
 			assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(oop)));
 			contextSize = (sp >> 1);
 		l1:	/* end fetchStackPointerOf: */;
-			return (CtxtTempFrameStart + contextSize) * BytesPerWord;
+			return (CtxtTempFrameStart + contextSize) * BytesPerOop;
 		}
 		return (sizeBitsOfSafe(oop)) - BaseHeaderSize;
 	}
@@ -25421,7 +25439,7 @@
 	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
-	return (numLiterals * BytesPerWord) + BaseHeaderSize;
+	return (numLiterals + LiteralStart) * BytesPerOop;
 }
 
 sqInt
@@ -25758,7 +25776,7 @@
 
 						/* compiled method; start after methodHeader and literals */
 
-						wordAddr = (wordAddr + BytesPerWord) + ((literalCountOfHeader(headerOf(oop1))) * BytesPerWord);
+						wordAddr += ((literalCountOfHeader(headerOf(oop1))) + LiteralStart) * BytesPerOop;
 					}
 					/* begin reverseBytesFrom:to: */
 					stopAddr1 = oop1 + (sizeBitsOf(oop1));
@@ -26146,9 +26164,7 @@
     sqInt header1;
     sqInt header2;
     sqInt header3;
-    sqInt headerPointer;
     sqInt i;
-    sqInt methodHeader;
     sqInt obj;
     sqInt obj1;
     sqInt oop;
@@ -26191,16 +26207,7 @@
 		if ((((((usqInt) (longAt(oop))) >> 8) & 15) <= 4)
 		 || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
 			if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
-				/* begin literalCountOfHeader: */
-				/* begin headerOf: */
-				methodHeader = longAt((oop + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
-				headerPointer = (isCogMethodReference(methodHeader)
-					? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
-						(((CogMethod *) methodHeader)->methodHeader))
-					: methodHeader);
-				i = ((((sqInt) headerPointer)) < 0
-										? (((usqInt) headerPointer) >> 1) & 65535
-										: (((usqInt) headerPointer) >> 10) & 255);
+				i = (literalCountOfHeader(headerOf(oop))) + LiteralStart;
 			}
 			else {
 				if (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex) {
@@ -27296,9 +27303,7 @@
 		if ((!(isFree(thePage)))
 		 && (((thePage->trace)) == 0)) {
 			assert(noMarkedContextsOnPage(thePage));
-			/* begin freeStackPage: */
-			freeStackPageNoAssert(thePage);
-			assert(pageListIsWellFormed());
+			freeStackPage(thePage);
 		}
 		assert(((thePage->trace = -1)) != 0);
 	}
@@ -27612,8 +27617,14 @@
 markAndTrace(sqInt oop)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt action;
+    sqInt ccIndex;
+    sqInt ccIndex1;
     sqInt child;
     sqInt childType;
+    sqInt class;
+    sqInt class1;
+    sqInt classFormat;
+    sqInt classFormat1;
     sqInt contextSize;
     sqInt contextSize1;
     sqInt field;
@@ -27634,8 +27645,9 @@
     sqInt lastFieldOffset1;
     sqInt methodHeader;
     sqInt methodHeader1;
-    sqInt numLiterals;
-    sqInt numLiterals1;
+    sqInt numFields;
+    sqInt numFields1;
+    sqInt oop1;
     sqInt parentField;
     void *pointer;
     void *pointer1;
@@ -27682,7 +27694,15 @@
 					}
 					GIV(weakRoots)[GIV(weakRootCount)] = oop;
 				}
-				lastFieldOffset = (nonWeakFieldsOf(oop)) << ShiftForWord;
+				/* begin nonWeakFieldsOf: */
+				VM_LABEL(1nonWeakFieldsOf);
+				assert(isWeakNonInt(oop));
+				class1 = (((ccIndex1 = (((usqInt) (longAt(oop))) >> 12) & 31)) == 0
+					? (longAt(oop - BaseHeaderSize)) & AllButTypeMask
+					: longAt(((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (CompactClasses << ShiftForWord))) + BaseHeaderSize) + ((ccIndex1 - 1) << ShiftForWord)));
+				classFormat1 = (longAt((class1 + BaseHeaderSize) + (InstanceSpecificationIndex << ShiftForWord))) - 1;
+				numFields1 = (((((usqInt) classFormat1) >> 11) & 192) + ((((usqInt) classFormat1) >> 2) & 63)) - 1;
+				lastFieldOffset = numFields1 * BytesPerWord;
 				goto l7;
 			}
 			if (((((usqInt) header4) >> 12) & 31) == ClassMethodContextCompactIndex) {
@@ -27715,7 +27735,7 @@
 				contextSize1 = (sp1 >> 1);
 			l6:	/* end fetchStackPointerOf: */;
 				assert((ReceiverIndex + contextSize1) < (lengthOfbaseHeaderformat(oop, header4, fmt1)));
-				lastFieldOffset = (CtxtTempFrameStart + contextSize1) * BytesPerWord;
+				lastFieldOffset = (CtxtTempFrameStart + contextSize1) * BytesPerOop;
 				goto l7;
 			}
 		}
@@ -27743,10 +27763,10 @@
 		? (assert(((((CogMethod *) methodHeader1)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader1)->methodHeader))
 		: methodHeader1);
-	numLiterals1 = ((((sqInt) headerPointer1)) < 0
+	numFields1 = ((((sqInt) headerPointer1)) < 0
 				? (((usqInt) headerPointer1) >> 1) & 65535
 				: (((usqInt) headerPointer1) >> 10) & 255);
-	lastFieldOffset = (numLiterals1 * BytesPerWord) + BaseHeaderSize;
+	lastFieldOffset = (numFields1 + LiteralStart) * BytesPerOop;
 l7:	/* end lastPointerOf:recordWeakRoot: */;
 	field = oop + lastFieldOffset;
 	action = StartField;
@@ -27822,7 +27842,8 @@
 				goto l2;
 			}
 			/* begin lastPointerOf:recordWeakRoot: */
-			header3 = longAt(child);
+			oop1 = child;
+			header3 = longAt(oop1);
 			fmt = (((usqInt) header3) >> 8) & 15;
 			if (fmt <= 4) {
 				if (fmt >= 3) {
@@ -27835,18 +27856,26 @@
 							if (!(((GIV(weakRootCount) += 1)) <= WeakRootTableSize)) {
 								error("weakRoots table overflow");
 							}
-							GIV(weakRoots)[GIV(weakRootCount)] = child;
+							GIV(weakRoots)[GIV(weakRootCount)] = oop1;
 						}
-						lastFieldOffset1 = (nonWeakFieldsOf(child)) << ShiftForWord;
+						/* begin nonWeakFieldsOf: */
+						VM_LABEL(2nonWeakFieldsOf);
+						assert(isWeakNonInt(oop1));
+						class = (((ccIndex = (((usqInt) (longAt(oop1))) >> 12) & 31)) == 0
+							? (longAt(oop1 - BaseHeaderSize)) & AllButTypeMask
+							: longAt(((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (CompactClasses << ShiftForWord))) + BaseHeaderSize) + ((ccIndex - 1) << ShiftForWord)));
+						classFormat = (longAt((class + BaseHeaderSize) + (InstanceSpecificationIndex << ShiftForWord))) - 1;
+						numFields = (((((usqInt) classFormat) >> 11) & 192) + ((((usqInt) classFormat) >> 2) & 63)) - 1;
+						lastFieldOffset1 = numFields * BytesPerWord;
 						goto l5;
 					}
 					if (((((usqInt) header3) >> 12) & 31) == ClassMethodContextCompactIndex) {
 						/* begin setTraceFlagOnContextsFramesPageIfNeeded: */
-						if ((((longAt((child + BaseHeaderSize) + (SenderIndex << ShiftForWord))) & 1))
-						 && (!(isWidowedContext(child)))) {
+						if ((((longAt((oop1 + BaseHeaderSize) + (SenderIndex << ShiftForWord))) & 1))
+						 && (!(isWidowedContext(oop1)))) {
 							/* begin stackPageFor: */
 							/* begin frameOfMarriedContext: */
-							value = longAt((child + BaseHeaderSize) + (SenderIndex << ShiftForWord));
+							value = longAt((oop1 + BaseHeaderSize) + (SenderIndex << ShiftForWord));
 							/* begin withoutSmallIntegerTags: */
 							assert((value & 1));
 							pointer = ((char *) (pointerForOop(value - 1)));
@@ -27861,28 +27890,28 @@
 							}
 						}
 						/* begin fetchStackPointerOf: */
-						sp = longAt((child + BaseHeaderSize) + (StackPointerIndex << ShiftForWord));
+						sp = longAt((oop1 + BaseHeaderSize) + (StackPointerIndex << ShiftForWord));
 						if (!((sp & 1))) {
 							contextSize = 0;
 							goto l4;
 						}
-						assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(child)));
+						assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(oop1)));
 						contextSize = (sp >> 1);
 					l4:	/* end fetchStackPointerOf: */;
-						assert((ReceiverIndex + contextSize) < (lengthOfbaseHeaderformat(child, header3, fmt)));
-						lastFieldOffset1 = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+						assert((ReceiverIndex + contextSize) < (lengthOfbaseHeaderformat(oop1, header3, fmt)));
+						lastFieldOffset1 = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 						goto l5;
 					}
 				}
 				/* begin sizeBitsOfSafe: */
-				header11 = longAt(child);
+				header11 = longAt(oop1);
 				type1 = ((header11 & SizeMask) == 0
 					? HeaderTypeSizeAndClass
 					: ((header11 & CompactClassMask) == 0
 							? HeaderTypeClass
 							: HeaderTypeShort));
 				sz = (type1 == HeaderTypeSizeAndClass
-					? (longAt(child - (BytesPerWord * 2))) & AllButTypeMask
+					? (longAt(oop1 - (BytesPerWord * 2))) & AllButTypeMask
 					: header11 & SizeMask);
 				lastFieldOffset1 = sz - BaseHeaderSize;
 				goto l5;
@@ -27893,15 +27922,15 @@
 			}
 			/* begin literalCountOfHeader: */
 			/* begin headerOf: */
-			methodHeader = longAt((child + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+			methodHeader = longAt((oop1 + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
 			headerPointer = (isCogMethodReference(methodHeader)
 				? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 					(((CogMethod *) methodHeader)->methodHeader))
 				: methodHeader);
-			numLiterals = ((((sqInt) headerPointer)) < 0
+			numFields = ((((sqInt) headerPointer)) < 0
 								? (((usqInt) headerPointer) >> 1) & 65535
 								: (((usqInt) headerPointer) >> 10) & 255);
-			lastFieldOffset1 = (numLiterals * BytesPerWord) + BaseHeaderSize;
+			lastFieldOffset1 = (numFields + LiteralStart) * BytesPerOop;
 		l5:	/* end lastPointerOf:recordWeakRoot: */;
 			header1 = (header1 & AllButTypeMask) | (MarkBit | HeaderTypeGC);
 			longAtput(child, header1);
@@ -28619,6 +28648,21 @@
 }
 
 
+/*	<Integer> */
+
+static sqInt
+mframeIsBlockActivation(char *theFP)
+{
+	return ((longAt(theFP + FoxMethod)) & MFMethodFlagIsBlockFlag) != 0;
+}
+
+static sqInt
+mframeReceiver(char *theFP)
+{
+	return longAt(theFP + FoxMFReceiver);
+}
+
+
 /*	Traverse all stack pages looking for non-zero bytes in the headroom part
 	of each page.
 	Answer the minimum size of unused headroom (zero bytes) in the pages. This
@@ -28929,7 +28973,7 @@
 				assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(methodObj)));
 				contextSize = (sp >> 1);
 			l2:	/* end fetchStackPointerOf: */;
-				startBcpc = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+				startBcpc = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 				goto l3;
 			}
 			startBcpc = (sizeBitsOfSafe(methodObj)) - BaseHeaderSize;
@@ -28949,7 +28993,7 @@
 		numLiterals = ((((sqInt) headerPointer)) < 0
 						? (((usqInt) headerPointer) >> 1) & 65535
 						: (((usqInt) headerPointer) >> 10) & 255);
-		startBcpc = (numLiterals * BytesPerWord) + BaseHeaderSize;
+		startBcpc = (numLiterals + LiteralStart) * BytesPerOop;
 	l3:	/* end lastPointerOf: */;
 	}
 	/* begin ensureMethodIsCogged: */
@@ -29208,31 +29252,6 @@
 	return 1;
 }
 
-
-/*	Return the number of non-weak fields in oop (i.e. the number of fixed
-	fields). Note: The following is copied from fixedFieldsOf:format:length:
-	since we do know
-	the format of the oop (e.g. format = 4) and thus don't need the length.
- */
-
-static sqInt
-nonWeakFieldsOf(sqInt oop)
-{   DECL_MAYBE_SQ_GLOBAL_STRUCT
-    sqInt ccIndex;
-    sqInt class;
-    sqInt classFormat;
-
-
-	/* No need to inline - we won't call this often */
-
-	assert(isWeakNonInt(oop));
-	class = (((ccIndex = (((usqInt) (longAt(oop))) >> 12) & 31)) == 0
-		? (longAt(oop - BaseHeaderSize)) & AllButTypeMask
-		: longAt(((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (CompactClasses << ShiftForWord))) + BaseHeaderSize) + ((ccIndex - 1) << ShiftForWord)));
-	classFormat = (longAt((class + BaseHeaderSize) + (InstanceSpecificationIndex << ShiftForWord))) - 1;
-	return (((((usqInt) classFormat) >> 11) & 192) + ((((usqInt) classFormat) >> 2) & 63)) - 1;
-}
-
 sqInt
 nullHeaderForMachineCodeMethod(void)
 {
@@ -30117,7 +30136,7 @@
 			assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(array1)));
 			contextSize = (sp >> 1);
 		l3:	/* end fetchStackPointerOf: */;
-			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerWord;
+			fieldOffset = (CtxtTempFrameStart + contextSize) * BytesPerOop;
 			goto l4;
 		}
 		fieldOffset = (sizeBitsOfSafe(array1)) - BaseHeaderSize;
@@ -30137,7 +30156,7 @@
 	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
-	fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
+	fieldOffset = (numLiterals + LiteralStart) * BytesPerOop;
 l4:	/* end lastPointerOf: */;
 	while (fieldOffset >= BaseHeaderSize) {
 		oop1 = longAt(array1 + fieldOffset);
@@ -31597,7 +31616,6 @@
     sqInt frameNumArgs1;
     sqInt i;
     sqInt methodHeader;
-    sqInt methodPointer;
     sqInt newCopy;
     sqInt objHeader;
     sqInt rcvr;
@@ -31670,8 +31688,7 @@
 
 			/* begin rawHeaderOf:put: */
 			/* begin headerOf: */
-			methodPointer = longAt(GIV(stackPointer));
-			methodHeader = longAt((methodPointer + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+			methodHeader = longAt(((longAt(GIV(stackPointer))) + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
 			cogMethodOrMethodHeader = (isCogMethodReference(methodHeader)
 				? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 					(((CogMethod *) methodHeader)->methodHeader))
@@ -37815,6 +37832,7 @@
 static void
 primitiveInterruptSemaphore(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt anObject;
     sqInt arg;
     sqInt ccIndex;
     sqInt top;
@@ -37837,11 +37855,12 @@
 	}
 	else {
 		/* begin splObj:put: */
+		anObject = GIV(nilObj);
 		/* begin storePointer:ofObject:withValue: */
 		if ((((usqInt) GIV(specialObjectsOop))) < (((usqInt) GIV(youngStart)))) {
-			possibleRootStoreIntovalue(GIV(specialObjectsOop), GIV(nilObj));
+			possibleRootStoreIntovalue(GIV(specialObjectsOop), anObject);
 		}
-		longAtput((GIV(specialObjectsOop) + BaseHeaderSize) + (TheInterruptSemaphore << ShiftForWord), GIV(nilObj));
+		longAtput((GIV(specialObjectsOop) + BaseHeaderSize) + (TheInterruptSemaphore << ShiftForWord), anObject);
 	}
 }
 
@@ -38628,6 +38647,7 @@
 static void
 primitiveLowSpaceSemaphore(void)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    sqInt anObject;
     sqInt arg;
     sqInt ccIndex;
     sqInt top;
@@ -38650,11 +38670,12 @@
 	}
 	else {
 		/* begin splObj:put: */
+		anObject = GIV(nilObj);
 		/* begin storePointer:ofObject:withValue: */
 		if ((((usqInt) GIV(specialObjectsOop))) < (((usqInt) GIV(youngStart)))) {
-			possibleRootStoreIntovalue(GIV(specialObjectsOop), GIV(nilObj));
+			possibleRootStoreIntovalue(GIV(specialObjectsOop), anObject);
 		}
-		longAtput((GIV(specialObjectsOop) + BaseHeaderSize) + (TheLowSpaceSemaphore << ShiftForWord), GIV(nilObj));
+		longAtput((GIV(specialObjectsOop) + BaseHeaderSize) + (TheLowSpaceSemaphore << ShiftForWord), anObject);
 	}
 }
 
@@ -39973,14 +39994,12 @@
     sqInt header;
     sqInt header1;
     sqInt header2;
-    sqInt headerPointer;
     sqInt i;
     sqInt i1;
     sqInt iLimiT;
     sqInt iLimiT1;
     sqInt index;
     sqInt methodField;
-    sqInt methodHeader;
     sqInt next;
     sqInt path;
     char *sp;
@@ -40146,16 +40165,7 @@
 					hdr = longAt(next);
 					longAtput(next, hdr | MarkBit);
 					if (((((usqInt) hdr) >> 8) & 15) >= 12) {
-						/* begin literalCountOfHeader: */
-						/* begin headerOf: */
-						methodHeader = longAt((next + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
-						headerPointer = (isCogMethodReference(methodHeader)
-							? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
-								(((CogMethod *) methodHeader)->methodHeader))
-							: methodHeader);
-						index = ((((sqInt) headerPointer)) < 0
-														? (((usqInt) headerPointer) >> 1) & 65535

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list