CompiledVirtualMachine.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. CompiledVirtualMachine::CompiledVirtualMachine() {
  20. totalSize = 0;
  21. }
  22. void CompiledVirtualMachine::setDataset(dataset_t ds) {
  23. mem.ds = ds;
  24. }
  25. void CompiledVirtualMachine::initialize() {
  26. VirtualMachine::initialize();
  27. compiler.generateProgram(program);
  28. }
  29. void CompiledVirtualMachine::execute() {
  30. //executeProgram(reg, mem, scratchpad, InstructionCount);
  31. //totalSize += compiler.getCodeSize();
  32. compiler.getProgramFunc()(reg, mem, scratchpad, InstructionCount);
  33. #ifdef TRACEVM
  34. for (int32_t i = InstructionCount - 1; i >= 0; --i) {
  35. std::cout << std::hex << tracepad[i].u64 << std::endl;
  36. }
  37. #endif
  38. }
  39. }