Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.2773/ClosedVMMaker-eem.93
Browse files Browse the repository at this point in the history
Cogit:
Fix the use of the undefined ceFlushDCache function when DUAL_WRITE_CODE_ZONE is not defined and flushDCacheFrom:to: is not a no-op.
Make sure any generated check features, and the generated run-time are cache flushed before use.
Move maybeGenerateCheckLZCNT later initializeCodeZoneFrom:upTo:; its result is not used until compiling primitives.
  • Loading branch information
eliotmiranda committed Jul 9, 2020
1 parent 839a5ca commit 41115d4
Show file tree
Hide file tree
Showing 36 changed files with 913 additions and 875 deletions.
2 changes: 1 addition & 1 deletion nsspur64src/vm/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2772 uuid: 925a3892-829d-4417-bd5b-1a6a26678025
CCodeGenerator VMMaker.oscog-eem.2773 uuid: 3c51054d-e839-4959-b3e1-562845a4fa54
*/


Expand Down
99 changes: 50 additions & 49 deletions nsspur64src/vm/cogitARMv8.c
@@ -1,11 +1,11 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2771 uuid: a7ba3af0-70cc-4104-be1b-8895f533ed7b
CCodeGenerator VMMaker.oscog-eem.2773 uuid: 3c51054d-e839-4959-b3e1-562845a4fa54
from
StackToRegisterMappingCogit VMMaker.oscog-eem.2771 uuid: a7ba3af0-70cc-4104-be1b-8895f533ed7b
CogARMv8Compiler ClosedVMMaker-eem.91 uuid: 9eed98a3-f3c9-460f-896a-c05bcf527040
StackToRegisterMappingCogit VMMaker.oscog-eem.2773 uuid: 3c51054d-e839-4959-b3e1-562845a4fa54
CogARMv8Compiler ClosedVMMaker-eem.93 uuid: 6b76492f-7d98-4758-9c5d-3ffe9d5d6cce
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2771 uuid: a7ba3af0-70cc-4104-be1b-8895f533ed7b\n\
CogARMv8Compiler ClosedVMMaker-eem.91 uuid: 9eed98a3-f3c9-460f-896a-c05bcf527040 " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2773 uuid: 3c51054d-e839-4959-b3e1-562845a4fa54\n\
CogARMv8Compiler ClosedVMMaker-eem.93 uuid: 6b76492f-7d98-4758-9c5d-3ffe9d5d6cce " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -822,7 +822,6 @@ static sqInt NoDbgRegParms markLiteralspcmethod(sqInt annotation, char *mcpc, sq
extern void markMethodAndReferents(CogBlockMethod *aCogMethod);
extern usqInt maxCogMethodAddress(void);
static sqInt maybeAllocAndInitIRCs(void);
static void NoDbgRegParms maybeFlushWritableZoneFromto(usqInt startAddress, usqInt endAddress);
static sqInt NoDbgRegParms maybeFreeCogMethodDoesntLookKosher(CogMethod *cogMethod);
static sqInt mclassIsSmallInteger(void);
extern usqInt mcPCForBackwardBranchstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
Expand Down Expand Up @@ -4968,7 +4967,6 @@ dispatchConcretize(AbstractInstruction * self_in_dispatchConcretize)

case MulOverflowRRR:
/* begin concretizeMulOverflowRRR */
/* send of break elided */;
reg12 = ((self_in_dispatchConcretize->operands))[0];
reg22 = ((self_in_dispatchConcretize->operands))[1];
reg32 = ((self_in_dispatchConcretize->operands))[2];
Expand Down Expand Up @@ -12590,18 +12588,18 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
sqInt fixupSize;
sqInt fixupSize1;
sqInt fixupSize11;
sqInt fixupSize3;
sqInt fixupSize2;
sqInt numberOfAbstractOpcodes;
sqInt numberOfAbstractOpcodes1;
sqInt numberOfAbstractOpcodes11;
sqInt numberOfAbstractOpcodes3;
sqInt numberOfAbstractOpcodes2;
sqInt opcodeSize;
sqInt opcodeSize1;
sqInt opcodeSize11;
sqInt opcodeSize3;
sqInt opcodeSize2;
usqInt startAddress1;
usqInt startAddress2;
usqInt startAddress4;
usqInt startAddress3;
sqInt v;

v = 0;
Expand Down Expand Up @@ -12640,24 +12638,24 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
outputInstructionsForGeneratedRuntimeAt(startAddress2);
recordGeneratedRunTimeaddress("ceCheckFeaturesFunction", startAddress2);
ceCheckFeaturesFunction = ((usqIntptr_t (*)(void)) startAddress2);
/* begin maybeGenerateCheckLZCNT */
initialFlushICacheFromto(backEnd, startAddress2, methodZoneBase);
/* begin maybeGenerateCacheFlush */
/* begin allocateOpcodes:bytecodes: */
numberOfAbstractOpcodes3 = 24 /* numICacheFlushOpcodes */;
numAbstractOpcodes = numberOfAbstractOpcodes3;
opcodeSize3 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes;
fixupSize3 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes;
abstractOpcodes = alloca(opcodeSize3 + fixupSize3);
bzero(abstractOpcodes, opcodeSize3 + fixupSize3);
fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize3));
numberOfAbstractOpcodes2 = 24 /* numICacheFlushOpcodes */;
numAbstractOpcodes = numberOfAbstractOpcodes2;
opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes;
fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes;
abstractOpcodes = alloca(opcodeSize2 + fixupSize2);
bzero(abstractOpcodes, opcodeSize2 + fixupSize2);
fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2));
zeroOpcodeIndexForNewOpcodes();
labelCounter = 0;
startAddress4 = methodZoneBase;
startAddress3 = methodZoneBase;
generateICacheFlush(backEnd);
outputInstructionsForGeneratedRuntimeAt(startAddress4);
recordGeneratedRunTimeaddress("ceFlushICache", startAddress4);
ceFlushICache = ((void (*)(usqIntptr_t,usqIntptr_t)) startAddress4);
initialFlushICacheFromto(backEnd, startAddress4, methodZoneBase);
outputInstructionsForGeneratedRuntimeAt(startAddress3);
recordGeneratedRunTimeaddress("ceFlushICache", startAddress3);
ceFlushICache = ((void (*)(usqIntptr_t,usqIntptr_t)) startAddress3);
initialFlushICacheFromto(backEnd, startAddress3, methodZoneBase);

# if DUAL_MAPPED_CODE_ZONE
if ((numDCacheFlushOpcodes(backEnd)) > 0) {
Expand All @@ -12671,14 +12669,15 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize11));
zeroOpcodeIndexForNewOpcodes();
labelCounter = 0;
startAddress4 = methodZoneBase;
startAddress3 = methodZoneBase;
generateDCacheFlush(backEnd);
outputInstructionsForGeneratedRuntimeAt(startAddress4);
recordGeneratedRunTimeaddress("ceFlushDCache", startAddress4);
ceFlushDCache = ((void (*)(usqIntptr_t,usqIntptr_t)) startAddress4);
initialFlushICacheFromto(backEnd, startAddress4, methodZoneBase);
outputInstructionsForGeneratedRuntimeAt(startAddress3);
recordGeneratedRunTimeaddress("ceFlushDCache", startAddress3);
ceFlushDCache = ((void (*)(usqIntptr_t,usqIntptr_t)) startAddress3);
initialFlushICacheFromto(backEnd, startAddress3, methodZoneBase);
}
# endif /* DUAL_MAPPED_CODE_ZONE */
/* begin maybeGenerateCheckLZCNT */
/* begin generateVMOwnerLockFunctions */

# if COGMTVM
Expand Down Expand Up @@ -12714,7 +12713,14 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
computeFullBlockEntryOffsets();
generateClosedPICPrototype();
alignMethodZoneBase();
maybeFlushWritableZoneFromto(startAddress, ((usqInt)methodZoneBase));
flushICacheFromto(backEnd, startAddress, ((usqInt)methodZoneBase));
/* begin maybeFlushWritableZoneFrom:to: */

# if DUAL_MAPPED_CODE_ZONE
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, startAddress, ((usqInt)methodZoneBase));
}
# endif /* DUAL_MAPPED_CODE_ZONE */
/* begin manageFrom:to: */
mzFreeStart = (baseAddress = methodZoneBase);
youngReferrers = (limitAddress = endAddress);
Expand Down Expand Up @@ -14045,23 +14051,6 @@ maybeAllocAndInitIRCs(void)
}


/* If there is a dual mapped code zone (the normal zone but marked with
read/execute, and a read/write zone codeToDataDelta bytes away) then the
data cache for the read/write
zone must be flushed, and the data cache for the read/execute zone must be
invalidated, for the Cogit to see the same values in both zones after a
write to the read/write zone. */

/* Cogit>>#maybeFlushWritableZoneFrom:to: */
static void NoDbgRegParms
maybeFlushWritableZoneFromto(usqInt startAddress, usqInt endAddress)
{
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, startAddress, endAddress);
}
}


/* Check that the header fields are consistent with the type.
Answer 0 if it is ok, otherwise answer a code for the error. */

Expand Down Expand Up @@ -16483,7 +16472,13 @@ compactCompiledCode(void)
if (((source->cmType)) != CMFree) {
methodCount += 1;
codeMemmove(dest, source, bytes);
maybeFlushWritableZoneFromto(((usqInt)dest), (((usqInt)dest)) + bytes);
/* begin maybeFlushWritableZoneFrom:to: */

# if DUAL_MAPPED_CODE_ZONE
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, ((usqInt)dest), (((usqInt)dest)) + bytes);
}
# endif /* DUAL_MAPPED_CODE_ZONE */
((writableVersion = ((CogMethod *) ((((usqInt)dest)) + codeToDataDelta)))->objectHeader = objectHeaderValue);
if (((dest->cmType)) == CMMethod) {

Expand All @@ -16509,7 +16504,13 @@ compactCompiledCode(void)
if (((dest->cmUsageCount)) > 0) {
(writableVersion->cmUsageCount = ((dest->cmUsageCount)) / 2);
}
maybeFlushWritableZoneFromto(((usqInt)dest), ((usqInt)(dest + 1)));
/* begin maybeFlushWritableZoneFrom:to: */

# if DUAL_MAPPED_CODE_ZONE
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, ((usqInt)dest), ((usqInt)(dest + 1)));
}
# endif /* DUAL_MAPPED_CODE_ZONE */
dest = ((CogMethod *) ((((usqInt)dest)) + bytes));
}
source = ((CogMethod *) ((((usqInt)source)) + bytes));
Expand Down
59 changes: 30 additions & 29 deletions nsspur64src/vm/cogitX64SysV.c
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2771 uuid: a7ba3af0-70cc-4104-be1b-8895f533ed7b
CCodeGenerator VMMaker.oscog-eem.2773 uuid: 3c51054d-e839-4959-b3e1-562845a4fa54
from
StackToRegisterMappingCogit VMMaker.oscog-eem.2771 uuid: a7ba3af0-70cc-4104-be1b-8895f533ed7b
StackToRegisterMappingCogit VMMaker.oscog-eem.2773 uuid: 3c51054d-e839-4959-b3e1-562845a4fa54
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2771 uuid: a7ba3af0-70cc-4104-be1b-8895f533ed7b " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2773 uuid: 3c51054d-e839-4959-b3e1-562845a4fa54 " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -699,7 +699,6 @@ static sqInt NoDbgRegParms markLiteralspcmethod(sqInt annotation, char *mcpc, sq
extern void markMethodAndReferents(CogBlockMethod *aCogMethod);
extern usqInt maxCogMethodAddress(void);
static sqInt maybeAllocAndInitIRCs(void);
static void NoDbgRegParms maybeFlushWritableZoneFromto(usqInt startAddress, usqInt endAddress);
static sqInt NoDbgRegParms maybeFreeCogMethodDoesntLookKosher(CogMethod *cogMethod);
static sqInt mclassIsSmallInteger(void);
extern usqInt mcPCForBackwardBranchstartBcpcin(sqInt bcpc, sqInt startbcpc, CogBlockMethod *cogMethod);
Expand Down Expand Up @@ -8446,6 +8445,11 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
methodCount = 0;
assertValidDualZone();
/* begin maybeGenerateCheckFeatures */
/* begin maybeGenerateCacheFlush */

# if DUAL_MAPPED_CODE_ZONE

# endif /* DUAL_MAPPED_CODE_ZONE */
/* begin maybeGenerateCheckLZCNT */
/* begin allocateOpcodes:bytecodes: */
numberOfAbstractOpcodes3 = 11 /* numCheckLZCNTOpcodes */;
Expand Down Expand Up @@ -8482,11 +8486,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
outputInstructionsForGeneratedRuntimeAt(startAddress4);
recordGeneratedRunTimeaddress("ceCheckLZCNTFunction", startAddress4);
ceCheckLZCNTFunction = ((usqIntptr_t (*)(void)) startAddress4);
/* begin maybeGenerateCacheFlush */

# if DUAL_MAPPED_CODE_ZONE

# endif /* DUAL_MAPPED_CODE_ZONE */
/* begin generateVMOwnerLockFunctions */

# if COGMTVM
Expand Down Expand Up @@ -8522,7 +8521,14 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
computeFullBlockEntryOffsets();
generateClosedPICPrototype();
alignMethodZoneBase();
maybeFlushWritableZoneFromto(startAddress, ((usqInt)methodZoneBase));
flushICacheFromto(backEnd, startAddress, ((usqInt)methodZoneBase));
/* begin maybeFlushWritableZoneFrom:to: */

# if DUAL_MAPPED_CODE_ZONE
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, startAddress, ((usqInt)methodZoneBase));
}
# endif /* DUAL_MAPPED_CODE_ZONE */
/* begin manageFrom:to: */
mzFreeStart = (baseAddress = methodZoneBase);
youngReferrers = (limitAddress = endAddress);
Expand Down Expand Up @@ -9864,23 +9870,6 @@ maybeAllocAndInitIRCs(void)
}


/* If there is a dual mapped code zone (the normal zone but marked with
read/execute, and a read/write zone codeToDataDelta bytes away) then the
data cache for the read/write
zone must be flushed, and the data cache for the read/execute zone must be
invalidated, for the Cogit to see the same values in both zones after a
write to the read/write zone. */

/* Cogit>>#maybeFlushWritableZoneFrom:to: */
static void NoDbgRegParms
maybeFlushWritableZoneFromto(usqInt startAddress, usqInt endAddress)
{
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, startAddress, endAddress);
}
}


/* Check that the header fields are consistent with the type.
Answer 0 if it is ok, otherwise answer a code for the error. */

Expand Down Expand Up @@ -12262,7 +12251,13 @@ compactCompiledCode(void)
if (((source->cmType)) != CMFree) {
methodCount += 1;
codeMemmove(dest, source, bytes);
maybeFlushWritableZoneFromto(((usqInt)dest), (((usqInt)dest)) + bytes);
/* begin maybeFlushWritableZoneFrom:to: */

# if DUAL_MAPPED_CODE_ZONE
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, ((usqInt)dest), (((usqInt)dest)) + bytes);
}
# endif /* DUAL_MAPPED_CODE_ZONE */
((writableVersion = ((CogMethod *) ((((usqInt)dest)) + codeToDataDelta)))->objectHeader = objectHeaderValue);
if (((dest->cmType)) == CMMethod) {

Expand All @@ -12288,7 +12283,13 @@ compactCompiledCode(void)
if (((dest->cmUsageCount)) > 0) {
(writableVersion->cmUsageCount = ((dest->cmUsageCount)) / 2);
}
maybeFlushWritableZoneFromto(((usqInt)dest), ((usqInt)(dest + 1)));
/* begin maybeFlushWritableZoneFrom:to: */

# if DUAL_MAPPED_CODE_ZONE
if (codeToDataDelta > 0) {
flushDCacheFromto(backEnd, ((usqInt)dest), ((usqInt)(dest + 1)));
}
# endif /* DUAL_MAPPED_CODE_ZONE */
dest = ((CogMethod *) ((((usqInt)dest)) + bytes));
}
source = ((CogMethod *) ((((usqInt)source)) + bytes));
Expand Down

0 comments on commit 41115d4

Please sign in to comment.