diff --git a/src/backend.rs b/src/backend.rs index 11fe1aefe5..9c292f64b2 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -565,7 +565,22 @@ impl<'module, M> CodeGenSession<'module, M> { } } - pub fn into_translated_code_section(self) -> Result { + fn finalize(&mut self) { + let mut values = self.labels.values_mut().collect::>(); + values.sort_unstable_by_key(|(_, align, _)| *align); + for (label, align, func) in values { + if let Some(mut func) = func.take() { + dynasm!(self.assembler + ; .align *align as usize + ); + self.assembler.dynamic_label(label.0); + func(&mut self.assembler); + } + } + } + + pub fn into_translated_code_section(mut self) -> Result { + self.finalize(); let exec_buf = self .assembler .finalize() @@ -2150,6 +2165,11 @@ impl<'this, M: ModuleContext> Context<'this, M> { return; } + if let ValueLocation::Cond(loc) = val { + self.push(ValueLocation::Cond(!loc)); + return; + } + let reg = self.into_reg(I32, val).unwrap(); let out = self.take_reg(I32).unwrap(); @@ -2174,6 +2194,11 @@ impl<'this, M: ModuleContext> Context<'this, M> { return; } + if let ValueLocation::Cond(loc) = val { + self.push(ValueLocation::Cond(!loc)); + return; + } + let reg = self.into_reg(I64, val).unwrap(); let out = self.take_reg(I64).unwrap(); @@ -5352,20 +5377,7 @@ impl<'this, M: ModuleContext> Context<'this, M> { ); } - /// Writes the function epilogue (right now all this does is add the trap label that the - /// conditional traps in `call_indirect` use) pub fn epilogue(&mut self) { - let mut values = self.labels.values_mut().collect::>(); - values.sort_unstable_by_key(|(_, align, _)| *align); - for (label, align, func) in values { - if let Some(mut func) = func.take() { - dynasm!(self.asm - ; .align *align as usize - ); - self.asm.dynamic_label(label.0); - func(&mut self.asm); - } - } } pub fn trap(&mut self) { diff --git a/src/microwasm.rs b/src/microwasm.rs index 6f75be5b71..3bbd3c856b 100644 --- a/src/microwasm.rs +++ b/src/microwasm.rs @@ -458,8 +458,8 @@ pub enum Operator