TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Build your own WebAssembly Compiler (2019)

161 pointsby davikrover 1 year ago

5 comments

ColinEberhardtover 1 year ago
Oh wow, really chuffed to see a blog post I wrote 4 years ago back on the front page of HN once again. It was a real rollercoaster, spending ages developing a talk, that I wasn&#x27;t able to give due to a flight cancellation - then turning it into a blog post that lots of people seemed to like.<p>Hard work pays off in the end :-)
评论 #38510472 未加载
Joker_vDover 1 year ago
<p><pre><code> (block (loop [loop condition] i32.eqz [nested statements] br_if 1 br 0) ) </code></pre> That&#x27;s... not really the while loop, is it? That should&#x27;ve been something like this IMO<p><pre><code> (block (loop [loop condition] i32.eqz br_if 1 [nested statements] br 0) ) </code></pre> Honestly, WASM&#x27;s &quot;br&quot;&#x2F;&quot;br_if&quot; semantics is quite wacky: for a block &quot;br&quot;&#x2F;&quot;br_if&quot; mean &quot;break&quot;, and for a loop they mean &quot;continue&quot;. I understand that they didn&#x27;t want to have two separate opcodes which would only make sense in certain contexts but could we at least have gotten two mnemonics for them? Having &quot;break&#x2F;break_if&quot; for targeting a block and &quot;continue&#x2F;continue_if&quot; for targeting a loop would reduce some confusion and I don&#x27;t think there are any difficulties in either assembling or disaseembling that.<p>I&#x27;ve seen only about three toy-ish WASM interpreters and they all translate those unorthodox control flow instructions into something like goto&#x27;s during the parsing stage. Why did the WASM authors did it this way, I don&#x27;t know: it&#x27;s just as well possible to give types to traditional asm-like GOTOs and labels.
评论 #38510344 未加载
评论 #38601452 未加载
评论 #38516592 未加载
crabmusketover 1 year ago
If you&#x27;re interested in this, there&#x27;s also <a href="https:&#x2F;&#x2F;wasmgroundup.com&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;wasmgroundup.com&#x2F;</a> currently in early access.<p>I&#x27;ve worked through the first couple of chapters and found it pretty well structured and helpful.
评论 #38512721 未加载
dangover 1 year ago
Discussed at the time:<p><i>Build Your Own WebAssembly Compiler</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21889614">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21889614</a> - Dec 2019 (19 comments)
ReactiveJellyover 1 year ago
[2019] Author builds a compiler that _targets_ WebAssembly, not a compiler that _takes in_ WebAssembly. Interesting but I was hoping for the other side, a minimal AOT or JIT wasm --&gt; machine code compiler.
评论 #38508528 未加载
评论 #38509341 未加载
评论 #38508225 未加载
评论 #38508206 未加载