Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.3071
Browse files Browse the repository at this point in the history
Allow cFramePointerInUse to be defined at compile time.  Some compilers
do not use the frame pointer consistently and don't allow overriding
their inconsistent use (clang-cl 10).
  • Loading branch information
eliotmiranda committed Sep 17, 2021
1 parent ab171a6 commit bbcacee
Show file tree
Hide file tree
Showing 33 changed files with 1,760 additions and 908 deletions.
10 changes: 9 additions & 1 deletion platforms/Cross/vm/sqCogStackAlignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,18 @@
# define STACK_SP_ALIGNMENT 0
#endif
#if !defined(assertCStackWellAligned)
# define assertCStackWellAligned() do { \
# if defined(cFramePointerInUse)
# define assertCStackWellAligned() do { \
if (cFramePointerInUse) \
assert((getfp() & STACK_ALIGN_MASK) == STACK_FP_ALIGNMENT); \
assert((getsp() & STACK_ALIGN_MASK) == STACK_SP_ALIGNMENT); \
} while (0)
# else
# define assertCStackWellAligned() do { \
extern sqInt cFramePointerInUse; \
if (cFramePointerInUse) \
assert((getfp() & STACK_ALIGN_MASK) == STACK_FP_ALIGNMENT); \
assert((getsp() & STACK_ALIGN_MASK) == STACK_SP_ALIGNMENT); \
} while (0)
# endif
#endif
4 changes: 3 additions & 1 deletion src/spur32.cog/cogit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95
CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd
*/


Expand Down Expand Up @@ -118,7 +118,9 @@ extern sqInt ceReturnToInterpreterTrampoline;
#if COGMTVM
extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t);
#endif
#if !defined(cFramePointerInUse)
extern sqInt cFramePointerInUse;
#endif
extern sqInt cmEntryOffset;
extern sqInt cmNoCheckEntryOffset;
extern usqInt methodZoneBase;
Expand Down
131 changes: 80 additions & 51 deletions src/spur32.cog/cogitARMv5.c

Large diffs are not rendered by default.

155 changes: 98 additions & 57 deletions src/spur32.cog/cogitIA32.c

Large diffs are not rendered by default.

91 changes: 59 additions & 32 deletions src/spur32.cog/cointerp.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd
from
CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95
CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd
*/
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ;
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ;
char *__interpBuildInfo = __buildInfo;


Expand Down Expand Up @@ -1242,7 +1242,7 @@ static sqInt noUnscannedEphemerons(void);
static sqInt NoDbgRegParms numBytesOfBitsformat(sqInt objOop, sqInt format);
static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop);
extern sqInt numBytesOf(sqInt objOop);
extern usqInt numPointerSlotsOf(sqInt objOop);
extern sqInt numPointerSlotsOf(sqInt objOop);
static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop);
extern usqInt numSlotsOf(sqInt objOop);
static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop);
Expand Down Expand Up @@ -2597,7 +2597,7 @@ sqInt debugCallbackInvokes;
sqInt debugCallbackReturns;
sqInt ffiExceptionResponse;
sqInt checkedPluginName;
const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]";
const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */;
char primitiveDoMixedArithmetic = 1;
char expensiveAsserts = 0;
Expand Down Expand Up @@ -15542,7 +15542,7 @@ checkForAndFollowForwardedPrimitiveState(void)
/* Necessary because we very much want CStackPointer and CFramePointer to be
static/private and grouped
with other interpreter variables which will hence be accessed via
VarBaseReg on platforms trhat have one.
VarBaseReg on platforms that have one.
*/

/* CoInterpreter>>#checkIfCFramePointerInUse */
Expand Down Expand Up @@ -16222,7 +16222,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext)
level. This is the actual implementation, separated from
enterSmalltalkExecutive so the
simulator can wrap it in an exception handler and hence simulate the
setjmp/longjmp. */
Cogit's jump
back into C code on interpreting; see ceInvokeInterpret.

Conceptually, an invocation of interpret exists at each level of execution
from the
initial invocation through each callback. Entry to each execution level is
through this function. It captures the C stack & frame pointers for this
level of execution
and then either invokes machine code or interpret, depending on whether
the current frame (the effective entry-point into Smalltalk execution) is
a machine code
or interpreted frame. In addition, interpret captures the return address
of its caller
(this funciton). The Cogit then uses the captured C stack pointers and
return address to invoke interpret as if it had been called from this
function. */

/* CoInterpreter>>#enterSmalltalkExecutiveImplementation */
static sqInt
Expand Down Expand Up @@ -19100,7 +19115,8 @@ mnuMethodOrNilFor(sqInt rcvr)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt currentClass;
sqInt dictionary;
sqInt index;
sqInt fieldIndex;
usqInt index;
usqInt length;
sqInt mask;
sqInt methodArray;
Expand Down Expand Up @@ -19149,7 +19165,7 @@ mnuMethodOrNilFor(sqInt rcvr)
wrapAround = 0;
while (1) {
/* begin fetchPointer:ofObject: */
nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord())))));
nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord())));
if (nextSelector == GIV(nilObj)) {
mnuMethod = null;
goto l11;
Expand All @@ -19167,10 +19183,12 @@ mnuMethodOrNilFor(sqInt rcvr)
}
methodArray = objOop;
/* begin followField:ofObject: */
objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord())))));
fieldIndex = index - SelectorStart;
/* begin fetchPointer:ofObject: */
objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord())))));
if (((!(objOop1 & (tagMask()))))
&& ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) {
objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1);
objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1);
}
mnuMethod = objOop1;
goto l11;
Expand Down Expand Up @@ -20127,11 +20145,17 @@ printCogMethod(CogMethod *cogMethod)
print(" prim ");
printNum(primitive);
}
if ((addressCouldBeObj((cogMethod->methodObject)))
&& (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) {
/* begin space */
putchar(' ');
printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2);
if (addressCouldBeObj((cogMethod->methodObject))) {
if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) {
print(" [full]");
}
else {
if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) {
/* begin space */
putchar(' ');
printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2);
}
}
}
}
if (((cogMethod->cmType)) == CMBlock) {
Expand Down Expand Up @@ -20354,7 +20378,7 @@ printFrameWithSP(char *theFP, char *theSP)
usqInt index;
sqInt methodField;
usqInt numArgs;
sqInt numTemps;
usqInt numTemps;
char *rcvrAddress;
sqInt rcvrOrClosure;
CogBlockMethod * self_in_cmHomeMethod;
Expand Down Expand Up @@ -38591,7 +38615,7 @@ followForwardedObjectFieldstoDepth(sqInt objOop, sqInt depth)
sqInt header1;
sqInt i;
sqInt numLiterals;
usqInt numSlots;
sqInt numSlots;
usqInt numSlots1;
sqInt oop;
sqInt referent;
Expand Down Expand Up @@ -45805,7 +45829,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS
sqInt iLimiT;
sqInt methodHeader;
sqInt numLiterals;
usqInt numMediatedSlots;
sqInt numMediatedSlots;
usqInt numSlots;
usqInt numSlots1;
sqInt oop;
Expand Down Expand Up @@ -45837,7 +45861,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS
here but that requires access to framePointer. */
/* begin numSlotsOfMarriedContext: */
contextSize = stackPointerIndexForFrame(frameOfMarriedContext(objOop));
numMediatedSlots = ((sqInt) (CtxtTempFrameStart + contextSize));
numMediatedSlots = CtxtTempFrameStart + contextSize;
for (i1 = 0; i1 < numMediatedSlots; i1 += 1) {
oop = fetchPointerofMarriedContext(i1, objOop);
assert(!(isOopForwarded(copy)));
Expand Down Expand Up @@ -52240,7 +52264,7 @@ numBytesOf(sqInt objOop)
Works with CompiledMethods, as well as ordinary objects. */

/* SpurMemoryManager>>#numPointerSlotsOf: */
usqInt
sqInt
numPointerSlotsOf(sqInt objOop)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt contextSize;
Expand Down Expand Up @@ -55235,7 +55259,7 @@ printReferencesTo(sqInt anOop)
assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj1)));
contextSize = (sp >> 1);
l9: /* end fetchStackPointerOf: */;
i = ((usqInt) (CtxtTempFrameStart + contextSize));
i = CtxtTempFrameStart + contextSize;
goto l10;
}
/* begin numSlotsOf: */
Expand Down Expand Up @@ -55268,7 +55292,7 @@ printReferencesTo(sqInt anOop)
/* begin literalCountOfMethodHeader: */
assert((header & 1));
numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask;
i = ((usqInt) (numLiterals + LiteralStart));
i = numLiterals + LiteralStart;
l10: /* end numPointerSlotsOf: */;
while (((i -= 1)) >= 0) {
if (anOop == (longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) {
Expand Down Expand Up @@ -58480,10 +58504,10 @@ updatePointers(void)
sqInt numLiterals1;
sqInt numLiterals2;
sqInt numLiterals3;
usqInt numPointerSlots;
usqInt numPointerSlots1;
usqInt numPointerSlots2;
usqInt numPointerSlots3;
sqInt numPointerSlots;
sqInt numPointerSlots1;
sqInt numPointerSlots2;
sqInt numPointerSlots3;
usqInt numSlots;
usqInt numSlots1;
usqInt numSlots11;
Expand Down Expand Up @@ -59642,7 +59666,7 @@ prepareForSnapshot(void)
sqInt limit;
sqInt newEndOfMemory;
sqInt next;
sqInt node;
usqInt node;
SpurSegmentInfo *seg;
sqInt smallChild;
sqInt treeNode;
Expand Down Expand Up @@ -65362,7 +65386,8 @@ lookupSelectorinClass(sqInt selector, sqInt class)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt currentClass;
sqInt dictionary;
sqInt index;
sqInt fieldIndex;
usqInt index;
usqInt length;
sqInt mask;
sqInt meth;
Expand Down Expand Up @@ -65406,7 +65431,7 @@ lookupSelectorinClass(sqInt selector, sqInt class)
wrapAround = 0;
while (1) {
/* begin fetchPointer:ofObject: */
nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord())))));
nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord())));
if (nextSelector == GIV(nilObj)) {
meth = null;
goto l8;
Expand All @@ -65424,10 +65449,12 @@ lookupSelectorinClass(sqInt selector, sqInt class)
}
methodArray = objOop2;
/* begin followField:ofObject: */
objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord())))));
fieldIndex = index - SelectorStart;
/* begin fetchPointer:ofObject: */
objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord())))));
if (((!(objOop1 & (tagMask()))))
&& ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) {
objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1);
objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1);
}
meth = objOop1;
goto l8;
Expand Down
4 changes: 2 additions & 2 deletions src/spur32.cog/cointerp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd
*/


Expand Down Expand Up @@ -242,7 +242,7 @@ extern sqInt minSlotsForShortening(void);
extern sqInt nilObject(void);
extern sqInt nonIndexablePointerFormat(void);
extern sqInt numBytesOf(sqInt objOop);
extern usqInt numPointerSlotsOf(sqInt objOop);
extern sqInt numPointerSlotsOf(sqInt objOop);
extern usqInt numSlotsOf(sqInt objOop);
extern sqInt numStrongSlotsOfWeakling(sqInt objOop);
extern sqInt objectAfter(sqInt objOop);
Expand Down
Loading

0 comments on commit bbcacee

Please sign in to comment.