Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
stack_restriction_tests.cpp File Reference
#include <iostream>
#include <vector>
#include <sysio/vm/backend.hpp>
#include <sysio/vm/watchdog.hpp>
#include "utils.hpp"
#include <catch2/catch.hpp>
Include dependency graph for stack_restriction_tests.cpp:

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Test that we can load and run a wasm that uses 8191 stack elements", "[8k_minus_1_stack_elems_test]")
 
 BACKEND_TEST_CASE ("Test that we can load and run a wasm that uses 8192 stack elements", "[8k_stack_elems_test]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE() [1/2]

BACKEND_TEST_CASE ( "Test that we can load and run a wasm that uses 8191 stack elements" ,
"" [8k_minus_1_stack_elems_test] )

Definition at line 15 of file stack_restriction_tests.cpp.

16 {
17 // comes from the wasm
18 /*
19 (module
20 (type (;0;) (func))
21 (type (;1;) (func (param i32)))
22 (func (;0;) (type 1) (param i32)
23 (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
24 i64 i64 i64 i64 i64) get_local 0 i32.const 249 i32.eq br_if 0 (;@0;) get_local 0 i32.const 1 i32.add call 0) (func
25 (;1;) (type 0) (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
26 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
27 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
28 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
29 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
30 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
31 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) i32.const 0 call 0) (memory
32 (;0;) 0) (export "fun" (func 1)))
33 */
34 std::vector<uint8_t> _8k_stack_size_1_under_wasm = {
35 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60, 0x00, 0x00, 0x60, 0x01, 0x7f, 0x00,
36 0x03, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x00, 0x07, 0x07, 0x01, 0x03, 0x66, 0x75, 0x6e, 0x00,
37 0x01, 0x0a, 0x1f, 0x02, 0x13, 0x01, 0x1f, 0x7e, 0x20, 0x00, 0x41, 0xf9, 0x01, 0x46, 0x0d, 0x00, 0x20, 0x00,
38 0x41, 0x01, 0x6a, 0x10, 0x00, 0x0b, 0x09, 0x01, 0xbe, 0x01, 0x7e, 0x41, 0x00, 0x10, 0x00, 0x0b
39 };
40
42 backend_t bkend(_8k_stack_size_1_under_wasm, &wa);
44}
void execute_all(Watchdog &&wd, host_t &host)
Definition backend.hpp:219
backend_t bkend(hello_wasm, ehm, &wa)
wasm_allocator wa
Definition main.cpp:10
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [2/2]

BACKEND_TEST_CASE ( "Test that we can load and run a wasm that uses 8192 stack elements" ,
"" [8k_stack_elems_test] )

Definition at line 46 of file stack_restriction_tests.cpp.

46 {
47 // comes from the wasm
48 /*
49 (module
50 (type (;0;) (func))
51 (type (;1;) (func (param i32)))
52 (func (;0;) (type 1) (param i32)
53 (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
54 i64 i64 i64 i64 i64) get_local 0 i32.const 249 i32.eq br_if 0 (;@0;) get_local 0 i32.const 1 i32.add call 0) (func
55 (;1;) (type 0) (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
56 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
57 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
58 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
59 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
60 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
61 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) i32.const 0 call 0) (memory
62 (;0;) 0) (export "fun" (func 1)))
63 */
64
65 std::vector<uint8_t> _8k_stack_size_wasm = { 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60,
66 0x00, 0x00, 0x60, 0x01, 0x7f, 0x00, 0x03, 0x03, 0x02, 0x01, 0x00, 0x05,
67 0x03, 0x01, 0x00, 0x00, 0x07, 0x07, 0x01, 0x03, 0x66, 0x75, 0x6e, 0x00,
68 0x01, 0x0a, 0x1f, 0x02, 0x13, 0x01, 0x9d, 0x03, 0x7e, 0x20, 0x00, 0x41,
69 0x14, 0x46, 0x0d, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x10, 0x00, 0x0b,
70 0x09, 0x01, 0xfe, 0x02, 0x7e, 0x41, 0x00, 0x10, 0x00, 0x0b };
71
73 backend_t bkend(_8k_stack_size_wasm, &wa);
75}
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.