Skip to content

Commit

Permalink
chore: Update wasmencoder to v0.10.0
Browse files Browse the repository at this point in the history
This update will make it easier to keep track of the index space of each
section while constructing modules by relying on the provided `len`
method of each section rather than having to maintain internal data
structure for this purpose.
  • Loading branch information
saulecabrera committed Mar 24, 2022
1 parent d5c8b39 commit c53fd69
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 132 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/wasmlink/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ anyhow = "1.0.40"
heck = "0.3.3"
lazy_static = "1.4.0"
petgraph = "0.5.1"
wasm-encoder = "0.4.1"
wasm-encoder = "0.10.0"
wasmparser = "0.78.1"
wit-parser = { path = "../parser" }

Expand Down
18 changes: 9 additions & 9 deletions crates/wasmlink/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ impl<'a> ModuleAdapter<'a> {
let mut func = wasm_encoder::Function::new(std::iter::empty());

for i in 0..info.import_type.params.len() as u32 {
func.instruction(wasm_encoder::Instruction::LocalGet(i));
func.instruction(&wasm_encoder::Instruction::LocalGet(i));
}

func.instruction(wasm_encoder::Instruction::I32Const(func_index as i32));
func.instruction(wasm_encoder::Instruction::CallIndirect {
func.instruction(&wasm_encoder::Instruction::I32Const(func_index as i32));
func.instruction(&wasm_encoder::Instruction::CallIndirect {
ty: *type_index,
table: 0,
});

func.instruction(wasm_encoder::Instruction::End);
func.instruction(&wasm_encoder::Instruction::End);

code.function(&func);
}
Expand All @@ -170,10 +170,8 @@ impl<'a> ModuleAdapter<'a> {

tables.table(wasm_encoder::TableType {
element_type: wasm_encoder::ValType::FuncRef,
limits: wasm_encoder::Limits {
min: table_len,
max: Some(table_len),
},
minimum: table_len,
maximum: Some(table_len),
});

exports.export(FUNCTION_TABLE_NAME, wasm_encoder::Export::Table(0));
Expand Down Expand Up @@ -300,7 +298,9 @@ impl<'a> ModuleAdapter<'a> {
PARENT_MODULE_NAME,
Some(MEMORY_EXPORT_NAME),
wasm_encoder::EntityType::Memory(wasm_encoder::MemoryType {
limits: wasm_encoder::Limits { min: 0, max: None },
maximum: None,
minimum: 0,
memory64: false,
}),
);

Expand Down
Loading

0 comments on commit c53fd69

Please sign in to comment.