Giter Club home page Giter Club logo

owi's Introduction

owi is an OCaml toolchain to work with WebAssembly. It provides an interpreter as an executable and a library.

Installation

owi can be installed with opam:

$ opam install owi

If you don't have opam, you can install it following the how to install opam guide.

If you can't or don't want to use opam, you can build the package with dune build -p owi @install but you'll first have to install the dependencies by yourself. You can find the list of dependencies in the dune-project file.

Quickstart

Given a file test/passing/quickstart.wast with the following content:

(module $quickstart
  (func $f
    i32.const 24
    i32.const 24
    i32.add
    drop
  )
  (start $f)
)

Running the executable interpreter is as simple as:

$ dune exec owi -- --debug test/passing/quickstart.wast
parsing      ...
checking     ...
grouping     ...
assigning    ...
rewriting    ...
typechecking ...
linking      ...
interpreting ...
stack        : [  ]
running instr: call 0
calling func : func f
stack        : [  ]
running instr: i32.const 24
stack        : [ i32.const 24 ]
running instr: i32.const 24
stack        : [ i32.const 24 ; i32.const 24 ]
running instr: i32.add
stack        : [ i32.const 48 ]
running instr: drop
stack        : [  ]
stack        : [  ]

You can also pass the --script flag to run the file as a reference test suite script. This will allow you to add constructs like assertions and will also link the spectest module, which provides function for e.g. printing.

If you're interested in the library part of owi, here's how to get started:

# open Owi;;
# let filename = "test/passing/quickstart.wast";;
val filename : string = "test/passing/quickstart.wast"
# let m =
    match Parse.Module.from_file ~filename with
    | Ok script -> script
    | Error e -> failwith e;;
val m : Symbolic.modul =
...
# let module_to_run, link_state =
    match Compile.until_link Link.empty_state ~optimize:false ~name:None m with
    | Ok v -> v
    | Error e -> failwith e;;
val module_to_run : Link.module_to_run =
...
val link_state : Link.state =
...
# let () =
    Log.debug_on := true;
    match Interpret.modul module_to_run with
    | Ok () -> ()
    | Error e -> failwith e;;
interpreting ...
stack        : [  ]
running instr: call 0
calling func : func f
stack        : [  ]
running instr: i32.const 24
stack        : [ i32.const 24 ]
running instr: i32.const 24
stack        : [ i32.const 24 ; i32.const 24 ]
running instr: i32.add
stack        : [ i32.const 48 ]
running instr: drop
stack        : [  ]
stack        : [  ]

For more, have a look at the example folder, at the documentation or at the test suite.

Supported proposals

The ๐ŸŒ status means the proposal is not applicable to owi.

Adopted proposals

Proposal Status
Import/Export of Mutable Globals โœ”๏ธ
Non-trapping float-to-int conversions โœ”๏ธ
Sign-extension operators โœ”๏ธ
Multi-value โœ”๏ธ
Reference Types โœ”๏ธ
Bulk memory operations โœ”๏ธ
Fixed-width SIMD โŒ
JavaScript BigInt to WebAssembly i64 integration ๐ŸŒ

Current proposals

We only list proposals that reached phase 3 at least.

Proposal Status
Tail call โœ”๏ธ
Typed Function References โœ”๏ธ
Garbage collection Ongoing
Extended Constant Expressions โŒ
Multiple memories โŒ
Custom Annotation Syntax in the Text Format โŒ
Memory64 โŒ
Exception handling โŒ
Branch Hinting โŒ
Relaxed SIMD โŒ
Threads โŒ
Web Content Security Policy ๐ŸŒ
JS Promise Integration ๐ŸŒ
Type Reflection for WebAssembly JavaScript API ๐ŸŒ

About

owi's People

Contributors

zapashcanon avatar chambart avatar epatrizio avatar radiopotin 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.