Skip to Content

WebAssembly: An In-Browser VM ISA

WebAssembly is a technology developed for conscise and efficient client sides of web applications. Essentially it defines a VM (virtual machine) ISA (instruction set architecture) that can support web applications and can be hosted in a browser.

WebAssembly may be an interesting target language for the CS370 compiler projects. This page is a start of collecting information and links about it.

The Main Problem for CS370

The term assembly language has always meant a textual programming language that directly represents the machine instructions that are implemented in hardware. Humans write assembly code and then use an assembler (think, a simple compiler) to convert it into binary executable code.

However, the official WebAssembly format that can be loaded into a browser and executed is a binary format. In that sense it is like a Java .class file or an executable compiled from C/C++. It is not a human-friendly textual format like most assembly languages are.

So if we are to use WebAssembly in CS370, we need an assembler for it! (This is because it would be too hard to actually write out the binary in a small one-semester compiler project; generating the textual format is much simpler.)

Potential Interesting Tools

Most tools that you can find out there are compilers that take other high-level programming languages and output WebAssembly binary code. These don’t help us. The ones below might help, however!

WABT, the WebAssembly Binary Toolkit, does include an assembly, wat2wasm (meaning “WebAssembly Text to WebAssembly”). However, its precompiled release version needs some libraries I don’t have yet, and so I have not been able to test it. Lots of other manipulation tools are in the toolkit, too, which is nice.

BinaryEn is a project that claims to assembly textual WebAssembly into binary WebAssembly. It seems to not have many dependencies, just “plain” C++, and so it might be fairly easy to use. I have not tried yet. There is an issue on its site that says it does not support the latest WebAssembly changes, but what it does support would be good enough for CS370.

AssemblyScript is an interesting project.

Other Resources

None for now.