pub struct Runtime { /* private fields */ }
Expand description
A simple mmap
ed runtime with executable pages.
Implementations§
source§impl Runtime
impl Runtime
sourcepub fn with_profile() -> Runtime
pub fn with_profile() -> Runtime
Create a new Runtime which also generates static perf metat data.
For each function added to the Runtime, an entry will be generated in the
/tmp/perf-<PID>.map
file, which perf report
uses to symbolicate unknown addresses.
This is applicable for static runtimes only.
§Panics
Panics if the mmap
call fails.
sourcepub unsafe fn add_code<F>(&mut self, code: impl AsRef<[u8]>) -> F
pub unsafe fn add_code<F>(&mut self, code: impl AsRef<[u8]>) -> F
Add the block of code
to the runtime and a get function pointer of type F
.
§Panics
Panics if the code
does not fit on the mmap
ed pages or is empty.
§Safety
The code added must fulfill the ABI of the specified function F
and the returned function
pointer is only valid until the Runtime
is dropped.
§Examples
let mut rt = juicebox_asm::Runtime::new();
let code = [ 0x90 /* nop */, 0xc3 /* ret */ ];
let nop = unsafe { rt.add_code::<extern "C" fn()>(&code) };
nop();
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Runtime
impl RefUnwindSafe for Runtime
impl !Send for Runtime
impl !Sync for Runtime
impl Unpin for Runtime
impl UnwindSafe for Runtime
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more