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

Method custom_publish

crates/wasmtime/src/runtime/code_memory.rs:477–498  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

475 }
476
477 fn custom_publish(&mut self) -> Result<bool> {
478 if let Some(mem) = self.custom_code_memory.as_ref() {
479 let text = self.text();
480 // The text section should be aligned to
481 // `custom_code_memory.required_alignment()` due to a
482 // combination of two invariants:
483 //
484 // - MmapVec aligns its start address, even in owned-Vec mode; and
485 // - The text segment inside the ELF image will be aligned according
486 // to the platform's requirements.
487 let text_addr = text.as_ptr() as usize;
488 assert_eq!(text_addr & (mem.required_alignment() - 1), 0);
489
490 // The custom code memory handler will ensure the
491 // memory is executable and also handle icache
492 // coherence.
493 mem.publish_executable(text.as_ptr(), text.len())?;
494 Ok(true)
495 } else {
496 Ok(false)
497 }
498 }
499
500 /// "Unpublish" code memory (transition it from executable to read/writable).
501 ///

Callers 1

publishMethod · 0.80

Calls 6

OkFunction · 0.85
publish_executableMethod · 0.80
as_refMethod · 0.45
textMethod · 0.45
as_ptrMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected