From 7f049cf3740387b8a36b116bad32c8d9db860798 Mon Sep 17 00:00:00 2001 From: Christof Petig Date: Sun, 26 Jul 2026 19:08:05 +0200 Subject: [PATCH 1/3] deactivate the old flattening of fixed length lists --- Cargo.lock | 24 ++++------ Cargo.toml | 14 +++--- crates/core/src/abi.rs | 90 ++++++++++++++++++----------------- crates/cpp/src/lib.rs | 54 ++++++++++----------- crates/csharp/src/function.rs | 4 +- crates/moonbit/src/lib.rs | 56 +++++++++++----------- crates/rust/src/bindgen.rs | 48 +++++++++---------- 7 files changed, 142 insertions(+), 148 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec2bd3b10..09d874941 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1222,8 +1222,7 @@ checksum = "1b6c48003fe59c201c97a7786ff55feabe6b6f83b598aa9ff5bcc4f94d940bf3" [[package]] name = "wasm-compose" version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd717357bff09b5f1ea49aea8ed1cd149b0c521823a1cc70bc2ac16b90b651a" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "anyhow", "heck", @@ -1252,8 +1251,7 @@ dependencies = [ [[package]] name = "wasm-encoder" version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09480d646178e5fdd12bb06e812d0af9a3a191dbc9cd697fdc86687beade7393" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "leb128fmt", "wasmparser 0.254.0", @@ -1281,8 +1279,7 @@ dependencies = [ [[package]] name = "wasm-metadata" version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01df5f3b4ca7881e843f3bc0fb8a3905d79c68692250dcb8e33e698705ccdb6" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "anyhow", "indexmap", @@ -1306,8 +1303,7 @@ dependencies = [ [[package]] name = "wasmparser" version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5769a29f799fbab136aaf65b4fe5384cd7d93fe6fc9ba0dcb6c8382a1f16e27" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "bitflags", "hashbrown 0.17.1", @@ -1319,8 +1315,7 @@ dependencies = [ [[package]] name = "wast" version = "254.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ed4dfc8f6b9fc38b231065e2cdfbf7359af5ab945990abf09658dcc63c3e32" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "bumpalo", "leb128fmt", @@ -1332,8 +1327,7 @@ dependencies = [ [[package]] name = "wat" version = "1.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7127f7f9b8f127c879991cecd35f494e4628bae1b0874c681414d8d8831e952c" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "wast", ] @@ -1545,8 +1539,7 @@ dependencies = [ [[package]] name = "wit-component" version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0e65bb94c369b3c4741ce3d1d2704b1fec93db7c540df0e521a097e7ceeb5be" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "anyhow", "bitflags", @@ -1565,8 +1558,7 @@ dependencies = [ [[package]] name = "wit-parser" version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1655131e4f7d3f0cb141f6eca71315ca40eff0f3d4de7cff0a82bacedd8c89b4" +source = "git+https://github.com/cpetig/wasm-tools?branch=fixed-lenght-640#c251fb40769755dc2cf0ff3e2495901dac16dcc2" dependencies = [ "anyhow", "hashbrown 0.17.1", diff --git a/Cargo.toml b/Cargo.toml index c1344cd1f..fc49d4437 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,13 +47,13 @@ syn = { version = "2.0.89", features = ["printing"] } futures = "0.3.31" macro-string = "0.2.0" -wat = "1.254.0" -wasmparser = "0.254.0" -wasm-encoder = "0.254.0" -wasm-metadata = { version = "0.254.0", default-features = false } -wit-parser = "0.254.0" -wit-component = "0.254.0" -wasm-compose = "0.254.0" +wat = { git = "https://github.com/cpetig/wasm-tools", branch = "fixed-lenght-640" } +wasmparser = { git = "https://github.com/cpetig/wasm-tools", branch = "fixed-lenght-640" } +wasm-encoder = { git = "https://github.com/cpetig/wasm-tools", branch = "fixed-lenght-640" } +wasm-metadata = { git = "https://github.com/cpetig/wasm-tools", branch = "fixed-lenght-640", default-features = false } +wit-parser = { git = "https://github.com/cpetig/wasm-tools", branch = "fixed-lenght-640" } +wit-component = { git = "https://github.com/cpetig/wasm-tools", branch = "fixed-lenght-640" } +wasm-compose = { git = "https://github.com/cpetig/wasm-tools", branch = "fixed-lenght-640" } wit-bindgen-core = { path = 'crates/core', version = '0.60.0' } wit-bindgen-c = { path = 'crates/c', version = '0.60.0' } diff --git a/crates/core/src/abi.rs b/crates/core/src/abi.rs index 73238fc93..297cf90eb 100644 --- a/crates/core/src/abi.rs +++ b/crates/core/src/abi.rs @@ -332,20 +332,20 @@ def_instruction! { ty: TypeId, } : [2] => [1], - /// Pops all fields for a fixed list off the stack and then composes them - /// into an array. - FixedLengthListLift { - element: &'a Type, - size: u32, - id: TypeId, - } : [*size as usize] => [1], - - /// Pops an array off the stack, decomposes the elements and then pushes them onto the stack. - FixedLengthListLower { - element: &'a Type, - size: u32, - id: TypeId, - } : [1] => [*size as usize], + // /// Pops all fields for a fixed list off the stack and then composes them + // /// into an array. + // FixedLengthListLift { + // element: &'a Type, + // size: u32, + // id: TypeId, + // } : [*size as usize] => [1], + + // /// Pops an array off the stack, decomposes the elements and then pushes them onto the stack. + // FixedLengthListLower { + // element: &'a Type, + // size: u32, + // id: TypeId, + // } : [1] => [*size as usize], /// Pops an array and an address off the stack, passes each element to a block storing it FixedLengthListLowerToMemory { @@ -1641,20 +1641,21 @@ impl<'a, B: Bindgen> Generator<'a, B> { }); } TypeDefKind::Unknown => unreachable!(), - TypeDefKind::FixedLengthList(ty, size) => { - self.emit(&FixedLengthListLower { - element: ty, - size: *size, - id, - }); - let mut values = self - .stack - .drain(self.stack.len() - (*size as usize)..) - .collect::>(); - for value in values.drain(..) { - self.stack.push(value); - self.lower(ty); - } + TypeDefKind::FixedLengthList(_ty, _size) => { + todo!() + // self.emit(&FixedLengthListLower { + // element: ty, + // size: *size, + // id, + // }); + // let mut values = self + // .stack + // .drain(self.stack.len() - (*size as usize)..) + // .collect::>(); + // for value in values.drain(..) { + // self.stack.push(value); + // self.lower(ty); + // } } TypeDefKind::Map(key, value) => { let realloc = self.list_realloc(); @@ -1858,22 +1859,23 @@ impl<'a, B: Bindgen> Generator<'a, B> { } TypeDefKind::Unknown => unreachable!(), TypeDefKind::FixedLengthList(ty, size) => { - let temp = flat_types(self.resolve, ty, None).unwrap(); - let flat_per_elem = temp.to_vec().len(); - let flatsize = flat_per_elem * (*size as usize); - let mut lowered_args = self - .stack - .drain(self.stack.len() - flatsize..) - .collect::>(); - for _ in 0..*size { - self.stack.extend(lowered_args.drain(..flat_per_elem)); - self.lift(ty); - } - self.emit(&FixedLengthListLift { - element: ty, - size: *size, - id, - }); + todo!() + // let temp = flat_types(self.resolve, ty, None).unwrap(); + // let flat_per_elem = temp.to_vec().len(); + // let flatsize = flat_per_elem * (*size as usize); + // let mut lowered_args = self + // .stack + // .drain(self.stack.len() - flatsize..) + // .collect::>(); + // for _ in 0..*size { + // self.stack.extend(lowered_args.drain(..flat_per_elem)); + // self.lift(ty); + // } + // self.emit(&FixedLengthListLift { + // element: ty, + // size: *size, + // id, + // }); } TypeDefKind::Map(key, value) => { let value_offset = self.bindgen.sizes().field_offsets([key, value])[1].0; diff --git a/crates/cpp/src/lib.rs b/crates/cpp/src/lib.rs index 2d7b30099..32209e504 100644 --- a/crates/cpp/src/lib.rs +++ b/crates/cpp/src/lib.rs @@ -2778,24 +2778,24 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { results.push(move_if_necessary(&result)); } } - abi::Instruction::FixedLengthListLift { - element, - size, - id: _, - } => { - let tmp = self.tmp(); - let result = format!("_result{tmp}"); - let typename = self - .r#gen - .type_name(element, &self.namespace, Flavor::InStruct); - self.push_str(&format!("std::array<{typename}, {size}> {result} = {{",)); - for a in operands.drain(0..(*size as usize)) { - self.push_str(&a); - self.push_str(", "); - } - self.push_str("};\n"); - results.push(result); - } + // abi::Instruction::FixedLengthListLift { + // element, + // size, + // id: _, + // } => { + // let tmp = self.tmp(); + // let result = format!("_result{tmp}"); + // let typename = self + // .r#gen + // .type_name(element, &self.namespace, Flavor::InStruct); + // self.push_str(&format!("std::array<{typename}, {size}> {result} = {{",)); + // for a in operands.drain(0..(*size as usize)) { + // self.push_str(&a); + // self.push_str(", "); + // } + // self.push_str("};\n"); + // results.push(result); + // } abi::Instruction::FixedLengthListLiftFromMemory { element, size: elemsize, @@ -2825,15 +2825,15 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { self.push_str("\n}\n}\n"); results.push(vec); } - abi::Instruction::FixedLengthListLower { - element: _, - size, - id: _, - } => { - for i in 0..(*size as usize) { - results.push(format!("{}[{i}]", operands[0])); - } - } + // abi::Instruction::FixedLengthListLower { + // element: _, + // size, + // id: _, + // } => { + // for i in 0..(*size as usize) { + // results.push(format!("{}[{i}]", operands[0])); + // } + // } abi::Instruction::FixedLengthListLowerToMemory { element, size: elemsize, diff --git a/crates/csharp/src/function.rs b/crates/csharp/src/function.rs index 9de5852cf..c583fa481 100644 --- a/crates/csharp/src/function.rs +++ b/crates/csharp/src/function.rs @@ -1941,8 +1941,8 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::ErrorContextLower { .. } | Instruction::ErrorContextLift { .. } | Instruction::DropHandle { .. } - | Instruction::FixedLengthListLift { .. } - | Instruction::FixedLengthListLower { .. } + // | Instruction::FixedLengthListLift { .. } + // | Instruction::FixedLengthListLower { .. } | Instruction::FixedLengthListLowerToMemory { .. } | Instruction::FixedLengthListLiftFromMemory { .. } => { dbg!(inst); diff --git a/crates/moonbit/src/lib.rs b/crates/moonbit/src/lib.rs index 78d1a0dbf..676d349d3 100644 --- a/crates/moonbit/src/lib.rs +++ b/crates/moonbit/src/lib.rs @@ -2635,34 +2635,34 @@ impl Bindgen for FunctionBindgen<'_, '_> { } } Instruction::ErrorContextLower { .. } | Instruction::ErrorContextLift { .. } => todo!(), - Instruction::FixedLengthListLift { - element: _, - size, - id: _, - } => { - let array = self.locals.tmp("array"); - let mut elements = String::new(); - for a in operands.drain(0..(*size as usize)) { - elements.push_str(&a); - elements.push_str(", "); - } - uwriteln!(self.src, "let {array} : FixedArray[_] = [{elements}]"); - results.push(array); - } - Instruction::FixedLengthListLower { - element: _, - size, - id: _, - } => { - uwriteln!( - self.src, - "if ({}).length() != {size} {{ panic() }}", - operands[0] - ); - for i in 0..(*size as usize) { - results.push(format!("({})[{i}]", operands[0])); - } - } + // Instruction::FixedLengthListLift { + // element: _, + // size, + // id: _, + // } => { + // let array = self.locals.tmp("array"); + // let mut elements = String::new(); + // for a in operands.drain(0..(*size as usize)) { + // elements.push_str(&a); + // elements.push_str(", "); + // } + // uwriteln!(self.src, "let {array} : FixedArray[_] = [{elements}]"); + // results.push(array); + // } + // Instruction::FixedLengthListLower { + // element: _, + // size, + // id: _, + // } => { + // uwriteln!( + // self.src, + // "if ({}).length() != {size} {{ panic() }}", + // operands[0] + // ); + // for i in 0..(*size as usize) { + // results.push(format!("({})[{i}]", operands[0])); + // } + // } Instruction::FixedLengthListLowerToMemory { element, size: fixed_length, diff --git a/crates/rust/src/bindgen.rs b/crates/rust/src/bindgen.rs index 767beb6a9..61d549c9a 100644 --- a/crates/rust/src/bindgen.rs +++ b/crates/rust/src/bindgen.rs @@ -1356,30 +1356,30 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::DropHandle { .. } => { uwriteln!(self.src, "let _ = {};", operands[0]); } - Instruction::FixedLengthListLift { - element: _, - size, - id: _, - } => { - let tmp = self.tmp(); - let result = format!("result{tmp}"); - self.push_str(&format!("let {result} = [",)); - for a in operands.drain(0..(*size as usize)) { - self.push_str(&a); - self.push_str(", "); - } - self.push_str("];\n"); - results.push(result); - } - Instruction::FixedLengthListLower { - element: _, - size, - id: _, - } => { - for i in 0..(*size as usize) { - results.push(format!("{}[{i}]", operands[0])); - } - } + // Instruction::FixedLengthListLift { + // element: _, + // size, + // id: _, + // } => { + // let tmp = self.tmp(); + // let result = format!("result{tmp}"); + // self.push_str(&format!("let {result} = [",)); + // for a in operands.drain(0..(*size as usize)) { + // self.push_str(&a); + // self.push_str(", "); + // } + // self.push_str("];\n"); + // results.push(result); + // } + // Instruction::FixedLengthListLower { + // element: _, + // size, + // id: _, + // } => { + // for i in 0..(*size as usize) { + // results.push(format!("{}[{i}]", operands[0])); + // } + // } Instruction::FixedLengthListLiftFromMemory { element, size, From 0431100a7ca0564d90810dad684acd186af590f1 Mon Sep 17 00:00:00 2001 From: Christof Petig Date: Sun, 26 Jul 2026 19:14:52 +0200 Subject: [PATCH 2/3] fix warning --- crates/core/src/abi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/core/src/abi.rs b/crates/core/src/abi.rs index 297cf90eb..767bca840 100644 --- a/crates/core/src/abi.rs +++ b/crates/core/src/abi.rs @@ -1858,7 +1858,7 @@ impl<'a, B: Bindgen> Generator<'a, B> { }); } TypeDefKind::Unknown => unreachable!(), - TypeDefKind::FixedLengthList(ty, size) => { + TypeDefKind::FixedLengthList(_ty, _size) => { todo!() // let temp = flat_types(self.resolve, ty, None).unwrap(); // let flat_per_elem = temp.to_vec().len(); From 9cbf33768e834bb78480944a9e3d4ad717b64dd5 Mon Sep 17 00:00:00 2001 From: Christof Petig Date: Mon, 27 Jul 2026 00:24:26 +0200 Subject: [PATCH 3/3] Change towards the new lifting behavior --- crates/core/src/abi.rs | 70 ++++++++++++----------------------- crates/cpp/src/lib.rs | 28 +------------- crates/csharp/src/function.rs | 3 +- crates/moonbit/src/lib.rs | 29 +-------------- crates/rust/src/bindgen.rs | 33 +++++------------ 5 files changed, 35 insertions(+), 128 deletions(-) diff --git a/crates/core/src/abi.rs b/crates/core/src/abi.rs index 767bca840..72f34135b 100644 --- a/crates/core/src/abi.rs +++ b/crates/core/src/abi.rs @@ -332,20 +332,12 @@ def_instruction! { ty: TypeId, } : [2] => [1], - // /// Pops all fields for a fixed list off the stack and then composes them - // /// into an array. - // FixedLengthListLift { - // element: &'a Type, - // size: u32, - // id: TypeId, - // } : [*size as usize] => [1], - - // /// Pops an array off the stack, decomposes the elements and then pushes them onto the stack. - // FixedLengthListLower { - // element: &'a Type, - // size: u32, - // id: TypeId, - // } : [1] => [*size as usize], + /// Pops a canonical array off the stack, pushes borrow address to elements. + FixedLengthListCanonLower { + element: &'a Type, + size: u32, + id: TypeId, + } : [1] => [1], /// Pops an array and an address off the stack, passes each element to a block storing it FixedLengthListLowerToMemory { @@ -1641,21 +1633,12 @@ impl<'a, B: Bindgen> Generator<'a, B> { }); } TypeDefKind::Unknown => unreachable!(), - TypeDefKind::FixedLengthList(_ty, _size) => { - todo!() - // self.emit(&FixedLengthListLower { - // element: ty, - // size: *size, - // id, - // }); - // let mut values = self - // .stack - // .drain(self.stack.len() - (*size as usize)..) - // .collect::>(); - // for value in values.drain(..) { - // self.stack.push(value); - // self.lower(ty); - // } + TypeDefKind::FixedLengthList(ty, size) => { + self.emit(&FixedLengthListCanonLower { + element: ty, + size: *size, + id, + }); } TypeDefKind::Map(key, value) => { let realloc = self.list_realloc(); @@ -1858,24 +1841,17 @@ impl<'a, B: Bindgen> Generator<'a, B> { }); } TypeDefKind::Unknown => unreachable!(), - TypeDefKind::FixedLengthList(_ty, _size) => { - todo!() - // let temp = flat_types(self.resolve, ty, None).unwrap(); - // let flat_per_elem = temp.to_vec().len(); - // let flatsize = flat_per_elem * (*size as usize); - // let mut lowered_args = self - // .stack - // .drain(self.stack.len() - flatsize..) - // .collect::>(); - // for _ in 0..*size { - // self.stack.extend(lowered_args.drain(..flat_per_elem)); - // self.lift(ty); - // } - // self.emit(&FixedLengthListLift { - // element: ty, - // size: *size, - // id, - // }); + TypeDefKind::FixedLengthList(ty, size) => { + self.push_block(); + self.emit(&IterBasePointer); + let elemaddr = self.stack.pop().unwrap(); + self.read_from_memory(ty, elemaddr, Default::default()); + self.finish_block(1); + self.emit(&FixedLengthListLiftFromMemory { + element: ty, + size: *size, + id, + }); } TypeDefKind::Map(key, value) => { let value_offset = self.bindgen.sizes().field_offsets([key, value])[1].0; diff --git a/crates/cpp/src/lib.rs b/crates/cpp/src/lib.rs index 32209e504..95f78428d 100644 --- a/crates/cpp/src/lib.rs +++ b/crates/cpp/src/lib.rs @@ -2778,24 +2778,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { results.push(move_if_necessary(&result)); } } - // abi::Instruction::FixedLengthListLift { - // element, - // size, - // id: _, - // } => { - // let tmp = self.tmp(); - // let result = format!("_result{tmp}"); - // let typename = self - // .r#gen - // .type_name(element, &self.namespace, Flavor::InStruct); - // self.push_str(&format!("std::array<{typename}, {size}> {result} = {{",)); - // for a in operands.drain(0..(*size as usize)) { - // self.push_str(&a); - // self.push_str(", "); - // } - // self.push_str("};\n"); - // results.push(result); - // } + abi::Instruction::FixedLengthListCanonLower { .. } => todo!(), abi::Instruction::FixedLengthListLiftFromMemory { element, size: elemsize, @@ -2825,15 +2808,6 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { self.push_str("\n}\n}\n"); results.push(vec); } - // abi::Instruction::FixedLengthListLower { - // element: _, - // size, - // id: _, - // } => { - // for i in 0..(*size as usize) { - // results.push(format!("{}[{i}]", operands[0])); - // } - // } abi::Instruction::FixedLengthListLowerToMemory { element, size: elemsize, diff --git a/crates/csharp/src/function.rs b/crates/csharp/src/function.rs index c583fa481..8aa037754 100644 --- a/crates/csharp/src/function.rs +++ b/crates/csharp/src/function.rs @@ -1941,8 +1941,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::ErrorContextLower { .. } | Instruction::ErrorContextLift { .. } | Instruction::DropHandle { .. } - // | Instruction::FixedLengthListLift { .. } - // | Instruction::FixedLengthListLower { .. } + | Instruction::FixedLengthListCanonLower { .. } | Instruction::FixedLengthListLowerToMemory { .. } | Instruction::FixedLengthListLiftFromMemory { .. } => { dbg!(inst); diff --git a/crates/moonbit/src/lib.rs b/crates/moonbit/src/lib.rs index 676d349d3..d5021d844 100644 --- a/crates/moonbit/src/lib.rs +++ b/crates/moonbit/src/lib.rs @@ -2635,34 +2635,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { } } Instruction::ErrorContextLower { .. } | Instruction::ErrorContextLift { .. } => todo!(), - // Instruction::FixedLengthListLift { - // element: _, - // size, - // id: _, - // } => { - // let array = self.locals.tmp("array"); - // let mut elements = String::new(); - // for a in operands.drain(0..(*size as usize)) { - // elements.push_str(&a); - // elements.push_str(", "); - // } - // uwriteln!(self.src, "let {array} : FixedArray[_] = [{elements}]"); - // results.push(array); - // } - // Instruction::FixedLengthListLower { - // element: _, - // size, - // id: _, - // } => { - // uwriteln!( - // self.src, - // "if ({}).length() != {size} {{ panic() }}", - // operands[0] - // ); - // for i in 0..(*size as usize) { - // results.push(format!("({})[{i}]", operands[0])); - // } - // } + Instruction::FixedLengthListCanonLower { .. } => todo!(), Instruction::FixedLengthListLowerToMemory { element, size: fixed_length, diff --git a/crates/rust/src/bindgen.rs b/crates/rust/src/bindgen.rs index 61d549c9a..c43d294ec 100644 --- a/crates/rust/src/bindgen.rs +++ b/crates/rust/src/bindgen.rs @@ -1356,30 +1356,15 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::DropHandle { .. } => { uwriteln!(self.src, "let _ = {};", operands[0]); } - // Instruction::FixedLengthListLift { - // element: _, - // size, - // id: _, - // } => { - // let tmp = self.tmp(); - // let result = format!("result{tmp}"); - // self.push_str(&format!("let {result} = [",)); - // for a in operands.drain(0..(*size as usize)) { - // self.push_str(&a); - // self.push_str(", "); - // } - // self.push_str("];\n"); - // results.push(result); - // } - // Instruction::FixedLengthListLower { - // element: _, - // size, - // id: _, - // } => { - // for i in 0..(*size as usize) { - // results.push(format!("{}[{i}]", operands[0])); - // } - // } + Instruction::FixedLengthListCanonLower { .. } => { + let tmp = self.tmp(); + let addr = format!("result{tmp}"); + let elem = &operands[0]; + self.push_str(&format!( + "let {addr} = core::ptr::from_ref(&{elem}[0]).cast::().cast_mut();", + )); + results.push(addr); + } Instruction::FixedLengthListLiftFromMemory { element, size,