mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-17 08:40:50 +00:00
In the `wrap` functions, we use `std::mem::transmute(&())` to get the pointer to the value “around” `wrap` (`Fn` has a method `to_raw` which declares a `wrap` function, which uses `transmute` to retrieve `Fn`). This is an undefined behavior. It was working until the `FuncCtx` is introduced. Since then, the undefined behavior was causing an error with the Singlepass backend. This patch stores the pointer to `Fn` in `func_env`, so that the pointer to the user-defined host function is always predictable.
Wasmer Libraries
Wasmer is modularized into different libraries, separated into three main sections:
Runtime
The core of Wasmer is the runtime, which provides the necessary abstractions to create a good user experience when embedding.
The runtime is divided into two main libraries:
- runtime-core: The main implementation of the runtime.
- runtime: Easy-to-use API on top of
runtime-core
.
Integrations
The integration builds on the Wasmer runtime and allow us to run WebAssembly files compiled for different environments.
Wasmer intends to support different integrations:
- WASI: run WebAssembly files with the WASI ABI.
- Emscripten: run Emscripten-generated WebAssembly files, such as Lua or nginx.
- Go ABI: we will work on this soon! Want to give us a hand? ✋
- Blazor: research period, see tracking issue
Backends
The Wasmer runtime is designed to support multiple compiler backends, allowing the user to tune the codegen properties (compile speed, performance, etc) to best fit their use case.
Currently, we support multiple backends for compiling WebAssembly to machine code:
- singlepass-backend: Single pass backend - super fast compilation, slower runtime speed
- clif-backend: Cranelift backend - slower compilation, normal runtime speed
- llvm-backend: LLVM backend - slow compilation, native runtime speed