Merge pull request #1439 from SChernykh/dev

Add vzeroupper for processors with AVX
This commit is contained in:
xmrig 2019-12-18 18:32:17 +07:00 committed by GitHub
commit eeb8bbe5bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View file

@ -289,6 +289,11 @@ namespace randomx {
JitCompilerX86::JitCompilerX86() {
applyTweaks();
int32_t info[4];
cpuid(1, info);
hasAVX = ((info[2] & (1 << 27)) != 0) && ((info[2] & (1 << 28)) != 0);
allocatedCode = (uint8_t*)allocExecutableMemory(CodeSize * 2);
// Shift code base address to improve caching - all threads will use different L2/L3 cache sets
code = allocatedCode + (codeOffset.fetch_add(59 * 64) % CodeSize);
@ -374,6 +379,9 @@ namespace randomx {
code[codePos + 5] = 0xc0 + pcfg.readReg1;
*(uint32_t*)(code + codePos + 10) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
*(uint32_t*)(code + codePos + 20) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
if (hasAVX) {
*(uint32_t*)(code + codePos + 29) = 0xE977F8C5;
}
codePos = prologueSize;
memcpy(code + codePos - 48, &pcfg.eMask, sizeof(pcfg.eMask));

View file

@ -73,6 +73,7 @@ namespace randomx {
uint32_t vm_flags;
static bool BranchesWithin32B;
bool hasAVX;
static void applyTweaks();
void generateProgramPrologue(Program&, ProgramConfiguration&);

View file

@ -94,6 +94,9 @@ DECL(randomx_program_prologue_first_load):
ror rdx, 32
and edx, RANDOMX_SCRATCHPAD_MASK
stmxcsr dword ptr [rsp-20]
nop
nop
nop
jmp DECL(randomx_program_loop_begin)
.balign 64

View file

@ -82,6 +82,9 @@ randomx_program_prologue_first_load PROC
ror rdx, 32
and edx, RANDOMX_SCRATCHPAD_MASK
stmxcsr dword ptr [rsp-20]
nop
nop
nop
jmp randomx_program_loop_begin
randomx_program_prologue_first_load ENDP