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

Method new_with_size

cranelift/jit/src/memory/arena.rs:108–124  ·  view source on GitHub ↗

Create a new memory region with the given size.

(reserve_size: usize)

Source from the content-addressed store, hash-verified

106impl ArenaMemoryProvider {
107 /// Create a new memory region with the given size.
108 pub fn new_with_size(reserve_size: usize) -> Result<Self, region::Error> {
109 let size = align_up(reserve_size, region::page::size());
110 // Note: The region crate uses `MEM_RESERVE | MEM_COMMIT` on Windows.
111 // This means that allocations that exceed the page file plus system
112 // memory will fail here.
113 // https://github.com/darfink/region-rs/pull/34
114 let mut alloc = region::alloc(size, region::Protection::NONE)?;
115 let ptr = alloc.as_mut_ptr();
116
117 Ok(Self {
118 alloc: ManuallyDrop::new(Some(alloc)),
119 segments: Vec::new(),
120 ptr,
121 size,
122 position: 0,
123 })
124 }
125
126 fn allocate_inner(
127 &mut self,

Callers

nothing calls this directly

Calls 5

allocFunction · 0.85
OkFunction · 0.85
align_upFunction · 0.70
newFunction · 0.50
as_mut_ptrMethod · 0.45

Tested by

no test coverage detected