@@ -50,7 +50,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
5050 environ : & mut FE ,
5151) -> WasmResult < ( ) > {
5252 if !state. reachable {
53- translate_unreachable_operator ( wasm_types, & op, builder, state) ?;
53+ translate_unreachable_operator ( wasm_types, & op, builder, state, environ ) ?;
5454 return Ok ( ( ) ) ;
5555 }
5656
@@ -134,13 +134,13 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
134134 ***********************************************************************************/
135135 Operator :: Block { ty } => {
136136 let ( params, results) = blocktype_params_results ( wasm_types, * ty) ?;
137- let next = ebb_with_params ( builder, results) ?;
137+ let next = ebb_with_params ( builder, results, environ ) ?;
138138 state. push_block ( next, params. len ( ) , results. len ( ) ) ;
139139 }
140140 Operator :: Loop { ty } => {
141141 let ( params, results) = blocktype_params_results ( wasm_types, * ty) ?;
142- let loop_body = ebb_with_params ( builder, params) ?;
143- let next = ebb_with_params ( builder, results) ?;
142+ let loop_body = ebb_with_params ( builder, params, environ ) ?;
143+ let next = ebb_with_params ( builder, results, environ ) ?;
144144 builder. ins ( ) . jump ( loop_body, state. peekn ( params. len ( ) ) ) ;
145145 state. push_loop ( loop_body, next, params. len ( ) , results. len ( ) ) ;
146146
@@ -163,16 +163,16 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
163163 // destination ebb following the whole `if...end`. If we do end
164164 // up discovering an `else`, then we will allocate an ebb for it
165165 // and go back and patch the jump.
166- let destination = ebb_with_params ( builder, results) ?;
166+ let destination = ebb_with_params ( builder, results, environ ) ?;
167167 let branch_inst = builder
168168 . ins ( )
169169 . brz ( val, destination, state. peekn ( params. len ( ) ) ) ;
170170 ( destination, ElseData :: NoElse { branch_inst } )
171171 } else {
172172 // The `if` type signature is not valid without an `else` block,
173173 // so we eagerly allocate the `else` block here.
174- let destination = ebb_with_params ( builder, results) ?;
175- let else_block = ebb_with_params ( builder, params) ?;
174+ let destination = ebb_with_params ( builder, results, environ ) ?;
175+ let else_block = ebb_with_params ( builder, params, environ ) ?;
176176 builder
177177 . ins ( )
178178 . brz ( val, else_block, state. peekn ( params. len ( ) ) ) ;
@@ -215,7 +215,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
215215 * reachable_from_top = false ;
216216
217217 let ( params, _results) = blocktype_params_results ( wasm_types, blocktype) ?;
218- let else_ebb = ebb_with_params ( builder, params) ?;
218+ let else_ebb = ebb_with_params ( builder, params, environ ) ?;
219219 builder. ins ( ) . jump ( destination, state. peekn ( params. len ( ) ) ) ;
220220 state. popn ( params. len ( ) ) ;
221221
@@ -1193,11 +1193,12 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
11931193/// Deals with a Wasm instruction located in an unreachable portion of the code. Most of them
11941194/// are dropped but special ones like `End` or `Else` signal the potential end of the unreachable
11951195/// portion so the translation state must be updated accordingly.
1196- fn translate_unreachable_operator (
1196+ fn translate_unreachable_operator < FE : FuncEnvironment + ? Sized > (
11971197 wasm_types : & WasmTypesMap ,
11981198 op : & Operator ,
11991199 builder : & mut FunctionBuilder ,
12001200 state : & mut TranslationState ,
1201+ environ : & mut FE ,
12011202) -> WasmResult < ( ) > {
12021203 match * op {
12031204 Operator :: If { ty } => {
@@ -1233,7 +1234,7 @@ fn translate_unreachable_operator(
12331234 * reachable_from_top = false ;
12341235
12351236 let ( params, _results) = blocktype_params_results ( wasm_types, blocktype) ?;
1236- let else_ebb = ebb_with_params ( builder, params) ?;
1237+ let else_ebb = ebb_with_params ( builder, params, environ ) ?;
12371238
12381239 // We change the target of the branch instruction.
12391240 builder. change_jump_destination ( branch_inst, else_ebb) ;
0 commit comments