A small WebAssembly compiler is demonstrated, showcasing how an arithmetic expression in reverse polish notation can be turned into a WebAssembly module in just 192 bytes. The post deconstructs code optimization tricks used to minimize the byte size, including variable reuse, sparse arrays, coercion, and other code golfing

11m read timeFrom wasmgroundup.com
Post cover image
Table of contents
IntroductionFormatRemove Assignment ExpressionUndo Variable TricksAdd Missing ZerosRemove Extra 4 bytes on Length DefinitionRemove String Template Literal Instead of Function CallRemove the Ternary OperatorRemove Number Check With CoercionRemove indexOf -1 TrickRemove indexOf TrickRemove the Empty Export NameImplicit Design DecisionsA Trick that Almost WorkedExplaining the Numbers in the ArrayConclusion
1 Comment

Sort: