Expand description
§revmc
Experimental JIT and AOT compiler for the Ethereum Virtual Machine.
The compiler implementation is abstracted over an intermediate representation backend. It performs very well, as demonstrated below from our criterion benchmarks, and exposes an intuitive API via Revm.
This repository hosts two backend implementations:
- LLVM (
revmc-llvm
): main backend with full test coverage; - Cranelift (
revmc-cranelift
); currently not functional due to missingi256
support in Cranelift. This will likely require a custom fork of Cranelift.
§Requirements
- Latest stable Rust version
§LLVM backend
- Linux or macOS, Windows is not supported
- LLVM 18
- On Debian-based Linux distros: see apt.llvm.org
- On Arch-based Linux distros:
pacman -S llvm
- On macOS:
brew install llvm@18
- The following environment variables may be required:
prefix=$(llvm-config --prefix) # or #prefix=$(llvm-config-18 --prefix) # on macOS: #prefix=$(brew --prefix llvm@18) export LLVM_SYS_180_PREFIX=$prefix
§Usage
The compiler is implemented as a library and can be used as such through the revmc
crate.
A minimal runtime is required to run AOT-compiled bytecodes. A default runtime implementation is
provided through symbols exported in the revmc-builtins
crate and must be exported in the final
binary. This can be achieved with the following build script:
fn main() {
revmc_build::emit();
}
You can check out the examples directory for example usage.
§Credits
The initial compiler implementation was inspired by paradigmxyz/jitevm
.
§License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Re-exports§
pub use llvm::EvmLlvmBackend;
llvm
pub use cranelift::EvmCraneliftBackend;
cranelift
pub use revm_interpreter as interpreter;
pub use revm_interpreter::primitives;
Modules§
- bytecode 🔒
- Internal EVM bytecode and opcode representation.
- compiler 🔒
- EVM bytecode compiler implementation.
- cranelift
cranelift
- revmc-cranelift
- eyre
- This library provides
eyre::Report
, a trait object based error handling type for easy idiomatic error handling and reporting in Rust applications. - linker 🔒
- llvm
llvm
- revmc-llvm
- ruint
- Rust
uint
crate using const-generics - tests
__fuzzing
- Internal tests and testing utilities. Not public API.
Macros§
- extern_
revmc - Declare
RawEvmCompilerFn
functions in anextern "C"
block.
Structs§
- EvmCompiler
- EVM bytecode compiler.
- EvmCompiler
Fn - An EVM bytecode function.
- EvmContext
- The EVM bytecode compiler runtime context.
- EvmStack
- EVM context stack.
- EvmWord
- A native-endian 256-bit unsigned integer, aligned to 8 bytes.
- Linker
- EVM bytecode compiler linker.
- Opcode
- An opcode and its immediate data. Returned by
OpcodesIter
. - Opcode
Info - Opcode information.
- Opcodes
Iter - An iterator that yields opcodes and their immediate data.
- Opcodes
Iter With Pc - A bytecode iterator that yields opcodes and their immediate data, alongside the program counter.
- Pointer
- A pointer to a value.
Enums§
- Attribute
- Function or parameter attribute.
- EvmCompiler
Input EvmCompiler
input.- Function
Attribute Location - Determines where on a function an attribute is assigned to.
- IntCC
- Integer comparison condition.
- Linkage
- Linkage type.
- Optimization
Level - Optimization level.
- Pointer
Base - The base of a pointer. Either an address or a stack slot.
- Tail
Call Kind - Tail call kind.
- Target
- Target machine.
Constants§
- I256_
MIN 🔒
Traits§
- Backend
- Backend
Types - Builder
- HostExt
Non- host-ext-any
- Extension trait for [
Host
]. - Type
Methods
Functions§
- format_
bytecode - Returns a string representation of the given bytecode.
- format_
bytecode_ to - Formats an EVM bytecode to the given writer.
- min_
imm_ len - Returns the length of the immediate data for the given opcode, or
0
if none. - op_
info_ map - Returns the static info map for the given
SpecId
. - stack_
io - Returns the number of input and output stack elements of the given opcode.
Type Aliases§
- Error
- Compilation error.
- RawEvm
Compiler Fn - The raw function signature of a bytecode function.
- Result
- Compilation result.
- U256
Uint
for256
bits.