Fixed alignment of VirtualMachine

This commit is contained in:
tevador 2019-02-18 08:54:55 +01:00
parent dce8c74fa8
commit 954365634e
2 changed files with 12 additions and 2 deletions

View file

@ -19,6 +19,7 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once #pragma once
//#define STATS //#define STATS
#include <new>
#include "VirtualMachine.hpp" #include "VirtualMachine.hpp"
#include "Program.hpp" #include "Program.hpp"
#include "intrinPortable.h" #include "intrinPortable.h"
@ -60,6 +61,15 @@ namespace RandomX {
class InterpretedVirtualMachine : public VirtualMachine { class InterpretedVirtualMachine : public VirtualMachine {
public: 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(bool soft, bool async) : softAes(soft), asyncWorker(async) {}
~InterpretedVirtualMachine(); ~InterpretedVirtualMachine();
void setDataset(dataset_t ds) override; void setDataset(dataset_t ds) override;

View file

@ -46,8 +46,8 @@ namespace RandomX {
return &program; return &program;
} }
protected: protected:
alignas(16) Program program; alignas(64) Program program;
alignas(16) RegisterFile reg; alignas(64) RegisterFile reg;
MemoryRegisters mem; MemoryRegisters mem;
uint8_t* scratchpad; uint8_t* scratchpad;
uint32_t readReg0, readReg1, readReg2, readReg3; uint32_t readReg0, readReg1, readReg2, readReg3;