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

Function register_code

crates/wasmtime/src/runtime/module/registry.rs:398–407  ·  view source on GitHub ↗

Registers a new region of code. Must not have been previously registered and must be `unregister`'d to prevent leaking memory. This is required to enable traps to work correctly since the signal handler will lookup in the `GLOBAL_CODE` list to determine which a particular pc is a trap or not.

(image: &Arc<CodeMemory>, address: Range<usize>)

Source from the content-addressed store, hash-verified

396/// will lookup in the `GLOBAL_CODE` list to determine which a particular pc
397/// is a trap or not.
398pub fn register_code(image: &Arc<CodeMemory>, address: Range<usize>) -> Result<(), OutOfMemory> {
399 if address.is_empty() {
400 return Ok(());
401 }
402 let start = address.start;
403 let end = address.end - 1;
404 let prev = global_code().write().insert(end, (start, image.clone()))?;
405 assert!(prev.is_none());
406 Ok(())
407}
408
409/// Unregisters a code mmap from the global map.
410///

Callers 1

newMethod · 0.85

Calls 6

OkFunction · 0.85
global_codeFunction · 0.85
is_emptyMethod · 0.45
insertMethod · 0.45
writeMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected