[Vm-dev] [commit][2624] CogVM source as per VMMaker.oscog-eem.225.

commits at squeakvm.org commits at squeakvm.org
Fri Nov 30 23:16:14 UTC 2012


Revision: 2624
Author:   eliot
Date:     2012-11-30 15:16:14 -0800 (Fri, 30 Nov 2012)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.225.

Fixes for cog issue 109, base frames and CallPrimitive, and merge
with VMMaker.oscog-lw.224.

Cogit:
StackToRegisterMappingCogit, cog issue 109.
Fix pc mapping for popped folded constants as in, e.g. 1-1.  Need to
check for annotateUse on popping a stack descriptor.

CoInterpreter:
Fix makeBaseFrame: for methods with CallPrimitive that get restarted.
e.g. on:do:.  We could make the CallPrimitive bytecode check for
being at the start of a method, but I have decided, for strictness, to
make executing CallPrimitive an error for the moment.  This means
that thater we could use it to embed primitive calls in the middle of methods.

Streamline once again activation sequence to make setting method
(actually bytecodeSetSelector) faster and on primitive failure to
increment pc past CallPrimitive before checking for err code store.

Make ensureMethodIsCogged: answer the cogged method, again for efficiency.

Add tracing of stack overflows.

Fix bug in printing of bytecode addresses in long/printOop: on CompiledMethods.

Fix bug in printStringOf: so that it prints ... when truncating.

Add missing case to isNullExternalPrimitiveCall:.

Streamline long/printReferencesTo:.

Slang:
Improve formatting of code for cppIf:ifTrue:.

Modified Paths:
--------------
    branches/Cog/nscogsrc/vm/cogit.c
    branches/Cog/nscogsrc/vm/cogit.h
    branches/Cog/nscogsrc/vm/cogmethod.h
    branches/Cog/nscogsrc/vm/cointerp.c
    branches/Cog/nscogsrc/vm/cointerp.h
    branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
    branches/Cog/nscogsrc/vm/interp.h
    branches/Cog/nscogsrc/vm/vmCallback.h
    branches/Cog/platforms/Mac OS/vm/sqMacEncoding.c
    branches/Cog/platforms/Mac OS/vm/sqMacMain.c
    branches/Cog/platforms/Mac OS/vm/sqMacMemory.c
    branches/Cog/platforms/Mac OS/vm/sqMacUIAppleEvents.c
    branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c
    branches/Cog/platforms/unix/vm/sqUnixMain.c
    branches/Cog/src/vm/cogit.c
    branches/Cog/src/vm/cogit.h
    branches/Cog/src/vm/cogmethod.h
    branches/Cog/src/vm/cointerp.c
    branches/Cog/src/vm/cointerp.h
    branches/Cog/src/vm/cointerpmt.c
    branches/Cog/src/vm/cointerpmt.h
    branches/Cog/src/vm/gcc3x-cointerp.c
    branches/Cog/src/vm/gcc3x-cointerpmt.c
    branches/Cog/src/vm/interp.h
    branches/Cog/src/vm/vmCallback.h

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

Modified: branches/Cog/nscogsrc/vm/cogit.c
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.c	2012-11-30 19:01:01 UTC (rev 2623)
+++ branches/Cog/nscogsrc/vm/cogit.c	2012-11-30 23:16:14 UTC (rev 2624)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd
+	CCodeGenerator VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd
+	StackToRegisterMappingCogit VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -368,6 +368,7 @@
 static sqInt allocate(sqInt numBytes);
 static sqInt allYoungObjectsAgeInFullGC(void);
 static AbstractInstruction * annotateAbsolutePCRef(AbstractInstruction *abstractInstruction);
+static void annotateBytecodeIfAnnotated(SimStackEntry aSimStackEntry);
 static AbstractInstruction * annotateBytecode(AbstractInstruction *abstractInstruction);
 static AbstractInstruction * annotateobjRef(AbstractInstruction *abstractInstruction, sqInt anOop);
 static AbstractInstruction * annotatewith(AbstractInstruction *abstractInstruction, sqInt annotationFlag);
@@ -1946,7 +1947,7 @@
 		opcodeIndex = labelCounter = annotationIndex = 0; \
 } while (0)
 #define blockStartAt(index) (&blockStarts[index])
-#define breakOnImplicitReceiver() (traceFlags & 32)
+#define breakOnImplicitReceiver() (traceFlags & 64)
 #define ceBaseFrameReturnPC() ceBaseFrameReturnTrampoline
 #define ceCannotResumePC() ((usqInt)ceCannotResumeTrampoline)
 #define ceCheckFeatures() ceCheckFeaturesFunction()
@@ -1983,6 +1984,7 @@
 #define print(aString) printf(aString)
 #define recordBlockTrace() (traceFlags & 4)
 #define recordEventTrace() (traceFlags & 16)
+#define recordOverflowTrace() (traceFlags & 32)
 #define recordPrimTrace() (traceFlags & 8)
 #define recordSendTrace() (traceFlags & 2)
 #define reportError(n) warning("compilation error")
@@ -2269,6 +2271,23 @@
 	return annotatewith(abstractInstruction, IsAbsPCReference);
 }
 
+static void
+annotateBytecodeIfAnnotated(SimStackEntry aSimStackEntry)
+{
+    AbstractInstruction *abstractInstruction;
+
+	if (annotateUse(aSimStackEntry)) {
+		/* begin annotateBytecode: */
+		abstractInstruction = (prevInstIsPCAnnotated()
+			? (/* begin Nop */
+				gen(Nop))
+			: (/* begin Label */
+				genoperandoperand(Label, (labelCounter += 1), bytecodePC)));
+		annotatewith(abstractInstruction, HasBytecodePC);
+		annotateUse(aSimStackEntry, 0);
+	}
+}
+
 static AbstractInstruction *
 annotateBytecode(AbstractInstruction *abstractInstruction)
 {
@@ -2338,7 +2357,7 @@
 static sqInt
 blockCreationBytecodeSizeForHeader(sqInt methodHeader)
 {
-	return 		(headerIndicatesAlternateBytecodeSet(methodHeader)
+	return (headerIndicatesAlternateBytecodeSet(methodHeader)
 				? AltBlockCreationBytecodeSize
 				: BlockCreationBytecodeSize);
 }
@@ -2828,7 +2847,7 @@
 			}
 		}
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		if (!(asserta(((((CogMethod *) cogMethod)->cmType)) == CMMethod))) {
 			return 3;
@@ -2896,7 +2915,7 @@
 			return 1;
 		}
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		cacheTag = inlineCacheTagAt(backEnd, ((sqInt)mcpc));
 		if (!(checkValidInlineCacheTag(cacheTag))) {
@@ -4326,7 +4345,7 @@
 		genoperand(PushR, SendNumArgsReg);
 	}
 	if ((primitiveIndex > 0)
-	 && (methodHasErrorCodeheaderinitialIP(methodObj, methodHeader, pointerForOop(initialPCForHeadermethod(methodHeader, methodObj))))) {
+	 && ((longStoreBytecodeForHeader(methodHeader)) == (fetchByteofObject(initialPC + (sizeOfCallPrimitiveBytecode(methodHeader)), methodObj)))) {
 		compileGetErrorCode();
 		initialPC = (initialPC + (sizeOfCallPrimitiveBytecode(methodHeader))) + (sizeOfLongStoreTempBytecode(methodHeader));
 	}
@@ -4927,7 +4946,7 @@
 
 	missOffset = (((sendMissCall->address)) + ((sendMissCall->machineCodeSize))) - methodZoneBase;
 	entryPointMask = BytesPerWord - 1;
-	while (		((cmEntryOffset & entryPointMask) == (cmNoCheckEntryOffset & entryPointMask))
+	while (((cmEntryOffset & entryPointMask) == (cmNoCheckEntryOffset & entryPointMask))
 			 || (((cmEntryOffset & entryPointMask) == (cmDynSuperEntryOffset & entryPointMask))
 			 || ((cmNoCheckEntryOffset & entryPointMask) == (cmDynSuperEntryOffset & entryPointMask)))) {
 		entryPointMask = (entryPointMask + entryPointMask) + 1;
@@ -9504,7 +9523,7 @@
 
 
 	/* Generate the non-send runtime support for Newspeak, explicit outer and implicit receiver.
-	   The dynamic frequency of explicit outer is so low we merely cann an interpreter routine. */
+	   The dynamic frequency of explicit outer is so low we merely call an interpreter routine. */
 
 
 	/* Cached push implicit receiver implementation.  Caller looks like
@@ -10873,6 +10892,7 @@
 static sqInt
 genPopStackBytecode(void)
 {
+	annotateBytecodeIfAnnotated(ssTop());
 	if ((ssTop()->spilled)) {
 		/* begin AddCq:R: */
 		genoperandoperand(AddCqR, BytesPerWord, SPReg);
@@ -12529,8 +12549,6 @@
 static sqInt
 genSpecialSelectorArithmetic(void)
 {
-    AbstractInstruction *abstractInstruction;
-    AbstractInstruction *abstractInstruction1;
     sqInt annotateInst;
     sqInt argInt;
     sqInt argIsConst;
@@ -12574,24 +12592,8 @@
 
 			/* Must enter any annotatedConstants into the map */
 
-			if ((ssValue(1)->annotateUse)) {
-				/* begin annotateBytecode: */
-				abstractInstruction = (prevInstIsPCAnnotated()
-					? (/* begin Nop */
-						gen(Nop))
-					: (/* begin Label */
-						genoperandoperand(Label, (labelCounter += 1), bytecodePC)));
-				annotatewith(abstractInstruction, HasBytecodePC);
-			}
-			if ((ssTop()->annotateUse)) {
-				/* begin annotateBytecode: */
-				abstractInstruction1 = (prevInstIsPCAnnotated()
-					? (/* begin Nop */
-						gen(Nop))
-					: (/* begin Label */
-						genoperandoperand(Label, (labelCounter += 1), bytecodePC)));
-				annotatewith(abstractInstruction1, HasBytecodePC);
-			}
+			annotateBytecodeIfAnnotated(ssValue(1));
+			annotateBytecodeIfAnnotated(ssTop());
 			return (ssPop(2),
 			ssPushAnnotatedConstant(((result << 1) | 1)));
 		}
@@ -12715,7 +12717,7 @@
 		/* begin MoveCq:R: */
 		genoperandoperand(MoveCqR, argInt, Arg0Reg);
 	}
-	genMarshalledSendnumArgs(specialSelector(byte0 - (	(bytecodeSetOffset == 256
+	genMarshalledSendnumArgs(specialSelector(byte0 - ((bytecodeSetOffset == 256
 		? 80 + 256
 		: 176))), 1);
 	jmpTarget(jumpContinue, gLabel());
@@ -12738,8 +12740,6 @@
 genSpecialSelectorComparison(void)
 {
     AbstractInstruction *abstractInstruction;
-    AbstractInstruction *abstractInstruction1;
-    AbstractInstruction *abstractInstruction2;
     sqInt annotateInst;
     sqInt argInt;
     sqInt argIsInt;
@@ -12788,24 +12788,8 @@
 		default:
 			error("Case not found and no otherwise clause");
 		}
-		if ((ssValue(1)->annotateUse)) {
-			/* begin annotateBytecode: */
-			abstractInstruction = (prevInstIsPCAnnotated()
-				? (/* begin Nop */
-					gen(Nop))
-				: (/* begin Label */
-					genoperandoperand(Label, (labelCounter += 1), bytecodePC)));
-			annotatewith(abstractInstruction, HasBytecodePC);
-		}
-		if ((ssTop()->annotateUse)) {
-			/* begin annotateBytecode: */
-			abstractInstruction1 = (prevInstIsPCAnnotated()
-				? (/* begin Nop */
-					gen(Nop))
-				: (/* begin Label */
-					genoperandoperand(Label, (labelCounter += 1), bytecodePC)));
-			annotatewith(abstractInstruction1, HasBytecodePC);
-		}
+		annotateBytecodeIfAnnotated(ssValue(1));
+		annotateBytecodeIfAnnotated(ssTop());
 		ssPop(2);
 		return ssPushAnnotatedConstant((result
 			? trueObject()
@@ -12863,8 +12847,8 @@
 		if (annotateInst) {
 			/* begin annotateBytecode: */
 			/* begin CmpCq:R: */
-			abstractInstruction2 = genoperandoperand(CmpCqR, argInt, ReceiverResultReg);
-			annotatewith(abstractInstruction2, HasBytecodePC);
+			abstractInstruction = genoperandoperand(CmpCqR, argInt, ReceiverResultReg);
+			annotatewith(abstractInstruction, HasBytecodePC);
 		}
 		else {
 			/* begin CmpCq:R: */
@@ -12886,7 +12870,7 @@
 		/* begin MoveCq:R: */
 		genoperandoperand(MoveCqR, argInt, Arg0Reg);
 	}
-	return genMarshalledSendnumArgs(specialSelector(byte0 - (	(bytecodeSetOffset == 256
+	return genMarshalledSendnumArgs(specialSelector(byte0 - ((bytecodeSetOffset == 256
 		? 80 + 256
 		: 176))), 1);
 }
@@ -13004,7 +12988,7 @@
     sqInt numArgs;
     sqInt selector;
 
-	index = byte0 - (	(bytecodeSetOffset == 256
+	index = byte0 - ((bytecodeSetOffset == 256
 		? 80 + 256
 		: 176));
 	selector = specialSelector(index);
@@ -13636,7 +13620,7 @@
     sqInt table;
     CogMethod *targetMethod;
 
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		entryPoint = callTargetFromReturnAddress(backEnd, ((sqInt)mcpc));
 		if (entryPoint > methodZoneBase) {
@@ -14131,7 +14115,7 @@
 static sqInt
 isPCMappedAnnotation(sqInt annotation)
 {
-	return (	(annotation == IsSendCall)
+	return ((annotation == IsSendCall)
 	 || (annotation == IsNSSendCall))
 	 || (annotation == HasBytecodePC);
 }
@@ -14603,7 +14587,7 @@
 		endbcpc = (byteSizeOf(aMethodObj)) - 1;
 		/* begin bytecodeSetOffsetForHeader: */
 		methodHeader = (homeMethod->methodHeader);
-		bsOffset = 			(headerIndicatesAlternateBytecodeSet(methodHeader)
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader)
 						? 256
 						: 0);
 	}
@@ -14625,7 +14609,7 @@
 		bcpc = startbcpc - (blockCreationBytecodeSizeForHeader((homeMethod->methodHeader)));
 		/* begin bytecodeSetOffsetForHeader: */
 		methodHeader1 = (homeMethod->methodHeader);
-		bsOffset = 			(headerIndicatesAlternateBytecodeSet(methodHeader1)
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader1)
 						? 256
 						: 0);
 		byte = (fetchByteofObject(bcpc, aMethodObj)) + bsOffset;
@@ -14656,7 +14640,7 @@
 		if (mapByte >= FirstAnnotation) {
 			annotation = ((usqInt) mapByte) >> AnnotationShift;
 			mcpc += mapByte & DisplacementMask;
-			if ((	(annotation == IsSendCall)
+			if (((annotation == IsSendCall)
 	 || (annotation == IsNSSendCall))
 			 || (annotation == HasBytecodePC)) {
 							while (1) {
@@ -15212,7 +15196,7 @@
 		literal = literalBeforeFollowingAddress(backEnd, ((sqInt)mcpc));
 		markAndTraceLiteral(literal);
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		entryPoint = callTargetFromReturnAddress(backEnd, ((sqInt)mcpc));
 		cacheTag = inlineCacheTagAt(backEnd, ((sqInt)mcpc));
@@ -15309,7 +15293,7 @@
 		literal = literalBeforeFollowingAddress(backEnd, ((sqInt)mcpc));
 		markAndTraceLiteral(literal);
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		cacheTag = inlineCacheTagAt(backEnd, ((sqInt)mcpc));
 		cacheTagMarked = cacheTagIsMarked(cacheTag);
@@ -15389,7 +15373,7 @@
 		literal = literalBeforeFollowingAddress(backEnd, ((sqInt)mcpc));
 		markAndTraceLiteralIfYoung(literal);
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		cacheTag = inlineCacheTagAt(backEnd, ((sqInt)mcpc));
 		markAndTraceLiteralIfYoung(cacheTag);
@@ -15418,7 +15402,7 @@
 		literal = literalBeforeFollowingAddress(backEnd, ((sqInt)mcpc));
 		markAndTraceLiteralIfYoung(literal);
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		cacheTag = inlineCacheTagAt(backEnd, ((sqInt)mcpc));
 		markAndTraceLiteralIfYoung(cacheTag);
@@ -16492,7 +16476,7 @@
     CogMethod *targetMethod;
     sqInt unlinkedRoutine;
 
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		entryPoint = callTargetFromReturnAddress(backEnd, ((sqInt)mcpc));
 		if (entryPoint <= methodZoneBase) {
@@ -16612,7 +16596,7 @@
 			}
 		}
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		cacheTag = inlineCacheTagAt(backEnd, ((sqInt)mcpc));
 		if (couldBeObject(cacheTag)) {
@@ -16678,7 +16662,7 @@
 			}
 		}
 	}
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		cacheTag = inlineCacheTagAt(backEnd, ((sqInt)mcpc));
 		if (couldBeObject(cacheTag)) {
@@ -17807,7 +17791,7 @@
     CogMethod *targetMethod;
     sqInt unlinkedRoutine;
 
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		entryPoint = callTargetFromReturnAddress(backEnd, ((sqInt)mcpc));
 		if (entryPoint > methodZoneBase) {
@@ -17859,7 +17843,7 @@
     CogMethod *targetMethod;
     sqInt unlinkedRoutine;
 
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		entryPoint = callTargetFromReturnAddress(backEnd, ((sqInt)mcpc));
 		if (entryPoint > methodZoneBase) {
@@ -17908,7 +17892,7 @@
     CogMethod *targetMethod;
     sqInt unlinkedRoutine;
 
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		entryPoint = callTargetFromReturnAddress(backEnd, ((sqInt)mcpc));
 		if (entryPoint == ceImplicitReceiverTrampoline) {
@@ -17967,7 +17951,7 @@
     CogMethod *targetMethod;
     sqInt unlinkedRoutine;
 
-	if (		(annotation == IsSendCall)
+	if ((annotation == IsSendCall)
 			 || (annotation == IsNSSendCall)) {
 		entryPoint = callTargetFromReturnAddress(backEnd, ((sqInt)mcpc));
 		if (entryPoint > methodZoneBase) {

Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h	2012-11-30 19:01:01 UTC (rev 2623)
+++ branches/Cog/nscogsrc/vm/cogit.h	2012-11-30 23:16:14 UTC (rev 2624)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd
+	CCodeGenerator VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6
  */
 
 
@@ -109,7 +109,7 @@
 
 
 /*** Macros ***/
-#define breakOnImplicitReceiver() (traceFlags & 32)
+#define breakOnImplicitReceiver() (traceFlags & 64)
 #define ceBaseFrameReturnPC() ceBaseFrameReturnTrampoline
 #define ceCannotResumePC() ((usqInt)ceCannotResumeTrampoline)
 #define ceReturnToInterpreterPC() ((usqInt)ceReturnToInterpreterTrampoline)
@@ -123,6 +123,7 @@
 #define printOnTrace() (traceFlags & 1)
 #define recordBlockTrace() (traceFlags & 4)
 #define recordEventTrace() (traceFlags & 16)
+#define recordOverflowTrace() (traceFlags & 32)
 #define recordPrimTrace() (traceFlags & 8)
 #define recordSendTrace() (traceFlags & 2)
 #define setCFramePointer(theFP) (CFramePointer = (void *)(theFP))

Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h	2012-11-30 19:01:01 UTC (rev 2623)
+++ branches/Cog/nscogsrc/vm/cogmethod.h	2012-11-30 23:16:14 UTC (rev 2624)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd
+	CCodeGenerator VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6
  */
 
 typedef struct {

Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c	2012-11-30 19:01:01 UTC (rev 2623)
+++ branches/Cog/nscogsrc/vm/cointerp.c	2012-11-30 23:16:14 UTC (rev 2624)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6
    from
-	CoInterpreter VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd
+	CoInterpreter VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.223 uuid: 62151b21-ad34-403a-b5a0-63d83c023cdd " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.225 uuid: 222bea80-06c8-4893-b1e1-d191688f36e6 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -319,6 +319,7 @@
 #define TraceIncrementalGC 9
 #define TraceIsFromInterpreter 2
 #define TraceIsFromMachineCode 1
+#define TraceStackOverflow 27
 #define TraceVMCallback 23
 #define TraceVMCallbackReturn 25
 #define TrueObject 2
@@ -454,6 +455,7 @@
 static sqInt containOnlyOopsand(sqInt array1, sqInt array2);
 static sqInt contextInstructionPointerframe(sqInt theIP, char *theFP);
 static sqInt contexthasSender(sqInt thisCntx, sqInt aContext);
+static sqInt contexthasValidInversePCMappingOfin(sqInt aContext, sqInt theIP, char *theFP);
 sqInt copyBits(void);
 sqInt copyBitsFromtoat(sqInt x0, sqInt x1, sqInt y);
 static sqInt copyObjtoSegmentaddrstopAtsaveOopAtheaderAt(sqInt oop, sqInt segmentWordArray, sqInt lastSeg, sqInt stopAddr, sqInt oopPtr, sqInt hdrPtr);
@@ -660,6 +662,7 @@
 void loadInitialContext(void);
 void longPrintOop(sqInt oop);
 void longPrintReferencesTo(sqInt anOop);
+sqInt longStoreBytecodeForHeader(sqInt methodHeader);
 static sqInt lookupInMethodCacheSelclass(sqInt selector, sqInt class);
 static sqInt lookupMethodInClass(sqInt class);
 static sqInt lookupMethodInDictionary(sqInt dictionary);
@@ -695,7 +698,7 @@
 sqInt methodClassAssociationOf(sqInt methodPointer);
 static sqInt methodClassOf(sqInt methodPointer);
 sqInt methodHasCogMethod(sqInt aMethodOop);
-sqInt methodHasErrorCodeheaderinitialIP(sqInt aMethodObj, sqInt methodHeader, char *initialPC);
+static sqInt methodHeaderHasPrimitive(sqInt methodHeader);
 sqInt methodPrimitiveIndex(void);
 sqInt methodReturnValue(sqInt oop);
 sqInt methodShouldBeCogged(sqInt aMethodObj);
@@ -1152,7 +1155,7 @@
 void updateStackZoneReferencesToCompiledCodePreCompaction(void);
 static void updateStateOfSpouseContextForFrameWithSP(char *theFP, char *theSP);
 static sqInt validInstructionPointerinFrame(usqInt anInstrPointer, char *fp);
-sqInt validInstructionPointerinMethodframePointer(usqInt anInstrPointer, usqInt aMethod, char *fp);
+sqInt validInstructionPointerinMethodframePointer(usqInt instrPointer, usqInt aMethod, char *fp);
 static sqInt validStackPageBaseFrames(void);
 static void verifyCleanHeaders(void);
 sqInt vmEndianness(void);
@@ -1194,8 +1197,8 @@
 _iss sqInt trueObj;
 _iss sqInt falseObj;
 _iss sqInt remapBufferCount;
+_iss sqInt traceLogIndex;
 _iss sqInt bytesPerPage;
-_iss sqInt traceLogIndex;
 _iss char * stackLimit;
 _iss usqInt reserveStart;
 _iss usqInt memoryLimit;
@@ -1926,7 +1929,7 @@
 	/* 575 */ (void (*)(void))0,
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.223";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.225";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -5031,7 +5034,7 @@
 						}
 					}
 					else {
-						if ((	((((sqInt) methodHeader1)) < 0
+						if ((((((sqInt) methodHeader1)) < 0
 		? (((usqInt) methodHeader1) >> 1) & 65535
 		: (((usqInt) methodHeader1) >> 10) & 255)) <= maxLiteralCountForCompile) {
 							cogselector(GIV(newMethod), GIV(messageSelector));
@@ -5182,11 +5185,11 @@
 					localFP = localSP;
 					/* begin internalPush: */
 					longAtPointerput((localSP -= BytesPerOop), GIV(newMethod));
-					/* begin setMethod: */
-					assert((((usqInt)GIV(newMethod))) >= (startOfMemory()));
+					/* begin setMethod:methodHeader: */
 					GIV(method) = GIV(newMethod);
 					assert(isOopCompiledMethod(GIV(method)));
-					GIV(bytecodeSetSelector) = (methodUsesAlternateBytecodeSet(GIV(method))
+					assert((headerOf(GIV(method))) == methodHeader);
+					GIV(bytecodeSetSelector) = ((((sqInt) methodHeader)) < 0
 						? 256
 						: 0);
 
@@ -5213,20 +5216,23 @@
 						/* begin internalPush: */
 						longAtPointerput((localSP -= BytesPerOop), GIV(nilObj));
 					}
-					localIP = pointerForOop(((GIV(newMethod) + ((LiteralStart + (	((((sqInt) methodHeader)) < 0
+					localIP = pointerForOop(((GIV(newMethod) + ((LiteralStart + (((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255))) * BytesPerWord)) + BaseHeaderSize) - 1);
-					if (						((((sqInt) methodHeader)) < 0
+					if (((((sqInt) methodHeader)) < 0
 												? methodHeader & (65536 << SmallIntegerShift)
 												: (methodHeader & 536871934) != 0)) {
 
-						/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method
-						   starts with a long store temp.  Strictly no need to skip the store because it's a noop. */
+						/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method starts
+						   with a long store temp.  Strictly no need to skip the store because it's effectively a noop. */
 
-						if (							((((sqInt) methodHeader)) < 0
-														? (byteAt((localIP + 1) + 3)) == 234
-														: (byteAt(localIP + 1)) == 129)) {
-							if (GIV(primFailCode) != 0) {
+						localIP += ((((sqInt) methodHeader)) < 0
+														? 3
+														: 0);
+						if (GIV(primFailCode) != 0) {
+							if ((byteAt(localIP + 1)) == (((((sqInt) methodHeader)) < 0
+		? 234
+		: 129))) {
 								/* begin getErrorObjectFromPrimFailCode */
 								if (GIV(primFailCode) > 0) {
 									table = longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (PrimErrTableIndex << ShiftForWord));
@@ -5241,9 +5247,6 @@
 							}
 							GIV(primFailCode) = 0;
 						}
-						localIP += 							((((sqInt) methodHeader)) < 0
-														? 3
-														: 0);
 					}
 					assert((frameNumArgs(localFP)) == GIV(argumentCount));
 					assert(!(frameIsBlockActivation(localFP)));
@@ -12603,19 +12606,21 @@
 		longAtput((sp2 = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
 		GIV(stackPointer) = sp2;
 	}
-	if (		((((sqInt) methodHeader)) < 0
+	if (((((sqInt) methodHeader)) < 0
 				? methodHeader & (65536 << SmallIntegerShift)
 				: (methodHeader & 536871934) != 0)) {
 
 		/* Store the error code if the method starts with a long store temp.  No instructionPointer skip because we're heading for machine code. */
 
-		initialPC = (GIV(newMethod) + ((LiteralStart + (	((((sqInt) methodHeader)) < 0
+		initialPC = ((GIV(newMethod) + ((LiteralStart + (((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
-		: (((usqInt) methodHeader) >> 10) & 255))) * BytesPerWord)) + BaseHeaderSize;
-		if (			((((sqInt) methodHeader)) < 0
-						? (byteAt((pointerForOop(initialPC)) + 3)) == 234
-						: (byteAt(pointerForOop(initialPC))) == 129)) {
-			if (GIV(primFailCode) != 0) {
+		: (((usqInt) methodHeader) >> 10) & 255))) * BytesPerWord)) + BaseHeaderSize) + (((((sqInt) methodHeader)) < 0
+		? 3
+		: 0));
+		if (GIV(primFailCode) != 0) {
+			if ((byteAt(initialPC)) == (((((sqInt) methodHeader)) < 0
+		? 234
+		: 129))) {
 				/* begin getErrorObjectFromPrimFailCode */
 				if (GIV(primFailCode) > 0) {
 					table = longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (PrimErrTableIndex << ShiftForWord));
@@ -12707,11 +12712,11 @@
 	/* begin push: */
 	longAtput((sp3 = GIV(stackPointer) - BytesPerWord), GIV(newMethod));
 	GIV(stackPointer) = sp3;
-	/* begin setMethod: */
-	assert((((usqInt)GIV(newMethod))) >= (startOfMemory()));
+	/* begin setMethod:methodHeader: */
 	GIV(method) = GIV(newMethod);
 	assert(isOopCompiledMethod(GIV(method)));
-	GIV(bytecodeSetSelector) = (methodUsesAlternateBytecodeSet(GIV(method))
+	assert((headerOf(GIV(method))) == methodHeader);
+	GIV(bytecodeSetSelector) = ((((sqInt) methodHeader)) < 0
 		? 256
 		: 0);
 
@@ -12743,20 +12748,23 @@
 		longAtput((sp = GIV(stackPointer) - BytesPerWord), GIV(nilObj));
 		GIV(stackPointer) = sp;
 	}
-	GIV(instructionPointer) = ((GIV(newMethod) + ((LiteralStart + (	((((sqInt) methodHeader)) < 0
+	GIV(instructionPointer) = ((GIV(newMethod) + ((LiteralStart + (((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255))) * BytesPerWord)) + BaseHeaderSize) - 1;
-	if (		((((sqInt) methodHeader)) < 0
+	if (((((sqInt) methodHeader)) < 0
 				? methodHeader & (65536 << SmallIntegerShift)
 				: (methodHeader & 536871934) != 0)) {
 
-		/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method
-		   starts with a long store temp.  Strictly no need to skip the store because it's a noop. */
+		/* Skip the CallPrimitive bytecode, if it's there, and store the error code if the method starts
+		   with a long store temp.  Strictly no need to skip the store because it's effectively a noop. */
 
-		if (			((((sqInt) methodHeader)) < 0
-						? (byteAt((GIV(instructionPointer) + 1) + 3)) == 234
-						: (byteAt(GIV(instructionPointer) + 1)) == 129)) {
-			if (GIV(primFailCode) != 0) {
+		GIV(instructionPointer) += ((((sqInt) methodHeader)) < 0
+						? 3
+						: 0);
+		if (GIV(primFailCode) != 0) {
+			if ((byteAt(GIV(instructionPointer) + 1)) == (((((sqInt) methodHeader)) < 0
+		? 234
+		: 129))) {
 				/* begin getErrorObjectFromPrimFailCode */
 				if (GIV(primFailCode) > 0) {
 					table = longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (PrimErrTableIndex << ShiftForWord));
@@ -12771,9 +12779,6 @@
 			}
 			GIV(primFailCode) = 0;
 		}
-		GIV(instructionPointer) += 			((((sqInt) methodHeader)) < 0
-						? 3
-						: 0);
 	}
 	switched = 1;
 	if (GIV(stackPointer) < GIV(stackLimit)) {
@@ -12888,7 +12893,7 @@
 			? (assert(((((CogMethod *) methodHeader1)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 				(((CogMethod *) methodHeader1)->methodHeader))
 			: methodHeader1);
-		primitiveIndex = 			((((sqInt) methodHeader)) < 0
+		primitiveIndex = ((((sqInt) methodHeader)) < 0
 						? (methodHeader & (65536 << SmallIntegerShift)
 								? ((firstBytecode = (GIV(newMethod) + ((LiteralStart + ((((usqInt) methodHeader) >> 1) & 65535)) * BytesPerWord)) + BaseHeaderSize),
 									(byteAt(firstBytecode + 1)) + ((byteAt(firstBytecode + 2)) << 8))
@@ -13137,7 +13142,7 @@
 		? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader)->methodHeader))
 		: methodHeader);
-	numLiterals = 		((((sqInt) headerPointer)) < 0
+	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
 	fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
@@ -13351,7 +13356,6 @@
 attemptToSwitchToMachineCode(sqInt bcpc)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt aCompiledMethodHeader;
-    sqInt aMethodOop;
     sqInt closure;
     CogMethod *cogMethod;
     CogBlockMethod *cogMethod1;
@@ -13373,8 +13377,7 @@
 	}
 	if (methodHasCogMethod(GIV(method))) {
 		/* begin cogMethodOf: */
-		aMethodOop = GIV(method);
-		methodHeader = longAt((aMethodOop + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+		methodHeader = longAt((GIV(method) + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
 		assert((isNonIntegerObject(methodHeader))
 		 && ((((usqInt)methodHeader)) < (startOfMemory())));
 		cogMethod = ((CogMethod *) methodHeader);
@@ -13406,7 +13409,7 @@
 		else {
 			/* begin startPCOfMethodHeader: */
 			aCompiledMethodHeader = (cogMethod->methodHeader);
-			startBcpc = ((	((((sqInt) aCompiledMethodHeader)) < 0
+			startBcpc = ((((((sqInt) aCompiledMethodHeader)) < 0
 		? (((usqInt) aCompiledMethodHeader) >> 1) & 65535
 		: (((usqInt) aCompiledMethodHeader) >> 10) & 255)) * BytesPerWord) + BaseHeaderSize;
 			cogMethod2 = ((CogBlockMethod *) cogMethod);
@@ -13585,7 +13588,7 @@
 			? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 				(((CogMethod *) methodHeader)->methodHeader))
 			: methodHeader);
-		numLiterals = 			((((sqInt) headerPointer)) < 0
+		numLiterals = ((((sqInt) headerPointer)) < 0
 						? (((usqInt) headerPointer) >> 1) & 65535
 						: (((usqInt) headerPointer) >> 10) & 255);
 		fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
@@ -13947,7 +13950,7 @@
     sqInt primBits;
     sqInt primitiveIndex;
 
-	primitiveIndex = 		((((sqInt) methodHeader)) < 0
+	primitiveIndex = ((((sqInt) methodHeader)) < 0
 				? (methodHeader & (65536 << SmallIntegerShift)
 						? ((firstBytecode = (theMethod + ((LiteralStart + ((((usqInt) methodHeader) >> 1) & 65535)) * BytesPerWord)) + BaseHeaderSize),
 							(byteAt(firstBytecode + 1)) + ((byteAt(firstBytecode + 2)) << 8))
@@ -14366,7 +14369,7 @@
 			}
 		}
 		else {
-			if ((	((((sqInt) methodHeader)) < 0
+			if ((((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile) {
 				cogselector(GIV(newMethod), selector);
@@ -14464,7 +14467,7 @@
 		? (assert(((((CogMethod *) methodHeader1)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader1)->methodHeader))
 		: methodHeader1);
-	primitiveIndex = 		((((sqInt) methodHeader)) < 0
+	primitiveIndex = ((((sqInt) methodHeader)) < 0
 				? (methodHeader & (65536 << SmallIntegerShift)
 						? ((firstBytecode = (aMethodObj + ((LiteralStart + ((((usqInt) methodHeader) >> 1) & 65535)) * BytesPerWord)) + BaseHeaderSize),
 							(byteAt(firstBytecode + 1)) + ((byteAt(firstBytecode + 2)) << 8))
@@ -14529,7 +14532,7 @@
 			? (assert(((((CogMethod *) methodHeader1)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 				(((CogMethod *) methodHeader1)->methodHeader))
 			: methodHeader1);
-		primitiveIndex = 			((((sqInt) methodHeader)) < 0
+		primitiveIndex = ((((sqInt) methodHeader)) < 0
 						? (methodHeader & (65536 << SmallIntegerShift)
 								? ((firstBytecode = (aMethodObj + ((LiteralStart + ((((usqInt) methodHeader) >> 1) & 65535)) * BytesPerWord)) + BaseHeaderSize),
 									(byteAt(firstBytecode + 1)) + ((byteAt(firstBytecode + 2)) << 8))
@@ -14981,7 +14984,7 @@
 			}
 		}
 		else {
-			if ((	((((sqInt) methodHeader)) < 0
+			if ((((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile) {
 				cogselector(GIV(newMethod), selector);
@@ -15079,7 +15082,7 @@
 			}
 		}
 		else {
-			if ((	((((sqInt) methodHeader)) < 0
+			if ((((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile) {
 				cogselector(GIV(newMethod), selector);
@@ -15223,7 +15226,7 @@
 			}
 		}
 		else {
-			if ((	((((sqInt) methodHeader)) < 0
+			if ((((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile) {
 				cogselector(GIV(newMethod), selector);
@@ -17251,7 +17254,7 @@
 		? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader)->methodHeader))
 		: methodHeader);
-	numLiterals = 		((((sqInt) headerPointer)) < 0
+	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
 	fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
@@ -17316,7 +17319,7 @@
 		? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader)->methodHeader))
 		: methodHeader);
-	numLiterals = 		((((sqInt) headerPointer)) < 0
+	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
 	fieldOffset = (numLiterals * BytesPerWord) + BaseHeaderSize;
@@ -17384,6 +17387,29 @@
 }
 
 
+/*	For asserts. Check that theIP maps back correctly to the context's pc.
+	The CallPrimitive bytecode presents a complication. */
+
+static sqInt
+contexthasValidInversePCMappingOfin(sqInt aContext, sqInt theIP, char *theFP)
+{
+    sqInt encodedip;
+    sqInt methodHeader;
+    sqInt pc;
+
+	pc = longAt((aContext + BaseHeaderSize) + (InstructionPointerIndex << ShiftForWord));
+	encodedip = contextInstructionPointerframe(theIP, theFP);
+	return (pc == encodedip)
+			 || (((methodHeader = headerOf(longAt((aContext + BaseHeaderSize) + (MethodIndex << ShiftForWord)))),
+			(((((sqInt) methodHeader)) < 0
+				? methodHeader & (65536 << SmallIntegerShift)
+				: (methodHeader & 536871934) != 0))
+				 && ((((encodedip >> 1)) - ((pc >> 1))) == (((((sqInt) methodHeader)) < 0
+				? 3
+				: 0)))));
+}
+
+
 /*	This entry point needs to be implemented for the interpreter proxy.
 	Since BitBlt is now a plugin we need to look up BitBltPlugin:=copyBits
 	and call it. This entire mechanism should eventually go away and be
@@ -19381,7 +19407,7 @@
 	}
 	methodHeader = longAt((GIV(newMethod) + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
 	if (!(isCogMethodReference(methodHeader))) {
-		if ((	((((sqInt) methodHeader)) < 0
+		if ((((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile) {
 			cogselector(GIV(newMethod), GIV(nilObj));
@@ -20195,7 +20221,7 @@
 		? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader)->methodHeader))
 		: methodHeader);
-	numLiterals = 		((((sqInt) headerPointer)) < 0
+	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
 	lastField = (numLiterals * BytesPerWord) + BaseHeaderSize;
@@ -20554,7 +20580,7 @@
 			}
 		}
 		else {
-			if ((	((((sqInt) methodHeader)) < 0
+			if ((((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile) {
 				cogselector(GIV(newMethod), GIV(messageSelector));
@@ -21024,7 +21050,7 @@
 					? (assert(((((CogMethod *) methodHeader1)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 						(((CogMethod *) methodHeader1)->methodHeader))
 					: methodHeader1);
-				primIdx = 					((((sqInt) methodHeader)) < 0
+				primIdx = ((((sqInt) methodHeader)) < 0
 										? (methodHeader & (65536 << SmallIntegerShift)
 												? ((firstBytecode = (oop + ((LiteralStart + ((((usqInt) methodHeader) >> 1) & 65535)) * BytesPerWord)) + BaseHeaderSize),
 													(byteAt(firstBytecode + 1)) + ((byteAt(firstBytecode + 2)) << 8))
@@ -21828,7 +21854,7 @@
 			}
 		}
 		else {
-			if ((	((((sqInt) methodHeader)) < 0
+			if ((((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile) {
 				cogselector(GIV(newMethod), GIV(messageSelector));
@@ -21895,6 +21921,7 @@
     StackPage *newPage;
     sqInt overflowCount;
     char *overflowLimitAddress;
+    sqInt source;
     char *theFP;
     StackPage *thePage;
     char *theSP;
@@ -21907,6 +21934,17 @@
 	if (!(GIV(stackPointer) < ((GIV(stackPage)->realStackLimit)))) {
 		return;
 	}
+	/* begin maybeTraceStackOverflow */
+	if (recordOverflowTrace()) {
+		/* begin recordTrace:thing:source: */
+		source = ((((usqInt)(longAt(GIV(framePointer) + FoxMethod)))) < (startOfMemory())
+			? TraceIsFromMachineCode
+			: TraceIsFromInterpreter);
+		GIV(traceLog)[GIV(traceLogIndex)] = TraceStackOverflow;
+		GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceStackOverflow;
+		GIV(traceLog)[GIV(traceLogIndex) + 2] = source;
+		GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize;
+	}
 
 	/* The stack has overflowed this page.  If the system is executing some recursive algorithm,
 	   e.g. fibonacci, then the system could thrash overflowing the stack if the call soon returns
@@ -23275,7 +23313,7 @@
 sqInt
 initialPCForHeadermethod(sqInt methodHeader, sqInt theMethod)
 {
-	return (theMethod + ((LiteralStart + (	((((sqInt) methodHeader)) < 0
+	return (theMethod + ((LiteralStart + (((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255))) * BytesPerWord)) + BaseHeaderSize;
 }
@@ -24079,7 +24117,8 @@
 	return (((lit & 1) == 0)
  && (((((usqInt) (longAt(lit))) >> 8) & 15) == 2))
 	 && (((lengthOf(lit)) == 4)
-	 && ((longAt((lit + BaseHeaderSize) + (3 << ShiftForWord))) == ConstZero));
+	 && (((longAt((lit + BaseHeaderSize) + (3 << ShiftForWord))) == ConstZero)
+	 || ((longAt((lit + BaseHeaderSize) + (3 << ShiftForWord))) == ConstMinusOne)));
 }
 
 
@@ -24445,7 +24484,7 @@
 		? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader)->methodHeader))
 		: methodHeader);
-	numLiterals = 		((((sqInt) headerPointer)) < 0
+	numLiterals = ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
 	return (numLiterals * BytesPerWord) + BaseHeaderSize;
@@ -24564,7 +24603,7 @@
 sqInt
 literalCountOfHeader(sqInt headerPointer)
 {
-	return 		((((sqInt) headerPointer)) < 0
+	return ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
 }
@@ -24582,7 +24621,7 @@
 		? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader)->methodHeader))
 		: methodHeader);
-	return 		((((sqInt) headerPointer)) < 0
+	return ((((sqInt) headerPointer)) < 0
 				? (((usqInt) headerPointer) >> 1) & 65535
 				: (((usqInt) headerPointer) >> 10) & 255);
 }
@@ -25117,7 +25156,7 @@
 		column = 1;
 		for (index = startIP; index <= lastIndex; index += 1) {
 			if (column == 1) {
-				printf("%08x: ", oop+index-1);
+				printf("0x%08x: ", oop+BaseHeaderSize+index-1);
 			}
 			byte = byteAt((oop + BaseHeaderSize) + (index - 1));
 			printf(" %02x/%-3d", byte,byte);
@@ -25154,7 +25193,10 @@
     sqInt header;
     sqInt header1;
     sqInt header2;
+    sqInt header3;
+    sqInt headerPointer;
     sqInt i;
+    sqInt methodHeader;
     sqInt obj;
     sqInt obj1;
     sqInt oop;
@@ -25162,6 +25204,7 @@
     sqInt sz;
     sqInt sz1;
     sqInt sz2;
+    sqInt sz3;
 
 	prntObj = 0;
 	/* begin firstAccessibleObject */
@@ -25172,7 +25215,7 @@
 	while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
 		if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
 			oop = obj1;
-			goto l2;
+			goto l3;
 		}
 		/* begin objectAfter: */
 		if (DoAssertionChecks) {
@@ -25181,37 +25224,68 @@
 			}
 		}
 		if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
-			sz = (longAt(obj1)) & AllButTypeMask;
+			sz1 = (longAt(obj1)) & AllButTypeMask;
 		}
 		else {
 			/* begin sizeBitsOf: */
-			header = longAt(obj1);
-			sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+			header1 = longAt(obj1);
+			sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
 				? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
-				: header & SizeMask);
+				: header1 & SizeMask);
 		}
-		obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+		obj1 = (obj1 + sz1) + (headerTypeBytes[(longAt(obj1 + sz1)) & TypeMask]);
 	}
 	error("heap is empty");
 	oop = null;
-l2:	/* end firstAccessibleObject */;
+l3:	/* end firstAccessibleObject */;
 	while (!(oop == null)) {
 		if ((((oop & 1) == 0)
  && (((((usqInt) (longAt(oop))) >> 8) & 15) <= 4))
 		 || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
 			if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
-				i = (literalCountOfHeader(headerOf(oop))) - 1;
+				/* 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);
 			}
 			else {
 				if (((oop & 1) == 0)
 				 && (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex)) {
-					i = (CtxtTempFrameStart + (fetchStackPointerOf(oop))) - 1;
+					i = CtxtTempFrameStart + (fetchStackPointerOf(oop));
 				}
 				else {
-					i = (lengthOf(oop)) - 1;
+					/* begin lengthOf: */
+					header = longAt(oop);
+					/* begin lengthOf:baseHeader:format: */
+					if ((header & TypeMask) == HeaderTypeSizeAndClass) {
+						sz = (longAt(oop - (BytesPerWord * 2))) & LongSizeMask;
+					}
+					else {
+						sz = header & SizeMask;
+					}
+					sz -= header & Size4Bit;
+					if (((((usqInt) header) >> 8) & 15) <= 4) {
+						i = ((usqInt) (sz - BaseHeaderSize)) >> ShiftForWord;
+						goto l1;
+					}
+					if (((((usqInt) header) >> 8) & 15) < 8) {
+						i = ((usqInt) (sz - BaseHeaderSize)) >> 2;
+						goto l1;
+					}
+					else {
+						i = (sz - BaseHeaderSize) - (((((usqInt) header) >> 8) & 15) & 3);
+						goto l1;
+					}
+				l1:	/* end lengthOf: */;
 				}
 			}
-			while (i >= 0) {
+			while (((i -= 1)) >= 0) {
 				if (anOop == (longAt((oop + BaseHeaderSize) + (i << ShiftForWord)))) {
 					printHex(oop);
 					print(" @ ");
@@ -25221,7 +25295,6 @@
 					prntObj = 1;
 					i = 0;
 				}
-				i -= 1;
 			}
 			if (prntObj) {
 				prntObj = 0;
@@ -25236,20 +25309,20 @@
 			}
 		}
 		if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
-			sz2 = (longAt(oop)) & AllButTypeMask;
+			sz3 = (longAt(oop)) & AllButTypeMask;
 		}
 		else {
 			/* begin sizeBitsOf: */
-			header2 = longAt(oop);
-			sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
+			header3 = longAt(oop);
+			sz3 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
 				? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
-				: header2 & SizeMask);
+				: header3 & SizeMask);
 		}
-		obj = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+		obj = (oop + sz3) + (headerTypeBytes[(longAt(oop + sz3)) & TypeMask]);
 		while ((((usqInt) obj)) < (((usqInt) GIV(freeStart)))) {
 			if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
 				oop = obj;
-				goto l1;
+				goto l2;
 			}
 			/* begin objectAfter: */
 			if (DoAssertionChecks) {
@@ -25258,23 +25331,39 @@
 				}
 			}
 			if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
-				sz1 = (longAt(obj)) & AllButTypeMask;
+				sz2 = (longAt(obj)) & AllButTypeMask;
 			}
 			else {
 				/* begin sizeBitsOf: */
-				header1 = longAt(obj);
-				sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+				header2 = longAt(obj);
+				sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
 					? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
-					: header1 & SizeMask);
+					: header2 & SizeMask);
 			}
-			obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+			obj = (obj + sz2) + (headerTypeBytes[(longAt(obj + sz2)) & TypeMask]);
 		}
 		oop = null;
-	l1:	/* end accessibleObjectAfter: */;
+	l2:	/* end accessibleObjectAfter: */;
 	}
 }
 
 
+/*	Answer the relevant long store temp bytecode, which indicates it has a
+	primitive error code.
+ */
+/*	234		11101010	i i i i i i i i	Store Temporary Variable #iiiiiiii */
+/*	129 10000001 jjkkkkkk Store (Receiver Variable, Temporary Location,
+	Illegal, Literal Variable) [jj] #kkkkkk */
+
+sqInt
+longStoreBytecodeForHeader(sqInt methodHeader)
+{
+	return ((((sqInt) methodHeader)) < 0
+				? 234
+				: 129);
+}
+
+
 /*	This method implements a simple method lookup cache. If an entry for the
 	given selector and class is found in the cache, set the values of
 	'newMethod' and 'primitiveFunctionPointer' and return true. Otherwise,
@@ -25582,6 +25671,8 @@
 static StackPage *
 makeBaseFrameFor(sqInt aContext)
 {   DECL_MAYBE_SQ_GLOBAL_STRUCT
+    CogMethod *cogMethod;
+    CogMethod *cogMethod1;
     sqInt header;
     sqInt i;
     StackPage *lruOrFree;
@@ -25592,6 +25683,7 @@
     sqInt oop1;
     StackPage *page;
     char *pointer;
+    sqInt rawHeader;
     sqInt stackPtrIndex;
     sqInt theIP;
     sqInt theMethod;
@@ -25610,11 +25702,11 @@
 	lruOrFree = (mostRecentlyUsedPage()->nextPage);
 	if (isFree(lruOrFree)) {
 		page = lruOrFree;
-		goto l1;
+		goto l2;
 	}
 	divorceFramesIn(lruOrFree);
 	page = lruOrFree;
-l1:	/* end newStackPage */;
+l2:	/* end newStackPage */;
 	longAtput((pointer = (page->baseAddress)), longAt((aContext + BaseHeaderSize) + (SenderIndex << ShiftForWord)));
 	longAtput((pointer -= BytesPerWord), aContext);
 	maybeClosure = longAt((aContext + BaseHeaderSize) + (ClosureIndex << ShiftForWord));
@@ -25626,8 +25718,6 @@
 		longAtput((pointer -= BytesPerWord), maybeClosure);
 	}
 	else {
-		/* begin argumentCountOf: */
-		/* begin argumentCountOfMethodHeader: */
 		/* begin headerOf: */
 		methodHeader = longAt((theMethod + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
 		header = (isCogMethodReference(methodHeader)
@@ -25635,6 +25725,19 @@
 				(((CogMethod *) methodHeader)->methodHeader))
 			: methodHeader);
 		numArgs = (((usqInt) header) >> 25) & 15;
+		
+		/* If this is a synthetic context its IP could be pointing at the CallPrimitive opcode.  If so, skip it. */
+
+		if (((((sqInt) theIP)) > 0)
+		 && ((((((sqInt) header)) < 0
+		? header & (65536 << SmallIntegerShift)
+		: (header & 536871934) != 0))
+		 && (theIP == (1 + (lastPointerOf(theMethod)))))) {
+			theIP += ((((sqInt) header)) < 0
+								? 3
+								: 0);
+		}
+
 		longAtput((pointer -= BytesPerWord), longAt((aContext + BaseHeaderSize) + (ReceiverIndex << ShiftForWord)));
 	}
 	for (i = 1; i <= numArgs; i += 1) {
@@ -25649,17 +25752,23 @@
 		   the native pc anyway we should create a native method and native frame. */
 
 		/* begin ensureMethodIsCogged: */
-		if (!(methodHasCogMethod(theMethod))) {
-			if (((cogselector(theMethod, GIV(nilObj))) == null)
-			 && (GIV(cogCompiledCodeCompactionCalledFor))) {
-				commenceCogCompiledCodeCompaction();
-				cogselector(theMethod, GIV(nilObj));
-			}
+		rawHeader = longAt((theMethod + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
+		if (isCogMethodReference(rawHeader)) {
+			cogMethod = ((CogMethod *) rawHeader);
+			goto l1;
 		}
-		if (!(asserta(methodHasCogMethod(theMethod)))) {
+		cogMethod1 = cogselector(theMethod, GIV(nilObj));
+		if ((cogMethod1 == null)
+		 && (GIV(cogCompiledCodeCompactionCalledFor))) {
+			commenceCogCompiledCodeCompaction();
+			cogMethod1 = cogselector(theMethod, GIV(nilObj));
+		}
+		if (!(asserta(cogMethod1 != null))) {
 			error("could not compile method that should have been compiled");
 		}
-		theMethod = ((sqInt)(cogMethodOf(theMethod)));
+		cogMethod = cogMethod1;
+	l1:	/* end ensureMethodIsCogged: */;
+		theMethod = ((sqInt)cogMethod);
 		if (maybeClosure != GIV(nilObj)) {
 
 			/* If the pc is the special HasBeenReturnedFromMCPC pc set the pc
@@ -25720,8 +25829,8 @@
 		longAtput((pointer -= BytesPerWord), longAt((aContext + BaseHeaderSize) + ((ReceiverIndex + i) << ShiftForWord)));
 	}
 	longAtput((pointer -= BytesPerWord), theIP);
-	assert((fetchPointerofObject(InstructionPointerIndex, aContext)) == (contextInstructionPointerframe(theIP, (page->baseFP))));
 	(page->headSP = pointer);
+	assert(contexthasValidInversePCMappingOfin(aContext, theIP, (page->baseFP)));
 	/* begin storePointerUnchecked:ofObject:withValue: */
 	/* begin withSmallIntegerTags: */
 	value = (page->baseFP);
@@ -26552,7 +26661,7 @@
 		? (assert(((((CogMethod *) methodHeader1)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader1)->methodHeader))
 		: methodHeader1);
-	numLiterals1 = 		((((sqInt) headerPointer1)) < 0
+	numLiterals1 = ((((sqInt) headerPointer1)) < 0
 				? (((usqInt) headerPointer1) >> 1) & 65535
 				: (((usqInt) headerPointer1) >> 10) & 255);
 	lastFieldOffset = (numLiterals1 * BytesPerWord) + BaseHeaderSize;
@@ -26708,7 +26817,7 @@
 				? (assert(((((CogMethod *) methodHeader)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 					(((CogMethod *) methodHeader)->methodHeader))
 				: methodHeader);
-			numLiterals = 				((((sqInt) headerPointer)) < 0
+			numLiterals = ((((sqInt) headerPointer)) < 0
 								? (((usqInt) headerPointer) >> 1) & 65535
 								: (((usqInt) headerPointer) >> 10) & 255);
 			lastFieldOffset1 = (numLiterals * BytesPerWord) + BaseHeaderSize;
@@ -27245,7 +27354,7 @@
     sqInt offset1;
     sqInt oop;
 
-	return 		(/* begin literal:ofMethod: */
+	return (/* begin literal:ofMethod: */
 			(offset = (literalCountOfHeader(headerOf(methodPointer))) - 1),
 			(literal = longAt((methodPointer + BaseHeaderSize) + ((offset + LiteralStart) << ShiftForWord))),
 			(literal == GIV(nilObj)
@@ -27266,19 +27375,17 @@
 }
 
 
-/*	Answer if the method starts with a long store temp bytecode, which
-	indicates it has a primitive error code.
- */
-/*	234		11101010	i i i i i i i i	Store Temporary Variable #iiiiiiii */
-/*	129 10000001 jjkkkkkk Store (Receiver Variable, Temporary Location,
-	Illegal, Literal Variable) [jj] #kkkkkk */
+/*	Note: We now have 10 bits of primitive index, but they are in two places
+	for temporary backward compatibility. The time to unpack is negligible,
+	since the derived primitive function pointer is stored in the method
+	cache.  */
 
-sqInt
-methodHasErrorCodeheaderinitialIP(sqInt aMethodObj, sqInt methodHeader, char *initialPC)
+static sqInt
+methodHeaderHasPrimitive(sqInt methodHeader)
 {
-	return 		((((sqInt) methodHeader)) < 0
-				? (byteAt(initialPC + 3)) == 234
-				: (byteAt(initialPC)) == 129);
+	return ((((sqInt) methodHeader)) < 0
+				? methodHeader & (65536 << SmallIntegerShift)
+				: (methodHeader & 536871934) != 0);
 }
 
 sqInt
@@ -27304,7 +27411,7 @@
 		? (assert(((((CogMethod *) methodHeader1)->objectHeader)) == (nullHeaderForMachineCodeMethod())),
 			(((CogMethod *) methodHeader1)->methodHeader))
 		: methodHeader1);
-	return 		((((sqInt) methodHeader)) < 0
+	return ((((sqInt) methodHeader)) < 0
 				? (methodHeader & (65536 << SmallIntegerShift)
 						? ((firstBytecode = (GIV(newMethod) + ((LiteralStart + ((((usqInt) methodHeader) >> 1) & 65535)) * BytesPerWord)) + BaseHeaderSize),
 							(byteAt(firstBytecode + 1)) + ((byteAt(firstBytecode + 2)) << 8))
@@ -27382,7 +27489,7 @@
 static sqInt
 methodWithHeaderShouldBeCogged(sqInt methodHeader)
 {
-	return (	((((sqInt) methodHeader)) < 0
+	return (((((sqInt) methodHeader)) < 0
 		? (((usqInt) methodHeader) >> 1) & 65535
 		: (((usqInt) methodHeader) >> 10) & 255)) <= maxLiteralCountForCompile;
 }
@@ -27541,7 +27648,7 @@
 		if (mnuMethod != null) {
 			methodHeader = longAt((mnuMethod + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
 			if ((!(isCogMethodReference(methodHeader)))

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list