[Vm-dev] [commit][2894] CogVM source as per VMMaker.oscog-eem.674

commits at squeakvm.org commits at squeakvm.org
Mon Apr 14 22:32:18 UTC 2014


Revision: 2894
Author:   eliot
Date:     2014-04-14 15:32:11 -0700 (Mon, 14 Apr 2014)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.674

Deal with the pc ambiguity of conditional branches followed by backward branches
(conditional branches map to the following pc, backward branches to themselves)
by providing and using mcPCForBackwardBranch:startBcpc:in: when converting
interpreted frames containing loops to machine code frames.  This eliminates a
bogus mustBeBoolean when converting interpreter loops in Sista.

Change mcPCFor[BackwardBranch]:startBcpc:in: to answer the absolute mcpc (as was
commented) rather than the relative mcpc.

This requires a 5-argument perform in mapFor:bcpc:performUntil:arg:.  Refactor
to add an isBackwardBranch argument to the function perfomed in all clients.

For performance, specify that mapFor:[bcpc:]performUntil:arg: are
inlined, eliminating the perform/indirect function call.  This adds of
the order of 3% to the size of a cogit.o's text seg so is acceptable.

Fix a bug in printing frame flags (order was the wrong way around).

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/nsspursrc/vm/cogit.c
    branches/Cog/nsspursrc/vm/cogit.h
    branches/Cog/nsspursrc/vm/cogmethod.h
    branches/Cog/nsspursrc/vm/cointerp.c
    branches/Cog/nsspursrc/vm/cointerp.h
    branches/Cog/nsspursrc/vm/gcc3x-cointerp.c
    branches/Cog/nsspursrc/vm/interp.h
    branches/Cog/nsspursrc/vm/vmCallback.h
    branches/Cog/sistasrc/vm/cogit.c
    branches/Cog/sistasrc/vm/cogit.h
    branches/Cog/sistasrc/vm/cogmethod.h
    branches/Cog/sistasrc/vm/cointerp.c
    branches/Cog/sistasrc/vm/cointerp.h
    branches/Cog/sistasrc/vm/gcc3x-cointerp.c
    branches/Cog/sistasrc/vm/interp.h
    branches/Cog/sistasrc/vm/vmCallback.h
    branches/Cog/spursistasrc/vm/cogit.c
    branches/Cog/spursistasrc/vm/cogit.h
    branches/Cog/spursistasrc/vm/cogmethod.h
    branches/Cog/spursistasrc/vm/cointerp.c
    branches/Cog/spursistasrc/vm/cointerp.h
    branches/Cog/spursistasrc/vm/gcc3x-cointerp.c
    branches/Cog/spursistasrc/vm/interp.h
    branches/Cog/spursistasrc/vm/vmCallback.h
    branches/Cog/spursrc/vm/cogit.c
    branches/Cog/spursrc/vm/cogit.h
    branches/Cog/spursrc/vm/cogmethod.h
    branches/Cog/spursrc/vm/cointerp.c
    branches/Cog/spursrc/vm/cointerp.h
    branches/Cog/spursrc/vm/gcc3x-cointerp.c
    branches/Cog/spursrc/vm/interp.h
    branches/Cog/spursrc/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	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/cogit.c	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGenerator VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	StackToRegisterMappingCogit VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -564,10 +564,9 @@
 static CogMethod * fillInOPICHeadersizenumArgsselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt selector);
 static usqInt findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc);
 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 CogMethod * findPreviouslyCompiledVersionOfwith(sqInt aMethodObj, sqInt aSelectorOop);
+static sqInt findIsBackwardBranchMcpcBcpcMatchingMcpc(BytecodeDescriptor *descriptor, sqInt isBackwardBranch, char *mcpc, sqInt bcpc, void *targetMcpc);
 static sqInt frameOffsetOfTemporary(sqInt index);
 static void freeMethod(CogMethod *cogMethod);
 static void freeOlderMethodsForCompaction(void);
@@ -907,7 +906,6 @@
 static sqInt machineCodeBytes(AbstractInstruction * self_in_machineCodeBytes);
 static void manageFromto(sqInt theStartAddress, sqInt theLimitAddress);
 static sqInt mapEndFor(CogMethod *cogMethod);
-static sqInt mapForbcpcperformUntilarg(CogBlockMethod *cogMethod, sqInt startbcpc, sqInt (*functionSymbol)(char *mcpc, sqInt bcpc, void *arg), void *arg);
 static sqInt mapForperformUntilarg(CogMethod *cogMethod, int (*functionSymbol)(sqInt annotation, char *mcpc, sqInt arg), sqInt arg);
 static sqInt mapObjectReferencesInClosedPIC(CogMethod *cPIC);
 static void mapObjectReferencesInGeneratedRuntime(void);
@@ -933,7 +931,7 @@
 static sqInt maybeFreeCogMethodDoesntLookKosher(CogMethod *cogMethod);
 static sqInt maybeGenerateCheckFeatures(void);
 static sqInt maybeGenerateICacheFlush(void);
-sqInt mcPCForstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
+usqInt mcPCForBackwardBranchstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
 static CogSimStackEntry * mergeAtfrom(CogSimStackEntry * self_in_mergeAtfrom, sqInt baseOffset, sqInt baseRegister);
 static void mergeafterContinuation(BytecodeFixup *fixup, sqInt mergeWithContinuation);
 static sqInt methodAbortTrampolineFor(sqInt numArgs);
@@ -2523,7 +2521,156 @@
 sqInt
 bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod)
 {
-	return mapForbcpcperformUntilarg(cogMethod, startbcpc, findMcpcBcpcMatchingMcpc, ((void *)mcpc));
+    sqInt aMethodObj;
+    sqInt annotation;
+    sqInt bcpc;
+    sqInt bsOffset;
+    sqInt byte;
+    BytecodeDescriptor *descriptor;
+    sqInt distance;
+    sqInt endbcpc;
+    CogMethod *homeMethod;
+    sqInt isBackwardBranch;
+    sqInt isInBlock;
+    sqInt latestContinuation;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc1;
+    sqInt methodHeader;
+    sqInt methodHeader1;
+    sqInt nExts;
+    sqInt nextBcpc;
+    sqInt result;
+    sqInt targetPC;
+
+	/* begin mapFor:bcpc:performUntil:arg: */
+	assert(((cogMethod->stackCheckOffset)) > 0);
+	if (((cogMethod->cmType)) == CMMethod) {
+		isInBlock = 0;
+		homeMethod = ((CogMethod *) cogMethod);
+		assert(startbcpc == (startPCOfMethodHeader((homeMethod->methodHeader))));
+		map = ((((usqInt)homeMethod)) + ((homeMethod->blockSize))) - 1;
+		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == IsAbsPCReference)
+		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsObjectReference)
+		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsRelativeCall)
+		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N))));
+		latestContinuation = startbcpc;
+		aMethodObj = (homeMethod->methodObject);
+		endbcpc = (byteLengthOf(aMethodObj)) - 1;
+		/* begin bytecodeSetOffsetForHeader: */
+		methodHeader = (homeMethod->methodHeader);
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader)
+						? 256
+						: 0);
+	}
+	else {
+		isInBlock = 1;
+		homeMethod = cmHomeMethod(cogMethod);
+		map = findMapLocationForMcpcinMethod((((usqInt)cogMethod)) + (sizeof(CogBlockMethod)), homeMethod);
+		assert(map != 0);
+		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == HasBytecodePC)
+		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N));
+		while ((((usqInt) (byteAt(map))) >> AnnotationShift) != HasBytecodePC) {
+			map -= 1;
+		}
+
+		/* skip fiducial; i.e. the map entry for the pc immediately following the method header. */
+
+		map -= 1;
+		aMethodObj = (homeMethod->methodObject);
+		bcpc = startbcpc - (blockCreationBytecodeSizeForHeader((homeMethod->methodHeader)));
+		/* begin bytecodeSetOffsetForHeader: */
+		methodHeader1 = (homeMethod->methodHeader);
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader1)
+						? 256
+						: 0);
+		byte = (fetchByteofObject(bcpc, aMethodObj)) + bsOffset;
+		descriptor = generatorAt(byte);
+		endbcpc = (bcpc + ((descriptor->numBytes))) + (((descriptor->isBlockCreation)
+	? ((descriptor->spanFunction))(descriptor, bcpc, -1, aMethodObj)
+	: 0));
+	}
+	bcpc = startbcpc;
+	mcpc1 = (((usqInt)cogMethod)) + ((cogMethod->stackCheckOffset));
+
+	/* The stack check maps to the start of the first bytecode,
+	   the first bytecode being effectively after frame build. */
+
+	nExts = 0;
+	result = findIsBackwardBranchMcpcBcpcMatchingMcpc(null, 0, (((char *) mcpc1)), startbcpc, (((void *)mcpc)));
+	if (result != 0) {
+		return result;
+	}
+	while ((((usqInt) (byteAt(map))) >> AnnotationShift) != HasBytecodePC) {
+		map -= 1;
+	}
+	map -= 1;
+	while (((mapByte = byteAt(map))) != MapEnd) {
+
+		/* defensive; we exit on bcpc */
+
+		if (mapByte >= FirstAnnotation) {
+			annotation = ((usqInt) mapByte) >> AnnotationShift;
+			mcpc1 += mapByte & DisplacementMask;
+			if ((annotation == IsSendCall)
+							 || (((annotation == IsNSSendCall)
+				 && ((bsOffset > 0
+					? AltNSSendIsPCAnnotated
+					: NSSendIsPCAnnotated)))
+							 || (annotation == HasBytecodePC))) {
+				while (1) {
+					byte = (fetchByteofObject(bcpc, aMethodObj)) + bsOffset;
+					descriptor = generatorAt(byte);
+					if (isInBlock) {
+						if (bcpc >= endbcpc) {
+							return 0;
+						}
+					}
+					else {
+						if (((descriptor->isReturn))
+						 && (bcpc >= latestContinuation)) {
+							return 0;
+						}
+						if ((isBranch(descriptor))
+						 || ((descriptor->isBlockCreation))) {
+							/* begin latestContinuationPCFor:at:exts:in: */
+							distance = ((descriptor->spanFunction))(descriptor, bcpc, nExts, aMethodObj);
+							targetPC = (bcpc + ((descriptor->numBytes))) + (((distance < 0) ? 0 : distance));
+							latestContinuation = ((latestContinuation < targetPC) ? targetPC : latestContinuation);
+						}
+					}
+					nextBcpc = (bcpc + ((descriptor->numBytes))) + (((descriptor->isBlockCreation)
+	? ((descriptor->spanFunction))(descriptor, bcpc, nExts, aMethodObj)
+	: 0));
+					if (((descriptor->isMapped))
+ || (isInBlock
+ && ((descriptor->isMappedInBlock)))) break;
+					bcpc = nextBcpc;
+					nExts = ((descriptor->isExtension)
+						? nExts + 1
+						: 0);
+				}
+				isBackwardBranch = (isBranch(descriptor))
+				 && (isBackwardBranchatextsin(descriptor, bcpc, nExts, aMethodObj));
+				result = findIsBackwardBranchMcpcBcpcMatchingMcpc(descriptor, isBackwardBranch, (((char *) mcpc1)), bcpc, (((void *)mcpc)));
+				if (result != 0) {
+					return result;
+				}
+				bcpc = nextBcpc;
+				nExts = ((descriptor->isExtension)
+					? nExts + 1
+					: 0);
+			}
+			/* begin maybeRememberPrevMap:absPCMcpc: */
+		}
+		else {
+			mcpc1 += (mapByte >= DisplacementX2N
+				? (mapByte - DisplacementX2N) << AnnotationShift
+				: mapByte);
+		}
+		map -= 1;
+	}
+	return 0;
 }
 
 static AbstractInstruction *
@@ -10210,23 +10357,7 @@
 	return 0;
 }
 
-static sqInt
-findMcpcBcpcMatchingBcpc(char *mcpc, sqInt bcpc, void *targetBcpc)
-{
-	return ((((sqInt)targetBcpc)) == bcpc
-		? ((sqInt)mcpc)
-		: 0);
-}
 
-static sqInt
-findMcpcBcpcMatchingMcpc(char *mcpc, sqInt bcpc, void *targetMcpc)
-{
-	return (targetMcpc == mcpc
-		? bcpc
-		: 0);
-}
-
-
 /*	Find the CMMethod or CMBlock that has zero-relative startbcpc as its first
 	bytecode pc.
 	As this is for cannot resume processing and/or conversion to machine-code
@@ -10283,7 +10414,23 @@
 	return null;
 }
 
+
+/*	Machine code addresses map to the following bytecode for all bytecodes
+	except backward branches, where they map to the backward branch itself.
+	This is so that loops continue, rather than terminate prematurely. */
+
 static sqInt
+findIsBackwardBranchMcpcBcpcMatchingMcpc(BytecodeDescriptor *descriptor, sqInt isBackwardBranch, char *mcpc, sqInt bcpc, void *targetMcpc)
+{
+	return (targetMcpc == mcpc
+		? ((descriptor == null)
+			 || (isBackwardBranch)
+				? bcpc
+				: bcpc + ((descriptor->numBytes)))
+		: 0);
+}
+
+static sqInt
 frameOffsetOfTemporary(sqInt index)
 {
 	return (index < methodOrBlockNumArgs
@@ -17209,168 +17356,9 @@
 }
 
 
-/*	Machine-code <-> bytecode pc mapping support. Evaluate functionSymbol
-	for each mcpc, bcpc pair in the map until the function returns non-zero,
-	answering that result, or 0 if it fails to. This works only for frameful
-	methods.  */
+/*	Unlinking/GC/Disassembly support */
 
 static sqInt
-mapForbcpcperformUntilarg(CogBlockMethod *cogMethod, sqInt startbcpc, sqInt (*functionSymbol)(char *mcpc, sqInt bcpc, void *arg), void *arg)
-{
-    sqInt aMethodObj;
-    sqInt annotation;
-    sqInt bcpc;
-    sqInt bsOffset;
-    sqInt byte;
-    BytecodeDescriptor *descriptor;
-    sqInt distance;
-    sqInt endbcpc;
-    CogMethod *homeMethod;
-    sqInt isInBlock;
-    sqInt latestContinuation;
-    sqInt map;
-    sqInt mapByte;
-    sqInt mcpc;
-    sqInt methodHeader;
-    sqInt methodHeader1;
-    sqInt nExts;
-    sqInt nextBcpc;
-    sqInt result;
-    sqInt targetPC;
-
-	assert(((cogMethod->stackCheckOffset)) > 0);
-	if (((cogMethod->cmType)) == CMMethod) {
-		isInBlock = 0;
-		homeMethod = ((CogMethod *) cogMethod);
-		assert(startbcpc == (startPCOfMethodHeader((homeMethod->methodHeader))));
-		map = ((((usqInt)homeMethod)) + ((homeMethod->blockSize))) - 1;
-		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == IsAbsPCReference)
-		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsObjectReference)
-		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsRelativeCall)
-		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N))));
-		latestContinuation = startbcpc;
-		aMethodObj = (homeMethod->methodObject);
-		endbcpc = (byteLengthOf(aMethodObj)) - 1;
-		/* begin bytecodeSetOffsetForHeader: */
-		methodHeader = (homeMethod->methodHeader);
-		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader)
-						? 256
-						: 0);
-	}
-	else {
-		isInBlock = 1;
-		homeMethod = cmHomeMethod(cogMethod);
-		map = findMapLocationForMcpcinMethod((((usqInt)cogMethod)) + (sizeof(CogBlockMethod)), homeMethod);
-		assert(map != 0);
-		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == HasBytecodePC)
-		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N));
-		while ((((usqInt) (byteAt(map))) >> AnnotationShift) != HasBytecodePC) {
-			map -= 1;
-		}
-
-		/* skip fiducial; i.e. the map entry for the pc immediately following the method header. */
-
-		map -= 1;
-		aMethodObj = (homeMethod->methodObject);
-		bcpc = startbcpc - (blockCreationBytecodeSizeForHeader((homeMethod->methodHeader)));
-		/* begin bytecodeSetOffsetForHeader: */
-		methodHeader1 = (homeMethod->methodHeader);
-		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader1)
-						? 256
-						: 0);
-		byte = (fetchByteofObject(bcpc, aMethodObj)) + bsOffset;
-		descriptor = generatorAt(byte);
-		endbcpc = (bcpc + ((descriptor->numBytes))) + (((descriptor->isBlockCreation)
-	? ((descriptor->spanFunction))(descriptor, bcpc, -1, aMethodObj)
-	: 0));
-	}
-	bcpc = startbcpc;
-	mcpc = (((usqInt)cogMethod)) + ((cogMethod->stackCheckOffset));
-
-	/* The stack check maps to the start of the first bytecode,
-	   the first bytecode being effectively after frame build. */
-
-	nExts = 0;
-	result = functionSymbol((((char *) mcpc)), startbcpc, arg);
-	if (result != 0) {
-		return result;
-	}
-	while ((((usqInt) (byteAt(map))) >> AnnotationShift) != HasBytecodePC) {
-		map -= 1;
-	}
-	map -= 1;
-	while (((mapByte = byteAt(map))) != MapEnd) {
-
-		/* defensive; we exit on bcpc */
-
-		if (mapByte >= FirstAnnotation) {
-			annotation = ((usqInt) mapByte) >> AnnotationShift;
-			mcpc += mapByte & DisplacementMask;
-			if ((annotation == IsSendCall)
-							 || (((annotation == IsNSSendCall)
-				 && ((bsOffset > 0
-					? AltNSSendIsPCAnnotated
-					: NSSendIsPCAnnotated)))
-							 || (annotation == HasBytecodePC))) {
-				while (1) {
-					byte = (fetchByteofObject(bcpc, aMethodObj)) + bsOffset;
-					descriptor = generatorAt(byte);
-					if (isInBlock) {
-						if (bcpc >= endbcpc) {
-							return 0;
-						}
-					}
-					else {
-						if (((descriptor->isReturn))
-						 && (bcpc >= latestContinuation)) {
-							return 0;
-						}
-						if ((isBranch(descriptor))
-						 || ((descriptor->isBlockCreation))) {
-							/* begin latestContinuationPCFor:at:exts:in: */
-							distance = ((descriptor->spanFunction))(descriptor, bcpc, nExts, aMethodObj);
-							targetPC = (bcpc + ((descriptor->numBytes))) + (((distance < 0) ? 0 : distance));
-							latestContinuation = ((latestContinuation < targetPC) ? targetPC : latestContinuation);
-						}
-					}
-					nextBcpc = (bcpc + ((descriptor->numBytes))) + (((descriptor->isBlockCreation)
-	? ((descriptor->spanFunction))(descriptor, bcpc, nExts, aMethodObj)
-	: 0));
-					if (((descriptor->isMapped))
- || (isInBlock
- && ((descriptor->isMappedInBlock)))) break;
-					bcpc = nextBcpc;
-					nExts = ((descriptor->isExtension)
-						? nExts + 1
-						: 0);
-				}
-				result = functionSymbol((((char *) mcpc)), (((isBranch(descriptor))
- && (isBackwardBranchatextsin(descriptor, bcpc, nExts, aMethodObj))
-	? bcpc
-	: bcpc + ((descriptor->numBytes)))), arg);
-				if (result != 0) {
-					return result;
-				}
-				bcpc = nextBcpc;
-				nExts = ((descriptor->isExtension)
-					? nExts + 1
-					: 0);
-			}
-		}
-		else {
-			mcpc += (mapByte >= DisplacementX2N
-				? (mapByte - DisplacementX2N) << AnnotationShift
-				: mapByte);
-		}
-		map -= 1;
-	}
-	return 0;
-}
-
-
-/*	Disassembly/GC support */
-
-static sqInt
 mapForperformUntilarg(CogMethod *cogMethod, int (*functionSymbol)(sqInt annotation, char *mcpc, sqInt arg), sqInt arg)
 {
     sqInt map;
@@ -17461,7 +17449,11 @@
     sqInt freedPIC;
     sqInt hasYoungObj;
     sqInt hasYoungObjPtr;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
     sqInt remappedMethod;
+    sqInt result;
     sqInt val;
 
 	hasYoungObj = 0;
@@ -17511,7 +17503,27 @@
 						hasYoungObj = 1;
 					}
 				}
-				mapForperformUntilarg(cogMethod, remapIfObjectRefpchasYoung, hasYoungObjPtr);
+				/* begin mapFor:performUntil:arg: */
+				mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+				map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+				while (((mapByte = byteAt(map))) != MapEnd) {
+					if (mapByte >= FirstAnnotation) {
+						mcpc += mapByte & DisplacementMask;
+						result = remapIfObjectRefpchasYoung((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), hasYoungObjPtr);
+						if (result != 0) {
+							result;
+							goto l1;
+						}
+					}
+					else {
+						mcpc += (mapByte >= DisplacementX2N
+							? (mapByte - DisplacementX2N) << AnnotationShift
+							: mapByte);
+					}
+					map -= 1;
+				}
+				0;
+			l1:	/* end mapFor:performUntil:arg: */;
 				if (hasYoungObj) {
 					if (!((cogMethod->cmRefersToYoung))) {
 						(cogMethod->cmRefersToYoung = 1);
@@ -17548,6 +17560,10 @@
 mapObjectReferencesInMachineCodeForFullGC(void)
 {
     CogMethod *cogMethod;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt result;
 
 	codeModified = 0;
 	mapObjectReferencesInGeneratedRuntime();
@@ -17565,7 +17581,27 @@
 					assert(((cogMethod->objectHeader)) == (nullHeaderForMachineCodeMethod()));
 					(cogMethod->methodObject = remapOop((cogMethod->methodObject)));
 				}
-				mapForperformUntilarg(cogMethod, remapIfObjectRefpchasYoung, 0);
+				/* begin mapFor:performUntil:arg: */
+				mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+				map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+				while (((mapByte = byteAt(map))) != MapEnd) {
+					if (mapByte >= FirstAnnotation) {
+						mcpc += mapByte & DisplacementMask;
+						result = remapIfObjectRefpchasYoung((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), 0);
+						if (result != 0) {
+							result;
+							goto l1;
+						}
+					}
+					else {
+						mcpc += (mapByte >= DisplacementX2N
+							? (mapByte - DisplacementX2N) << AnnotationShift
+							: mapByte);
+					}
+					map -= 1;
+				}
+				0;
+			l1:	/* end mapFor:performUntil:arg: */;
 				if (((cogMethod->cmRefersToYoung))
 				 && (allYoungObjectsAgeInFullGC())) {
 					(cogMethod->cmRefersToYoung = 0);
@@ -17598,7 +17634,11 @@
     CogMethod *cogMethod;
     sqInt hasYoungObj;
     sqInt hasYoungObjPtr;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
     usqInt pointer;
+    sqInt result;
     sqInt val;
 
 	hasYoungObj = 0;
@@ -17627,7 +17667,27 @@
 						hasYoungObj = 1;
 					}
 				}
-				mapForperformUntilarg(cogMethod, remapIfObjectRefpchasYoung, hasYoungObjPtr);
+				/* begin mapFor:performUntil:arg: */
+				mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+				map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+				while (((mapByte = byteAt(map))) != MapEnd) {
+					if (mapByte >= FirstAnnotation) {
+						mcpc += mapByte & DisplacementMask;
+						result = remapIfObjectRefpchasYoung((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), hasYoungObjPtr);
+						if (result != 0) {
+							result;
+							goto l1;
+						}
+					}
+					else {
+						mcpc += (mapByte >= DisplacementX2N
+							? (mapByte - DisplacementX2N) << AnnotationShift
+							: mapByte);
+					}
+					map -= 1;
+				}
+				0;
+			l1:	/* end mapFor:performUntil:arg: */;
 				if (hasYoungObj) {
 					hasYoungObj = 0;
 				}
@@ -17701,7 +17761,11 @@
 markAndTraceMachineCodeForNewSpaceGC(void)
 {
     CogMethod *cogMethod;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
     usqInt pointer;
+    sqInt result;
 
 	if (leakCheckNewSpaceGC()) {
 		assert(allMachineCodeObjectReferencesValid());
@@ -17731,7 +17795,27 @@
 				 && (isYoung((cogMethod->methodObject)))) {
 					markAndTrace((cogMethod->methodObject));
 				}
-				mapForperformUntilarg(cogMethod, markYoungObjectspcmethod, ((sqInt)cogMethod));
+				/* begin mapFor:performUntil:arg: */
+				mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+				map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+				while (((mapByte = byteAt(map))) != MapEnd) {
+					if (mapByte >= FirstAnnotation) {
+						mcpc += mapByte & DisplacementMask;
+						result = markYoungObjectspcmethod((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), (((sqInt)cogMethod)));
+						if (result != 0) {
+							result;
+							goto l1;
+						}
+					}
+					else {
+						mcpc += (mapByte >= DisplacementX2N
+							? (mapByte - DisplacementX2N) << AnnotationShift
+							: mapByte);
+					}
+					map -= 1;
+				}
+				0;
+			l1:	/* end mapFor:performUntil:arg: */;
 			}
 		}
 		pointer += BytesPerWord;
@@ -17756,6 +17840,14 @@
 markAndTraceMachineCodeOfMarkedMethods(void)
 {
     CogMethod *cogMethod;
+    sqInt map;
+    sqInt map1;
+    sqInt mapByte;
+    sqInt mapByte1;
+    sqInt mcpc;
+    sqInt mcpc1;
+    sqInt result;
+    sqInt result1;
 
 	if (leakCheckFullGC()) {
 		assert(allMachineCodeObjectReferencesValid());
@@ -17773,7 +17865,27 @@
 			 && ((isImmediate((cogMethod->selector)))
 			 || (isMarked((cogMethod->selector))))));
 			markAndTraceLiteral((cogMethod->selector));
-			mapForperformUntilarg(cogMethod, markLiteralspcmethod, ((sqInt)cogMethod));
+			/* begin mapFor:performUntil:arg: */
+			mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+			map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+			while (((mapByte = byteAt(map))) != MapEnd) {
+				if (mapByte >= FirstAnnotation) {
+					mcpc += mapByte & DisplacementMask;
+					result = markLiteralspcmethod((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), (((sqInt)cogMethod)));
+					if (result != 0) {
+						result;
+						goto l1;
+					}
+				}
+				else {
+					mcpc += (mapByte >= DisplacementX2N
+						? (mapByte - DisplacementX2N) << AnnotationShift
+						: mapByte);
+				}
+				map -= 1;
+			}
+			0;
+		l1:	/* end mapFor:performUntil:arg: */;
 		}
 		if ((((cogMethod->cmType)) == CMOpenPIC)
 		 && ((isImmediate((cogMethod->selector)))
@@ -17785,7 +17897,27 @@
 			 && ((isImmediate((cogMethod->selector)))
 			 || (isMarked((cogMethod->selector))))));
 			markAndTraceLiteral((cogMethod->selector));
-			mapForperformUntilarg(cogMethod, markLiteralspcmethod, ((sqInt)cogMethod));
+			/* begin mapFor:performUntil:arg: */
+			mcpc1 = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+			map1 = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+			while (((mapByte1 = byteAt(map1))) != MapEnd) {
+				if (mapByte1 >= FirstAnnotation) {
+					mcpc1 += mapByte1 & DisplacementMask;
+					result1 = markLiteralspcmethod((((usqInt) mapByte1) >> AnnotationShift), (((char *) mcpc1)), (((sqInt)cogMethod)));
+					if (result1 != 0) {
+						result1;
+						goto l2;
+					}
+				}
+				else {
+					mcpc1 += (mapByte1 >= DisplacementX2N
+						? (mapByte1 - DisplacementX2N) << AnnotationShift
+						: mapByte1);
+				}
+				map1 -= 1;
+			}
+			0;
+		l2:	/* end mapFor:performUntil:arg: */;
 		}
 		cogMethod = ((CogMethod *) (roundUpLength((((sqInt)cogMethod)) + ((cogMethod->blockSize)))));
 	}
@@ -17845,6 +17977,11 @@
 static sqInt
 markAndTraceOrFreeCogMethodfirstVisit(CogMethod *cogMethod, sqInt firstVisit)
 {
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt result;
+
 	if (((cogMethod->cmType)) == CMFree) {
 		return 1;
 	}
@@ -17859,7 +17996,27 @@
 			assert(((cogMethod->cmType)) == CMMethod);
 			assert(isMarked((cogMethod->methodObject)));
 			markAndTraceLiteral((cogMethod->selector));
-			mapForperformUntilarg(cogMethod, markLiteralsAndUnlinkIfUnmarkedSendpcmethod, ((sqInt)cogMethod));
+			/* begin mapFor:performUntil:arg: */
+			mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+			map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+			while (((mapByte = byteAt(map))) != MapEnd) {
+				if (mapByte >= FirstAnnotation) {
+					mcpc += mapByte & DisplacementMask;
+					result = markLiteralsAndUnlinkIfUnmarkedSendpcmethod((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), (((sqInt)cogMethod)));
+					if (result != 0) {
+						result;
+						goto l1;
+					}
+				}
+				else {
+					mcpc += (mapByte >= DisplacementX2N
+						? (mapByte - DisplacementX2N) << AnnotationShift
+						: mapByte);
+				}
+				map -= 1;
+			}
+			0;
+		l1:	/* end mapFor:performUntil:arg: */;
 		}
 		return 0;
 	}
@@ -18103,6 +18260,10 @@
 markMethodAndReferents(CogBlockMethod *aCogMethod)
 {
     CogMethod *cogMethod;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt result;
 
 	assert((((aCogMethod->cmType)) == CMMethod)
 	 || (((aCogMethod->cmType)) == CMBlock));
@@ -18110,7 +18271,27 @@
 		? ((CogMethod *) aCogMethod)
 		: cmHomeMethod(aCogMethod));
 	(cogMethod->cmUsageCount = CMMaxUsageCount);
-	mapForperformUntilarg(cogMethod, incrementUsageOfTargetIfLinkedSendmcpcignored, 0);
+	/* begin mapFor:performUntil:arg: */
+	mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+	map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+	while (((mapByte = byteAt(map))) != MapEnd) {
+		if (mapByte >= FirstAnnotation) {
+			mcpc += mapByte & DisplacementMask;
+			result = incrementUsageOfTargetIfLinkedSendmcpcignored((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), 0);
+			if (result != 0) {
+				result;
+				goto l1;
+			}
+		}
+		else {
+			mcpc += (mapByte >= DisplacementX2N
+				? (mapByte - DisplacementX2N) << AnnotationShift
+				: mapByte);
+		}
+		map -= 1;
+	}
+	0;
+l1:	/* end mapFor:performUntil:arg: */;
 }
 
 
@@ -18334,19 +18515,166 @@
 }
 
 
-/*	Answer the absolute machine code pc matching the zero-relative bytecode pc
-	argument in cogMethod, given the start of the bytecodes for cogMethod's
-	block or method object. */
+/*	Answer the absolute machine code pc matching the zero-relative
+	bytecode pc of a backward branch in cogMethod, given the start
+	of the bytecodes for cogMethod's block or method object. */
 
-sqInt
-mcPCForstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod)
+usqInt
+mcPCForBackwardBranchstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod)
 {
-    sqInt absPC;
+    sqInt aMethodObj;
+    sqInt annotation;
+    sqInt bcpc1;
+    sqInt bsOffset;
+    sqInt byte;
+    BytecodeDescriptor *descriptor;
+    sqInt distance;
+    sqInt endbcpc;
+    CogMethod *homeMethod;
+    sqInt isBackwardBranch;
+    sqInt isInBlock;
+    sqInt latestContinuation;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt methodHeader;
+    sqInt methodHeader1;
+    sqInt nExts;
+    sqInt nextBcpc;
+    sqInt result;
+    sqInt targetPC;
 
-	absPC = mapForbcpcperformUntilarg(cogMethod, startbcpc, findMcpcBcpcMatchingBcpc, ((void *)bcpc));
-	return (absPC != 0
-		? (((usqInt)absPC)) - (((usqInt)cogMethod))
-		: absPC);
+	/* begin mapFor:bcpc:performUntil:arg: */
+	assert(((cogMethod->stackCheckOffset)) > 0);
+	if (((cogMethod->cmType)) == CMMethod) {
+		isInBlock = 0;
+		homeMethod = ((CogMethod *) cogMethod);
+		assert(startbcpc == (startPCOfMethodHeader((homeMethod->methodHeader))));
+		map = ((((usqInt)homeMethod)) + ((homeMethod->blockSize))) - 1;
+		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == IsAbsPCReference)
+		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsObjectReference)
+		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsRelativeCall)
+		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N))));
+		latestContinuation = startbcpc;
+		aMethodObj = (homeMethod->methodObject);
+		endbcpc = (byteLengthOf(aMethodObj)) - 1;
+		/* begin bytecodeSetOffsetForHeader: */
+		methodHeader = (homeMethod->methodHeader);
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader)
+						? 256
+						: 0);
+	}
+	else {
+		isInBlock = 1;
+		homeMethod = cmHomeMethod(cogMethod);
+		map = findMapLocationForMcpcinMethod((((usqInt)cogMethod)) + (sizeof(CogBlockMethod)), homeMethod);
+		assert(map != 0);
+		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == HasBytecodePC)
+		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N));
+		while ((((usqInt) (byteAt(map))) >> AnnotationShift) != HasBytecodePC) {
+			map -= 1;
+		}
+
+		/* skip fiducial; i.e. the map entry for the pc immediately following the method header. */
+
+		map -= 1;
+		aMethodObj = (homeMethod->methodObject);
+		bcpc1 = startbcpc - (blockCreationBytecodeSizeForHeader((homeMethod->methodHeader)));
+		/* begin bytecodeSetOffsetForHeader: */
+		methodHeader1 = (homeMethod->methodHeader);
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader1)
+						? 256
+						: 0);
+		byte = (fetchByteofObject(bcpc1, aMethodObj)) + bsOffset;
+		descriptor = generatorAt(byte);
+		endbcpc = (bcpc1 + ((descriptor->numBytes))) + (((descriptor->isBlockCreation)
+	? ((descriptor->spanFunction))(descriptor, bcpc1, -1, aMethodObj)
+	: 0));
+	}
+	bcpc1 = startbcpc;
+	mcpc = (((usqInt)cogMethod)) + ((cogMethod->stackCheckOffset));
+
+	/* The stack check maps to the start of the first bytecode,
+	   the first bytecode being effectively after frame build. */
+
+	nExts = 0;
+	result = 0;
+	if (result != 0) {
+		return ((sqInt) result);
+	}
+	while ((((usqInt) (byteAt(map))) >> AnnotationShift) != HasBytecodePC) {
+		map -= 1;
+	}
+	map -= 1;
+	while (((mapByte = byteAt(map))) != MapEnd) {
+
+		/* defensive; we exit on bcpc */
+
+		if (mapByte >= FirstAnnotation) {
+			annotation = ((usqInt) mapByte) >> AnnotationShift;
+			mcpc += mapByte & DisplacementMask;
+			if ((annotation == IsSendCall)
+							 || (((annotation == IsNSSendCall)
+				 && ((bsOffset > 0
+					? AltNSSendIsPCAnnotated
+					: NSSendIsPCAnnotated)))
+							 || (annotation == HasBytecodePC))) {
+				while (1) {
+					byte = (fetchByteofObject(bcpc1, aMethodObj)) + bsOffset;
+					descriptor = generatorAt(byte);
+					if (isInBlock) {
+						if (bcpc1 >= endbcpc) {
+							return ((sqInt) 0);
+						}
+					}
+					else {
+						if (((descriptor->isReturn))
+						 && (bcpc1 >= latestContinuation)) {
+							return ((sqInt) 0);
+						}
+						if ((isBranch(descriptor))
+						 || ((descriptor->isBlockCreation))) {
+							/* begin latestContinuationPCFor:at:exts:in: */
+							distance = ((descriptor->spanFunction))(descriptor, bcpc1, nExts, aMethodObj);
+							targetPC = (bcpc1 + ((descriptor->numBytes))) + (((distance < 0) ? 0 : distance));
+							latestContinuation = ((latestContinuation < targetPC) ? targetPC : latestContinuation);
+						}
+					}
+					nextBcpc = (bcpc1 + ((descriptor->numBytes))) + (((descriptor->isBlockCreation)
+	? ((descriptor->spanFunction))(descriptor, bcpc1, nExts, aMethodObj)
+	: 0));
+					if (((descriptor->isMapped))
+ || (isInBlock
+ && ((descriptor->isMappedInBlock)))) break;
+					bcpc1 = nextBcpc;
+					nExts = ((descriptor->isExtension)
+						? nExts + 1
+						: 0);
+				}
+				isBackwardBranch = (isBranch(descriptor))
+				 && (isBackwardBranchatextsin(descriptor, bcpc1, nExts, aMethodObj));
+				result = (isBackwardBranch
+				 && ((((sqInt)(((void *)bcpc)))) == bcpc1)
+					? ((sqInt)(((char *) mcpc)))
+					: 0);
+				if (result != 0) {
+					return ((sqInt) result);
+				}
+				bcpc1 = nextBcpc;
+				nExts = ((descriptor->isExtension)
+					? nExts + 1
+					: 0);
+			}
+			/* begin maybeRememberPrevMap:absPCMcpc: */
+		}
+		else {
+			mcpc += (mapByte >= DisplacementX2N
+				? (mapByte - DisplacementX2N) << AnnotationShift
+				: mapByte);
+		}
+		map -= 1;
+	}
+	return ((sqInt) 0);
 }
 
 
@@ -19416,6 +19744,10 @@
 relocateCallsAndSelfReferencesInMethod(CogMethod *cogMethod)
 {
     sqInt delta;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt result;
 
 	delta = (cogMethod->objectHeader);
 	assert((((cogMethod->cmType)) == CMMethod)
@@ -19424,7 +19756,27 @@
 	? methodAbortTrampolineFor((cogMethod->cmNumArgs))
 	: picAbortTrampolineFor((cogMethod->cmNumArgs)))));
 	relocateCallBeforeReturnPCby(backEnd, (((sqInt)cogMethod)) + missOffset, -delta);
-	mapForperformUntilarg(cogMethod, relocateIfCallOrMethodReferencemcpcdelta, delta);
+	/* begin mapFor:performUntil:arg: */
+	mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+	map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+	while (((mapByte = byteAt(map))) != MapEnd) {
+		if (mapByte >= FirstAnnotation) {
+			mcpc += mapByte & DisplacementMask;
+			result = relocateIfCallOrMethodReferencemcpcdelta((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), delta);
+			if (result != 0) {
+				result;
+				goto l1;
+			}
+		}
+		else {
+			mcpc += (mapByte >= DisplacementX2N
+				? (mapByte - DisplacementX2N) << AnnotationShift
+				: mapByte);
+		}
+		map -= 1;
+	}
+	0;
+l1:	/* end mapFor:performUntil:arg: */;
 }
 
 static void
@@ -20802,6 +21154,10 @@
 unlinkAllSends(void)
 {
     CogMethod *cogMethod;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt result;
 
 	if (methodZoneBase == null) {
 		return;
@@ -20809,7 +21165,27 @@
 	cogMethod = ((CogMethod *) methodZoneBase);
 	while (cogMethod < (limitZony())) {
 		if (((cogMethod->cmType)) == CMMethod) {
-			mapForperformUntilarg(cogMethod, unlinkIfLinkedSendpcignored, 0);
+			/* begin mapFor:performUntil:arg: */
+			mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+			map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+			while (((mapByte = byteAt(map))) != MapEnd) {
+				if (mapByte >= FirstAnnotation) {
+					mcpc += mapByte & DisplacementMask;
+					result = unlinkIfLinkedSendpcignored((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), 0);
+					if (result != 0) {
+						result;
+						goto l1;
+					}
+				}
+				else {
+					mcpc += (mapByte >= DisplacementX2N
+						? (mapByte - DisplacementX2N) << AnnotationShift
+						: mapByte);
+				}
+				map -= 1;
+			}
+			0;
+		l1:	/* end mapFor:performUntil:arg: */;
 		}
 		else {
 			if (((cogMethod->cmType)) != CMFree) {
@@ -21031,7 +21407,11 @@
 unlinkSendsOfisMNUSelector(sqInt selector, sqInt isMNUSelector)
 {
     CogMethod *cogMethod;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
     sqInt mustScanAndUnlink;
+    sqInt result;
 
 	if (methodZoneBase == null) {
 		return;
@@ -21074,7 +21454,27 @@
 	cogMethod = ((CogMethod *) methodZoneBase);
 	while (cogMethod < (limitZony())) {
 		if (((cogMethod->cmType)) == CMMethod) {
-			mapForperformUntilarg(cogMethod, unlinkIfFreeOrLinkedSendpcof, selector);
+			/* begin mapFor:performUntil:arg: */
+			mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+			map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+			while (((mapByte = byteAt(map))) != MapEnd) {
+				if (mapByte >= FirstAnnotation) {
+					mcpc += mapByte & DisplacementMask;
+					result = unlinkIfFreeOrLinkedSendpcof((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), selector);
+					if (result != 0) {
+						result;
+						goto l1;
+					}
+				}
+				else {
+					mcpc += (mapByte >= DisplacementX2N
+						? (mapByte - DisplacementX2N) << AnnotationShift
+						: mapByte);
+				}
+				map -= 1;
+			}
+			0;
+		l1:	/* end mapFor:performUntil:arg: */;
 		}
 		cogMethod = ((CogMethod *) (roundUpLength((((sqInt)cogMethod)) + ((cogMethod->blockSize)))));
 	}
@@ -21093,6 +21493,10 @@
 unlinkSendsToFree(void)
 {
     CogMethod *cogMethod;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt result;
 
 	if (methodZoneBase == null) {
 		return;
@@ -21101,7 +21505,27 @@
 	cogMethod = ((CogMethod *) methodZoneBase);
 	while (cogMethod < (limitZony())) {
 		if (((cogMethod->cmType)) == CMMethod) {
-			mapForperformUntilarg(cogMethod, unlinkIfLinkedSendToFreepcignored, 0);
+			/* begin mapFor:performUntil:arg: */
+			mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+			map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+			while (((mapByte = byteAt(map))) != MapEnd) {
+				if (mapByte >= FirstAnnotation) {
+					mcpc += mapByte & DisplacementMask;
+					result = unlinkIfLinkedSendToFreepcignored((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), 0);
+					if (result != 0) {
+						result;
+						goto l1;
+					}
+				}
+				else {
+					mcpc += (mapByte >= DisplacementX2N
+						? (mapByte - DisplacementX2N) << AnnotationShift
+						: mapByte);
+				}
+				map -= 1;
+			}
+			0;
+		l1:	/* end mapFor:performUntil:arg: */;
 		}
 		else {
 			if (((cogMethod->cmType)) == CMClosedPIC) {
@@ -21128,6 +21552,10 @@
 {
     CogMethod *cogMethod;
     sqInt freedPIC;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc;
+    sqInt result;
     CogMethod *targetMethod;
 
 	if (!((isOopCompiledMethod(targetMethodObject))
@@ -21142,7 +21570,27 @@
 	cogMethod = ((CogMethod *) methodZoneBase);
 	while (cogMethod < (limitZony())) {
 		if (((cogMethod->cmType)) == CMMethod) {
-			mapForperformUntilarg(cogMethod, unlinkIfLinkedSendpcto, ((sqInt)targetMethod));
+			/* begin mapFor:performUntil:arg: */
+			mcpc = (((sqInt)cogMethod)) + cmNoCheckEntryOffset;
+			map = ((((usqInt)cogMethod)) + ((cogMethod->blockSize))) - 1;
+			while (((mapByte = byteAt(map))) != MapEnd) {
+				if (mapByte >= FirstAnnotation) {
+					mcpc += mapByte & DisplacementMask;
+					result = unlinkIfLinkedSendpcto((((usqInt) mapByte) >> AnnotationShift), (((char *) mcpc)), (((sqInt)targetMethod)));
+					if (result != 0) {
+						result;
+						goto l1;
+					}
+				}
+				else {
+					mcpc += (mapByte >= DisplacementX2N
+						? (mapByte - DisplacementX2N) << AnnotationShift
+						: mapByte);
+				}
+				map -= 1;
+			}
+			0;
+		l1:	/* end mapFor:performUntil:arg: */;
 		}
 		else {
 			if ((((cogMethod->cmType)) == CMClosedPIC)

Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/cogit.h	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGenerator VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
 
 
@@ -48,7 +48,7 @@
 void markAndTraceObjectsOrFreeMachineCode(sqInt inFullGC);
 void markMethodAndReferents(CogBlockMethod *aCogMethod);
 usqInt maxCogMethodAddress(void);
-sqInt mcPCForstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
+usqInt mcPCForBackwardBranchstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
 CogMethod * methodFor(void *address);
 sqInt minCogMethodAddress(void);
 sqInt mnuOffset(void);

Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/cogmethod.h	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGenerator VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
 
 typedef struct {

Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/cointerp.c	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
    from
-	CoInterpreter VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CoInterpreter VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -2045,7 +2045,7 @@
 	/* 574 */ (void (*)(void))0,
 	/* 575 */ (void (*)(void))0,
  0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.672";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.674";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -14212,7 +14212,7 @@
     sqInt methodHeader;
     char *p;
     sqInt pc;
-    sqInt pc1;
+    usqInt pc1;
     sqInt savedIP;
     char *sp;
     char *sp1;
@@ -14268,9 +14268,9 @@
 			longAtput((p + FoxMFReceiver) - FoxIFReceiver, longAt(p));
 		}
 		GIV(stackPointer) = (GIV(stackPointer) + FoxMFReceiver) - FoxIFReceiver;
-		pc1 = mcPCForstartBcpcin(bcpc, startBcpc, cogMethod2);
-		assert(pc1 > (noCheckEntryOffset()));
-		pc = (((sqInt)cogMethod2)) + pc1;
+		pc1 = mcPCForBackwardBranchstartBcpcin(bcpc, startBcpc, cogMethod2);
+		assert(pc1 > ((((sqInt)cogMethod2)) + (noCheckEntryOffset())));
+		pc = pc1;
 		/* begin assertValidMachineCodeFrame: */
 		assert(isMachineCodeFrame(GIV(framePointer)));
 		/* begin mframeCogMethod: */
@@ -47345,11 +47345,11 @@
 		: 0));
 	printFrameThingat("saved fp", theFP + FoxSavedFP);
 	printFrameMethodFor(theFP);
-	if (!((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory()))) {
+	if ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())) {
 		printFrameFlagsForFP(theFP);
 	}
 	printFrameOopat("context", theFP + FoxThisContext);
-	if ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())) {
+	if (!((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory()))) {
 		printFrameFlagsForFP(theFP);
 	}
 	if ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())) {

Modified: branches/Cog/nscogsrc/vm/cointerp.h
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.h	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/cointerp.h	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
 
 

Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c	2014-04-14 22:32:11 UTC (rev 2894)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
    from
-	CoInterpreter VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CoInterpreter VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -2048,7 +2048,7 @@
 	/* 574 */ (void (*)(void))0,
 	/* 575 */ (void (*)(void))0,
  0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.672";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.674";
 sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
 volatile int sendTrace;
 
@@ -14221,7 +14221,7 @@
     sqInt methodHeader;
     char *p;
     sqInt pc;
-    sqInt pc1;
+    usqInt pc1;
     sqInt savedIP;
     char *sp;
     char *sp1;
@@ -14277,9 +14277,9 @@
 			longAtput((p + FoxMFReceiver) - FoxIFReceiver, longAt(p));
 		}
 		GIV(stackPointer) = (GIV(stackPointer) + FoxMFReceiver) - FoxIFReceiver;
-		pc1 = mcPCForstartBcpcin(bcpc, startBcpc, cogMethod2);
-		assert(pc1 > (noCheckEntryOffset()));
-		pc = (((sqInt)cogMethod2)) + pc1;
+		pc1 = mcPCForBackwardBranchstartBcpcin(bcpc, startBcpc, cogMethod2);
+		assert(pc1 > ((((sqInt)cogMethod2)) + (noCheckEntryOffset())));
+		pc = pc1;
 		/* begin assertValidMachineCodeFrame: */
 		assert(isMachineCodeFrame(GIV(framePointer)));
 		/* begin mframeCogMethod: */
@@ -47354,11 +47354,11 @@
 		: 0));
 	printFrameThingat("saved fp", theFP + FoxSavedFP);
 	printFrameMethodFor(theFP);
-	if (!((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory()))) {
+	if ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())) {
 		printFrameFlagsForFP(theFP);
 	}
 	printFrameOopat("context", theFP + FoxThisContext);
-	if ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())) {
+	if (!((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory()))) {
 		printFrameFlagsForFP(theFP);
 	}
 	if ((((usqInt)(longAt(theFP + FoxMethod)))) < (startOfMemory())) {

Modified: branches/Cog/nscogsrc/vm/interp.h
===================================================================
--- branches/Cog/nscogsrc/vm/interp.h	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/interp.h	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
 
 #define VM_PROXY_MAJOR 1

Modified: branches/Cog/nscogsrc/vm/vmCallback.h
===================================================================
--- branches/Cog/nscogsrc/vm/vmCallback.h	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nscogsrc/vm/vmCallback.h	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,5 +1,5 @@
 /* Automatically generated by
-	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGeneratorGlobalStructure VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
 
 #define VM_CALLBACK_INC 1

Modified: branches/Cog/nsspursrc/vm/cogit.c
===================================================================
--- branches/Cog/nsspursrc/vm/cogit.c	2014-04-11 19:55:48 UTC (rev 2893)
+++ branches/Cog/nsspursrc/vm/cogit.c	2014-04-14 22:32:11 UTC (rev 2894)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	CCodeGenerator VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	CCodeGenerator VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
    from
-	StackToRegisterMappingCogit VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c
+	StackToRegisterMappingCogit VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.672 uuid: 21493732-2e31-4b57-a8ae-aa6e6a9e4c3c " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.674 uuid: eefd603d-9638-4ad8-99c0-4ee12e87d49d " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -551,10 +551,9 @@
 static CogMethod * fillInOPICHeadersizenumArgsselector(CogMethod *pic, sqInt size, sqInt numArgs, sqInt selector);
 static usqInt findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc);
 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 CogMethod * findPreviouslyCompiledVersionOfwith(sqInt aMethodObj, sqInt aSelectorOop);
+static sqInt findIsBackwardBranchMcpcBcpcMatchingMcpc(BytecodeDescriptor *descriptor, sqInt isBackwardBranch, char *mcpc, sqInt bcpc, void *targetMcpc);
 void followForwardedLiteralsIn(CogMethod *cogMethod);
 void followForwardedMethods(void);
 static sqInt followMaybeObjRefAt(sqInt mcpc);
@@ -908,7 +907,6 @@
 static sqInt machineCodeBytes(AbstractInstruction * self_in_machineCodeBytes);
 static void manageFromto(sqInt theStartAddress, sqInt theLimitAddress);
 static sqInt mapEndFor(CogMethod *cogMethod);
-static sqInt mapForbcpcperformUntilarg(CogBlockMethod *cogMethod, sqInt startbcpc, sqInt (*functionSymbol)(char *mcpc, sqInt bcpc, void *arg), void *arg);
 static sqInt mapForperformUntilarg(CogMethod *cogMethod, int (*functionSymbol)(sqInt annotation, char *mcpc, sqInt arg), sqInt arg);
 static sqInt mapObjectReferencesInClosedPIC(CogMethod *cPIC);
 static void mapObjectReferencesInGeneratedRuntime(void);
@@ -927,7 +925,7 @@
 static sqInt maybeFreeCogMethodDoesntLookKosher(CogMethod *cogMethod);
 static sqInt maybeGenerateCheckFeatures(void);
 static sqInt maybeGenerateICacheFlush(void);
-sqInt mcPCForstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
+usqInt mcPCForBackwardBranchstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
 static CogSimStackEntry * mergeAtfrom(CogSimStackEntry * self_in_mergeAtfrom, sqInt baseOffset, sqInt baseRegister);
 static void mergeafterContinuation(BytecodeFixup *fixup, sqInt mergeWithContinuation);
 static sqInt methodAbortTrampolineFor(sqInt numArgs);
@@ -2520,7 +2518,156 @@
 sqInt
 bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod)
 {
-	return mapForbcpcperformUntilarg(cogMethod, startbcpc, findMcpcBcpcMatchingMcpc, ((void *)mcpc));
+    sqInt aMethodObj;
+    sqInt annotation;
+    sqInt bcpc;
+    sqInt bsOffset;
+    sqInt byte;
+    BytecodeDescriptor *descriptor;
+    sqInt distance;
+    sqInt endbcpc;
+    CogMethod *homeMethod;
+    sqInt isBackwardBranch;
+    sqInt isInBlock;
+    sqInt latestContinuation;
+    sqInt map;
+    sqInt mapByte;
+    sqInt mcpc1;
+    sqInt methodHeader;
+    sqInt methodHeader1;
+    sqInt nExts;
+    sqInt nextBcpc;
+    sqInt result;
+    sqInt targetPC;
+
+	/* begin mapFor:bcpc:performUntil:arg: */
+	assert(((cogMethod->stackCheckOffset)) > 0);
+	if (((cogMethod->cmType)) == CMMethod) {
+		isInBlock = 0;
+		homeMethod = ((CogMethod *) cogMethod);
+		assert(startbcpc == (startPCOfMethodHeader((homeMethod->methodHeader))));
+		map = ((((usqInt)homeMethod)) + ((homeMethod->blockSize))) - 1;
+		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == IsAbsPCReference)
+		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsObjectReference)
+		 || (((((usqInt) (byteAt(map))) >> AnnotationShift) == IsRelativeCall)
+		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N))));
+		latestContinuation = startbcpc;
+		aMethodObj = (homeMethod->methodObject);
+		endbcpc = (byteLengthOf(aMethodObj)) - 1;
+		/* begin bytecodeSetOffsetForHeader: */
+		methodHeader = (homeMethod->methodHeader);
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader)
+						? 256
+						: 0);
+	}
+	else {
+		isInBlock = 1;
+		homeMethod = cmHomeMethod(cogMethod);
+		map = findMapLocationForMcpcinMethod((((usqInt)cogMethod)) + (sizeof(CogBlockMethod)), homeMethod);
+		assert(map != 0);
+		assert(((((usqInt) (byteAt(map))) >> AnnotationShift) == HasBytecodePC)
+		 || ((((usqInt) (byteAt(map))) >> AnnotationShift) == IsDisplacementX2N));
+		while ((((usqInt) (byteAt(map))) >> AnnotationShift) != HasBytecodePC) {
+			map -= 1;
+		}
+
+		/* skip fiducial; i.e. the map entry for the pc immediately following the method header. */
+
+		map -= 1;
+		aMethodObj = (homeMethod->methodObject);
+		bcpc = startbcpc - (blockCreationBytecodeSizeForHeader((homeMethod->methodHeader)));
+		/* begin bytecodeSetOffsetForHeader: */
+		methodHeader1 = (homeMethod->methodHeader);
+		bsOffset = (headerIndicatesAlternateBytecodeSet(methodHeader1)
+						? 256

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list