Optimise away a memory copy for returned structs in simple cases

This commit is contained in:
Brian Carroll 2021-09-17 21:49:21 +01:00
parent 4f55b7a56e
commit 52a56bfa27
2 changed files with 12 additions and 6 deletions

View file

@ -6,14 +6,14 @@ use crate::{PTR_SIZE, PTR_TYPE};
// See README for background information on Wasm locals, memory and function calls
#[derive(Debug)]
pub enum WasmLayout {
// Most number types can fit in a Wasm local without any stack memory.
// Roc i8 is represented as an i32 local. Store the type and the original size.
// Primitive number value. Just a Wasm local, without any stack memory.
// For example, Roc i8 is represented as Wasm i32. Store the type and the original size.
LocalOnly(ValueType, u32),
// A `local` pointing to stack memory
// Local pointer to stack memory
StackMemory { size: u32, alignment_bytes: u32 },
// A `local` pointing to heap memory
// Local pointer to heap memory
HeapMemory,
}