mirror of
https://github.com/xmrig/xmrig.git
synced 2024-10-30 21:17:52 +00:00
Reduce JIT memory for ARM.
This commit is contained in:
parent
4c7d20c8e6
commit
6b331b6945
4 changed files with 46 additions and 13 deletions
|
@ -110,6 +110,7 @@ namespace randomx {
|
||||||
|
|
||||||
cache->jit->generateSuperscalarHash(cache->programs);
|
cache->jit->generateSuperscalarHash(cache->programs);
|
||||||
cache->jit->generateDatasetInitCode();
|
cache->jit->generateDatasetInitCode();
|
||||||
|
cache->datasetInit = cache->jit->getDatasetInitFunc();
|
||||||
|
|
||||||
# ifdef XMRIG_SECURE_JIT
|
# ifdef XMRIG_SECURE_JIT
|
||||||
cache->jit->enableExecution();
|
cache->jit->enableExecution();
|
||||||
|
|
|
@ -98,14 +98,10 @@ static size_t CalcDatasetItemSize()
|
||||||
|
|
||||||
constexpr uint32_t IntRegMap[8] = { 4, 5, 6, 7, 12, 13, 14, 15 };
|
constexpr uint32_t IntRegMap[8] = { 4, 5, 6, 7, 12, 13, 14, 15 };
|
||||||
|
|
||||||
JitCompilerA64::JitCompilerA64(bool hugePagesEnable)
|
JitCompilerA64::JitCompilerA64(bool hugePagesEnable) :
|
||||||
: literalPos(ImulRcpLiteralsEnd)
|
hugePages(hugePagesJIT && hugePagesEnable),
|
||||||
|
literalPos(ImulRcpLiteralsEnd)
|
||||||
{
|
{
|
||||||
allocatedSize = CodeSize + CalcDatasetItemSize();
|
|
||||||
code = static_cast<uint8_t*>(allocExecutableMemory(allocatedSize, hugePagesJIT && hugePagesEnable));
|
|
||||||
|
|
||||||
memset(reg_changed_offset, 0, sizeof(reg_changed_offset));
|
|
||||||
memcpy(code, (void*) randomx_program_aarch64, CodeSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JitCompilerA64::~JitCompilerA64()
|
JitCompilerA64::~JitCompilerA64()
|
||||||
|
@ -115,9 +111,14 @@ JitCompilerA64::~JitCompilerA64()
|
||||||
|
|
||||||
void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& config, uint32_t)
|
void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& config, uint32_t)
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_SECURE_JIT
|
if (!allocatedSize) {
|
||||||
enableWriting();
|
allocate(CodeSize);
|
||||||
# endif
|
}
|
||||||
|
#ifdef XMRIG_SECURE_JIT
|
||||||
|
else {
|
||||||
|
enableWriting();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t codePos = MainLoopBegin + 4;
|
uint32_t codePos = MainLoopBegin + 4;
|
||||||
|
|
||||||
|
@ -170,6 +171,15 @@ void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& con
|
||||||
|
|
||||||
void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration& config, uint32_t datasetOffset)
|
void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration& config, uint32_t datasetOffset)
|
||||||
{
|
{
|
||||||
|
if (!allocatedSize) {
|
||||||
|
allocate(CodeSize);
|
||||||
|
}
|
||||||
|
#ifdef XMRIG_SECURE_JIT
|
||||||
|
else {
|
||||||
|
enableWriting();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t codePos = MainLoopBegin + 4;
|
uint32_t codePos = MainLoopBegin + 4;
|
||||||
|
|
||||||
// and w16, w10, ScratchpadL3Mask64
|
// and w16, w10, ScratchpadL3Mask64
|
||||||
|
@ -228,6 +238,15 @@ void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N])
|
void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N])
|
||||||
{
|
{
|
||||||
|
if (!allocatedSize) {
|
||||||
|
allocate(CodeSize + CalcDatasetItemSize());
|
||||||
|
}
|
||||||
|
#ifdef XMRIG_SECURE_JIT
|
||||||
|
else {
|
||||||
|
enableWriting();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t codePos = CodeSize;
|
uint32_t codePos = CodeSize;
|
||||||
|
|
||||||
uint8_t* p1 = (uint8_t*)randomx_calc_dataset_item_aarch64;
|
uint8_t* p1 = (uint8_t*)randomx_calc_dataset_item_aarch64;
|
||||||
|
@ -369,6 +388,16 @@ void JitCompilerA64::enableExecution() const
|
||||||
xmrig::VirtualMemory::protectRX(code, allocatedSize);
|
xmrig::VirtualMemory::protectRX(code, allocatedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void JitCompilerA64::allocate(size_t size)
|
||||||
|
{
|
||||||
|
allocatedSize = size;
|
||||||
|
code = static_cast<uint8_t*>(allocExecutableMemory(allocatedSize, hugePages));
|
||||||
|
|
||||||
|
memcpy(code, reinterpret_cast<const void *>(randomx_program_aarch64), CodeSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void JitCompilerA64::emitMovImmediate(uint32_t dst, uint32_t imm, uint8_t* code, uint32_t& codePos)
|
void JitCompilerA64::emitMovImmediate(uint32_t dst, uint32_t imm, uint8_t* code, uint32_t& codePos)
|
||||||
{
|
{
|
||||||
uint32_t k = codePos;
|
uint32_t k = codePos;
|
||||||
|
|
|
@ -77,12 +77,15 @@ namespace randomx {
|
||||||
static InstructionGeneratorA64 engine[256];
|
static InstructionGeneratorA64 engine[256];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t reg_changed_offset[8];
|
const bool hugePages;
|
||||||
uint8_t* code;
|
uint32_t reg_changed_offset[8]{};
|
||||||
|
uint8_t* code = nullptr;
|
||||||
uint32_t literalPos;
|
uint32_t literalPos;
|
||||||
uint32_t num32bitLiterals = 0;
|
uint32_t num32bitLiterals = 0;
|
||||||
size_t allocatedSize = 0;
|
size_t allocatedSize = 0;
|
||||||
|
|
||||||
|
void allocate(size_t size);
|
||||||
|
|
||||||
static void emit32(uint32_t val, uint8_t* code, uint32_t& codePos)
|
static void emit32(uint32_t val, uint8_t* code, uint32_t& codePos)
|
||||||
{
|
{
|
||||||
*(uint32_t*)(code + codePos) = val;
|
*(uint32_t*)(code + codePos) = val;
|
||||||
|
|
|
@ -383,7 +383,7 @@ extern "C" {
|
||||||
case RANDOMX_FLAG_JIT:
|
case RANDOMX_FLAG_JIT:
|
||||||
cache->jit = new randomx::JitCompiler(false);
|
cache->jit = new randomx::JitCompiler(false);
|
||||||
cache->initialize = &randomx::initCacheCompile;
|
cache->initialize = &randomx::initCacheCompile;
|
||||||
cache->datasetInit = cache->jit->getDatasetInitFunc();
|
cache->datasetInit = nullptr;
|
||||||
cache->memory = memory;
|
cache->memory = memory;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue