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

Method with_size

cranelift/jit/src/memory/system.rs:29–40  ·  view source on GitHub ↗

Create a new `PtrLen` pointing to at least `size` bytes of memory, suitably sized and aligned for memory protection.

(size: usize)

Source from the content-addressed store, hash-verified

27 /// Create a new `PtrLen` pointing to at least `size` bytes of memory,
28 /// suitably sized and aligned for memory protection.
29 fn with_size(size: usize) -> io::Result<Self> {
30 let alloc_size = region::page::ceil(size as *const ()) as usize;
31 MmapMut::map_anon(alloc_size).map(|mut mmap| {
32 // The order here is important; we assign the pointer first to get
33 // around compile time borrow errors.
34 Self {
35 ptr: mmap.as_mut_ptr(),
36 map: Some(mmap),
37 len: alloc_size,
38 }
39 })
40 }
41}
42
43/// JIT memory manager. This manages pages of suitably aligned and

Callers

nothing calls this directly

Calls 3

ceilFunction · 0.85
mapMethod · 0.45
as_mut_ptrMethod · 0.45

Tested by

no test coverage detected