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

Method new

cranelift/jit/src/compiled_blob.rs:32–65  ·  view source on GitHub ↗
(
        memory: &mut dyn JITMemoryProvider,
        data: &[u8],
        align: u64,
        relocs: Vec<ModuleReloc>,
        #[cfg(feature = "wasmtime-unwinder")] wasmtime_exception_data: Option<V

Source from the content-addressed store, hash-verified

30
31impl CompiledBlob {
32 pub(crate) fn new(
33 memory: &mut dyn JITMemoryProvider,
34 data: &[u8],
35 align: u64,
36 relocs: Vec<ModuleReloc>,
37 #[cfg(feature = "wasmtime-unwinder")] wasmtime_exception_data: Option<Vec<u8>>,
38 kind: JITMemoryKind,
39 ) -> ModuleResult<Self> {
40 // Reserve veneers for all function calls just in case
41 let mut veneer_count = 0;
42 for reloc in &relocs {
43 match reloc.kind {
44 Reloc::Arm64Call => veneer_count += 1,
45 _ => {}
46 }
47 }
48
49 let ptr = memory
50 .allocate(data.len() + veneer_count * VENEER_SIZE, align, kind)
51 .map_err(|e| ModuleError::Allocation { err: e })?;
52
53 unsafe {
54 ptr::copy_nonoverlapping(data.as_ptr(), ptr, data.len());
55 }
56
57 Ok(CompiledBlob {
58 ptr,
59 size: data.len(),
60 relocs,
61 veneer_count,
62 #[cfg(feature = "wasmtime-unwinder")]
63 wasmtime_exception_data,
64 })
65 }
66
67 pub(crate) fn new_zeroed(
68 memory: &mut dyn JITMemoryProvider,

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
allocateMethod · 0.45
lenMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected