文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>JAVA vs C++之速度—

JAVA vs C++之速度—

时间:2010-09-03  来源:我爱我的家

让我们来看看JIT/Hotspot的工作 一般来说,JVM或JAVA的标准API没有提供让我们观察Hotspot工作(产生机器码)的接口.所以以前我们只能猜测Hotspot在背后究竟做了那些事情,我们写的JAVA代码被它弄成什么样子了. 不过现在好了,Java SE Update N这一系列因为处于开发状态,为了方便debug,这些JVM提供了一个运行参数:PrintOptoAssembly,你可以通过如下方式: 引用 java -XX:+PrintOptoAssembly -server -cp . Main 运行你的程序,就可以看到这些JAVA程序在编译为机器语言之后的样子. Kohsuke Kawaguchi做了一些测试,他在博客深入JAVA生成的机器码(Deep dive into assembly code from Java)中进行了一些展示与讲解.并且他对JVM生成的优化代码表示赞赏: 引用 All in all, modern JVMs seem pretty good at generating optimal code. In various situations, the resulting assembly code is far from the straight-forward instruction-by-instruction translation. JAVA之父James Gosling在他的博客Hotspot performance中描述了JIT/Hotspot生成的机器码有以下优点: 引用 ◇ Really aggressive inlining ◇ Even storage allocation & initialization gets inlined - new T() really is as efficient as C's alloca() (and it beats the pants off malloc()) ◇ Careful management of cache prefetching ◇ Deep understanding of variablity between the flavors of x86 machines ◇ Loop unrolling with warmup/cooldown ◇ "theorum proving away" of array index checks (and many other things) ◇ much cleverness with locks
相关阅读 更多 +
排行榜 更多 +
方块枪战战场安卓版

方块枪战战场安卓版

飞行射击 下载
战斗火力射击安卓版

战斗火力射击安卓版

飞行射击 下载
空中防御战安卓版

空中防御战安卓版

飞行射击 下载