Struct cranelift_codegen::binemit::MemoryCodeSink[][src]

pub struct MemoryCodeSink<'a> {
    pub info: CodeInfo,
    // some fields omitted
}
Expand description

A CodeSink that writes binary machine code directly into memory.

A MemoryCodeSink object should be used when emitting a Cranelift IR function into executable memory. It writes machine code directly to a raw pointer without any bounds checking, so make sure to allocate enough memory for the whole function. The number of bytes required is returned by the Context::compile() function.

Any relocations in the function are forwarded to the RelocSink trait object.

Note that MemoryCodeSink writes multi-byte values in the native byte order of the host. This is not the right thing to do for cross compilation.

Fields

info: CodeInfo

Information about the generated code and read-only data.

Implementations

Create a new memory code sink that writes a function to the memory pointed to by data.

Safety

This function is unsafe since MemoryCodeSink does not perform bounds checking on the memory buffer, and it can’t guarantee that the data pointer is valid.

Trait Implementations

Get the current position.

Add 1 byte to the code section.

Add 2 bytes to the code section.

Add 4 bytes to the code section.

Add 8 bytes to the code section.

Add a relocation referencing an external symbol plus the addend at the current offset.

Add a relocation referencing a constant.

Add a relocation referencing a jump table.

Add trap information for the current offset.

Machine code output is complete, jump table data may follow.

Jump table output is complete, raw read-only data may follow.

Read-only data output is complete, we’re done.

Add a stack map at the current code offset.

Add a call site for a call with the given opcode, returning at the current offset.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.