Java JIT循环展开策略? [英] Java JIT loop unrolling policy?

查看:101
本文介绍了Java JIT循环展开策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

推荐答案

如果 JVM展开循环,最好由

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆