diff --git a/Cargo.lock b/Cargo.lock index e389b55..3e67a6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,7 +280,7 @@ checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "wasmer-interface-types-fl" -version = "0.23.0" +version = "0.23.1" dependencies = [ "fluence-it-types", "it-lilo", diff --git a/wasmer-it/Cargo.toml b/wasmer-it/Cargo.toml index e8f25f8..481c752 100644 --- a/wasmer-it/Cargo.toml +++ b/wasmer-it/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmer-interface-types-fl" -version = "0.23.0" +version = "0.23.1" description = "WebAssembly Interface Types library for Wasmer" license = "MIT" authors = ["The Wasmer Engineering Team "] diff --git a/wasmer-it/src/interpreter/instructions/arrays.rs b/wasmer-it/src/interpreter/instructions/arrays.rs index edf8795..c52b2a9 100644 --- a/wasmer-it/src/interpreter/instructions/arrays.rs +++ b/wasmer-it/src/interpreter/instructions/arrays.rs @@ -12,8 +12,6 @@ use it_lilo::lowerer::ILowerer; use it_lilo::lowerer::LoweredArray; use it_lilo::traits::DEFAULT_MEMORY_INDEX; -use std::convert::TryInto; - pub(crate) fn array_lift_memory( instruction: Instruction, value_type: IType, @@ -37,15 +35,9 @@ where ) })?; - let offset: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "offset").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; + let offset = to_native::(inputs.remove(0), instruction.clone())? as u32; - let size: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "size").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; + let size = to_native::(inputs.remove(0), instruction.clone())? as u32; log::trace!( "array.lift_memory: lifting memory for value type: {:?}, popped offset {}, size {}", diff --git a/wasmer-it/src/interpreter/instructions/byte_arrays.rs b/wasmer-it/src/interpreter/instructions/byte_arrays.rs index 5fcb575..5600f03 100644 --- a/wasmer-it/src/interpreter/instructions/byte_arrays.rs +++ b/wasmer-it/src/interpreter/instructions/byte_arrays.rs @@ -9,8 +9,6 @@ use crate::{ use it_lilo::traits::DEFAULT_MEMORY_INDEX; -use std::convert::TryInto; - executable_instruction!( byte_array_lift_memory(instruction: Instruction) -> _ { move |runtime| -> _ { @@ -32,14 +30,8 @@ executable_instruction!( ) })?; - let pointer: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "pointer").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; - let length: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "length").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; + let pointer = to_native::(inputs.remove(0), instruction.clone())? as u32; + let length = to_native::(inputs.remove(0), instruction.clone())? as u32; let memory_view = memory.view(); @@ -73,17 +65,9 @@ executable_instruction!( ) })?; - let array_pointer: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "pointer").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; + let array_pointer = to_native::(inputs.remove(0), instruction.clone())? as u32; let array: Vec = to_native(inputs.remove(0), instruction.clone())?; - let length: u32 = array.len().try_into().map_err(|_| { - InstructionError::from_error_kind( - instruction.clone(), - InstructionErrorKind::NegativeValue { subject: "array_length" }, - ) - })?; + let length = array.len() as u32; let instance = &mut runtime.wasm_instance; let memory_index = DEFAULT_MEMORY_INDEX; diff --git a/wasmer-it/src/interpreter/instructions/records.rs b/wasmer-it/src/interpreter/instructions/records.rs index a4fc9f9..ebdb76b 100644 --- a/wasmer-it/src/interpreter/instructions/records.rs +++ b/wasmer-it/src/interpreter/instructions/records.rs @@ -9,8 +9,6 @@ use it_lilo::lifter::ILifter; use it_lilo::lowerer::ILowerer; use it_lilo::traits::DEFAULT_MEMORY_INDEX; -use std::convert::TryInto; - pub(crate) fn record_lift_memory( record_type_id: u64, instruction: Instruction, @@ -34,10 +32,7 @@ where ) })?; - let offset: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "offset").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; + let offset: u32 = to_native::(inputs.remove(0), instruction.clone())? as u32; // TODO: size = 0 let instance = &runtime.wasm_instance; diff --git a/wasmer-it/src/interpreter/instructions/strings.rs b/wasmer-it/src/interpreter/instructions/strings.rs index 97e9029..730f6b2 100644 --- a/wasmer-it/src/interpreter/instructions/strings.rs +++ b/wasmer-it/src/interpreter/instructions/strings.rs @@ -9,8 +9,6 @@ use crate::{ use it_lilo::traits::DEFAULT_MEMORY_INDEX; -use std::convert::TryInto; - executable_instruction!( string_lift_memory(instruction: Instruction) -> _ { move |runtime| -> _ { @@ -32,14 +30,8 @@ executable_instruction!( ) })?; - let pointer: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "pointer").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; - let length: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "length").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; + let pointer = to_native::(inputs.remove(0), instruction.clone())? as u32; + let length = to_native::(inputs.remove(0), instruction.clone())? as u32; let memory_view = memory.view(); if length == 0 { @@ -74,18 +66,10 @@ executable_instruction!( ) })?; - let string_pointer: u32 = to_native::(inputs.remove(0), instruction.clone())? - .try_into() - .map_err(|e| (e, "pointer").into()) - .map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?; + let string_pointer = to_native::(inputs.remove(0), instruction.clone())? as u32; let string: String = to_native(inputs.remove(0), instruction.clone())?; let string_bytes = string.as_bytes(); - let string_length: u32 = string_bytes.len().try_into().map_err(|_| { - InstructionError::from_error_kind( - instruction.clone(), - InstructionErrorKind::NegativeValue { subject: "string_length" }, - ) - })?; + let string_length: u32 = string_bytes.len() as u32; let instance = &mut runtime.wasm_instance; let memory_index = DEFAULT_MEMORY_INDEX;