Monero
Loading...
Searching...
No Matches
vm_compiled_light.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 "vm_compiled.hpp"
33
34namespace randomx {
35
36 template<class Allocator, bool softAes, bool secureJit>
37 class CompiledLightVm : public CompiledVm<Allocator, softAes, secureJit> {
38 public:
39 void* operator new(size_t size) {
41 if (ptr == nullptr)
42 throw std::bad_alloc();
43 return ptr;
44 }
45 void operator delete(void* ptr) {
47 }
48 void setCache(randomx_cache* cache) override;
49 void setDataset(randomx_dataset* dataset) override { }
50 void run(void* seed) override;
51
52 using CompiledVm<Allocator, softAes, secureJit>::mem;
53 using CompiledVm<Allocator, softAes, secureJit>::compiler;
54 using CompiledVm<Allocator, softAes, secureJit>::program;
55 using CompiledVm<Allocator, softAes, secureJit>::config;
56 using CompiledVm<Allocator, softAes, secureJit>::cachePtr;
57 using CompiledVm<Allocator, softAes, secureJit>::datasetOffset;
58 };
59
68}
Definition: vm_compiled_light.hpp:37
void setDataset(randomx_dataset *dataset) override
Definition: vm_compiled_light.hpp:49
void setCache(randomx_cache *cache) override
Definition: vm_compiled_light.cpp:36
void run(void *seed) override
Definition: vm_compiled_light.cpp:49
Definition: vm_compiled.hpp:41
JitCompiler compiler
Definition: vm_compiled.hpp:66
randomx_cache * cachePtr
Definition: virtual_machine.hpp:68
uint64_t datasetOffset
Definition: virtual_machine.hpp:71
randomx::MemoryRegisters mem
Definition: virtual_machine.hpp:65
randomx::ProgramConfiguration config
Definition: virtual_machine.hpp:64
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
static void * allocMemory(size_t)
Definition: allocator.cpp:38
static void freeMemory(void *, size_t)
Definition: allocator.cpp:46
Definition: dataset.hpp:46
Definition: dataset.hpp:40
randomx_cache * cache
Definition: tests.cpp:19