Java JIT loop unrolling policy?

后端 未结 2 1327
误落风尘
误落风尘 2021-01-17 19:14

What is the loop unrolling policy for JIT? Or if there is no simple answer to that, then is there some way i can check where/when loop unrolling is being performed in a loop

2条回答
  •  太阳男子
    2021-01-17 19:44

    Another way to see if loop unrolling is being performed in the loop is to specify -XX:LoopUnrollLimit=1 as an argument to the JVM when running your code.

    If you have an executable jar, then an example of how you can use this is:

    java -XX:LoopUnrollLimit=1 -jar your-jar.jar
    

    This flag will

    Unroll loop bodies with server compiler intermediate representation node count less than this value

    And that'll directly address your question without needing to look at the generated assembly

提交回复
热议问题