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.
This commit is contained in:
@@ -112,9 +112,9 @@ mod test {
|
|||||||
|
|
||||||
let binding = body_inputs
|
let binding = body_inputs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|func| compile(&*isa, module, types, func))
|
.map(|func| compile(&*isa, module, types, func).join("\n"))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("\n");
|
.join("\n\n");
|
||||||
let actual = binding.as_str();
|
let actual = binding.as_str();
|
||||||
|
|
||||||
if std::env::var("WINCH_TEST_BLESS").unwrap_or_default() == "1" {
|
if std::env::var("WINCH_TEST_BLESS").unwrap_or_default() == "1" {
|
||||||
@@ -151,7 +151,7 @@ mod test {
|
|||||||
) -> Vec<String> {
|
) -> Vec<String> {
|
||||||
let index = module.func_index(f.0);
|
let index = module.func_index(f.0);
|
||||||
let sig = types
|
let sig = types
|
||||||
.func_type_at(index.as_u32())
|
.function_at(index.as_u32())
|
||||||
.expect(&format!("function type at index {:?}", index.as_u32()));
|
.expect(&format!("function type at index {:?}", index.as_u32()));
|
||||||
let FunctionBodyData { body, validator } = f.1;
|
let FunctionBodyData { body, validator } = f.1;
|
||||||
let validator = validator.into_validator(Default::default());
|
let validator = validator.into_validator(Default::default());
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ fn compile(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let index = module.func_index(f.0);
|
let index = module.func_index(f.0);
|
||||||
let sig = types
|
let sig = types
|
||||||
.func_type_at(index.as_u32())
|
.function_at(index.as_u32())
|
||||||
.expect(&format!("function type at index {:?}", index.as_u32()));
|
.expect(&format!("function type at index {:?}", index.as_u32()));
|
||||||
let FunctionBodyData { body, validator } = f.1;
|
let FunctionBodyData { body, validator } = f.1;
|
||||||
let validator = validator.into_validator(Default::default());
|
let validator = validator.into_validator(Default::default());
|
||||||
@@ -64,6 +64,7 @@ fn compile(
|
|||||||
.compile_function(&sig, &body, validator)
|
.compile_function(&sig, &body, validator)
|
||||||
.expect("Couldn't compile function");
|
.expect("Couldn't compile function");
|
||||||
|
|
||||||
|
println!("Disassembly for function: {}", index.as_u32());
|
||||||
disasm(buffer.data(), isa)?
|
disasm(buffer.data(), isa)?
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|s| println!("{}", s));
|
.for_each(|s| println!("{}", s));
|
||||||
|
|||||||
Reference in New Issue
Block a user