Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.3332
Browse files Browse the repository at this point in the history
Cogit: When a link register is in use, fix the failure to save & restore the
link register around the unforwarding call in a frameless block activation.
Thanks to Tom Braun for finding this bug.
  • Loading branch information
eliotmiranda committed Jul 17, 2023
1 parent 9f5bd00 commit 45ec521
Show file tree
Hide file tree
Showing 56 changed files with 1,751 additions and 1,749 deletions.
2 changes: 1 addition & 1 deletion src/spur32.cog.lowcode/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3329 uuid: 31a93bfc-1d06-4008-9439-27c01b0644f9
CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec
*/


Expand Down
42 changes: 23 additions & 19 deletions src/spur32.cog.lowcode/cogitARMv5.c
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3329 uuid: 31a93bfc-1d06-4008-9439-27c01b0644f9
CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec
from
StackToRegisterMappingCogit VMMaker.oscog-eem.3329 uuid: 31a93bfc-1d06-4008-9439-27c01b0644f9
StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3329 uuid: 31a93bfc-1d06-4008-9439-27c01b0644f9 " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -1071,7 +1071,6 @@ static sqInt NoDbgRegParms genConvertIntegerToCharacterInReg(sqInt reg);
static sqInt NoDbgRegParms genCreateClosureAtnumArgsnumCopiedcontextNumArgslargeinBlock(sqInt bcpc, sqInt numArgs, sqInt numCopied, sqInt ctxtNumArgs, sqInt isLargeCtxt, sqInt isInBlock);
static sqInt NoDbgRegParms genCreateFullClosurenumArgsnumCopiedignoreContextcontextNumArgslargeinBlock(sqInt compiledBlock, sqInt numArgs, sqInt numCopied, sqInt ignoreContext, sqInt contextNumArgs, sqInt contextIsLarge, sqInt contextIsBlock);
static sqInt NoDbgRegParms genEnsureObjInRegNotForwardedscratchReg(sqInt reg, sqInt scratch);
static sqInt NoDbgRegParms genEnsureOopInRegNotForwardedscratchReg(sqInt reg, sqInt scratch);
static sqInt NoDbgRegParms genEnsureOopInRegNotForwardedscratchRegifForwarderifNotForwarder(sqInt reg, sqInt scratch, void *fwdJumpTarget, void *nonFwdJumpTargetOrZero);
static sqInt NoDbgRegParms genEnsureOopInRegNotForwardedscratchRegupdatingSlotin(sqInt reg, sqInt scratch, sqInt index, sqInt objReg);
static void generateObjectRepresentationTrampolines(void);
Expand Down Expand Up @@ -2862,6 +2861,7 @@ void (*realCEEnterCogCodePopReceiverReg)(void);
#define literalInstructionAt(index) (&literals[index])
#define fullBlockEntryOffset() cbEntryOffset
#define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset
#define needsFrame() needsFrame
#define fixupAtIndex(index) (&fixups[index])
#define simNativeStackAt(index) (simNativeStack + (index))
#define simSelf() simStack
Expand Down Expand Up @@ -22947,17 +22947,6 @@ genEnsureObjInRegNotForwardedscratchReg(sqInt reg, sqInt scratch)
return 0;
}

/* CogObjectRepresentationForSpur>>#genEnsureOopInRegNotForwarded:scratchReg: */
static sqInt NoDbgRegParms
genEnsureOopInRegNotForwardedscratchReg(sqInt reg, sqInt scratch)
{
AbstractInstruction *instruction;

/* begin genEnsureOopInRegNotForwarded:scratchReg:jumpBackTo: */
instruction = genoperandoperand(Label, (labelCounter += 1), bytecodePC);
return genEnsureOopInRegNotForwardedscratchRegifForwarderifNotForwarder(reg, scratch, instruction, 0);
}


/* Make sure that the oop in reg is not forwarded.
Use the fact that isForwardedObjectClassIndexPun is a power of two to save
Expand Down Expand Up @@ -23021,10 +23010,12 @@ static sqInt NoDbgRegParms
genEnsureOopInRegNotForwardedscratchRegupdatingSlotin(sqInt reg, sqInt scratch, sqInt index, sqInt objReg)
{
AbstractInstruction *abstractInstruction;
AbstractInstruction *abstractInstruction1;
AbstractInstruction *anInstruction;
AbstractInstruction *anInstruction1;
AbstractInstruction *anInstruction2;
AbstractInstruction *imm;
AbstractInstruction *inst;
AbstractInstruction *loop;
AbstractInstruction *ok;
sqInt quickConstant;
Expand Down Expand Up @@ -23069,9 +23060,19 @@ genEnsureOopInRegNotForwardedscratchRegupdatingSlotin(sqInt reg, sqInt scratch,
assert((reg == Arg0Reg)
&& ((scratch == TempReg)
&& (objReg == ReceiverResultReg)));
/* begin CallRT: */
abstractInstruction = genoperand(Call, ceStoreCheckContextReceiverTrampoline);
(abstractInstruction->annotation = IsRelativeCall);
if (needsFrame()) {
/* begin CallRT: */
abstractInstruction = genoperand(Call, ceStoreCheckContextReceiverTrampoline);
(abstractInstruction->annotation = IsRelativeCall);
}
else {
/* begin saveAndRestoreLinkRegAround: */
inst = genoperand(PushR, LinkReg);
/* begin CallRT: */
abstractInstruction1 = genoperand(Call, ceStoreCheckContextReceiverTrampoline);
(abstractInstruction1->annotation = IsRelativeCall);
genoperand(PopR, LinkReg);
}
/* begin Jump: */
genoperand(Jump, ((sqInt)loop));
jmpTarget(ok, jmpTarget(imm, genoperandoperand(Label, (labelCounter += 1), bytecodePC)));
Expand Down Expand Up @@ -43781,6 +43782,7 @@ genMarshalledSendnumArgssendTable(sqInt selectorIndex, sqInt numArgs, sqInt *sen
AbstractInstruction *anInstruction;
AbstractInstruction *anInstruction1;
sqInt annotation;
AbstractInstruction *instruction;

assert(needsFrame);
/* begin annotationForSendTable: */
Expand All @@ -43801,7 +43803,9 @@ genMarshalledSendnumArgssendTable(sqInt selectorIndex, sqInt numArgs, sqInt *sen
l2: /* end annotationForSendTable: */;
if ((annotation == IsSuperSend)
|| (((annotation >= IsDirectedSuperSend) && (annotation <= IsDirectedSuperBindingSend)))) {
genEnsureOopInRegNotForwardedscratchReg(ReceiverResultReg, TempReg);
/* begin genEnsureOopInRegNotForwarded:scratchReg:jumpBackTo: */
instruction = genoperandoperand(Label, (labelCounter += 1), bytecodePC);
genEnsureOopInRegNotForwardedscratchRegifForwarderifNotForwarder(ReceiverResultReg, TempReg, instruction, 0);
}
if (numArgs >= (NumSendTrampolines - 1)) {
/* begin checkQuickConstant:forInstruction: */
Expand Down
39 changes: 20 additions & 19 deletions src/spur32.cog.lowcode/cogitIA32.c
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3329 uuid: 31a93bfc-1d06-4008-9439-27c01b0644f9
CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec
from
StackToRegisterMappingCogit VMMaker.oscog-eem.3329 uuid: 31a93bfc-1d06-4008-9439-27c01b0644f9
StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3329 uuid: 31a93bfc-1d06-4008-9439-27c01b0644f9 " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -1030,7 +1030,6 @@ static sqInt NoDbgRegParms genConvertIntegerToCharacterInReg(sqInt reg);
static sqInt NoDbgRegParms genCreateClosureAtnumArgsnumCopiedcontextNumArgslargeinBlock(sqInt bcpc, sqInt numArgs, sqInt numCopied, sqInt ctxtNumArgs, sqInt isLargeCtxt, sqInt isInBlock);
static sqInt NoDbgRegParms genCreateFullClosurenumArgsnumCopiedignoreContextcontextNumArgslargeinBlock(sqInt compiledBlock, sqInt numArgs, sqInt numCopied, sqInt ignoreContext, sqInt contextNumArgs, sqInt contextIsLarge, sqInt contextIsBlock);
static sqInt NoDbgRegParms genEnsureObjInRegNotForwardedscratchReg(sqInt reg, sqInt scratch);
static sqInt NoDbgRegParms genEnsureOopInRegNotForwardedscratchReg(sqInt reg, sqInt scratch);
static sqInt NoDbgRegParms genEnsureOopInRegNotForwardedscratchRegifForwarderifNotForwarder(sqInt reg, sqInt scratch, void *fwdJumpTarget, void *nonFwdJumpTargetOrZero);
static sqInt NoDbgRegParms genEnsureOopInRegNotForwardedscratchRegupdatingSlotin(sqInt reg, sqInt scratch, sqInt index, sqInt objReg);
static void generateObjectRepresentationTrampolines(void);
Expand Down Expand Up @@ -2799,6 +2798,7 @@ void (*realCEEnterCogCodePopReceiverReg)(void);
#define maybeConstant(sse) ((sse)->constant)
#define fullBlockEntryOffset() cbEntryOffset
#define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset
#define needsFrame() needsFrame
#define fixupAtIndex(index) (&fixups[index])
#define simNativeStackAt(index) (simNativeStack + (index))
#define simSelf() simStack
Expand Down Expand Up @@ -21818,17 +21818,6 @@ genEnsureObjInRegNotForwardedscratchReg(sqInt reg, sqInt scratch)
return 0;
}

/* CogObjectRepresentationForSpur>>#genEnsureOopInRegNotForwarded:scratchReg: */
static sqInt NoDbgRegParms
genEnsureOopInRegNotForwardedscratchReg(sqInt reg, sqInt scratch)
{
AbstractInstruction *instruction;

/* begin genEnsureOopInRegNotForwarded:scratchReg:jumpBackTo: */
instruction = genoperandoperand(Label, (labelCounter += 1), bytecodePC);
return genEnsureOopInRegNotForwardedscratchRegifForwarderifNotForwarder(reg, scratch, instruction, 0);
}


/* Make sure that the oop in reg is not forwarded.
Use the fact that isForwardedObjectClassIndexPun is a power of two to save
Expand Down Expand Up @@ -21886,6 +21875,7 @@ static sqInt NoDbgRegParms
genEnsureOopInRegNotForwardedscratchRegupdatingSlotin(sqInt reg, sqInt scratch, sqInt index, sqInt objReg)
{
AbstractInstruction *abstractInstruction;
AbstractInstruction *abstractInstruction1;
AbstractInstruction *anInstruction;
AbstractInstruction *anInstruction1;
AbstractInstruction *anInstruction2;
Expand Down Expand Up @@ -21925,9 +21915,17 @@ genEnsureOopInRegNotForwardedscratchRegupdatingSlotin(sqInt reg, sqInt scratch,
assert((reg == Arg0Reg)
&& ((scratch == TempReg)
&& (objReg == ReceiverResultReg)));
/* begin CallRT: */
abstractInstruction = genoperand(Call, ceStoreCheckContextReceiverTrampoline);
(abstractInstruction->annotation = IsRelativeCall);
if (needsFrame()) {
/* begin CallRT: */
abstractInstruction = genoperand(Call, ceStoreCheckContextReceiverTrampoline);
(abstractInstruction->annotation = IsRelativeCall);
}
else {
/* begin saveAndRestoreLinkRegAround: */
/* begin CallRT: */
abstractInstruction1 = genoperand(Call, ceStoreCheckContextReceiverTrampoline);
(abstractInstruction1->annotation = IsRelativeCall);
}
/* begin Jump: */
genoperand(Jump, ((sqInt)loop));
jmpTarget(ok, jmpTarget(imm, genoperandoperand(Label, (labelCounter += 1), bytecodePC)));
Expand Down Expand Up @@ -40542,6 +40540,7 @@ genMarshalledSendnumArgssendTable(sqInt selectorIndex, sqInt numArgs, sqInt *sen
AbstractInstruction *anInstruction;
AbstractInstruction *anInstruction1;
sqInt annotation;
AbstractInstruction *instruction;

assert(needsFrame);
/* begin annotationForSendTable: */
Expand All @@ -40562,7 +40561,9 @@ genMarshalledSendnumArgssendTable(sqInt selectorIndex, sqInt numArgs, sqInt *sen
l2: /* end annotationForSendTable: */;
if ((annotation == IsSuperSend)
|| (((annotation >= IsDirectedSuperSend) && (annotation <= IsDirectedSuperBindingSend)))) {
genEnsureOopInRegNotForwardedscratchReg(ReceiverResultReg, TempReg);
/* begin genEnsureOopInRegNotForwarded:scratchReg:jumpBackTo: */
instruction = genoperandoperand(Label, (labelCounter += 1), bytecodePC);
genEnsureOopInRegNotForwardedscratchRegifForwarderifNotForwarder(ReceiverResultReg, TempReg, instruction, 0);
}
if (numArgs >= (NumSendTrampolines - 1)) {
/* begin checkQuickConstant:forInstruction: */
Expand Down

0 comments on commit 45ec521

Please sign in to comment.