mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2025-01-03 05:38:54 +00:00
Use allocExecutableMemory
This commit is contained in:
parent
0b1761a846
commit
5a89c9b28e
@ -17,30 +17,18 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
|
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAGIC_DIVISION
|
|
||||||
#include "JitCompilerX86.hpp"
|
|
||||||
#include "Program.hpp"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#ifdef MAGIC_DIVISION
|
#include "JitCompilerX86.hpp"
|
||||||
|
#include "Program.hpp"
|
||||||
#include "divideByConstantCodegen.h"
|
#include "divideByConstantCodegen.h"
|
||||||
#endif
|
#include "virtualMemory.hpp"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#ifndef MAP_ANONYMOUS
|
|
||||||
#define MAP_ANONYMOUS MAP_ANON
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace RandomX {
|
namespace RandomX {
|
||||||
|
|
||||||
#if !defined(_M_X64) && !defined(__x86_64__)
|
#if !defined(_M_X64) && !defined(__x86_64__)
|
||||||
JitCompilerX86::JitCompilerX86() {
|
JitCompilerX86::JitCompilerX86() {
|
||||||
//throw std::runtime_error("JIT compiler only supports x86-64 CPUs");
|
throw std::runtime_error("JIT compiler only supports x86-64 CPUs");
|
||||||
}
|
}
|
||||||
|
|
||||||
void JitCompilerX86::generateProgram(Program& p) {
|
void JitCompilerX86::generateProgram(Program& p) {
|
||||||
@ -186,15 +174,7 @@ namespace RandomX {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JitCompilerX86::JitCompilerX86() {
|
JitCompilerX86::JitCompilerX86() {
|
||||||
#ifdef _WIN32
|
code = (uint8_t*)allocExecutableMemory(CodeSize);
|
||||||
code = (uint8_t*)VirtualAlloc(nullptr, CodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
|
||||||
if (code == nullptr)
|
|
||||||
throw std::runtime_error("VirtualAlloc failed");
|
|
||||||
#else
|
|
||||||
code = (uint8_t*)mmap(nullptr, CodeSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
|
||||||
if (code == (uint8_t*)-1)
|
|
||||||
throw std::runtime_error("mmap failed");
|
|
||||||
#endif
|
|
||||||
memcpy(code, codePrologue, prologueSize);
|
memcpy(code, codePrologue, prologueSize);
|
||||||
memcpy(code + CodeSize - epilogueSize, codeEpilogue, epilogueSize);
|
memcpy(code + CodeSize - epilogueSize, codeEpilogue, epilogueSize);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user