Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
stack.cpp
Go to the documentation of this file.
3#include <sys/mman.h>
4
5using namespace sysio::chain::eosvmoc;
6
7void execution_stack::reset(std::size_t max_call_depth) {
8 if(max_call_depth > call_depth_limit) {
9 reset();
10 std::size_t new_stack_size = max_call_depth * max_bytes_per_frame + 4*1024*1024;
11 void * ptr = mmap(nullptr, new_stack_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 0, 0);
12 FC_ASSERT(ptr != MAP_FAILED, "Failed to allocate wasm stack");
13 mprotect(ptr, max_bytes_per_frame, PROT_NONE);
14 stack_top = (char*)ptr + new_stack_size;
15 stack_size = new_stack_size;
16 call_depth_limit = max_call_depth;
17 }
18}
19
21 if(stack_top) {
22 munmap((char*)stack_top - stack_size, stack_size);
23 stack_top = nullptr;
24 stack_size = 0;
26 }
27}
Defines exception's used by fc.
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
static constexpr std::size_t max_bytes_per_frame
Definition stack.hpp:14