Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How Does Java Both Optimize Hot Loops and Allow Debugging (cliffc.org)
65 points by ot on Oct 10, 2015 | hide | past | favorite | 4 comments



I 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/


So 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?


I 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.


There 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"




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: