Java JIT循环展开策略? [英] Java JIT loop unrolling policy?
问题描述
JIT的循环展开策略是什么?或者,如果没有简单的答案,那么有什么方法可以检查循环中展开循环的位置/时间?
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?
GNode child = null;
for(int i=0;i<8;i++){
child = octree.getNeighbor(nn, i, MethodFlag.NONE);
if(child==null)
break;
RecurseForce(leaf, child, dsq, epssq);
}
基本上,我上面有一段代码,具有固定的迭代次数(八次),当我保持for循环不变时,它的效果很差.但是,当我手动展开循环时,效果会更好.我有兴趣了解JIT是否确实展开了循环,如果没有,那么为什么.
Basically, i have a piece of code above that has a static number of iterations (eight), and it does bad when i leave the for loop as it is. But when i manually unroll the loop, it does significantly better. I am interested in finding out if the JIT actually does unroll the loop, and if not, then why.
推荐答案
If the JVM unrolls the loop is probably best answered by actually printing the generated assembly. Note that this requires your code to actually be executed as a hot spot (i.e. the JVM considers it worthy of the expensive optimizations).
为什么 JVM决定一种或另一种方式要困难得多,并且可能需要对JIT代码进行深入分析.
Why the JVM decides one way or another is a much harder question and probably requires in-depth analysis of the JIT code.
这篇关于Java JIT循环展开策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!