vm_compiled.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 "vm_compiled.hpp"
  16. #include "common.hpp"
  17. namespace randomx {
  18. static_assert(sizeof(MemoryRegisters) == 2 * sizeof(addr_t) + sizeof(uintptr_t), "Invalid alignment of struct randomx::MemoryRegisters");
  19. static_assert(sizeof(RegisterFile) == 256, "Invalid alignment of struct randomx::RegisterFile");
  20. template<class Allocator, bool softAes>
  21. void CompiledVm<Allocator, softAes>::setDataset(randomx_dataset* dataset) {
  22. mem.memory = dataset->memory;
  23. //datasetBasePtr = dataset.memory;
  24. }
  25. template<class Allocator, bool softAes>
  26. void CompiledVm<Allocator, softAes>::run(void* seed) {
  27. VmBase<Allocator, softAes>::generateProgram(seed);
  28. randomx_vm::initialize();
  29. compiler.generateProgram(program, config);
  30. //mem.memory = datasetBasePtr + (datasetBase * CacheLineSize);
  31. execute();
  32. }
  33. template<class Allocator, bool softAes>
  34. void CompiledVm<Allocator, softAes>::execute() {
  35. //executeProgram(reg, mem, scratchpad, InstructionCount);
  36. compiler.getProgramFunc()(reg, mem, 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. }