Git Product home page Git Product logo

wag's Introduction

Wag is a WebAssembly compiler implemented as a Go package.

Features

  • The input is a wasm binary module.

  • The output is machine code.

  • It is only a compiler. A runtime environment for the compiled program, including all import functions, needs to be implemented separately. Wag has been developed for the Gate runtime.

  • Single-pass, fast ahead-of-time compilation.

  • The generated code requires minimal runtime support; it's designed to be executed in an isolated environment. Calling standard library ABIs is not directly supported.

  • Supports snapshot-and-restore across compiler versions and CPU architectures.

  • Supports breakpoint debugging via recompilation.

  • Cross-compilation is supported via Go build tags. If wagamd64 is specified, the x86-64 code generator is used regardless of host architecture, and CPU feature detection is disabled with pessimistic assumptions. Likewise for wagarm64 (but feature detection is not currently used for ARM64 in any case).

Status

  • Supports WebAssembly version 1 (wasm32). No wasm extensions are supported.

  • Supports x86-64 and ARM64 code generation.

  • Generated x86-64 code requires SSE4.1 floating-point instructions (available since 2007).

Security

Spectre variant 1: Out-of-bounds linear memory access detection requires that addressable but unallocated memory is inaccessible. It naturally prevents conditional branch exploitation.

Spectre variant 2: On x86-64, Retpoline is used to protect the runtime environment (although user programs shouldn't be able to inject arbitrary addresses into the branch target buffer).

Testing

Requires Linux, Make, Go, Python, Capstone, and a recent version of WABT. The applicable parts of the WebAssembly spec testsuite are run. Code execution tests are implemented in a separate Go module in the testsuite subdirectory (to work around circular dependencies). All tests can be run by checking out Git submodules and running make check.

wag's People

Contributors

dependabot[bot] avatar tsavola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wag's Issues

Interpreter backend

iOS doesn't allow executable code generation. Interpreter could be used to work around that.

Potential security bug in custom varint code

As preface: I am not a user nor had any knowledge of the existence of this project until I came across it in a blog post.

Recently there is a security related bug fixed in the standard library regarding varints. It seems that at this moment in time the version within this code base hasn't been updated. I am merely putting this issue down as a gentle nudge.

Commit that fixes the bug in the standard library: golang/go@027d724

Little bit of doc

Hello, that projects looks promising, (gate as well)
but it isn't clearly understandable how to use it right now (I'm not go dev),
so could you please provide a tiny bit of documentation on how to
build that tool and convert wasm into x86?
Thanks a lot!

cool project!

wow, this looks like a nice tool! will you have a README with more info?
and is there any screenshot?

keep it up, cheers.

Predictable wasm code size limits

Add support:

  • Limit module size so that it's hit before text size limit, regardless of which backend is used for code generation.
  • Limit wasm function size so that it's hit before ARM64 function size limit.

See #6.

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.