Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
stack.cpp
Go to the documentation of this file.
1
#include <
sysio/chain/webassembly/sys-vm-oc/stack.hpp
>
2
#include <
fc/exception/exception.hpp
>
3
#include <sys/mman.h>
4
5
using namespace
sysio::chain::eosvmoc
;
6
7
void
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
20
void
execution_stack::reset
() {
21
if
(
stack_top
) {
22
munmap((
char
*)
stack_top
-
stack_size
,
stack_size
);
23
stack_top
=
nullptr
;
24
stack_size
= 0;
25
call_depth_limit
= 4*1024*1024 /
max_bytes_per_frame
;
26
}
27
}
exception.hpp
Defines exception's used by fc.
FC_ASSERT
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition
exception.hpp:362
sysio::chain::eosvmoc
Definition
wasm_interface.hpp:15
stack.hpp
sysio::chain::eosvmoc::execution_stack::call_depth_limit
std::size_t call_depth_limit
Definition
stack.hpp:19
sysio::chain::eosvmoc::execution_stack::reset
void reset()
Definition
stack.cpp:20
sysio::chain::eosvmoc::execution_stack::stack_size
std::size_t stack_size
Definition
stack.hpp:17
sysio::chain::eosvmoc::execution_stack::max_bytes_per_frame
static constexpr std::size_t max_bytes_per_frame
Definition
stack.hpp:14
sysio::chain::eosvmoc::execution_stack::stack_top
void * stack_top
Definition
stack.hpp:16
libraries
chain
webassembly
runtimes
sys-vm-oc
stack.cpp
Generated by
1.12.0