From d3e1eff9593501ff8677b9399e1f0625f415ec78 Mon Sep 17 00:00:00 2001 From: johannst Date: Thu, 7 Dec 2023 23:53:44 +0000 Subject: deploy: b5aea3fb5fcce31599e3d7397d5413a934132231 --- juicebox_asm/struct.Runtime.html | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'juicebox_asm/struct.Runtime.html') diff --git a/juicebox_asm/struct.Runtime.html b/juicebox_asm/struct.Runtime.html index 6c73cc1..9fee473 100644 --- a/juicebox_asm/struct.Runtime.html +++ b/juicebox_asm/struct.Runtime.html @@ -1,10 +1,30 @@ -Runtime in juicebox_asm - Rust

Struct juicebox_asm::Runtime

source ·
pub struct Runtime { /* private fields */ }
Expand description

A simple mmaped runtime with executable pages.

-

Implementations§

source§

impl Runtime

source

pub fn new() -> Runtime

Create a new Runtime.

-
source

pub fn protect(&mut self)

Write protect the underlying code page(s).

-
source

pub unsafe fn add_code<F>(&mut self, code: impl AsRef<[u8]>) -> F

Add block of code to the runtime and get function pointer back.

-
source

pub fn dump(&self)

Dump the currently added code to a file called jit.asm. The disassembly can be inspected -as ndisasm -b 64 jit.asm.

-

Trait Implementations§

source§

impl Drop for Runtime

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere +Runtime in juicebox_asm - Rust

Struct juicebox_asm::Runtime

source ·
pub struct Runtime { /* private fields */ }
Expand description

A simple mmaped runtime with executable pages.

+

Implementations§

source§

impl Runtime

source

pub fn new() -> Runtime

Create a new Runtime.

+
Panics
+

Panics if the mmap call fails.

+
source

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 mmaped 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();
+
source

pub fn dump(&self)

Dump the code added so far to the runtime into a file called jit.asm in the processes +current working directory.

+

The code can be inspected with a disassembler as for example ndiasm from +nasm.us.

+
ndisasm -b 64 jit.asm
+
Panics
+

Panics if writing the file failed.

+

Trait Implementations§

source§

impl Drop for Runtime

source§

fn drop(&mut self)

Unmaps the code page. This invalidates all the function pointer returned by +Runtime::add_code.

+

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

-- cgit v1.2.3