2018-12-13 22:11:55 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2018 tevador
|
|
|
|
|
|
|
|
This file is part of RandomX.
|
|
|
|
|
|
|
|
RandomX is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
RandomX is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "CompiledVirtualMachine.hpp"
|
|
|
|
#include "common.hpp"
|
2018-12-18 21:00:58 +00:00
|
|
|
#include <stdexcept>
|
2018-12-13 22:11:55 +00:00
|
|
|
|
|
|
|
namespace RandomX {
|
|
|
|
|
2019-01-14 23:01:11 +00:00
|
|
|
CompiledVirtualMachine::CompiledVirtualMachine() {
|
2019-01-12 15:05:09 +00:00
|
|
|
totalSize = 0;
|
2018-12-18 21:00:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-14 23:01:11 +00:00
|
|
|
void CompiledVirtualMachine::setDataset(dataset_t ds) {
|
|
|
|
mem.ds = ds;
|
|
|
|
}
|
|
|
|
|
2019-02-09 14:45:26 +00:00
|
|
|
void CompiledVirtualMachine::initialize() {
|
|
|
|
VirtualMachine::initialize();
|
|
|
|
compiler.generateProgram(program);
|
2018-12-13 22:11:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompiledVirtualMachine::execute() {
|
2019-01-27 09:52:30 +00:00
|
|
|
//executeProgram(reg, mem, scratchpad, InstructionCount);
|
2019-02-19 21:47:45 +00:00
|
|
|
//totalSize += compiler.getCodeSize();
|
2019-01-27 09:52:30 +00:00
|
|
|
compiler.getProgramFunc()(reg, mem, scratchpad, InstructionCount);
|
2018-12-31 18:06:45 +00:00
|
|
|
#ifdef TRACEVM
|
2018-12-15 22:13:17 +00:00
|
|
|
for (int32_t i = InstructionCount - 1; i >= 0; --i) {
|
|
|
|
std::cout << std::hex << tracepad[i].u64 << std::endl;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-12-13 22:11:55 +00:00
|
|
|
}
|
|
|
|
}
|