mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 10:01:06 +00:00
Merge pull request #1248 from SChernykh/evo
Fixed code cache cleanup on iOS/Darwin
This commit is contained in:
commit
128c5f67ad
2 changed files with 25 additions and 14 deletions
|
@ -54,6 +54,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
|||
|
||||
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-2")
|
||||
|
||||
add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE)
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ox /Ot /Oi /MT /GL")
|
||||
|
|
|
@ -103,6 +103,21 @@ JitCompilerA64::~JitCompilerA64()
|
|||
freePagedMemory(code, CodeSize + CalcDatasetItemSize());
|
||||
}
|
||||
|
||||
#if defined(ios_HOST_OS) || defined (darwin_HOST_OS)
|
||||
void sys_icache_invalidate(void *start, size_t len);
|
||||
#endif
|
||||
|
||||
static void clear_code_cache(char* p1, char* p2)
|
||||
{
|
||||
# if defined(ios_HOST_OS) || defined (darwin_HOST_OS)
|
||||
sys_icache_invalidate(p1, static_cast<size_t>(p2 - p1));
|
||||
# elif defined (HAVE_BUILTIN_CLEAR_CACHE) || defined (__GNUC__)
|
||||
__builtin___clear_cache(p1, p2);
|
||||
# else
|
||||
# error "No clear code cache function found"
|
||||
# endif
|
||||
}
|
||||
|
||||
void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& config)
|
||||
{
|
||||
uint32_t codePos = MainLoopBegin + 4;
|
||||
|
@ -149,9 +164,7 @@ void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& con
|
|||
codePos = ((uint8_t*)randomx_program_aarch64_update_spMix1) - ((uint8_t*)randomx_program_aarch64);
|
||||
emit32(ARMV8A::EOR | 10 | (IntRegMap[config.readReg0] << 5) | (IntRegMap[config.readReg1] << 16), code, codePos);
|
||||
|
||||
# ifdef HAVE_BUILTIN_CLEAR_CACHE
|
||||
__builtin___clear_cache(reinterpret_cast<char*>(code + MainLoopBegin), reinterpret_cast<char*>(code + codePos));
|
||||
# endif
|
||||
clear_code_cache(reinterpret_cast<char*>(code + MainLoopBegin), reinterpret_cast<char*>(code + codePos));
|
||||
}
|
||||
|
||||
void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration& config, uint32_t datasetOffset)
|
||||
|
@ -206,9 +219,7 @@ void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration
|
|||
emit32(ARMV8A::ADD_IMM_LO | 2 | (2 << 5) | (imm_lo << 10), code, codePos);
|
||||
emit32(ARMV8A::ADD_IMM_HI | 2 | (2 << 5) | (imm_hi << 10), code, codePos);
|
||||
|
||||
# ifdef HAVE_BUILTIN_CLEAR_CACHE
|
||||
__builtin___clear_cache(reinterpret_cast<char*>(code + MainLoopBegin), reinterpret_cast<char*>(code + codePos));
|
||||
# endif
|
||||
clear_code_cache(reinterpret_cast<char*>(code + MainLoopBegin), reinterpret_cast<char*>(code + codePos));
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
|
@ -324,9 +335,7 @@ void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N], s
|
|||
memcpy(code + codePos, p1, p2 - p1);
|
||||
codePos += p2 - p1;
|
||||
|
||||
# ifdef HAVE_BUILTIN_CLEAR_CACHE
|
||||
__builtin___clear_cache(reinterpret_cast<char*>(code + CodeSize), reinterpret_cast<char*>(code + codePos));
|
||||
# endif
|
||||
clear_code_cache(reinterpret_cast<char*>(code + CodeSize), reinterpret_cast<char*>(code + codePos));
|
||||
}
|
||||
|
||||
template void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[RANDOMX_CACHE_MAX_ACCESSES], std::vector<uint64_t> &reciprocalCache);
|
||||
|
|
Loading…
Reference in a new issue