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

Method add_function

pulley/src/profile.rs:109–120  ·  view source on GitHub ↗

Adds a new function that may be sampled in the future. This must be given `code` where it resides and will be executed in the host address space.

(&mut self, name: &str, code: &[u8])

Source from the content-addressed store, hash-verified

107 /// This must be given `code` where it resides and will be executed in the
108 /// host address space.
109 pub fn add_function(&mut self, name: &str, code: &[u8]) -> Result<()> {
110 self.file.write_all(&[ID_FUNCTION])?;
111 self.file
112 .write_all(&u64::try_from(code.as_ptr() as usize)?.to_le_bytes())?;
113 self.file
114 .write_all(&u32::try_from(name.len())?.to_le_bytes())?;
115 self.file.write_all(name.as_bytes())?;
116 self.file
117 .write_all(&u32::try_from(code.len())?.to_le_bytes())?;
118 self.file.write_all(code)?;
119 Ok(())
120 }
121
122 /// Adds a new set of samples to this recorded.
123 pub fn add_samples(&mut self, samples: &mut Samples) -> Result<()> {

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
write_allMethod · 0.80
as_bytesMethod · 0.80
as_ptrMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected