On Wednesday, 19 August 2015 at 18:26:45 UTC, jmh530 wrote:
On Wednesday, 19 August 2015 at 17:25:13 UTC, deadalnix wrote:

Apple is invested in LLVM. For other thing you mention, WebAssembly is an AST representation, which is both dumb and do not look like anything like LLVM IR.

I saw more similarity between wasm and SPIR-V than LLVM, but it definitely seems to have some differences. I'm not sure what you mean when you say that using the AST representation is dumb. It probably wouldn't be what you would design initially, but I think part of the motivation of the design was to work within the context of the web's infrastructure.

AST is a useful representation to extract something usable from source code and to perform some semantic analysis. It is NOT a good representation to do optimization and codegen. For these SSA and/or stack machines + CFG is much more practical.

Having wasm as an AST forces the process to go roughly as follow :
source code -> AST -> SSA-CFG -> optimized SSA-CFG -> AST -> wasm -> AST -> SSA-CFG -> optimized SSA-CFG -> machine code.

It add many steps in the process for no good reason. Well, in fact there is a good reason. pNaCl is SSA-CFG but mozilla spend a fair amount of time to explain us how bad and evil it is compared to the glorious asm.js they proposed. Going back to SSA would be an admission of defeat, which nobody likes to do, and webasm want mozilla to be onboard, so sidestepping the whole issue by going AST makes sense politically. It has no engineering merit.

Reply via email to