MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / new_memory

Method new_memory

crates/wasmtime/src/runtime/vm/memory.rs:131–155  ·  view source on GitHub ↗

Create new MmapMemory

(
        &self,
        ty: &wasmtime_environ::Memory,
        memory_tunables: &MemoryTunables<'_>,
        minimum: usize,
        maximum: Option<usize>,
    )

Source from the content-addressed store, hash-verified

129impl RuntimeMemoryCreator for DefaultMemoryCreator {
130 /// Create new MmapMemory
131 fn new_memory(
132 &self,
133 ty: &wasmtime_environ::Memory,
134 memory_tunables: &MemoryTunables<'_>,
135 minimum: usize,
136 maximum: Option<usize>,
137 ) -> Result<Box<dyn RuntimeLinearMemory>> {
138 #[cfg(has_virtual_memory)]
139 if memory_tunables.tunables().signals_based_traps
140 || memory_tunables.guard_size() > 0
141 || memory_tunables.reservation() > 0
142 || memory_tunables.tunables().memory_init_cow
143 {
144 return Ok(
145 try_new::<Box<_>>(MmapMemory::new(ty, memory_tunables, minimum, maximum)?)?
146 as Box<dyn RuntimeLinearMemory>,
147 );
148 }
149
150 let _ = maximum;
151 Ok(
152 try_new::<Box<_>>(MallocMemory::new(ty, memory_tunables, minimum)?)?
153 as Box<dyn RuntimeLinearMemory>,
154 )
155 }
156}
157
158/// A linear memory and its backing storage.

Callers 1

new_dynamicMethod · 0.45

Calls 5

OkFunction · 0.85
guard_sizeMethod · 0.80
reservationMethod · 0.80
newFunction · 0.50
tunablesMethod · 0.45

Tested by

no test coverage detected