4 ms·
How Does Java Both Optimize Hot Loops and Allow Debugging
- chrisseaton 11y agoI wrote about a similar topic, but in the context of Ruby rather than Java if people find understanding that easier http://chrisseaton.com/rubytruffle/deoptimizing/ http://chrisseaton.com/rubytruffle/deoptimizing/
- gus_massa 11y agoThere is a problem with the html escape codes in the sample programs. It shows: for( int i=0; i<N; i++ ) sum += A[i] // set a breakpoint here, for "i>1e6" or maybe "i>1e7"
- michaelt 11y agoSo to take the example from the article, if your optimising compiler unrolls the loop so there are four loop iterations per jump, and i is incrementing 0, 4, 8, 12... if you set a conditional breakpoint on i=10, how does it work out that it needs to break at the earlier safepoint (when i=8) and switch to the non-optimised code?
- gsg 11y agoI don't think that needs to happen. From the article: "Basically, we re-enter a clone of the loop from above…. a clone specially made to be re-entered at any iteration" This is put forward as the explanation for how variables are mutated in the debugger, but as a mechanism for "un-unrolling" the loop it probably serves to support such conditional breakpoints too.