Git Product home page Git Product logo

bobbin-wasm's Introduction

bobbin-wasm

bobbin-wasm is a WebAssembly library and interpreter written using the Rust programming language, designed to run in resource constrained embedded systems such as ARM Cortex-M SOCs with limited flash, RAM, and processing power, but also also to be useful as a general purpose interpreter to be embedded in applications for scripting and sandboxing purposes.

To achieve those goals, bobbin-wasm does not depend on the Rust standard library and does not require an allocator. It is #[no_std] by default, though future versions could add opt-in features that make use of the standard library. It is also planned to make the entire parser, validator, and compiler / interpreter panic-free so that it is straightforward to use the system as a C library after wrappers are written.

To read more about these goals, see MOTIVATION.

The current version is based heavily on WABT, particularly the validation and typechecking components which are straight ports of their C++ counterparts.

In fact, for testing and validation purposes, bobbin-wasm implements clones of wasm-objdump and wasm-interp that produce output that is byte-for-byte identical to the originals, allowing the use of the extensive WABT test suite. See TESTING for more details.

Building

To build the library and binaries, use cargo build.

To run the object dumper directly without installing, use cargo run --bin wasm-objdump. To run the interpreter directly without installing, use cargo run --bin wasm-interp.

To install the binaries, use cargo install or cargo install --force to overwrite your existing binaries.

Hello Wasm

$ cargo install --force
$ cd wasm-hello
$ make run
   Compiling wasm-hello v0.1.0 (file:///Users/jcsoo/bobbin-dev/bobbin-wasm/wasm-hello)
    Finished release [optimized] target(s) in 1.11s
wasm-gc target/wasm32-unknown-unknown/release/wasm_hello.wasm -o wasm_hello.gc.wasm
wasm-opt -Os wasm_hello.gc.wasm -o wasm_hello.wasm
wasm-interp --run-all-exports wasm_hello.wasm
Hello, World
run_hello() =>

Current Status

bobbin-wasm should be considered extremely unstable.

Memory and Resource Limits

The biggest limitation is that there are many memory and resource limits that are hard coded and set high enough to run the test suite, but not nearly high enough to run typical WASM binaries produced by the current Rust and C toolchains, even after optimization. These limits will be gradually changed to be configurable.

Instruction Subset

Currently, only 32-bit integer instructions are fully implemented. The parser and validator should recognize 32-bit floating point instructions but they will not execute in the interpreter.

Eventually the goal is to provide support for 32-bit integer and floating point with a compile-time option for 32-bit integer only.

Host API

The host API is extremely crude and should be considered proof of concept. Eventually there should be a low-level API as well as higher-level APIs and macros and codegen tools to support type-safe Rust API implementation.

Documentation and Examples

Documentation is currently very sparse. wasm-interp is the best starting point for anyone that wants build a simple application and or to use the host API.

Cross-platform examples for running an interpreter on embedded devices will be released as soon as the underlying hardware crates are released.

bobbin-wasm's People

Contributors

jcsoo avatar

Stargazers

Jesse Braham avatar Val Packett avatar  avatar Harrison Chin avatar Jonathan Beri avatar Rust avatar Will Pankiewicz avatar Stanislav Panferov avatar Sergei Shulepov avatar Luke Matthew Sutton avatar Masashi Fujita avatar krircc avatar  avatar

Watchers

Marc avatar Jacob Rosenthal avatar James Cloos avatar  avatar Harrison Chin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.