Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

1,284 changes: 172 additions & 1,112 deletions crates/codegen/tests/fixtures/sonatina_ir/create_contract.snap

Large diffs are not rendered by default.

1,860 changes: 74 additions & 1,786 deletions crates/codegen/tests/fixtures/sonatina_ir/effect_handle_field_deref.snap

Large diffs are not rendered by default.

6,453 changes: 2,118 additions & 4,335 deletions crates/codegen/tests/fixtures/sonatina_ir/erc20.snap

Large diffs are not rendered by default.

902 changes: 63 additions & 839 deletions crates/codegen/tests/fixtures/sonatina_ir/high_level_contract.snap

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

53 changes: 52 additions & 1 deletion crates/mir/src/runtime/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,12 +930,63 @@ pub enum RuntimeInputPlan<'db> {
decode_args_fn: RuntimeInstance<'db>,
projected_fields: Box<[u32]>,
},
/// Optimized path for non-dynamic types whose fields each fit in a single
/// ABI head slot. Each field is loaded directly via `calldataload` at a
/// known offset, skipping malloc / calldatacopy / MemoryBytes / SolDecoder
/// entirely.
DirectCalldataLoad {
msg_ty: TyId<'db>,
/// Per-field ABI head sizes (in bytes). The calldata offset of
/// field `i` is `4 + sum(field_head_sizes[..i])`.
field_head_sizes: Box<[u32]>,
projected_fields: Box<[u32]>,
},
/// Hybrid path for message types where some fields are non-mut scalars at
/// known ABI offsets and others require the full decode pipeline.
LazyCalldataLoad {
msg_ty: TyId<'db>,
/// The decode function for the full message type. `None` when every
/// field uses a non-Decode strategy.
decode_fn: Option<RuntimeInstance<'db>>,
/// Per-field load strategy, indexed by the message struct's field order.
field_strategies: Box<[FieldLoadStrategy]>,
projected_fields: Box<[u32]>,
},
}

/// Describes how a single field of a message struct should be loaded from
/// calldata in a `LazyCalldataLoad` plan.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Update)]
pub enum FieldLoadStrategy {
/// Load directly via `calldataload` at a known offset.
Direct,
/// Load through the standard SolDecoder pipeline.
Decode,
/// Skip this field and pass the absolute calldata byte offset.
SkipWithOffset {
/// The ABI head-size of this field in bytes.
head_size: u32,
},
/// Decode a dynamic-typed view (BytesView or StringView) directly from
/// calldata without copying the payload into memory.
LazyDynamicView {
/// `true` for StringView fields, `false` for BytesView fields.
is_string_view: bool,
},
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Update)]
pub enum RuntimeReturnPlan<'db> {
Unit,
Value { ty: TyId<'db> },
Value {
ty: TyId<'db>,
},
/// Optimized path for a single word-scalar return value: emit a direct
/// `mstore` at offset 0 and `return(0, 32)` instead of calling
/// `encode_single_root_alloc`.
DirectScalarReturn {
ty: TyId<'db>,
},
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Update)]
Expand Down
Loading
Loading