Smart JVM and JIT Micro-Optimizations

前端 未结 3 1858
你的背包
你的背包 2021-02-06 11:20

Over time, Sun\'s JVM and JIT have gotten pretty smart. Things that used to be common knowledge as being a necessary micro-optimization are no longer needed, because it gets ta

相关标签:
3条回答
  • 2021-02-06 11:33

    It's beyond impressive. All of these are things you can't do in C++ (certainly to the same extent Java does). Keep in mind that early versions of Java started the "slow" reputation by not having these things, and we keep improving significantly over time. This is still a big research area.

    • Efficient interface dispatch.
    • Inlining and direct dispatch of virtual method calls.
    • Very fast object allocation with bump pointers (slide 19 or so) and escape analysis.
    0 讨论(0)
  • 2021-02-06 11:43

    Oracle has a wiki on Performance techniques used in the Hotspot JVM.

    0 讨论(0)
  • 2021-02-06 11:48

    Java is smarter at inlining as it can

    • inline code only available at runtime or even dynamically generated.
    • inline virtual methods (up to two at once)
    • perform escape analysis on inlined methods and the methods they were inlined to. (Much harder to do in C++)
    0 讨论(0)
提交回复
热议问题