Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.2864
Browse files Browse the repository at this point in the history
Sionara ceCheckFeatures.  Cache cpuid result(s) in variable(s).
Do throw-away compilation(s) to get at the CPUID result(s) needed.
  • Loading branch information
eliotmiranda committed Oct 30, 2020
1 parent f027c5c commit 61a3e3d
Show file tree
Hide file tree
Showing 87 changed files with 1,949 additions and 2,158 deletions.
2 changes: 1 addition & 1 deletion nsspur64src/vm/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2862 uuid: a30f9d13-a2a4-415a-982c-898cc5b69848
CCodeGenerator VMMaker.oscog-eem.2864 uuid: fe5cd24b-69ca-436c-80fb-04bb4f330099
*/


Expand Down
180 changes: 80 additions & 100 deletions nsspur64src/vm/cogitARMv8.c

Large diffs are not rendered by default.

169 changes: 86 additions & 83 deletions nsspur64src/vm/cogitX64SysV.c
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2862 uuid: a30f9d13-a2a4-415a-982c-898cc5b69848
CCodeGenerator VMMaker.oscog-eem.2864 uuid: fe5cd24b-69ca-436c-80fb-04bb4f330099
from
StackToRegisterMappingCogit VMMaker.oscog-eem.2862 uuid: a30f9d13-a2a4-415a-982c-898cc5b69848
StackToRegisterMappingCogit VMMaker.oscog-eem.2864 uuid: fe5cd24b-69ca-436c-80fb-04bb4f330099
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2862 uuid: a30f9d13-a2a4-415a-982c-898cc5b69848 " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2864 uuid: fe5cd24b-69ca-436c-80fb-04bb4f330099 " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -290,7 +290,7 @@ char *__cogitBuildInfo = __buildInfo;
#define NumSendTrampolines 4
#define NumSpecialSelectors 32
#define NumStoreTrampolines 5
#define NumTrampolines 89
#define NumTrampolines 88
#define OrCqR 109
#define OrCqRR 125
#define OrCwR 117
Expand Down Expand Up @@ -1016,6 +1016,7 @@ static sqInt NoDbgRegParms concretizePrefetchAw(AbstractInstruction * self_in_co
static sqInt NoDbgRegParms concretizeReverseOpRR(AbstractInstruction * self_in_concretizeReverseOpRR, sqInt x64opcode);
static sqInt NoDbgRegParms concretizeSet(AbstractInstruction * self_in_concretizeSet, sqInt conditionCode);
static sqInt NoDbgRegParms concretizeXCHGRR(AbstractInstruction * self_in_concretizeXCHGRR);
static AbstractInstruction * NoDbgRegParms detectFeatures(AbstractInstruction * self_in_detectFeatures);
static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_dispatchConcretize);
static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific);
static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative);
Expand Down Expand Up @@ -1050,7 +1051,6 @@ static usqInt NoDbgRegParms machineCodeAt(AbstractInstruction * self_in_machineC
static sqInt NoDbgRegParms machineCodeBytes(AbstractInstruction * self_in_machineCodeBytes);
static sqInt NoDbgRegParms modRMRO(AbstractInstruction * self_in_modRMRO, sqInt mod, sqInt regMode, sqInt regOpcode);
static sqInt NoDbgRegParms nsSendCacheAt(AbstractInstruction * self_in_nsSendCacheAt, char *callSiteReturnAddress);
static sqInt NoDbgRegParms numCheckLZCNTOpcodes(AbstractInstruction * self_in_numCheckLZCNTOpcodes);
static sqInt NoDbgRegParms numIntRegArgs(AbstractInstruction * self_in_numIntRegArgs);
static AbstractInstruction * NoDbgRegParms padIfPossibleWithStopsFromto(AbstractInstruction * self_in_padIfPossibleWithStopsFromto, sqInt startAddr, sqInt endAddr);
static AbstractInstruction * NoDbgRegParms relocateCallBeforeReturnPCby(AbstractInstruction * self_in_relocateCallBeforeReturnPCby, sqInt retpc, sqInt delta);
Expand Down Expand Up @@ -1317,7 +1317,6 @@ static sqInt byte3;
static sqInt bytecodePC;
static sqInt bytecodeSetOffset;
static sqInt ceByteSizeOfTrampoline;
static sqInt ceCheckFeaturesFunction;
static sqInt ceCPICMissTrampoline;
static sqInt ceDereferenceSelectorIndex;
static sqInt ceEnclosingObjectTrampoline;
Expand Down Expand Up @@ -2553,7 +2552,6 @@ static usqInt youngReferrers;
static int labelCounter;
static AbstractInstruction aMethodLabel;
static AbstractInstruction * const backEnd = &aMethodLabel;
static usqIntptr_t (*ceCheckLZCNTFunction)(void);
#if DUAL_MAPPED_CODE_ZONE
static void (*ceFlushDCache)(usqIntptr_t from, usqIntptr_t to);
#endif
Expand All @@ -2565,6 +2563,7 @@ static sqInt codeToDataDelta;
#else
# define codeToDataDelta 0
#endif
static uintptr_t cpuidWord1;
static AbstractInstruction * const methodLabel = &aMethodLabel;
static void (*postCompileHook)(CogMethod *);
sqInt blockNoContextSwitchOffset;
Expand Down Expand Up @@ -2623,8 +2622,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void);
#define breakOnImplicitReceiver() (traceFlags & 64)
#define ceBaseFrameReturnPC() ceBaseFrameReturnTrampoline
#define ceCannotResumePC() ((usqInt)ceCannotResumeTrampoline)
#define ceCheckFeatures() ceCheckFeaturesFunction()
#define ceCheckLZCNT() ceCheckLZCNTFunction()
#define ceReturnToInterpreterPC() ((usqInt)ceReturnToInterpreterTrampoline)
#define codeByteAtput(address,value) byteAtput((address) + codeToDataDelta, value)
#define codeLong32Atput(address,value) long32Atput((address) + codeToDataDelta, value)
Expand Down Expand Up @@ -2671,9 +2668,11 @@ void (*realCEEnterCogCodePopReceiverReg)(void);
#define methodBytesFreedSinceLastCompaction() methodBytesFreedSinceLastCompaction
#define youngReferrers() youngReferrers
#define maybeConstant(sse) ((sse)->constant)
#define cpuidWord1(ign) cpuidWord1
#define flushDCacheFromto(me,startAddress,endAddress) 0
#define flushICacheFromto(me,startAddress,endAddress) 0
#define inlineCacheValueForSelectorin(backEnd,selector,aCogMethod) indexForSelectorin(selector,aCogMethod)
#define setCpuidWord1(ign,word) cpuidWord1 = word
#define unalignedLong32At(inst,byteAddress) long32At(byteAddress)
#define unalignedLong32Atput(inst,byteAddress,aWord) long32Atput(byteAddress,aWord)
#define unalignedLongAt(byteAddress) longAt(byteAddress)
Expand Down Expand Up @@ -8529,15 +8528,10 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
AbstractInstruction *anInstruction;
AbstractInstruction *anInstruction1;
AbstractInstruction *anInstruction2;
AbstractInstruction *anInstruction3;
sqInt fixupSize3;
sqInt fixupSize4;
sqInt numberOfAbstractOpcodes3;
sqInt numberOfAbstractOpcodes4;
sqInt opcodeSize3;
sqInt opcodeSize4;
usqInt startAddress3;
usqInt startAddress4;
sqInt fixupSize2;
sqInt numberOfAbstractOpcodes2;
sqInt opcodeSize2;
usqInt startAddress2;
sqInt vmOwnerLockAddress;
sqInt vmOwnerLockAddressReg;

Expand All @@ -8560,62 +8554,26 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
methodBytesFreedSinceLastCompaction = 0;
methodCount = 0;
assertValidDualZone();
/* begin maybeGenerateCheckFeatures */
detectFeatures(backEnd);
/* begin maybeGenerateCacheFlush */

# if DUAL_MAPPED_CODE_ZONE

# endif
/* begin maybeGenerateCheckLZCNT */
/* begin allocateOpcodes:bytecodes: */
numberOfAbstractOpcodes4 = 11 /* numCheckLZCNTOpcodes */;
numAbstractOpcodes = numberOfAbstractOpcodes4;
opcodeSize4 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes;
fixupSize4 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes;
abstractOpcodes = alloca(opcodeSize4 + fixupSize4);
bzero(abstractOpcodes, opcodeSize4 + fixupSize4);
fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize4));
zeroOpcodeIndexForNewOpcodes();
labelCounter = 0;
startAddress4 = methodZoneBase;
(methodLabel->address = startAddress4);
/* begin generateCheckLZCNT */
genoperand(PushR, RDX);
/* begin PushR: */
genoperand(PushR, RCX);
/* begin PushR: */
genoperand(PushR, RBX);
/* begin checkQuickConstant:forInstruction: */
anInstruction3 = genoperandoperand(MoveCqR, 2147483649U, RAX);
gen(CPUID);
/* begin MoveR:R: */
genoperandoperand(MoveRR, RCX, RAX);
/* begin PopR: */
genoperand(PopR, RBX);
/* begin PopR: */
genoperand(PopR, RCX);
/* begin PopR: */
genoperand(PopR, RDX);
/* begin RetN: */
genoperand(RetN, 0);
((AbstractInstruction *) backEnd);
outputInstructionsForGeneratedRuntimeAt(startAddress4);
recordGeneratedRunTimeaddress("ceCheckLZCNTFunction", startAddress4);
ceCheckLZCNTFunction = ((usqIntptr_t (*)(void)) startAddress4);
/* begin generateVMOwnerLockFunctions */
# if COGMTVM
/* begin allocateOpcodes:bytecodes: */
numberOfAbstractOpcodes3 = 10 /* numLowLevelLockOpcodes */;
numAbstractOpcodes = numberOfAbstractOpcodes3;
opcodeSize3 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes;
fixupSize3 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes;
abstractOpcodes = alloca(opcodeSize3 + fixupSize3);
bzero(abstractOpcodes, opcodeSize3 + fixupSize3);
fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize3));
numberOfAbstractOpcodes2 = 10 /* numLowLevelLockOpcodes */;
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;
zeroOpcodeIndex();
startAddress3 = methodZoneBase;
startAddress2 = methodZoneBase;
/* begin generateLowLevelTryLock: */
vmOwnerLockAddress = vmOwnerAddress();
if (vmOwnerLockAddress == 0) {
Expand All @@ -8638,17 +8596,17 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
genoperand(RetN, 0);
((AbstractInstruction *) backEnd);
l6: /* end generateLowLevelTryLock: */;
outputInstructionsForGeneratedRuntimeAt(startAddress3);
recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress3);
ceTryLockVMOwner = ((usqIntptr_t (*)(void)) startAddress3);
outputInstructionsForGeneratedRuntimeAt(startAddress2);
recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2);
ceTryLockVMOwner = ((usqIntptr_t (*)(void)) startAddress2);
zeroOpcodeIndex();
initialPC = 0;
endPC = numAbstractOpcodes - 1;
startAddress3 = methodZoneBase;
startAddress2 = methodZoneBase;
generateLowLevelUnlock(backEnd, vmOwnerAddress());
outputInstructionsForGeneratedRuntimeAt(startAddress3);
recordGeneratedRunTimeaddress("ceUnlockVMOwner", startAddress3);
ceUnlockVMOwner = ((void (*)(void)) startAddress3);
outputInstructionsForGeneratedRuntimeAt(startAddress2);
recordGeneratedRunTimeaddress("ceUnlockVMOwner", startAddress2);
ceUnlockVMOwner = ((void (*)(void)) startAddress2);
# endif /* COGMTVM */
genGetLeafCallStackPointers();
generateStackPointerCapture();
Expand Down Expand Up @@ -13694,6 +13652,7 @@ genPrimitiveHighBit(void)
AbstractInstruction *jumpNegativeReceiver2;
sqInt literal;
sqInt quickConstant;
AbstractInstruction * self_in_genHighBitInofSmallIntegerOopWithSingleTagBit;


/* remove excess tag bits from the receiver oop */
Expand All @@ -13702,7 +13661,8 @@ genPrimitiveHighBit(void)
quickConstant = 2;
genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg);
/* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */
if (((ceCheckLZCNT()) & (32)) != 0) {
self_in_genHighBitInofSmallIntegerOopWithSingleTagBit = ((AbstractInstruction *) (backEnd()));
if ((cpuidWord1(self_in_genHighBitInofSmallIntegerOopWithSingleTagBit)) & (32)) {
/* begin genHighBitClzIn:ofSmallIntegerOopWithSingleTagBit: */
genoperandoperand(ClzRR, TempReg, TempReg);
if (!(setsConditionCodesFor(lastOpcode(), JumpZero))) {
Expand Down Expand Up @@ -21059,6 +21019,61 @@ concretizeXCHGRR(AbstractInstruction * self_in_concretizeXCHGRR)
}


/* Do a throw-away compilation to get at the cpuid info and initialize
cpuidWord1 N.B. All of MSVC, gcc & clang have intrinsics for this, so if
you have the energy
by all means reimplement as an #if _MSC_VER...#elif __GNUC__ #else ...
saga.
*/

/* CogX64Compiler>>#detectFeatures */
static AbstractInstruction * NoDbgRegParms
detectFeatures(AbstractInstruction * self_in_detectFeatures)
{
AbstractInstruction *anInstruction;
uintptr_t (*cpuid)(void);
sqInt fixupSize;
sqInt opcodeSize;
usqInt startAddress;

startAddress = methodZoneBase();
/* begin allocateOpcodes:bytecodes: */
numAbstractOpcodes = 10;
opcodeSize = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes;
fixupSize = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes;
abstractOpcodes = alloca(opcodeSize + fixupSize);
bzero(abstractOpcodes, opcodeSize + fixupSize);
fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize));
zeroOpcodeIndexForNewOpcodes();
labelCounter = 0;
cpuid = ((uintptr_t (*)(void)) startAddress);
/* begin PushR: */
genoperand(PushR, RDX);
/* begin PushR: */
genoperand(PushR, RCX);
/* begin PushR: */
genoperand(PushR, RBX);
/* begin checkQuickConstant:forInstruction: */
anInstruction = genoperandoperand(MoveCqR, 2147483649U, RAX);
gen(CPUID);
/* begin MoveR:R: */
genoperandoperand(MoveRR, RCX, RAX);
/* begin PopR: */
genoperand(PopR, RBX);
/* begin PopR: */
genoperand(PopR, RCX);
/* begin PopR: */
genoperand(PopR, RDX);
/* begin RetN: */
genoperand(RetN, 0);
outputInstructionsForGeneratedRuntimeAt(startAddress);
/* begin resetMethodZoneBase: */
methodZoneBase = startAddress;
setCpuidWord1(self_in_detectFeatures, cpuid());
return self_in_detectFeatures;
}


/* Attempt to generate concrete machine code for the instruction at address.
This is the inner dispatch of concretizeAt: actualAddress which exists
only to get around the branch size limits in the SqueakV3 (blue book
Expand Down Expand Up @@ -25268,18 +25283,6 @@ nsSendCacheAt(AbstractInstruction * self_in_nsSendCacheAt, char *callSiteReturnA
return literalBeforeFollowingAddress(self_in_nsSendCacheAt, (((usqInt)callSiteReturnAddress)) - 5);
}


/* Answer the number of opcodes required to compile the CPUID call to extract
the extended features information.
*/

/* CogX64Compiler>>#numCheckLZCNTOpcodes */
static sqInt NoDbgRegParms
numCheckLZCNTOpcodes(AbstractInstruction * self_in_numCheckLZCNTOpcodes)
{
return 11;
}

/* CogX64Compiler>>#numIntRegArgs */
static sqInt NoDbgRegParms
numIntRegArgs(AbstractInstruction * self_in_numIntRegArgs)
Expand Down

0 comments on commit 61a3e3d

Please sign in to comment.