Go Assembly WebAssembly C Rust
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmd/wasys wasys: standalone/unsafe program runner Aug 16, 2018
dewag change license to 3-clause BSD Aug 19, 2017
insnmap optional instruction map generation Feb 23, 2018
internal wasys: standalone/unsafe program runner Aug 16, 2018
sections declare Module contents in internal package Apr 11, 2018
testdata wasys: standalone/unsafe program runner Aug 16, 2018
traps change license to 3-clause BSD Aug 19, 2017
types change license to 3-clause BSD Aug 19, 2017
wasm change license to 3-clause BSD Aug 19, 2017
.gitmodules use tests directly from spec repo Jul 31, 2018
LICENSE change license to 3-clause BSD Aug 19, 2017
README.md implement all trunc instructions Jul 17, 2018
benchmark_test.go runner package is for internal testing Aug 15, 2018
code.go implement all trunc instructions Jul 17, 2018
data.go declare Module contents in internal package Apr 11, 2018
debug.go change license to 3-clause BSD Aug 19, 2017
exec_test.go runner package is for internal testing Aug 15, 2018
fuzz_test.go runner package is for internal testing Aug 15, 2018
initexpr.go declare Module contents in internal package Apr 11, 2018
load.go support all import types Aug 9, 2018
mach_amd64.go x86: make fixed register names stand out Feb 1, 2018
misc_test.go runner package is for internal testing Aug 15, 2018
op.go change license to 3-clause BSD Aug 19, 2017
opcodes.go x86: refactor op implementation code structure Jan 31, 2018
snapshot_test.go runner package is for internal testing Aug 15, 2018
spec_test.go runner package is for internal testing Aug 15, 2018
util_test.go support more spec tests Jul 17, 2018

README.md

wag is a WebAssembly compiler implemented as a Go package.

Features

  • Source is a wasm32 binary module. The application embedding the compiler decides what import functions it provides.

  • Supports x86-64. Support for 64-bit ARM is planned. (Support for non-64-bit or non-little-endian CPU architectures isn't planned.)

  • Single-pass, low-latency ahead-of-time compilation. Early functions can be executed while the latter functions are still being compiled, even while the source is still being downloaded.

  • Generated code requires minimal runtime support. It may be run e.g. in a strict seccomp sandbox. Note: calling standard library ABIs is not supported.

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

Status

  • WebAssembly binary encoding version 1.

  • The Go package API hasn't been finalized.

  • Cross-compilation will be supported once the backend interface stabilizes.

  • Multithreading is not supported. (WebAssembly doesn't define it yet.)

  • Much debugging remains to be done...

Testing

Requires Linux, Go, make, clang and libcapstone. About 75% of the WebAssembly spec testsuite is run, by first converting the tests to binary format:

  1. go get -t github.com/tsavola/wag
  2. make -C $GOPATH/src/github.com/tsavola/wag/testdata/wabt
  3. go test -v github.com/tsavola/wag

The wag-toolchain repository tests input from a C/C++ compiler.

Screenshot

=== RUN   TestSnapshot
--- PASS: TestSnapshot (0.00s)
	snapshot_test.go:73: print output:
		10
		--- snapshotting ---
		current memory limit: 0x6a96051ca000
		current stack ptr:    0x6a960533ffc0
		globals+memory addr:  0x6a96051ba000
		stack addr:           0x6a960533f000
		globals+memory size:  65536
		memory size:          65536
		stack offset:         4032
		stacktrace:
		#1  func-3
		#2  func-2
		--- shot snapped ---
		20
	snapshot_test.go:81: resuming
	snapshot_test.go:93: print output:
		20
		30
		330
		40
		440