Debian Codegraph @

crates/wit-component/tests/components/adapt-inject-stack-with-realloc/component.wat

raw
1 (component
2 (type (;0;)
3 (instance
4 (type (;0;) (tuple u32 u32))
5 (type (;1;) (func (result 0)))
6 (export (;0;) "get-two" (func (type 1)))
7 )
8 )
9 (import "new" (instance (;0;) (type 0)))
10 (core module (;0;)
11 (type (;0;) (func (result i32)))
12 (type (;1;) (func (param i32 i32 i32 i32) (result i32)))
13 (import "old" "get_sum" (func (;0;) (type 0)))
14 (memory (;0;) 1)
15 (export "memory" (memory 0))
16 (export "cabi_realloc" (func $cabi_realloc))
17 (func $cabi_realloc (;1;) (type 1) (param i32 i32 i32 i32) (result i32)
18 (local i32)
19 i32.const 0
20 local.get 0
21 i32.ne
22 if ;; label = @1
23 unreachable
24 end
25 i32.const 0
26 local.get 1
27 i32.ne
28 if ;; label = @1
29 unreachable
30 end
31 i32.const 65536
32 local.get 3
33 i32.ne
34 if ;; label = @1
35 unreachable
36 end
37 i32.const 1
38 memory.grow
39 local.tee 4
40 i32.const -1
41 i32.eq
42 if ;; label = @1
43 unreachable
44 end
45 local.get 4
46 i32.const 16
47 i32.shl
48 )
49 (@producers
50 (processed-by "wit-component" "$CARGO_PKG_VERSION")
51 (processed-by "my-fake-bindgen" "123.45")
52 )
53 )
54 (core module (;1;)
55 (type (;0;) (func (param i32)))
56 (type (;1;) (func (param i32 i32 i32 i32) (result i32)))
57 (type (;2;) (func (result i32)))
58 (type (;3;) (func))
59 (import "env" "memory" (memory (;0;) 0))
60 (import "new" "get-two" (func $get_two (;0;) (type 0)))
61 (import "__main_module__" "cabi_realloc" (func $cabi_realloc (;1;) (type 1)))
62 (global $__stack_pointer (;0;) (mut i32) i32.const 0)
63 (global $some_other_mutable_global (;1;) (mut i32) i32.const 0)
64 (global $allocation_state (;2;) (mut i32) i32.const 0)
65 (export "get_sum" (func 2))
66 (func (;2;) (type 2) (result i32)
67 (local i32 i32)
68 call $allocate_stack
69 global.get $allocation_state
70 i32.const 2
71 i32.ne
72 if ;; label = @1
73 unreachable
74 end
75 i32.const 0
76 i32.const 0
77 i32.const 8
78 i32.const 65536
79 call $cabi_realloc
80 local.set 0
81 local.get 0
82 i32.const 42
83 i32.store
84 local.get 0
85 i32.const 42
86 i32.store offset=65532
87 global.get $__stack_pointer
88 local.tee 0
89 i32.const 8
90 i32.sub
91 local.tee 1
92 global.set $__stack_pointer
93 local.get 1
94 call $get_two
95 local.get 1
96 i32.load
97 local.get 1
98 i32.load offset=4
99 i32.add
100 global.get $some_other_mutable_global
101 global.set $some_other_mutable_global
102 local.get 0
103 global.set $__stack_pointer
104 )
105 (func $allocate_stack (;3;) (type 3)
106 global.get $allocation_state
107 i32.const 0
108 i32.eq
109 if ;; label = @1
110 i32.const 1
111 global.set $allocation_state
112 i32.const 0
113 i32.const 0
114 i32.const 8
115 i32.const 65536
116 call $cabi_realloc
117 i32.const 65536
118 i32.add
119 global.set $__stack_pointer
120 i32.const 2
121 global.set $allocation_state
122 end
123 )
124 )
125 (core module (;2;)
126 (type (;0;) (func (result i32)))
127 (type (;1;) (func (param i32)))
128 (table (;0;) 2 2 funcref)
129 (export "0" (func $adapt-old-get_sum))
130 (export "1" (func $indirect-new-get-two))
131 (export "$imports" (table 0))
132 (func $adapt-old-get_sum (;0;) (type 0) (result i32)
133 i32.const 0
134 call_indirect (type 0)
135 )
136 (func $indirect-new-get-two (;1;) (type 1) (param i32)
137 local.get 0
138 i32.const 1
139 call_indirect (type 1)
140 )
141 (@producers
142 (processed-by "wit-component" "$CARGO_PKG_VERSION")
143 )
144 )
145 (core module (;3;)
146 (type (;0;) (func (result i32)))
147 (type (;1;) (func (param i32)))
148 (import "" "0" (func (;0;) (type 0)))
149 (import "" "1" (func (;1;) (type 1)))
150 (import "" "$imports" (table (;0;) 2 2 funcref))
151 (elem (;0;) (i32.const 0) func 0 1)
152 (@producers
153 (processed-by "wit-component" "$CARGO_PKG_VERSION")
154 )
155 )
156 (core instance (;0;) (instantiate 2))
157 (alias core export 0 "0" (core func (;0;)))
158 (core instance (;1;)
159 (export "get_sum" (func 0))
160 )
161 (core instance (;2;) (instantiate 0
162 (with "old" (instance 1))
163 )
164 )
165 (alias core export 2 "memory" (core memory (;0;)))
166 (core instance (;3;)
167 (export "memory" (memory 0))
168 )
169 (alias core export 0 "1" (core func (;1;)))
170 (core instance (;4;)
171 (export "get-two" (func 1))
172 )
173 (alias core export 2 "cabi_realloc" (core func (;2;)))
174 (core instance (;5;)
175 (export "cabi_realloc" (func 2))
176 )
177 (core instance (;6;) (instantiate 1
178 (with "env" (instance 3))
179 (with "new" (instance 4))
180 (with "__main_module__" (instance 5))
181 )
182 )
183 (alias core export 0 "$imports" (core table (;0;)))
184 (alias core export 6 "get_sum" (core func (;3;)))
185 (alias export 0 "get-two" (func (;0;)))
186 (core func (;4;) (canon lower (func 0) (memory 0)))
187 (core instance (;7;)
188 (export "$imports" (table 0))
189 (export "0" (func 3))
190 (export "1" (func 4))
191 )
192 (core instance (;8;) (instantiate 3
193 (with "" (instance 7))
194 )
195 )
196 (@producers
197 (processed-by "wit-component" "$CARGO_PKG_VERSION")
198 )
199 )