summaryrefslogtreecommitdiff
path: root/test/lld/basic_safe_stack.wat.out
blob: b92a3048c5a681ce2660a371e233d06af7f0cdcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
(module
 (type $none_=>_none (func))
 (type $i32_=>_none (func (param i32)))
 (type $i32_=>_i32 (func (param i32) (result i32)))
 (type $3 (func (param i32 i32)))
 (import "env" "__handle_stack_overflow" (func $__handle_stack_overflow (param i32)))
 (global $__stack_pointer (mut i32) (i32.const 66112))
 (global $__stack_base (mut i32) (i32.const 0))
 (global $__stack_limit (mut i32) (i32.const 0))
 (memory $0 2)
 (export "memory" (memory $0))
 (export "__wasm_call_ctors" (func $__wasm_call_ctors))
 (export "stackRestore" (func $stackRestore))
 (export "stackAlloc" (func $stackAlloc))
 (export "main" (func $main))
 (export "__set_stack_limits" (func $__set_stack_limits))
 (func $__wasm_call_ctors
 )
 (func $stackRestore (param $0 i32)
  (local $1 i32)
  (if
   (i32.or
    (i32.gt_u
     (local.tee $1
      (local.get $0)
     )
     (global.get $__stack_base)
    )
    (i32.lt_u
     (local.get $1)
     (global.get $__stack_limit)
    )
   )
   (then
    (call $__handle_stack_overflow
     (local.get $1)
    )
   )
  )
  (global.set $__stack_pointer
   (local.get $1)
  )
 )
 (func $stackAlloc (param $0 i32) (result i32)
  (local $1 i32)
  (local $2 i32)
  (local $3 i32)
  (block
   (if
    (i32.or
     (i32.gt_u
      (local.tee $3
       (local.tee $1
        (i32.and
         (i32.sub
          (global.get $__stack_pointer)
          (local.get $0)
         )
         (i32.const -16)
        )
       )
      )
      (global.get $__stack_base)
     )
     (i32.lt_u
      (local.get $3)
      (global.get $__stack_limit)
     )
    )
    (then
     (call $__handle_stack_overflow
      (local.get $3)
     )
    )
   )
   (global.set $__stack_pointer
    (local.get $3)
   )
  )
  (local.get $1)
 )
 (func $main
 )
 (func $__set_stack_limits (param $0 i32) (param $1 i32)
  (global.set $__stack_base
   (local.get $0)
  )
  (global.set $__stack_limit
   (local.get $1)
  )
 )
)