From 43125aa994438b2692e2407d410d3b6b81c2cbd5 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Tue, 2 Aug 2022 13:28:43 -0700 Subject: [PATCH] components: fix trampoline compilation for lists. (#4579) This commit fixes trampoline compilation for lists where the loop condition would only branch if the amount remaining was 0 instead of not 0. It resulted in only the first element of the list being copied. --- crates/environ/src/fact/trampoline.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/environ/src/fact/trampoline.rs b/crates/environ/src/fact/trampoline.rs index 405e8489c0..1ad9c2c9a7 100644 --- a/crates/environ/src/fact/trampoline.rs +++ b/crates/environ/src/fact/trampoline.rs @@ -833,6 +833,7 @@ impl Compiler<'_, '_> { let src_add = if src_opts.memory64 { I64Add } else { I32Add }; let dst_add = if dst_opts.memory64 { I64Add } else { I32Add }; let src_eqz = if src_opts.memory64 { I64Eqz } else { I32Eqz }; + let src_ne = if src_opts.memory64 { I64Ne } else { I32Ne }; // This block encompasses the entire loop and is use to exit before even // entering the loop if the list size is zero. @@ -887,7 +888,8 @@ impl Compiler<'_, '_> { self.instruction(iconst(-1, src_opts.ptr())); self.instruction(src_add.clone()); self.instruction(LocalTee(remaining)); - self.instruction(src_eqz.clone()); + self.instruction(iconst(0, src_opts.ptr())); + self.instruction(src_ne.clone()); self.instruction(BrIf(0)); self.instruction(End); // end of loop self.instruction(End); // end of block