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.
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.
Create a new dynamic label that can be referenced and defined.
Query the offset of a dynamic label.
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.
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.
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.
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.
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.
Report the current offset into the assembling target
Push a byte into the assembling target
Push a signed byte into the assembling target
Push a signed word into the assembling target
Push a signed doubleword into the assembling target
Push a signed quadword into the assembling target
Push an usigned word into the assembling target
Push an usigned doubleword into the assembling target
Push an usigned quadword into the assembling target
This function is called in when a runtime error has to be generated. It panics.
tuple of encoded (offset, size, kind)
Push nops until the assembling target end is aligned to the given alignment
Record the definition of a global label
Record a relocation spot for a reference to a global label
Record the definition of a dynamic label
Record a relocation spot for a reference to a dynamic label
Record the definition of a local label
Record a relocation spot for a forward reference to a local label
Record a relocation spot for a backward reference to a local label
Record a relocation spot to an arbitrary target
Extends a collection with the contents of an iterator. Read more
Extends a collection with the contents of an iterator. Read more
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)