Skip to content

Commit 939b6ea

Browse files
authored
winch: Fix retrieving function signature for compilation (#5725)
This commit fixes an incorrect usage of `func_type_at` to retrieve a defined function signature and instead uses `function_at` to retrieve the signature. Additionally it enhances `winch-tools` `compile` and `test` commands to handle modules with multiple functions correctly.
1 parent 1390882 commit 939b6ea

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

winch/filetests/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ mod test {
112112

113113
let binding = body_inputs
114114
.into_iter()
115-
.flat_map(|func| compile(&*isa, module, types, func))
115+
.map(|func| compile(&*isa, module, types, func).join("\n"))
116116
.collect::<Vec<String>>()
117-
.join("\n");
117+
.join("\n\n");
118118
let actual = binding.as_str();
119119

120120
if std::env::var("WINCH_TEST_BLESS").unwrap_or_default() == "1" {
@@ -151,7 +151,7 @@ mod test {
151151
) -> Vec<String> {
152152
let index = module.func_index(f.0);
153153
let sig = types
154-
.func_type_at(index.as_u32())
154+
.function_at(index.as_u32())
155155
.expect(&format!("function type at index {:?}", index.as_u32()));
156156
let FunctionBodyData { body, validator } = f.1;
157157
let validator = validator.into_validator(Default::default());

winch/src/compile.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ fn compile(
5656
) -> Result<()> {
5757
let index = module.func_index(f.0);
5858
let sig = types
59-
.func_type_at(index.as_u32())
59+
.function_at(index.as_u32())
6060
.expect(&format!("function type at index {:?}", index.as_u32()));
6161
let FunctionBodyData { body, validator } = f.1;
6262
let validator = validator.into_validator(Default::default());
6363
let buffer = isa
6464
.compile_function(&sig, &body, validator)
6565
.expect("Couldn't compile function");
6666

67+
println!("Disassembly for function: {}", index.as_u32());
6768
disasm(buffer.data(), isa)?
6869
.iter()
6970
.for_each(|s| println!("{}", s));

0 commit comments

Comments
 (0)