Re:A New Bytecode Format for JavaScriptCore
by eridius on Friday June 21, 2019 @04:26PM
(#20246033)
Swift and Rust also have their own higher-level intermediate representations that they translate their AST to before even going to LLVM IR (SIL and MIR respectively). Rust used to translate their AST directly into LLVM IR but they switched to going through MIR first because it unlocks a lot of optimizations as well as improved user-facing functionality such as non-lexical lifetimes in the borrow checker.
[ Parent
| on HN ]
Re:A New Bytecode Format for JavaScriptCore
by steveklabnik on Friday June 21, 2019 @05:44PM
(#20246539)
Rust has AST -> HIR -> MIR -> LLVM-IR. Two internal IRs and a third external one!
Good point, I forgot about HIR, though isn't HIR largely just a desugared representation of the AST?
Re:A New Bytecode Format for JavaScriptCore
by steveklabnik on Friday June 21, 2019 @07:19PM
(#20247045)
Yes, but also post macro expansion and name resolution.
Re:A New Bytecode Format for JavaScriptCore
by monocasa on Saturday June 22, 2019 @12:13AM
(#20247984)
And compcert has at least seven different IRs, several of which are ASTs. http://compcert.inria.fr/diagram.png
That being said, consistency of internal data structures is probably one of those areas that separates a JIT from an offline compiler. I can see the benefit of switching to a bytecode representation pretty early in that circumstance.