Hi, I am Nikolai Tillmann, a developer on the Prepack project. I am happy to answer any questions!
Prepack helps make JavaScript code more efficient
11–20 of 233 posts
Re: Prepack helps make JavaScript code more efficient
#12Looks like it's applying the same sort of optimizations a normal optimizing compiler would. With all of these JS "compilers" and transpilers, at some point, it just makes sense to build a client-side language in the browser that compiles down to native and runs sandboxed. I'm excited for WebAssembly, but I realize that, like with all shiny new web things (for example, WebRTC on Safari/iOS), mainstream browsers that m…
Prepack is quite complementary to traditional compilers. It's strength is that it comes with full knowledge of the JavaScript built-ins, and it uses that to pre-evaluate the code at compile time. In an extreme case, an entire program can get reduced to the final result.
Added the adjective "optimizing" to "compiler" in the first sentence (I meant something like LLVM opt, what you get when you -O3 your Makefile -- constant folding, loop unrolling, dead code elimination, compile-time constexpr function evaluation -- your extreme example being running the entire program at compile-time).
Added quotes around JS "compiler" -- what your run-of-the-mill JS developers call "compilers" aren't actually real optimizing compilers, even though the JS world would say otherwise, but I digress. Yours is the first to even come close.
Your approach is subject to all sorts of breakages. You mention the lack of "environments" in your documentation which means Prepack out-of-the-box is completely oblivious to the browser itself -- the DOM, etc. What really is annoying is if Fib(6) gets replaced with 8 (including the whole definition of Fib itself, then I can't pop open my console anymore and type Fib(3) -- nor can I bind a UI control to a textbox that evaluates Fib(text) in the box).
An actual working compiler takes in account the "execution environment" as a whole. You can't Fib(x) Linux into oblivion.
Re: Prepack helps make JavaScript code more efficient
#13Re: Prepack helps make JavaScript code more efficient
#14Or roughly, if it compiles without errors, is it safe to assume it won't introduce new bugs?
Re: Prepack helps make JavaScript code more efficient
#15Hi, I am Nikolai Tillmann, a developer on the Prepack project. I am happy to answer any questions!
Re: Prepack helps make JavaScript code more efficient
#16Hi, I am Nikolai Tillmann, a developer on the Prepack project. I am happy to answer any questions!
Can you provide any indications of the size of performance improvements?
Re: Prepack helps make JavaScript code more efficient
#17Hi, I am Nikolai Tillmann, a developer on the Prepack project. I am happy to answer any questions!
Are you seeing a noticeable improvement in peak performance using prepack or does it mostly help improve initial performance and warm up?
Re: Prepack helps make JavaScript code more efficient
#18How "safe" is it? I'm thinking, for example, of Google's closure compiler and the advanced optimizations, which can break some things. Or roughly, if it compiles without errors, is it safe to assume it won't introduce new bugs?
Having said that, it's quite safe, but won't be undetectable. Code using eval could detect injected identifiers, we don't currently aim at preserving function names, and the method bodies you get with toString() are altered. That should be roughly it.
Re: Prepack helps make JavaScript code more efficient
#19How "safe" is it? I'm thinking, for example, of Google's closure compiler and the advanced optimizations, which can break some things. Or roughly, if it compiles without errors, is it safe to assume it won't introduce new bugs?
It's not yet ready for production, so there are some bugs and cases where we should reject a program but don't do that yet. Having said that, it's quite safe, but won't be undetectable. Code using eval could detect injected identifiers, we don't currently aim at preserving function names, and the method bodies you get with toString() are altered. That should be roughly it.
Re: Prepack helps make JavaScript code more efficient
#20Hi, I am Nikolai Tillmann, a developer on the Prepack project. I am happy to answer any questions!
For instance, a common pattern being:
(function(w) { console.log(w.location); })(window)
This results in issues because it's unaware that window would contain other methods. Is it possible to exclude certain objects in this case?