3 ms·
Contrary to what the article says, there is no reason whatsoever that code in an eval, even if it uses the calling environment, cannot be optimised. I work on
by chrisseaton 8y ago
Contrary to what the article says, there is no reason whatsoever that code in an eval, even if it uses the calling environment, cannot be optimised.
I work on a Ruby implementation that optimises through eval just fine.
- zamalek 8y agoExactly. It's just like SQL: different queries end up as different entries in the query cache; although SQL is beneficially fuzzy in this case, if only the constants differ you should get a cache hit. The "safe" and fast way to use eval for JIT is to get it to return a function, with all user inputs as parameters (like like the safe and fast way to do SQL is with parameters): var f = eval("(function (a, b) { return a + b })"); f("a", "b");