Skip to content

Commit

Permalink
cranelift
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 1, 2024
1 parent 6675311 commit 1fb6a0f
Showing 1 changed file with 5 additions and 38 deletions.
43 changes: 5 additions & 38 deletions crates/cranelift/src/translate/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use cranelift_codegen::ir::{GlobalValue, MemoryType, Type};
use cranelift_entity::entity_impl;
use wasmtime_environ::Memory;

/// An opaque reference to a [`HeapData`][crate::HeapData].
///
Expand Down Expand Up @@ -62,43 +63,9 @@ pub struct HeapData {
/// The address of the start of the heap's storage.
pub base: GlobalValue,

/// Guaranteed minimum heap size in bytes. Heap accesses before `min_size`
/// don't need bounds checking.
pub min_size: u64,
/// The dynamic byte length of this heap, if needed.
pub bound: GlobalValue,

/// The maximum heap size in bytes.
///
/// Heap accesses larger than this will always trap.
pub max_size: Option<u64>,

/// Heap style, with additional style-specific info.
pub style: HeapStyle,

/// The index type for the heap.
pub index_type: Type,

/// The memory type for the pointed-to memory, if using proof-carrying code.
pub memory_type: Option<MemoryType>,

/// The log2 of this memory's page size.
pub page_size_log2: u8,
}

/// Style of heap including style-specific information.
#[derive(Clone, PartialEq, Hash)]
pub enum HeapStyle {
/// A dynamic heap can be relocated to a different base address when it is
/// grown.
Dynamic {
/// Global value providing the current bound of the heap in bytes.
bound_gv: GlobalValue,
},

/// A static heap has a fixed base address and a number of not-yet-allocated
/// pages before the offset-guard pages.
Static {
/// Heap bound in bytes. The offset-guard pages are allocated after the
/// bound.
bound: u64,
},
/// The type of wasm memory that this heap is operating on.
pub memory: Memory,
}

0 comments on commit 1fb6a0f

Please sign in to comment.