[英]Smart JVM and JIT Micro-Optimizations
Over time, Sun's JVM and JIT have gotten pretty smart. 随着时间的推移,Sun的JVM和JIT变得非常聪明。 Things that used to be common knowledge as being a necessary micro-optimization are no longer needed, because it gets taken care of for you.
以前不再需要将常识作为必要的微优化的东西,因为它会得到照顾。
For example, it used to be the case that you should mark all possible classes as final, so the JVM inlines as much code as possible. 例如,过去应该将所有可能的类标记为final,因此JVM会尽可能多地内联代码。 However now, the JIT knows whether your class is final based on what classes get loaded in at runtime, and if you load a class to make the original one non-final-able, it un-inlines the methods and un-marks it as final.
但是现在,JIT根据在运行时加载的类知道你的类是否是最终的,如果加载一个类使原始类不可能,它会取消内联方法并取消标记为最后。
What other smart micro-optimizations does the JVM or JIT do for you? JVM或JIT还为您做了哪些其他智能微优化?
EDIT : I made this a community wiki; 编辑 :我把它做成了社区维基; I'd like to collect these over time.
我想随着时间的推移收集它们。
It's beyond impressive. 它令人印象深刻。 All of these are things you
can't
do in C++ (certainly to the same extent Java does). 所有这些都是你在C ++中
can't
做到的事情(当然Java也是如此)。 Keep in mind that early versions of Java started the "slow" reputation by not having these things, and we keep improving significantly over time. 请记住,Java的早期版本开始由没有这些东西的“慢”的美誉,我们保留随着时间的推移显著改善。 This is still a big research area.
这仍然是一个很大的研究领域。
Oracle有一个关于Hotspot JVM中使用的性能技术的wiki。
Java is smarter at inlining as it can Java在内联方面更加智能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.