Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.3484
Browse files Browse the repository at this point in the history
On Spur, speed up new hash assignment in generated identityHash
by calling ceNewHashOf: on the Smalltalk stack.

Fix a crash in is:KindOfClass: in Cuis images that manifests when printing strings via printOop:/longPrintOop:.
  • Loading branch information
eliotmiranda committed Dec 20, 2024
1 parent 239bdc9 commit 7a840f0
Show file tree
Hide file tree
Showing 63 changed files with 2,346 additions and 921 deletions.
2 changes: 1 addition & 1 deletion src/spur32.cog.lowcode/cogit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3482 uuid: 361722fc-fb12-4419-8419-880fe062da35
CCodeGenerator VMMaker.oscog-eem.3484 uuid: c952326c-8119-4ef6-bb58-255dca8bbd22
(Compiler-eem.512)
*/

Expand Down
60 changes: 42 additions & 18 deletions src/spur32.cog.lowcode/cogitARMv5.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3482 uuid: 361722fc-fb12-4419-8419-880fe062da35
CCodeGenerator VMMaker.oscog-eem.3484 uuid: c952326c-8119-4ef6-bb58-255dca8bbd22
(Compiler-eem.512)
from
StackToRegisterMappingCogit VMMaker.oscog-eem.3482 uuid: 361722fc-fb12-4419-8419-880fe062da35
StackToRegisterMappingCogit VMMaker.oscog-eem.3484 uuid: c952326c-8119-4ef6-bb58-255dca8bbd22
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3482 uuid: 361722fc-fb12-4419-8419-880fe062da35 " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3484 uuid: c952326c-8119-4ef6-bb58-255dca8bbd22 " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -288,7 +288,7 @@ char *__cogitBuildInfo = __buildInfo;
#define NumSendTrampolines 4
#define NumSpecialSelectors 32
#define NumStoreTrampolines 5
#define NumTrampolines (84 + (IMMUTABILITY ? 5 : 0))
#define NumTrampolines (83 + (IMMUTABILITY ? 5 : 0))
#define OrCqR 109
#define OrCqRR 125
#define OrCwR 117
Expand Down Expand Up @@ -1019,6 +1019,7 @@ static sqInt numSmallIntegerBits(void);
static NoDbgRegParms sqInt validInlineCacheTag(usqInt classIndexOrTagPattern);
static void callStoreCheckTrampoline(void);
static NoDbgRegParms sqInt checkValidOopReference(sqInt anOop);
static void compileInvokeCENewHashOf(void);
static NoDbgRegParms sqInt couldBeObject(sqInt literal);
static NoDbgRegParms usqInt genActiveContextTrampolineLargeinBlockcalled(sqInt isLarge, sqInt isInBlock, char *aString);
static NoDbgRegParms AbstractInstruction * genAllocFloatValueintoscratchRegscratchReg(sqInt dpreg, sqInt resultReg, sqInt scratch1, sqInt scratch2);
Expand Down Expand Up @@ -1455,7 +1456,6 @@ static sqInt ceLargeActiveContextInFullBlockTrampoline;
static sqInt ceLargeActiveContextInMethodTrampoline;
static sqInt ceMallocTrampoline;
static sqInt ceMethodAbortTrampoline;
static sqInt ceNewHashTrampoline;
static sqInt ceNonLocalReturnTrampoline;
static sqInt cePICAbortTrampoline;
static sqInt cePositive32BitIntegerTrampoline;
Expand Down Expand Up @@ -8451,7 +8451,10 @@ CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved)
{
int callerSavedRegsToBeSaved;
AbstractInstruction *lastInst;
int mustSaveSPReg;
sqInt spareCalleeSavedReg;

spareCalleeSavedReg = 0;
callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved;

/* genPushRegisterMask: */
Expand All @@ -8462,7 +8465,21 @@ CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved)
/* Label */
genoperandoperand(Label, (labelCounter += 1), bytecodePC);
}

/* If the backEnd doesn't use the native SP register in generated code, and the non-native
SP is not callee-saved, then it too must be saved and restored around the call. */
mustSaveSPReg = 0 /* (usesNativeSPReg not) */;
if (mustSaveSPReg) {
spareCalleeSavedReg = availableRegisterOrNoneIn(((ABICalleeSavedRegisterMask | ((1U << SPReg))) - ((1U << SPReg))));
assert(!((spareCalleeSavedReg == NoReg)));

/* MoveR:R: */
genoperandoperand(MoveRR, SPReg, spareCalleeSavedReg);
}
lastInst = checkLiteralforInstruction(callTarget, genoperand(CallFull, callTarget));
if (mustSaveSPReg) {
lastInst = genoperandoperand(MoveRR, spareCalleeSavedReg, SPReg);
}
return /* genPopRegisterMask: */
(callerSavedRegsToBeSaved
? genoperand(PopLDM, callerSavedRegsToBeSaved)
Expand Down Expand Up @@ -12378,7 +12395,7 @@ generateCaptureCStackPointers(sqInt captureFramePointer)
pushedVarBaseReg = 0;
if (!(((CallerSavedRegisterMask & ((1U << VarBaseReg))) != 0))) {
/* TempReg used below */
callerSavedReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << TempReg)) - (1U << TempReg)));
callerSavedReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | ((1U << TempReg))) - ((1U << TempReg))));
if (callerSavedReg == NoReg) {
gNativePushR(VarBaseReg);
pushedVarBaseReg = 1;
Expand Down Expand Up @@ -21506,9 +21523,7 @@ genPrimitiveAtSigned(sqInt signedVersion)
static sqInt
genPrimitiveIdentityHash(void)
{
AbstractInstruction *abstractInstruction;
AbstractInstruction *anInstruction;
AbstractInstruction *inst;
AbstractInstruction *jumpImm;
AbstractInstruction *jumpNotSet;
AbstractInstruction *jumpSI;
Expand Down Expand Up @@ -21545,15 +21560,7 @@ genPrimitiveIdentityHash(void)
if (!(primitiveIndex == 75)) {
return 0;
}
backEnd;

/* begin saveAndRestoreLinkRegAround: */
inst = genoperand(PushR, LinkReg);
abstractInstruction = genoperand(Call, ceNewHashTrampoline);
(abstractInstruction->annotation = IsRelativeCall);

/* PopR: */
genoperand(PopR, LinkReg);
compileInvokeCENewHashOf();

/* genPrimReturn */
if (methodOrBlockNumArgs <= (numRegArgs())) {
Expand Down Expand Up @@ -23070,6 +23077,24 @@ checkValidOopReference(sqInt anOop)
|| ((heapMapAtWord(pointerForOop(anOop))) != 0);
}

/* CogObjectRepresentationForSpur>>#compileInvokeCENewHashOf */
static void
compileInvokeCENewHashOf(void)
{
AbstractInstruction *inst;

backEnd;

/* begin saveAndRestoreLinkRegAround: */
inst = genoperand(PushR, LinkReg);
genMarshallNArgsargargargarg(backEnd, 1, ReceiverResultReg, null, null, null);
CallFullRTregistersToBeSavedMask(((usqInt)ceNewHashOf), (1U << ReceiverResultReg) | (1U << VarBaseReg));
genWriteCResultIntoReg(backEnd, ReceiverResultReg);

/* PopR: */
genoperand(PopR, LinkReg);
}

/* CogObjectRepresentationForSpur>>#couldBeObject: */
static NoDbgRegParms sqInt
couldBeObject(sqInt literal)
Expand Down Expand Up @@ -23540,7 +23565,6 @@ generateObjectRepresentationTrampolines(void)
}
# endif // IMMUTABILITY

ceNewHashTrampoline = genTrampolineForcallednumArgsargargargargregsToSavepushLinkRegresultRegappendOpcodes(ceNewHashOf, "ceNewHash", 1, ReceiverResultReg, null, null, null, 0 /* emptyRegisterMask */, 1, ReceiverResultReg, 0);
ceInlineNewHashTrampoline = genTrampolineForcallednumArgsargargargargregsToSavepushLinkRegresultRegappendOpcodes(ceNewHashOf, "ceInlineNewHash", 1, ReceiverResultReg, null, null, null, ((CallerSavedRegisterMask | ((1U << ReceiverResultReg))) - ((1U << ReceiverResultReg))), 1, ReceiverResultReg, 0);

/* begin genStoreCheckTrampoline */
Expand Down
81 changes: 68 additions & 13 deletions src/spur32.cog.lowcode/cogitIA32.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3482 uuid: 361722fc-fb12-4419-8419-880fe062da35
CCodeGenerator VMMaker.oscog-eem.3484 uuid: c952326c-8119-4ef6-bb58-255dca8bbd22
(Compiler-eem.512)
from
StackToRegisterMappingCogit VMMaker.oscog-eem.3482 uuid: 361722fc-fb12-4419-8419-880fe062da35
StackToRegisterMappingCogit VMMaker.oscog-eem.3484 uuid: c952326c-8119-4ef6-bb58-255dca8bbd22
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3482 uuid: 361722fc-fb12-4419-8419-880fe062da35 " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3484 uuid: c952326c-8119-4ef6-bb58-255dca8bbd22 " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -278,7 +278,7 @@ char *__cogitBuildInfo = __buildInfo;
#define NumSendTrampolines 4
#define NumSpecialSelectors 32
#define NumStoreTrampolines 5
#define NumTrampolines (84 + (IMMUTABILITY ? 5 : 0))
#define NumTrampolines (83 + (IMMUTABILITY ? 5 : 0))
#define OrCqR 109
#define OrCwR 117
#define OrRR 103
Expand Down Expand Up @@ -549,7 +549,7 @@ static NoDbgRegParms AbstractInstruction * genSwapRRScratch(AbstractInstruction
static NoDbgRegParms int hasSSE2Instructions(AbstractInstruction *self_in_CogIA32Compiler);
static NoDbgRegParms int hasSSEInstructions(AbstractInstruction *self_in_CogIA32Compiler);
static NoDbgRegParms sqInt inlineCacheTagAt(AbstractInstruction *self_in_CogIA32Compiler, sqInt callSiteReturnAddress);
static NoDbgRegParms sqInt instructionSizeAt(AbstractInstruction *self_in_CogIA32Compiler, sqInt pc);
static NoDbgRegParms int instructionSizeAt(AbstractInstruction *self_in_CogIA32Compiler, sqInt pc);
static NoDbgRegParms int isCallPrecedingReturnPC(AbstractInstruction *self_in_CogIA32Compiler, sqInt mcpc);
static NoDbgRegParms sqInt isJumpAt(AbstractInstruction *self_in_CogIA32Compiler, sqInt pc);
static NoDbgRegParms sqInt isPCDependent(AbstractInstruction *self_in_CogIA32Compiler);
Expand Down Expand Up @@ -613,6 +613,7 @@ static NoDbgRegParms void assertSaneJumpTarget(AbstractInstruction *jumpTarget);
static NoDbgRegParms sqInt availableRegisterOrNoneIn(sqInt liveRegsMask);
static NoDbgRegParms sqInt blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg);
extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
static NoDbgRegParms AbstractInstruction * CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved);
static NoDbgRegParms AbstractInstruction * CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved);
static NoDbgRegParms AbstractInstruction * gCall(sqInt callTarget);
static NoDbgRegParms AbstractInstruction * gCmpCqR(sqInt quickConstant, sqInt reg);
Expand Down Expand Up @@ -1387,7 +1388,6 @@ static sqInt ceLargeActiveContextInFullBlockTrampoline;
static sqInt ceLargeActiveContextInMethodTrampoline;
static sqInt ceMallocTrampoline;
static sqInt ceMethodAbortTrampoline;
static sqInt ceNewHashTrampoline;
static sqInt ceNonLocalReturnTrampoline;
static sqInt cePICAbortTrampoline;
static sqInt cePositive32BitIntegerTrampoline;
Expand Down Expand Up @@ -7076,7 +7076,7 @@ inlineCacheTagAt(AbstractInstruction *self_in_CogIA32Compiler, sqInt callSiteRet
It only has to cope with the instructions generated in a block dispatch. */

/* CogIA32Compiler>>#instructionSizeAt: */
static NoDbgRegParms sqInt
static NoDbgRegParms int
instructionSizeAt(AbstractInstruction *self_in_CogIA32Compiler, sqInt pc)
{
sqInt op;
Expand Down Expand Up @@ -7248,7 +7248,7 @@ jumpTargetPCAt(AbstractInstruction *self_in_CogIA32Compiler, sqInt pc)
{
sqInt byte;
sqInt offset;
sqInt size;
int size;

size = instructionSizeAt(self_in_CogIA32Compiler, pc);
if (size == 2) {
Expand Down Expand Up @@ -8286,6 +8286,56 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod)
return 0;
}

/* Cogit>>#CallFullRT:registersToBeSavedMask: */
static NoDbgRegParms AbstractInstruction *
CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved)
{
int callerSavedRegsToBeSaved;
AbstractInstruction *lastInst;
int mustSaveSPReg;
sqInt reg;
int registersToBePushed;
sqInt spareCalleeSavedReg;

spareCalleeSavedReg = 0;
callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved;
registersToBePushed = callerSavedRegsToBeSaved;
reg = 0;
while (registersToBePushed != 0) {
if (((registersToBePushed & 1) != 0)) {
/* PushR: */
genoperand(PushR, reg);
}
reg += 1;
registersToBePushed = (registersToBePushed) >> 1;
}

/* If the backEnd doesn't use the native SP register in generated code, and the non-native
SP is not callee-saved, then it too must be saved and restored around the call. */
mustSaveSPReg = 0 /* (usesNativeSPReg not) */;
if (mustSaveSPReg) {
spareCalleeSavedReg = availableRegisterOrNoneIn(((ABICalleeSavedRegisterMask | ((1U << SPReg))) - ((1U << SPReg))));
assert(!((spareCalleeSavedReg == NoReg)));

/* MoveR:R: */
genoperandoperand(MoveRR, SPReg, spareCalleeSavedReg);
}

/* begin CallFullRT: */
lastInst = genoperand(CallFull, callTarget);
(lastInst->annotation = IsRelativeCall);
if (mustSaveSPReg) {
lastInst = genoperandoperand(MoveRR, spareCalleeSavedReg, SPReg);
}
while (reg > 0) {
reg -= 1;
if (((callerSavedRegsToBeSaved & (1U << reg)) != 0)) {
lastInst = genoperand(PopR, reg);
}
}
return lastInst;
}

/* Cogit>>#CallRT:registersToBeSavedMask: */
static NoDbgRegParms AbstractInstruction *
CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved)
Expand Down Expand Up @@ -20688,11 +20738,11 @@ genPrimitiveAtSigned(sqInt signedVersion)
static sqInt
genPrimitiveIdentityHash(void)
{
AbstractInstruction *abstractInstruction;
AbstractInstruction *jumpImm;
AbstractInstruction *jumpNotSet;
AbstractInstruction *jumpSI;
AbstractInstruction *ret;
AbstractInstruction *self_in_CogIA32Compiler;

jumpImm = genJumpImmediate(ReceiverResultReg);
genGetHashFieldNonImmOfasSmallIntegerInto(ReceiverResultReg, TempReg);
Expand Down Expand Up @@ -20722,9 +20772,15 @@ genPrimitiveIdentityHash(void)
return 0;
}

/* begin CallRT: */
abstractInstruction = genoperand(Call, ceNewHashTrampoline);
(abstractInstruction->annotation = IsRelativeCall);
/* begin compileInvokeCENewHashOf */
self_in_CogIA32Compiler = ((AbstractInstruction *) (backEnd));

/* PushR: */
genoperand(PushR, ReceiverResultReg);
/* end genMarshallNArgs:arg:arg:arg:arg: */
l1:
CallFullRTregistersToBeSavedMask(((usqInt)ceNewHashOf), (1U << ReceiverResultReg));
genWriteCResultIntoReg(backEnd, ReceiverResultReg);

/* genPrimReturn */
if (methodOrBlockNumArgs <= (numRegArgs())) {
Expand Down Expand Up @@ -22196,7 +22252,6 @@ generateObjectRepresentationTrampolines(void)
}
# endif // IMMUTABILITY

ceNewHashTrampoline = genTrampolineForcallednumArgsargargargargregsToSavepushLinkRegresultRegappendOpcodes(ceNewHashOf, "ceNewHash", 1, ReceiverResultReg, null, null, null, 0 /* emptyRegisterMask */, 1, ReceiverResultReg, 0);
ceInlineNewHashTrampoline = genTrampolineForcallednumArgsargargargargregsToSavepushLinkRegresultRegappendOpcodes(ceNewHashOf, "ceInlineNewHash", 1, ReceiverResultReg, null, null, null, ((CallerSavedRegisterMask | ((1U << ReceiverResultReg))) - ((1U << ReceiverResultReg))), 1, ReceiverResultReg, 0);

/* begin genStoreCheckTrampoline */
Expand Down
Loading

0 comments on commit 7a840f0

Please sign in to comment.