11/* Automatically generated by
2- CCodeGenerator VMMaker.oscog-eem.3114 uuid: 0522972d-531d-4f3a-9559-5c9bdbbf5427
2+ CCodeGenerator VMMaker.oscog-eem.3117 uuid: ede3f763-e691-4662-91d0-34fc19bc39a1
33 from
4- StackToRegisterMappingCogit VMMaker.oscog-eem.3114 uuid: 0522972d-531d-4f3a-9559-5c9bdbbf5427
4+ StackToRegisterMappingCogit VMMaker.oscog-eem.3117 uuid: ede3f763-e691-4662-91d0-34fc19bc39a1
55 */
6- static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3114 uuid: 0522972d-531d-4f3a-9559-5c9bdbbf5427 " __DATE__ ;
6+ static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3117 uuid: ede3f763-e691-4662-91d0-34fc19bc39a1 " __DATE__ ;
77char *__cogitBuildInfo = __buildInfo;
88
99
@@ -27,8 +27,11 @@ char *__cogitBuildInfo = __buildInfo;
2727
2828
2929/* Cogit class>>preambleCCode */
30- #if __APPLE__ && __MACH__ /* Mac OS X */
31- #include <libkern/OSCacheControl.h>
30+ #if __APPLE__ && __MACH__ // Mac OS X
31+ # include <libkern/OSCacheControl.h>
32+ #endif
33+ #if __linux__
34+ # include <sys/auxv.h>
3235#endif
3336/* end Cogit class>>preambleCCode */
3437
@@ -568,12 +571,15 @@ static sqInt NoDbgRegParms countLeadingOnes(AbstractInstruction * self_in_countL
568571static sqInt NoDbgRegParms countTrailingOnes(AbstractInstruction * self_in_countTrailingOnes, sqInt anInteger);
569572static sqInt NoDbgRegParms countTrailingZeros(AbstractInstruction * self_in_countTrailingZeros, sqInt anInteger);
570573static usqInt NoDbgRegParms decode64Immsimmr(AbstractInstruction * self_in_decode64Immsimmr, sqInt imms, sqInt immr);
571- #if !__APPLE__
574+ #if __linux__
572575static void NoDbgRegParms detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux);
573- #endif /* !__APPLE__ */
576+ #endif /* __linux__ */
574577#if __APPLE__
575578static void NoDbgRegParms detectFeaturesOnMacOS(AbstractInstruction * self_in_detectFeaturesOnMacOS);
576579#endif /* __APPLE__ */
580+ #if !__APPLE__ && !__linux__
581+ static void NoDbgRegParms detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMachine);
582+ #endif /* !__APPLE__ && !__linux__ */
577583static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_dispatchConcretize);
578584static sqInt NoDbgRegParms emitLdfprnrtimmshiftBy12at(AbstractInstruction * self_in_emitLdfprnrtimmshiftBy12at, sqInt baseReg, sqInt targetDPReg, sqInt offset, sqInt shiftBy12, sqInt instrOffset);
579585static sqInt NoDbgRegParms emitLdrnrtimmshiftBy12at(AbstractInstruction * self_in_emitLdrnrtimmshiftBy12at, sqInt unitSizeLog2MinusOne, sqInt baseReg, sqInt targetReg, sqInt offset, sqInt shiftBy12, sqInt instrOffset);
@@ -4290,19 +4296,19 @@ decode64Immsimmr(AbstractInstruction * self_in_decode64Immsimmr, sqInt imms, sqI
42904296}
42914297
42924298
4293- /* Do throw-away compilations to read CTR_EL0 & ID_AA64ISAR0_EL1 and
4294- initialize ctrEl0 & idISAR0
4295- */
4299+ /* Do a throw-away compilation to read CTR_EL0 and initialize ctrEl0.
4300+ Some linux kernels trap and synthesize access to ID_AA64ISAR0_EL1,
4301+ and some do not, so use getauxval(3) to access value(s) derived
4302+ there-from, i.e. whether the processor has atomic instructions. */
42964303
42974304 /* CogARMv8Compiler>>#detectFeaturesOnLinux */
4298- #if !__APPLE__
4305+ #if __linux__
42994306static void NoDbgRegParms
43004307detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux)
43014308{
43024309 sqInt ctrEL0;
43034310 sqInt fixupSize;
43044311 usqIntptr_t (*getFeatureReg)(void);
4305- sqInt idISAR0;
43064312 sqInt opcodeSize;
43074313 usqInt startAddress;
43084314
@@ -4355,32 +4361,9 @@ detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux)
43554361 if ((instructionCacheLineLength(self_in_detectFeaturesOnLinux)) == 0) {
43564362 setInstructionCacheLineLength(self_in_detectFeaturesOnLinux, 64);
43574363 }
4358- zeroOpcodeIndexForNewOpcodes();
4359- gen(Nop);
4360- genoperand(MRS_ID_AA64ISAR0_EL1, ABIResultReg);
4361- genoperand(RetN, 0);
4362- outputInstructionsForGeneratedRuntimeAt(startAddress);
4363- /* begin resetMethodZoneBase: */
4364- methodZoneBase = startAddress;
4365- /* begin ensureExecutableCodeZoneWithin: */
4366-
4367- # if !DUAL_MAPPED_CODE_ZONE
4368- /* begin makeCodeZoneExecutable */
4369- # if __APPLE__ && __MACH__
4370- pthread_jit_write_protect_np(1);
4371- # endif
4372- # endif
4373- idISAR0 = getFeatureReg();
4374- setHasAtomicInstructions(self_in_detectFeaturesOnLinux, ((((usqInt)(idISAR0)) >> 20) & 15) == 2);
4375- /* begin ensureWritableCodeZone */
4376- # if !DUAL_MAPPED_CODE_ZONE
4377- /* begin makeCodeZoneWritable */
4378- # if __APPLE__ && __MACH__
4379- pthread_jit_write_protect_np(0);
4380- # endif
4381- # endif
4364+ setHasAtomicInstructions(self_in_detectFeaturesOnLinux, (((getauxval(AT_HWCAP)) & HWCAP_ATOMICS) != 0));
43824365}
4383- #endif /* !__APPLE__ */
4366+ #endif /* __linux__ */
43844367
43854368
43864369/* MacOS does not allow access to ctl_el0, so derive cache information etc
@@ -4408,6 +4391,99 @@ detectFeaturesOnMacOS(AbstractInstruction * self_in_detectFeaturesOnMacOS)
44084391#endif /* __APPLE__ */
44094392
44104393
4394+ /* Do throw-away compilations to read CTR_EL0 & ID_AA64ISAR0_EL1 and
4395+ initialize ctrEl0 & idISAR0
4396+ */
4397+
4398+ /* CogARMv8Compiler>>#detectFeaturesOnRawMachine */
4399+ #if !__APPLE__ && !__linux__
4400+ static void NoDbgRegParms
4401+ detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMachine)
4402+ {
4403+ sqInt ctrEL0;
4404+ sqInt fixupSize;
4405+ usqIntptr_t (*getFeatureReg)(void);
4406+ sqInt idISAR0;
4407+ sqInt opcodeSize;
4408+ usqInt startAddress;
4409+
4410+ startAddress = methodZoneBase();
4411+ /* begin allocateOpcodes:bytecodes: */
4412+ numAbstractOpcodes = 4;
4413+ opcodeSize = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes;
4414+ fixupSize = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes;
4415+ abstractOpcodes = alloca(opcodeSize + fixupSize);
4416+ bzero(abstractOpcodes, opcodeSize + fixupSize);
4417+ fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize));
4418+ zeroOpcodeIndexForNewOpcodes();
4419+ labelCounter = 0;
4420+
4421+ /* Return the value of CTR_EL0; that's the control register that defines the vital statistics of the processor's caches. */
4422+ getFeatureReg = ((usqIntptr_t (*)(void)) startAddress);
4423+ gen(Nop);
4424+ genoperand(MRS_CTR_EL0, ABIResultReg);
4425+ genoperand(RetN, 0);
4426+ outputInstructionsForGeneratedRuntimeAt(startAddress);
4427+ /* begin resetMethodZoneBase: */
4428+ methodZoneBase = startAddress;
4429+ /* begin ensureExecutableCodeZoneWithin: */
4430+
4431+ # if !DUAL_MAPPED_CODE_ZONE
4432+ /* begin makeCodeZoneExecutable */
4433+ # if __APPLE__ && __MACH__
4434+ pthread_jit_write_protect_np(1);
4435+ # endif
4436+ # endif
4437+
4438+ /* see e.g. CogARMv8Compiler class>>printCTR_EL0:, concretizeCacheControlOp1:CRm:Op2: &
4439+ http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.100403_0200_00_en/lau1443435580346.html
4440+ DminLine & IminLine are Log2 words; 16 words miniumum */
4441+ ctrEL0 = getFeatureReg();
4442+ setDataCacheFlushRequired(self_in_detectFeaturesOnRawMachine, (!(ctrEL0 & (0x10000000))));
4443+ setDataCacheLineLength(self_in_detectFeaturesOnRawMachine, 4ULL << ((((usqInt)(ctrEL0)) >> 16) & 15));
4444+ if ((dataCacheLineLength(self_in_detectFeaturesOnRawMachine)) == 0) {
4445+ setDataCacheLineLength(self_in_detectFeaturesOnRawMachine, 64);
4446+ }
4447+ setInstructionCacheFlushRequired(self_in_detectFeaturesOnRawMachine, (!(ctrEL0 & (0x20000000))));
4448+ setInstructionCacheLineLength(self_in_detectFeaturesOnRawMachine, 4ULL << (ctrEL0 & 15));
4449+ /* begin ensureWritableCodeZone */
4450+ # if !DUAL_MAPPED_CODE_ZONE
4451+ /* begin makeCodeZoneWritable */
4452+ # if __APPLE__ && __MACH__
4453+ pthread_jit_write_protect_np(0);
4454+ # endif
4455+ # endif
4456+ if ((instructionCacheLineLength(self_in_detectFeaturesOnRawMachine)) == 0) {
4457+ setInstructionCacheLineLength(self_in_detectFeaturesOnRawMachine, 64);
4458+ }
4459+ zeroOpcodeIndexForNewOpcodes();
4460+ gen(Nop);
4461+ genoperand(MRS_ID_AA64ISAR0_EL1, ABIResultReg);
4462+ genoperand(RetN, 0);
4463+ outputInstructionsForGeneratedRuntimeAt(startAddress);
4464+ /* begin resetMethodZoneBase: */
4465+ methodZoneBase = startAddress;
4466+ /* begin ensureExecutableCodeZoneWithin: */
4467+
4468+ # if !DUAL_MAPPED_CODE_ZONE
4469+ /* begin makeCodeZoneExecutable */
4470+ # if __APPLE__ && __MACH__
4471+ pthread_jit_write_protect_np(1);
4472+ # endif
4473+ # endif
4474+ idISAR0 = getFeatureReg();
4475+ setHasAtomicInstructions(self_in_detectFeaturesOnRawMachine, ((((usqInt)(idISAR0)) >> 20) & 15) == 2);
4476+ /* begin ensureWritableCodeZone */
4477+ # if !DUAL_MAPPED_CODE_ZONE
4478+ /* begin makeCodeZoneWritable */
4479+ # if __APPLE__ && __MACH__
4480+ pthread_jit_write_protect_np(0);
4481+ # endif
4482+ # endif
4483+ }
4484+ #endif /* !__APPLE__ && !__linux__ */
4485+
4486+
44114487/* Attempt to generate concrete machine code for the instruction at address.
44124488 This is the inner dispatch of concretizeAt: actualAddress which exists
44134489 only to get around the branch size limits in the SqueakV3 (blue book
@@ -7284,7 +7360,7 @@ rewriteImm19JumpBeforetarget(AbstractInstruction * self_in_rewriteImm19JumpBefor
72847360static sqInt NoDbgRegParms
72857361rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBeforetarget, sqInt followingAddress, sqInt targetAddress)
72867362{
7287- usqInt instrOpcode;
7363+ sqInt instrOpcode;
72887364 sqInt mcpc;
72897365 sqInt offset;
72907366
@@ -7294,7 +7370,7 @@ rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBefor
72947370 instrOpcode = ((instructionBeforeAddress(self_in_rewriteImm26JumpBeforetarget, followingAddress))) >> 26;
72957371 assert((instrOpcode == 5)
72967372 || (instrOpcode == 37));
7297- codeLong32Atput(mcpc, (instrOpcode << 26) + (((offset) >> 2) & (0x3FFFFFF)));
7373+ codeLong32Atput(mcpc, (((sqInt)((usqInt)( instrOpcode) << 26)) ) + (((offset) >> 2) & (0x3FFFFFF)));
72987374 return 4;
72997375}
73007376
@@ -13162,8 +13238,12 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
1316213238# if __APPLE__
1316313239 detectFeaturesOnMacOS(((AbstractInstruction *) backEnd));
1316413240# else
13241+ # if __linux__
1316513242 detectFeaturesOnLinux(((AbstractInstruction *) backEnd));
13243+ # else
13244+ detectFeaturesOnRawMachine(((AbstractInstruction *) backEnd));
1316613245# endif
13246+ # endif // __APPLE__
1316713247 /* begin maybeGenerateCacheFlush */
1316813248 if ((numICacheFlushOpcodes(backEnd)) > 0) {
1316913249 /* begin allocateOpcodes:bytecodes: */
0 commit comments