From 03020080366241f1c5b610546d3e17687232eb30 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Wed, 13 Mar 2024 15:28:31 +0100 Subject: chore: optimize block stack, remove EndFunc (#12) Signed-off-by: Henry Gressmann --- crates/types/src/archive.rs | 3 +++ crates/types/src/instructions.rs | 4 +--- crates/types/src/lib.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'crates/types') diff --git a/crates/types/src/archive.rs b/crates/types/src/archive.rs index 273d6ed..9bf095b 100644 --- a/crates/types/src/archive.rs +++ b/crates/types/src/archive.rs @@ -47,6 +47,9 @@ impl Display for TwasmError { } } +#[cfg(feature = "std")] +extern crate std; + #[cfg(feature = "std")] impl std::error::Error for TwasmError {} diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index c932704..402cc9a 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -73,8 +73,7 @@ pub enum ConstInstruction { /// /// # Differences to the spec /// * `br_table` stores the jump labels in the following `br_label` instructions to keep this enum small. -/// * Lables/Blocks: we store the label end offset in the instruction itself and -/// have seperate EndBlockFrame and EndFunc instructions to mark the end of a block or function. +/// * Lables/Blocks: we store the label end offset in the instruction itself and use `EndBlockFrame` to mark the end of a block. /// This makes it easier to implement the label stack iteratively. /// /// See @@ -121,7 +120,6 @@ pub enum Instruction { If(BlockArgsPacked, ElseOffset, EndOffset), // If else offset is 0 if there is no else block Else(EndOffset), EndBlockFrame, - EndFunc, Br(LabelAddr), BrIf(LabelAddr), BrTable(BrTableDefault, BrTableLen), // has to be followed by multiple BrLabel instructions diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 679f3bf..c5c8071 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -3,7 +3,7 @@ attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_assignments, unused_variables)) ))] #![warn(missing_debug_implementations, rust_2018_idioms, unreachable_pub)] -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] #![cfg_attr(not(feature = "unsafe"), forbid(unsafe_code))] #![cfg_attr(feature = "unsafe", deny(unused_unsafe))] -- cgit v1.3.1