[][src]Struct dynasmrt::x64::Assembler

pub struct Assembler { /* fields omitted */ }

This struct is an implementation of a dynasm runtime. It supports incremental compilation as well as multithreaded execution with simultaneous compilation. Its implementation ensures that no memory is writeable and executable at the same time.

Methods

impl Assembler
[src]

pub fn new() -> Result<Assembler>
[src]

Create a new Assembler instance This function will return an error if it was not able to map the required executable memory. However, further methods on the Assembler will simply panic if an error occurs during memory remapping as otherwise it would violate the invariants of the assembler. This behaviour could be improved but currently the underlying memmap crate does not return the original mappings if a call to mprotect/VirtualProtect fails so there is no reliable way to error out if a call fails while leaving the logic of the Assembler intact.

pub fn new_dynamic_label(&mut self) -> DynamicLabel
[src]

Create a new dynamic label that can be referenced and defined.

pub fn get_dynamic_label_offset(
    &self,
    label: DynamicLabel
) -> Option<AssemblyOffset>
[src]

Query the offset of a dynamic label.

pub fn alter<F, O>(&mut self, f: F) -> O where
    F: FnOnce(&mut AssemblyModifier) -> O, 
[src]

To allow already committed code to be altered, this method allows modification of the internal ExecutableBuffer directly. When this method is called, all data will be committed and access to the internal ExecutableBuffer will be locked. The passed function will then be called with an AssemblyModifier as argument. Using this AssemblyModifier changes can be made to the committed code. After this function returns, any labels in these changes will be resolved and the ExecutableBuffer will be unlocked again.

pub fn alter_uncommitted(&mut self) -> UncommittedModifier
[src]

Similar to Assembler::alter, this method allows modification of the yet to be committed assembing buffer. Note that it is not possible to use labels in this context, and overriding labels will cause corruption when the assembler tries to resolve the labels at commit time.

pub fn commit(&mut self)
[src]

Commit the assembled code from a temporary buffer to the executable buffer. This method requires write access to the execution buffer and therefore has to obtain a lock on the datastructure. When this method is called, all labels will be resolved, and the result can no longer be changed.

pub fn finalize(self) -> Result<ExecutableBuffer, Assembler>
[src]

Consumes the assembler to return the internal ExecutableBuffer. This method will only fail if an Executor currently holds a lock on the datastructure, in which case it will return itself.

pub fn reader(&self) -> Executor
[src]

Creates a read-only reference to the internal ExecutableBuffer that must be locked to access it. Multiple of such read-only locks can be obtained at the same time, but as long as they are alive they will block any self.commit() calls.

Trait Implementations

impl DynasmApi for Assembler
[src]

fn push_i8(&mut self, value: i8)
[src]

Push a signed byte into the assembling target

fn push_i16(&mut self, value: i16)
[src]

Push a signed word into the assembling target

fn push_i32(&mut self, value: i32)
[src]

Push a signed doubleword into the assembling target

fn push_i64(&mut self, value: i64)
[src]

Push a signed quadword into the assembling target

fn push_u16(&mut self, value: u16)
[src]

Push an usigned word into the assembling target

fn push_u32(&mut self, value: u32)
[src]

Push an usigned doubleword into the assembling target

fn push_u64(&mut self, value: u64)
[src]

Push an usigned quadword into the assembling target

fn runtime_error(&self, msg: &'static str) -> !
[src]

This function is called in when a runtime error has to be generated. It panics.

impl DynasmLabelApi for Assembler
[src]

type Relocation = (u8, u8)

tuple of encoded (offset, size)

impl Extend<u8> for Assembler
[src]

impl<'a> Extend<&'a u8> for Assembler
[src]

impl Debug for Assembler
[src]

Auto Trait Implementations

impl Send for Assembler

impl Sync for Assembler

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]