Overly aggressive inlining of Date expressions
See original GitHub issueConsider this JavaScript code:
console.log(
(function() {
var start = new Date().getTime();
var end = new Date().getTime();
return end - start;
})()
);
Passing this through advanced optimizations yields
console.log((new Date).getTime()-(new Date).getTime());
which has different semantics: The unoptimized version will calculate an end date after the start date, and the difference will be non-negative. The optimized version will evaluate left to right, calculating the left date first, followed by the right date, producing non-positive values.
Example, using Nashorn:
jjs> (new Date).getTime()-(new Date).getTime()
-3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
c++ - What happens if function inlining is too aggressive?
What effect should I expect from having functions inlined overly aggressively and having one hundred times bigger executable?
Read more >c# - Is there a downside to using AggressiveInlining on simple ...
3) Inlining too much means the code becomes larger, and might not fit into caches anymore. Cache misses can be a significant performance...
Read more >A Deeper Look at Inline Functions - ACCU.org
Some compilers have an auto-inline function that lets the compiler decide which functions to inline and which to leave as is. Of course,...
Read more >Proposal: Mid-stack inlining in the Go compiler
Thus, even without aggressive inlining, the user might see inaccurate tracebacks due to inlining. To mitigate this problem somewhat, the Go 1.8 ...
Read more >performance | Dave Cheney
Even taking into account the opportunities for further optimisation, aggressive inlining tends to increase the size of, and the time too compile, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lazarljubenovic Yep, it is the result of a different optimization. This was found via ClojureScript, which can dynamically generate code (via a macro) to measure the length of time needed to evaluate an expression. If the thing you are measuring turns out to be trivial and gets (correctly) elided during advanced, then the inlining issue crops up.
Created internal issue http://b/133856418