6f36cc00ee
551: Try a new list of optimization passes. r=nlewycky a=nlewycky A few notes: a) the inliner doesn't help because all the calls are indirect and not even opt -O2 can figure out which functions they're actually calling. b) aggressive instruction combining is not a super-set of the instruction combiner. Instcombine is made up of a large number (probably 10,000s) of patterns, and some particularly slow ones were taken out and moved to the aggressive instruction combiner. Aggressive instcombine *only* runs that handful of optimizations, which fired zero times on our example wasm files. c) NewGVN is not ready for production, it has asserts that fire when building sqlite or cowsay. This is why sqlite didn't build with the llvm backend. d) Scalar-replacement-of-aggregates (sroa) is a strict superset of promote-memory-to-registers (mem2reg), and you probably want sroa because it's usually faster. It also fires 10,000s more times than mem2reg on lua.wasm. e) Aggressive-dead-code-elimination was only deleting as much regular dead-code-elimination, but is slower because it depends on a postdominator tree (PDT) analysis that. Other passes don't need PDT so we'll have to build it for just this one pass (as opposed to regular dominator-tree which is reused by many passes). I've replaced this with bit-tracking dead-code-elimination which deletes more code than dce/adce. Co-authored-by: Nick Lewycky <nicholas@mxc.ca> Co-authored-by: nlewycky <nicholas@mxc.ca> |
||
---|---|---|
.circleci | ||
.github/ISSUE_TEMPLATE | ||
docs | ||
examples | ||
integration_tests | ||
lib | ||
media | ||
scripts | ||
src | ||
wapm-cli@e2aefd4b6b | ||
.appveyor.yml | ||
.dockerignore | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
ARCHITECTURE.md | ||
ATTRIBUTIONS.md | ||
binary-name.sh | ||
bors.toml | ||
Cargo.lock | ||
Cargo.toml | ||
CHANGELOG.md | ||
Dockerfile | ||
install.sh | ||
LICENSE | ||
logo.png | ||
Makefile | ||
README.md | ||
rustfmt.toml | ||
SECURITY.md | ||
update_version_numbers.sh |
Introduction
Wasmer is a standalone JIT WebAssembly runtime, aiming to be fully compatible with WASI and Emscripten.
Install Wasmer with:
curl https://get.wasmer.io -sSfL | sh
Wasmer runtime can also be embedded in different languages, so you can use WebAssembly anywhere ✨:
Usage
Wasmer can execute both the standard binary format (.wasm
) and the text
format defined by the WebAssembly reference interpreter (.wat
).
Once installed, you will be able to run any WebAssembly files (including Lua, PHP, SQLite and nginx!):
# Run Lua
wasmer run examples/lua.wasm
# Run PHP
wasmer run examples/php.wasm
# Run SQLite
wasmer run examples/sqlite.wasm
# Run nginx
wasmer run examples/nginx/nginx.wasm -- -p examples/nginx -c nginx.conf
With WAPM
Installing Wasmer through wasmer.io
includes
wapm, the WebAssembly package manager.
Wapm allows you to easily download, run, and distribute WebAssembly binaries.
# Install cowsay globally
wapm install -g cowsay
# Run cowsay
wapm run cowsay "Hello, world!"
For more information about wapm, check out the website and this example program.
Code Structure
Wasmer is structured into different directories:
src
: code related to the Wasmer executable itselflib
: modularized libraries that Wasmer uses under the hoodexamples
: some useful examples to getting started with Wasmer
Dependencies
Building Wasmer requires rustup.
To build on Windows, download and run rustup-init.exe
then follow the onscreen instructions.
To build on other systems, run:
curl https://sh.rustup.rs -sSf | sh
Other dependencies
Please select your operating system:
macOS
If you have Homebrew installed:
brew install cmake
Or, in case you have MacPorts:
sudo port install cmake
Debian-based Linuxes
sudo apt install cmake pkg-config libssl-dev
FreeBSD
pkg install cmake
Windows (MSVC)
Windows support is highly experimental. Only simple Wasm programs may be run, and no syscalls are allowed. This means nginx and Lua do not work on Windows. See this issue regarding Emscripten syscall polyfills for Windows.
-
Install Visual Studio
-
Install Rust for Windows
-
Install Python for Windows. The Windows x86-64 MSI installer is fine. Make sure to enable "Add python.exe to Path" during installation.
-
Install Git for Windows. Allow it to add
git.exe
to your PATH (default settings for the installer are fine). -
Install CMake. Ensure CMake is in your PATH.
-
Install LLVM 7.0
Building
Wasmer is built with Cargo, the Rust package manager.
Set Rust Nightly:
rustup default nightly
And install Wasmer
# checkout code
git clone https://github.com/wasmerio/wasmer.git
cd wasmer
# install tools
# make sure that `python` is accessible.
make install
Testing
Thanks to spec tests we can ensure 100% compatibility with the WebAssembly spec test suite.
You can run all the tests with:
rustup default nightly
make test
Testing backends
Each backend can be tested separately:
- Singlepass:
make singlepass
- Cranelift:
make cranelift
- LLVM:
make llvm
Testing integrations
Each integration can be tested separately:
- Spec tests:
make spectests
- Emscripten:
make emtests
- WASI:
make wasi
- Middleware:
make middleware
- C API:
make capi
Benchmarking
Benchmarks can be run with:
make bench
Roadmap
Wasmer is an open project guided by strong principles, aiming to be modular, flexible and fast. It is open to the community to help set its direction.
Below are some of the goals of this project (in order of priority):
- It should be 100% compatible with the WebAssembly spec tests
- It should be fast (partially achieved)
- Support WASI - released in 0.3.0
- Support Emscripten calls (in the works)
- Support Rust ABI calls
- Support Go ABI calls
Architecture
If you would like to know how Wasmer works under the hood, please see ARCHITECTURE.md.
License
Wasmer is primarily distributed under the terms of the MIT license (LICENSE).