From 954365634e9ffb784d82588c84c2fa1f84ea786a Mon Sep 17 00:00:00 2001 From: tevador Date: Mon, 18 Feb 2019 08:54:55 +0100 Subject: [PATCH] Fixed alignment of VirtualMachine --- src/InterpretedVirtualMachine.hpp | 10 ++++++++++ src/VirtualMachine.hpp | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/InterpretedVirtualMachine.hpp b/src/InterpretedVirtualMachine.hpp index ee7655b..f29c20d 100644 --- a/src/InterpretedVirtualMachine.hpp +++ b/src/InterpretedVirtualMachine.hpp @@ -19,6 +19,7 @@ along with RandomX. If not, see. #pragma once //#define STATS +#include #include "VirtualMachine.hpp" #include "Program.hpp" #include "intrinPortable.h" @@ -60,6 +61,15 @@ namespace RandomX { class InterpretedVirtualMachine : public VirtualMachine { public: + void* operator new(size_t size) { + void* ptr = _mm_malloc(size, 64); + if (ptr == nullptr) + throw std::bad_alloc(); + return ptr; + } + void operator delete(void* ptr) { + _mm_free(ptr); + } InterpretedVirtualMachine(bool soft, bool async) : softAes(soft), asyncWorker(async) {} ~InterpretedVirtualMachine(); void setDataset(dataset_t ds) override; diff --git a/src/VirtualMachine.hpp b/src/VirtualMachine.hpp index d1dbe26..afeef37 100644 --- a/src/VirtualMachine.hpp +++ b/src/VirtualMachine.hpp @@ -46,8 +46,8 @@ namespace RandomX { return &program; } protected: - alignas(16) Program program; - alignas(16) RegisterFile reg; + alignas(64) Program program; + alignas(64) RegisterFile reg; MemoryRegisters mem; uint8_t* scratchpad; uint32_t readReg0, readReg1, readReg2, readReg3;