Skip to content

Commit 5f7b15e

Browse files
committed
refactor tranlate_end_func
1 parent 104eabb commit 5f7b15e

File tree

1 file changed

+9
-17
lines changed
  • crates/wasmi/src/engine/translator/func2

1 file changed

+9
-17
lines changed

crates/wasmi/src/engine/translator/func2/mod.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,7 @@ impl FuncTranslator {
253253
if !self.reachable {
254254
return Ok(());
255255
}
256-
let _fuel_info = match (&self.fuel_costs, frame.consume_fuel_instr()) {
257-
(Some(fuel_costs), Some(consume_fuel)) => {
258-
FuelInfo::some(fuel_costs.clone(), consume_fuel)
259-
}
260-
(None, None) => FuelInfo::None,
261-
_ => unreachable!(),
262-
};
256+
// let _fuel_info = self.fuel_info();
263257
let len_results = frame.ty().len_results(&self.engine);
264258
if frame.is_branched_to() && len_results > 1 {
265259
let height = frame.height();
@@ -309,13 +303,8 @@ impl FuncTranslator {
309303
}
310304
}
311305
}
312-
self.labels
313-
.pin_label(frame.label(), self.instrs.next_instr())
314-
.unwrap_or_else(|err| panic!("failed to pin label: {err}"));
315-
match len_results {
316-
0 => {
317-
self.instrs.push_instr(Instruction::Return);
318-
}
306+
let return_instr = match len_results {
307+
0 => self.instrs.push_instr(Instruction::Return),
319308
1 => {
320309
let instr = match self.stack.peek(0) {
321310
Operand::Local(operand) => {
@@ -352,15 +341,18 @@ impl FuncTranslator {
352341
}
353342
}
354343
};
355-
self.instrs.push_instr(instr);
344+
self.instrs.push_instr(instr)
356345
}
357346
_ => {
358347
let height = frame.height();
359348
let result = self.layout.temp_to_reg(OperandIdx::from(height - 1))?;
360349
let values = BoundedRegSpan::new(RegSpan::new(result), len_results);
361-
self.instrs.push_instr(Instruction::return_span(values));
350+
self.instrs.push_instr(Instruction::return_span(values))
362351
}
363-
}
352+
};
353+
self.labels
354+
.pin_label(frame.label(), return_instr)
355+
.unwrap_or_else(|err| panic!("failed to pin label: {err}"));
364356
Ok(())
365357
}
366358

0 commit comments

Comments
 (0)