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

Method set_readonly

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

Set all memory allocated in this `Memory` up to now as readonly.

(&mut self)

Source from the content-addressed store, hash-verified

112
113 /// Set all memory allocated in this `Memory` up to now as readonly.
114 pub(crate) fn set_readonly(&mut self) -> ModuleResult<()> {
115 self.finish_current();
116
117 for &PtrLen { ptr, len, .. } in self.non_protected_allocations_iter() {
118 unsafe {
119 region::protect(ptr, len, region::Protection::READ).map_err(|e| {
120 ModuleError::Backend(
121 anyhow::Error::new(e).context("unable to make memory readonly"),
122 )
123 })?;
124 }
125 }
126
127 self.already_protected = self.allocations.len();
128 Ok(())
129 }
130
131 /// Iterates non protected memory allocations that are of not zero bytes in size.
132 fn non_protected_allocations_iter(&self) -> impl Iterator<Item = &PtrLen> {

Callers 3

finalizeMethod · 0.45
make_heap_baseMethod · 0.45

Calls 7

BackendClass · 0.85
OkFunction · 0.85
finish_currentMethod · 0.80
newFunction · 0.50
contextMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected