CompiledVirtualMachine.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Copyright (c) 2018 tevador
  3. This file is part of RandomX.
  4. RandomX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. RandomX is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with RandomX. If not, see<http://www.gnu.org/licenses/>.
  14. */
  15. #include "CompiledVirtualMachine.hpp"
  16. #include "common.hpp"
  17. #include <stdexcept>
  18. namespace randomx {
  19. static_assert(sizeof(MemoryRegisters) == 2 * sizeof(addr_t) + sizeof(uintptr_t), "Invalid alignment of struct randomx::MemoryRegisters");
  20. static_assert(sizeof(RegisterFile) == 256, "Invalid alignment of struct randomx::RegisterFile");
  21. template<class Allocator, bool softAes>
  22. void CompiledVm<Allocator, softAes>::setDataset(randomx_dataset* dataset) {
  23. this->mem.memory = dataset->memory;
  24. //datasetRange = (size - RANDOMX_DATASET_SIZE + CacheLineSize) / CacheLineSize;
  25. //datasetBasePtr = ds.dataset.memory;
  26. }
  27. template<class Allocator, bool softAes>
  28. void CompiledVm<Allocator, softAes>::initialize() {
  29. randomx_vm::initialize();
  30. this->compiler.generateProgram(this->program, this->config);
  31. //mem.ds.dataset.memory = datasetBasePtr + (datasetBase * CacheLineSize);
  32. }
  33. template<class Allocator, bool softAes>
  34. void CompiledVm<Allocator, softAes>::execute() {
  35. //executeProgram(reg, mem, scratchpad, InstructionCount);
  36. compiler.getProgramFunc()(this->reg, this->mem, this->scratchpad, RANDOMX_PROGRAM_ITERATIONS);
  37. }
  38. template class CompiledVm<AlignedAllocator<CacheLineSize>, false>;
  39. template class CompiledVm<AlignedAllocator<CacheLineSize>, true>;
  40. template class CompiledVm<LargePageAllocator, false>;
  41. template class CompiledVm<LargePageAllocator, true>;
  42. }