Monero
Loading...
Searching...
No Matches
vm_compiled.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2018-2019, tevador <tevador@gmail.com>
3
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the copyright holder nor the
14 names of its contributors may be used to endorse or promote products
15 derived from this software without specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#pragma once
30
31#include <new>
32#include <cstdint>
33#include "virtual_machine.hpp"
34#include "jit_compiler.hpp"
35#include "allocator.hpp"
36#include "dataset.hpp"
37
38namespace randomx {
39
40 template<class Allocator, bool softAes, bool secureJit>
41 class CompiledVm : public VmBase<Allocator, softAes> {
42 public:
43 void* operator new(size_t size) {
45 if (ptr == nullptr)
46 throw std::bad_alloc();
47 return ptr;
48 }
49 void operator delete(void* ptr) {
51 }
53 void setDataset(randomx_dataset* dataset) override;
54 void run(void* seed) override;
55
56 using VmBase<Allocator, softAes>::mem;
57 using VmBase<Allocator, softAes>::program;
58 using VmBase<Allocator, softAes>::config;
59 using VmBase<Allocator, softAes>::reg;
60 using VmBase<Allocator, softAes>::scratchpad;
61 using VmBase<Allocator, softAes>::datasetPtr;
62 using VmBase<Allocator, softAes>::datasetOffset;
63 protected:
64 void execute();
65
67 };
68
77}
Definition vm_compiled.hpp:41
void execute()
Definition vm_compiled.cpp:65
void run(void *seed) override
Definition vm_compiled.cpp:50
void setDataset(randomx_dataset *dataset) override
Definition vm_compiled.cpp:45
CompiledVm()
Definition vm_compiled.cpp:38
Definition virtual_machine.hpp:80
uint64_t datasetOffset
Definition virtual_machine.hpp:71
randomx::MemoryRegisters mem
Definition virtual_machine.hpp:65
uint8_t * scratchpad
Definition virtual_machine.hpp:66
randomx::RegisterFile reg
Definition virtual_machine.hpp:63
randomx::ProgramConfiguration config
Definition virtual_machine.hpp:64
randomx_dataset * datasetPtr
Definition virtual_machine.hpp:69
randomx::Program program
Definition virtual_machine.hpp:62
Concept for allocating, resizing and freeing memory block.
const uint8_t seed[32]
Definition code-generator.cpp:37
Definition allocator.cpp:35
CompiledVm< AlignedAllocator< CacheLineSize >, true, true > CompiledVmDefaultSecure
Definition vm_compiled.hpp:73
CompiledVm< LargePageAllocator, true, false > CompiledVmLargePage
Definition vm_compiled.hpp:71
CompiledVm< AlignedAllocator< CacheLineSize >, false, true > CompiledVmHardAesSecure
Definition vm_compiled.hpp:74
CompiledVm< LargePageAllocator, false, false > CompiledVmLargePageHardAes
Definition vm_compiled.hpp:72
CompiledVm< LargePageAllocator, true, true > CompiledVmLargePageSecure
Definition vm_compiled.hpp:75
JitCompilerFallback JitCompiler
Definition common.hpp:135
CompiledVm< AlignedAllocator< CacheLineSize >, true, false > CompiledVmDefault
Definition vm_compiled.hpp:69
CompiledVm< LargePageAllocator, false, true > CompiledVmLargePageHardAesSecure
Definition vm_compiled.hpp:76
CompiledVm< AlignedAllocator< CacheLineSize >, false, false > CompiledVmHardAes
Definition vm_compiled.hpp:70
static void * allocMemory(size_t)
Definition allocator.cpp:38
static void freeMemory(void *, size_t)
Definition allocator.cpp:46
Definition dataset.hpp:40