diff --git a/Cargo.lock b/Cargo.lock index f43133d..4d73acc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,6 +41,7 @@ name = "it-lilo-utils" version = "0.1.0" dependencies = [ "fluence-it-types", + "log", "paste", "thiserror", ] diff --git a/crates/it-lilo-utils/Cargo.toml b/crates/it-lilo-utils/Cargo.toml index 32da557..05fe25e 100644 --- a/crates/it-lilo-utils/Cargo.toml +++ b/crates/it-lilo-utils/Cargo.toml @@ -15,3 +15,4 @@ fluence-it-types = { path = "../it-types/", version = "0.2.0" } paste = "1.0.5" thiserror = "1.0.24" +log = "0.4.14" diff --git a/crates/it-lilo-utils/src/memory_writer.rs b/crates/it-lilo-utils/src/memory_writer.rs index a616d1f..ceda3d4 100644 --- a/crates/it-lilo-utils/src/memory_writer.rs +++ b/crates/it-lilo-utils/src/memory_writer.rs @@ -122,6 +122,7 @@ impl<'w, 'm> SequentialWriter<'w, 'm> { // specialization of write_array for u8 pub fn write_u8(&self, value: u8) { let offset = self.offset.get(); + log::trace!("write_u8: write {} to {}", value, offset); self.writer.memory[offset].set(value); diff --git a/wasmer-it/src/interpreter/instructions/arrays.rs b/wasmer-it/src/interpreter/instructions/arrays.rs index 513f2a9..61e2589 100644 --- a/wasmer-it/src/interpreter/instructions/arrays.rs +++ b/wasmer-it/src/interpreter/instructions/arrays.rs @@ -119,6 +119,7 @@ where })?; } + log::trace!("array.lower_memory: 1"); let memory_index = 0; let memory_view = instance .memory(memory_index) @@ -129,10 +130,12 @@ where ) })? .view(); + log::trace!("array.lower_memory: 1"); let memory = memory_view.deref(); let lo_helper = lilo::LoHelper::new(&**instance, memory) .map_err(|e| InstructionError::from_lilo(instruction.clone(), e))?; + log::trace!("array.lower_memory: 3"); let (offset, size) = array_lower_memory_impl(&lo_helper, values) .map_err(|e| InstructionError::from_lilo(instruction.clone(), e))?; diff --git a/wasmer-it/src/interpreter/instructions/arrays/lift_array.rs b/wasmer-it/src/interpreter/instructions/arrays/lift_array.rs index 23f513d..88239a8 100644 --- a/wasmer-it/src/interpreter/instructions/arrays/lift_array.rs +++ b/wasmer-it/src/interpreter/instructions/arrays/lift_array.rs @@ -43,6 +43,7 @@ pub(crate) fn array_lift_memory_impl( Ok(IValue::Array(ivalues)) } +// Vec => Vec (2 * len of prev) fn read_string_array( li_helper: &LiHelper, offset: usize, diff --git a/wasmer-it/src/interpreter/instructions/arrays/lower_array.rs b/wasmer-it/src/interpreter/instructions/arrays/lower_array.rs index a27d867..db2a78d 100644 --- a/wasmer-it/src/interpreter/instructions/arrays/lower_array.rs +++ b/wasmer-it/src/interpreter/instructions/arrays/lower_array.rs @@ -9,6 +9,7 @@ pub(crate) fn array_lower_memory_impl( lo_helper: &LoHelper, array_values: Vec, ) -> LiLoResult<(usize, usize)> { + log::trace!("array_lower_memory_impl: 1"); if array_values.is_empty() { return Ok((0, 0)); } @@ -19,13 +20,16 @@ pub(crate) fn array_lower_memory_impl( size_to_allocate as _, type_tag_form_ivalue(&array_values[0]) as _, )?; + log::trace!("array_lower_memory_impl: 2"); let seq_writer = lo_helper .writer .sequential_writer(offset, size_to_allocate)?; + log::trace!("array_lower_memory_impl: 3"); // here it's known that all interface values have the same type for value in array_values { + log::trace!("array_lower_memory_impl: write {:?}", value); match value { IValue::Boolean(value) => seq_writer.write_u8(value as _), IValue::S8(value) => seq_writer.write_u8(value as _),