Expand description
The near_vm-compiler crate provides the necessary abstractions
to create a compiler.
It provides an universal way of parsing a module via wasmparser,
while giving the responsibility of compiling specific function
WebAssembly bodies to the Compiler implementation.
Re-exports§
pub use wasmparser;
Macros§
- wasm_
unsupported - Return an
Err(WasmError::Unsupported(msg))wheremsgthe string built by callingformat!on the arguments to this macro.
Structs§
- Compilation
- The result of compiling a WebAssembly module’s functions.
- Compile
Module Info - The required info for compiling a module.
- Compiled
Function - The result of compiling a WebAssembly function.
- Compiled
Function Frame Info - The frame info for a Compiled function.
- Custom
Section - A Section for a
Compilation. - Custom
Section Ref - See
CustomSection. - Dwarf
- The DWARF information for this Compilation.
- Features
- Controls which experimental features will be enabled. Features usually have a corresponding WebAssembly proposal.
- Function
Address Map - Function and its instructions addresses mappings.
- Function
Body - The function body.
- Function
Body Data - Contains function data: bytecode and its offset in the module.
- Function
Body Ref - See
FunctionBody. - Function
Reader - Represents a WebAssembly function body.
- Instruction
Address Map - Single source location to generated address mapping.
- Jump
Table - An opaque reference to a jump table.
- Middleware
Error - A error in the middleware.
- Module
Environment - The result of translating via
ModuleEnvironment. Function bodies are not yet translated, and data initializers have not yet been copied out of the original buffer. The function bodies will be translated by a specific compiler backend. - Module
Translation State - Contains information decoded from the Wasm module that must be referenced during each Wasm function’s translation.
- Relocation
- A record of a relocation to perform.
- Section
Body - The bytes in the section.
- Section
Index - Index type of a Section defined inside a WebAssembly
Compilation. - Source
Loc - A source location.
- Target
- This is the target that we will use for compiling the WebAssembly ModuleInfo, and then run it.
- Trampolines
Section - Trampolines section used by ARM short jump (26bits)
- Trap
Information - Information about trap.
- Triple
- A target “triple”. Historically such things had three fields, though they’ve added additional fields over time.
Enums§
- Architecture
- The “architecture” field, which in some cases also specifies a specific subarchitecture.
- Binary
Format - The “binary format” field, which is usually omitted, and the binary format is implied by the other fields.
- Calling
Convention - The calling convention, which specifies things like which registers are used for passing arguments, which registers are callee-saved, and so on.
- Compile
Error - The WebAssembly.CompileError object indicates an error during WebAssembly decoding or validation.
- CpuFeature
- The nomenclature is inspired by the
cpuidcrate. The list of supported features was initially retrieved fromcranelift-native. - Custom
Section Protection - Custom section Protection.
- Endianness
- The target memory endianness.
- Operating
System - The “operating system” field, which sometimes implies an environment, and sometimes isn’t an actual operating system.
- Parse
CpuFeature Error - The error that can happen while parsing a
strto retrieve aCpuFeature. - Pointer
Width - The width of a pointer (in the default address space).
- Relocation
Kind - Relocation kinds for every ISA.
- Relocation
Target - Destination function. Can be either user function or some special one, like
memory.grow. - Symbol
- The kinds of near_vm_types objects that might be found in a native object file.
- Wasm
Error - A WebAssembly translation error.
Constants§
- VERSION
- Version number of this crate.
Traits§
- Compiler
- An implementation of a Compiler from parsed WebAssembly module to Compiled native code.
- Compiler
Config - The compiler configuration options.
- Symbol
Registry - This trait facilitates symbol name lookups in a native object file.
Functions§
- translate_
module - Translate a sequence of bytes forming a valid Wasm binary into a
parsed ModuleInfo
ModuleTranslationState. - wptype_
to_ type - Helper function translating wasmparser types to Wasm Type.
Type Aliases§
- Addend
- Addend to add to the symbol value.
- Code
Offset - Offset in bytes from the beginning of the function.
- Custom
Sections - The custom sections for a Compilation.
- Functions
- The compiled functions map (index in the Wasm -> function)
- Jump
Table Offsets - Code offsets for Jump Tables.
- Relocations
- Relocations to apply to function bodies.
- Wasm
Result - A convenient alias for a
Resultthat usesWasmErroras the error type.