• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

henrythasler / rust-tiny-wasm / 22797002785

07 Mar 2026 10:04AM UTC coverage: 33.315% (-0.4%) from 33.732%
22797002785

push

github

henrythasler
add instruction cache clearing

0 of 9 new or added lines in 1 file covered. (0.0%)

17 existing lines in 1 file now uncovered.

592 of 1777 relevant lines covered (33.31%)

1.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/runtime.rs
1
use bytemuck;
2
use memmap2::{Mmap, MmapMut};
3
use std::mem;
4

5
#[cfg(target_arch = "aarch64")]
NEW
6
unsafe fn clear_cache(addr: *mut u8, len: usize) {
×
7
    // Use libc function
8
    unsafe extern "C" {
9
        fn __clear_cache(start: *mut u8, end: *mut u8);
10
    }
NEW
11
    unsafe {
×
NEW
12
        __clear_cache(addr, addr.add(len));
×
NEW
13
    }
×
NEW
14
}
×
15

16
pub struct Runtime {
17
    machinecode: Mmap,
18
}
19

20
impl Runtime {
21
    pub fn get_function(&self) -> fn(i32, i32) -> i32 {
×
NEW
22
        unsafe { mem::transmute::<*const u8, fn(i32, i32) -> i32>(self.machinecode.as_ptr()) }
×
23
    }
×
24
}
25

26
pub fn get_module_instance(jit_code: &[u32]) -> Runtime {
×
27
    // Allocate executable memory and copy JIT code into that region
28
    let bytes = bytemuck::cast_slice(jit_code);
×
29
    let mut mmap = MmapMut::map_anon(bytes.len()).expect("map_anon() failed");
×
30
    mmap.copy_from_slice(bytes);
×
31

32
    // clear instruction cache on aarch64 target
33
    #[cfg(target_arch = "aarch64")]
NEW
34
    unsafe {
×
NEW
35
        clear_cache(mmap.as_mut_ptr(), mmap.len());
×
NEW
36
    }
×
37

38
    // set execution permissions
39
    let machinecode = mmap.make_exec().expect("make_exec() failed");
×
40
    Runtime { machinecode }
×
41
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc