Skip to content

Commit fc60fe3

Browse files
committed
initialize function body enclosing block
1 parent a63410d commit fc60fe3

File tree

1 file changed

+14
-4
lines changed
  • crates/wasmi/src/engine/translator/translator2

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![expect(dead_code, unused_imports, unused_variables)]
22

3+
#[macro_use]
4+
mod utils;
35
mod instrs;
46
mod layout;
57
#[cfg(feature = "simd")]
68
mod simd;
79
mod stack;
8-
mod utils;
910
mod visit;
1011

1112
use self::{
@@ -18,8 +19,10 @@ use crate::{
1819
core::FuelCostsProvider,
1920
engine::{
2021
translator::{Instr, LabelRegistry, WasmTranslator},
22+
BlockType,
2123
CompiledFuncEntity,
2224
},
25+
ir::Instruction,
2326
module::{FuncIdx, ModuleHeader, WasmiValueType},
2427
Engine,
2528
Error,
@@ -143,15 +146,22 @@ impl FuncTranslator {
143146
.then(|| config.fuel_costs())
144147
.cloned();
145148
let FuncTranslatorAllocations {
146-
stack,
149+
mut stack,
147150
layout,
148-
labels,
149-
instrs,
151+
mut labels,
152+
mut instrs,
150153
} = {
151154
let mut alloc = alloc;
152155
alloc.reset();
153156
alloc
154157
};
158+
let func_ty = module.get_type_of_func(func);
159+
let block_ty = BlockType::func_type(func_ty);
160+
let end_label = labels.new_label();
161+
let consume_fuel = fuel_costs
162+
.as_ref()
163+
.map(|_| instrs.push_instr(Instruction::consume_fuel(1)));
164+
stack.push_block(block_ty, end_label, consume_fuel)?;
155165
Ok(Self {
156166
func,
157167
engine,

0 commit comments

Comments
 (0)