1
1
/* 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
3
3
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
5
5
*/
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__ ;
7
7
char *__cogitBuildInfo = __buildInfo;
8
8
9
9
@@ -27,8 +27,11 @@ char *__cogitBuildInfo = __buildInfo;
27
27
28
28
29
29
/* 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>
32
35
#endif
33
36
/* end Cogit class>>preambleCCode */
34
37
@@ -568,12 +571,15 @@ static sqInt NoDbgRegParms countLeadingOnes(AbstractInstruction * self_in_countL
568
571
static sqInt NoDbgRegParms countTrailingOnes(AbstractInstruction * self_in_countTrailingOnes, sqInt anInteger);
569
572
static sqInt NoDbgRegParms countTrailingZeros(AbstractInstruction * self_in_countTrailingZeros, sqInt anInteger);
570
573
static usqInt NoDbgRegParms decode64Immsimmr(AbstractInstruction * self_in_decode64Immsimmr, sqInt imms, sqInt immr);
571
- #if !__APPLE__
574
+ #if __linux__
572
575
static void NoDbgRegParms detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux);
573
- #endif /* !__APPLE__ */
576
+ #endif /* __linux__ */
574
577
#if __APPLE__
575
578
static void NoDbgRegParms detectFeaturesOnMacOS(AbstractInstruction * self_in_detectFeaturesOnMacOS);
576
579
#endif /* __APPLE__ */
580
+ #if !__APPLE__ && !__linux__
581
+ static void NoDbgRegParms detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMachine);
582
+ #endif /* !__APPLE__ && !__linux__ */
577
583
static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_dispatchConcretize);
578
584
static sqInt NoDbgRegParms emitLdfprnrtimmshiftBy12at(AbstractInstruction * self_in_emitLdfprnrtimmshiftBy12at, sqInt baseReg, sqInt targetDPReg, sqInt offset, sqInt shiftBy12, sqInt instrOffset);
579
585
static 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
4290
4296
}
4291
4297
4292
4298
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. */
4296
4303
4297
4304
/* CogARMv8Compiler>>#detectFeaturesOnLinux */
4298
- #if !__APPLE__
4305
+ #if __linux__
4299
4306
static void NoDbgRegParms
4300
4307
detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux)
4301
4308
{
4302
4309
sqInt ctrEL0;
4303
4310
sqInt fixupSize;
4304
4311
usqIntptr_t (*getFeatureReg)(void);
4305
- sqInt idISAR0;
4306
4312
sqInt opcodeSize;
4307
4313
usqInt startAddress;
4308
4314
@@ -4355,32 +4361,9 @@ detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux)
4355
4361
if ((instructionCacheLineLength(self_in_detectFeaturesOnLinux)) == 0) {
4356
4362
setInstructionCacheLineLength(self_in_detectFeaturesOnLinux, 64);
4357
4363
}
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));
4382
4365
}
4383
- #endif /* !__APPLE__ */
4366
+ #endif /* __linux__ */
4384
4367
4385
4368
4386
4369
/* MacOS does not allow access to ctl_el0, so derive cache information etc
@@ -4408,6 +4391,99 @@ detectFeaturesOnMacOS(AbstractInstruction * self_in_detectFeaturesOnMacOS)
4408
4391
#endif /* __APPLE__ */
4409
4392
4410
4393
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
+
4411
4487
/* Attempt to generate concrete machine code for the instruction at address.
4412
4488
This is the inner dispatch of concretizeAt: actualAddress which exists
4413
4489
only to get around the branch size limits in the SqueakV3 (blue book
@@ -7284,7 +7360,7 @@ rewriteImm19JumpBeforetarget(AbstractInstruction * self_in_rewriteImm19JumpBefor
7284
7360
static sqInt NoDbgRegParms
7285
7361
rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBeforetarget, sqInt followingAddress, sqInt targetAddress)
7286
7362
{
7287
- usqInt instrOpcode;
7363
+ sqInt instrOpcode;
7288
7364
sqInt mcpc;
7289
7365
sqInt offset;
7290
7366
@@ -7294,7 +7370,7 @@ rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBefor
7294
7370
instrOpcode = ((instructionBeforeAddress(self_in_rewriteImm26JumpBeforetarget, followingAddress))) >> 26;
7295
7371
assert((instrOpcode == 5)
7296
7372
|| (instrOpcode == 37));
7297
- codeLong32Atput(mcpc, (instrOpcode << 26) + (((offset) >> 2) & (0x3FFFFFF)));
7373
+ codeLong32Atput(mcpc, (((sqInt)((usqInt)( instrOpcode) << 26)) ) + (((offset) >> 2) & (0x3FFFFFF)));
7298
7374
return 4;
7299
7375
}
7300
7376
@@ -13162,8 +13238,12 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress)
13162
13238
# if __APPLE__
13163
13239
detectFeaturesOnMacOS(((AbstractInstruction *) backEnd));
13164
13240
# else
13241
+ # if __linux__
13165
13242
detectFeaturesOnLinux(((AbstractInstruction *) backEnd));
13243
+ # else
13244
+ detectFeaturesOnRawMachine(((AbstractInstruction *) backEnd));
13166
13245
# endif
13246
+ # endif // __APPLE__
13167
13247
/* begin maybeGenerateCacheFlush */
13168
13248
if ((numICacheFlushOpcodes(backEnd)) > 0) {
13169
13249
/* begin allocateOpcodes:bytecodes: */
0 commit comments