Java编译器优化 [英] Optimization by Java Compiler

查看:235
本文介绍了Java编译器优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我在阅读这篇文章

根据该文章,Java Compiler,即javac在生成字节码时不执行任何优化。是真的吗?如果是这样,那么它可以实现为中间代码生成器以消除冗余并生成最优代码?

According to that article, Java Compiler i.e. javac does not perform any optimization while generating bytecode. Is it really true? If so, then can it be implemented as an intermediate code generator to remove redundancy and generate optimal code?

推荐答案

javac 只会做一个很少的优化。

javac will only do a very little optimization, if any.

关键是JIT编译器做了大部分的优化,它工作最好,如果它有很多信息,其中一些可能会丢失,如果 javac 执行优化。如果 javac 执行某种循环展开,则JIT将更难以通常的方式来执行它 - 并且它有更多的信息,实际上工作,因为它知道目标平台。

The point is that the JIT compiler does most of the optimization - and it works best if it has a lot of information, some of which may be lost if javac performed optimization too. If javac performed some sort of loop unrolling, it would be harder for the JIT to do that itself in a general way - and it has more information about which optimizations will actually work, as it knows the target platform.

这篇关于Java编译器优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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