Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::eosvmoc::execution_stack Struct Reference

#include <stack.hpp>

Collaboration diagram for sysio::chain::eosvmoc::execution_stack:

Public Member Functions

 execution_stack ()=default
 
 execution_stack (const execution_stack &)=delete
 
execution_stackoperator= (const execution_stack &)=delete
 
void reset (std::size_t max_call_depth)
 
void reset ()
 
template<typename F >
void run (F &&f)
 
 ~execution_stack ()
 

Public Attributes

void * stack_top = nullptr
 
std::size_t stack_size = 0
 
std::size_t call_depth_limit = 4*1024*1024 / max_bytes_per_frame
 

Static Public Attributes

static constexpr std::size_t max_bytes_per_frame = 16*1024
 

Detailed Description

Definition at line 12 of file stack.hpp.

Constructor & Destructor Documentation

◆ execution_stack() [1/2]

sysio::chain::eosvmoc::execution_stack::execution_stack ( )
default

◆ execution_stack() [2/2]

sysio::chain::eosvmoc::execution_stack::execution_stack ( const execution_stack & )
delete

◆ ~execution_stack()

sysio::chain::eosvmoc::execution_stack::~execution_stack ( )
inline

Definition at line 37 of file stack.hpp.

37 {
38 reset();
39 }
Here is the call graph for this function:

Member Function Documentation

◆ operator=()

execution_stack & sysio::chain::eosvmoc::execution_stack::operator= ( const execution_stack & )
delete

◆ reset() [1/2]

void execution_stack::reset ( )

Definition at line 20 of file stack.cpp.

20 {
21 if(stack_top) {
22 munmap((char*)stack_top - stack_size, stack_size);
23 stack_top = nullptr;
24 stack_size = 0;
26 }
27}
static constexpr std::size_t max_bytes_per_frame
Definition stack.hpp:14
Here is the caller graph for this function:

◆ reset() [2/2]

void execution_stack::reset ( std::size_t max_call_depth)

Definition at line 7 of file stack.cpp.

7 {
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;
17 }
18}
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

template<typename F >
void sysio::chain::eosvmoc::execution_stack::run ( F && f)
inline

Definition at line 29 of file stack.hpp.

29 {
30 if (stack_top) {
31 eosvmoc_switch_stack(stack_top, [](void* data) { (*static_cast<F*>(data))(); }, &f);
32 } else {
33 f();
34 }
35 }
void eosvmoc_switch_stack(void *stack, void(*fn)(void *), void *data)
Here is the call graph for this function:

Member Data Documentation

◆ call_depth_limit

std::size_t sysio::chain::eosvmoc::execution_stack::call_depth_limit = 4*1024*1024 / max_bytes_per_frame

Definition at line 19 of file stack.hpp.

◆ max_bytes_per_frame

std::size_t sysio::chain::eosvmoc::execution_stack::max_bytes_per_frame = 16*1024
staticconstexpr

Definition at line 14 of file stack.hpp.

◆ stack_size

std::size_t sysio::chain::eosvmoc::execution_stack::stack_size = 0

Definition at line 17 of file stack.hpp.

◆ stack_top

void* sysio::chain::eosvmoc::execution_stack::stack_top = nullptr

Definition at line 16 of file stack.hpp.


The documentation for this struct was generated from the following files: