Earlier I posted about Static Hermes compiling unannotated JS to Wasm. Attached are screenshots of the input and part of the output.
Of course this is an ideal case, where we can infer all types. For regular code there would be many function calls, but it would still work.
@tmikov
Could someone hypothetically build a VS Code extension that tells you when it can’t infer types and thus is doing it the slow way?
function foo(bar) {
^^^
bar’s type is unable to be inferred, thus this function is not optimized
// stuff
}
…etc
@jamonholmgren
It is possible, but not trivial. Emitting diagnostics like that is something that we have been thinking about, but have not implemented yet.
But if you are worried about performance of a function, wouldn't it be easier to just add type annotations and not rely on inference?
@tmikov
This really reminds me of the early work of v8’s type info system by
@fhinkel
Although above is runtime but I guess the static Hermes means it does a run on compile and generates optimized code on top of it somehow