1. <small id='TGh6k'></small><noframes id='TGh6k'>

        <bdo id='TGh6k'></bdo><ul id='TGh6k'></ul>
      <tfoot id='TGh6k'></tfoot>

      <i id='TGh6k'><tr id='TGh6k'><dt id='TGh6k'><q id='TGh6k'><span id='TGh6k'><b id='TGh6k'><form id='TGh6k'><ins id='TGh6k'></ins><ul id='TGh6k'></ul><sub id='TGh6k'></sub></form><legend id='TGh6k'></legend><bdo id='TGh6k'><pre id='TGh6k'><center id='TGh6k'></center></pre></bdo></b><th id='TGh6k'></th></span></q></dt></tr></i><div id='TGh6k'><tfoot id='TGh6k'></tfoot><dl id='TGh6k'><fieldset id='TGh6k'></fieldset></dl></div>
      <legend id='TGh6k'><style id='TGh6k'><dir id='TGh6k'><q id='TGh6k'></q></dir></style></legend>

      什么是字节码以及 JVM 如何处理它们

      What are bytecodes and how does the JVM handle them(什么是字节码以及 JVM 如何处理它们)

          <legend id='Y2yrT'><style id='Y2yrT'><dir id='Y2yrT'><q id='Y2yrT'></q></dir></style></legend>

          <small id='Y2yrT'></small><noframes id='Y2yrT'>

            <bdo id='Y2yrT'></bdo><ul id='Y2yrT'></ul>
            <i id='Y2yrT'><tr id='Y2yrT'><dt id='Y2yrT'><q id='Y2yrT'><span id='Y2yrT'><b id='Y2yrT'><form id='Y2yrT'><ins id='Y2yrT'></ins><ul id='Y2yrT'></ul><sub id='Y2yrT'></sub></form><legend id='Y2yrT'></legend><bdo id='Y2yrT'><pre id='Y2yrT'><center id='Y2yrT'></center></pre></bdo></b><th id='Y2yrT'></th></span></q></dt></tr></i><div id='Y2yrT'><tfoot id='Y2yrT'></tfoot><dl id='Y2yrT'><fieldset id='Y2yrT'></fieldset></dl></div>
                <tbody id='Y2yrT'></tbody>
              <tfoot id='Y2yrT'></tfoot>
                本文介绍了什么是字节码以及 JVM 如何处理它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我多次听说 Java 实现了 JIT(即时)编译,其可跨平台移植的字节码被 JVM 解释".但是,我真的不知道字节码是什么,以及 JVM 在 Java 语言体系结构中的实际含义;我想了解更多关于他们的信息.

                I heard many times that Java implemments JIT(just-in-time) compilation, and its bytecodes which are portable across platforms get "interpreted" by JVM. However, I don't really know what the bytecodes are, and what the JVM actually mean in Java language architecture; I would like to know more about them.

                推荐答案

                JVM(Java虚拟机)有一个指令集,就像一个真正的机器.该指令集的名称是 Java Bytecode.Java 虚拟机规范 中对其进行了描述.其他语言在执行前会被翻译成字节码,例如 ruby 和 python.Java 的字节码处于相当低的级别,而 python 的字节码则更高.

                The JVM (Java Virtual Machine) has an instruction set just like a real machine. The name given to this instruction set is Java Bytecode. It is described in the Java Virtual Machine Specification. Other languages are translated into a bytecode before execution, for example ruby and python. Java's bytecode is at a fairly low level while python's is much more high level.

                解释和 JIT 编译是执行字节码的两种不同策略.解释一次处理一个字节码,对每条指令中编码的虚拟机状态进行更改.JIT 编译将字节码翻译成主机平台的本机指令,执行等效操作.

                Interpretation and JIT compilation are two different strategies for executing bytecode. Interpretation processes bytecodes one at a time making the changes to the virtual machine state that are encoded in each instruction. JIT compilation translates the bytecode into instructions native to the host platform that carry out equivalent operations.

                解释通常启动很快,但在执行过程中很慢,而 JIT 的启动开销更大,但之后运行得更快.现代 JVM 使用解释和 JIT 技术的组合来获得两者的好处.当 JIT 在后台翻译字节码时,首先解释字节码.一旦 JIT 编译完成,JVM 就会切换到使用该代码而不是解释器.有时 JIT 编译可以产生比用于 C 和 C++ 的提前编译更好的结果,因为它更具动态性.JVM 可以跟踪代码被调用的频率以及通过代码的典型路径是什么,并使用这些信息在程序运行时生成更高效的代码.JVM 可以切换到这个新代码,就像它最初从解释器切换到 JIT 代码一样.

                Interpretation is generally quick to start but slow during execution, while JIT has more startup overhead but runs quicker afterwards. Modern JVMs use a combination of interpretation and JIT techniques to get the benefit of both. The bytecode is first interpreted while the JIT is translating it in the background. Once the JIT compilation is complete, the JVM switches to using that code instead of the interpreter. Sometimes JIT compilation can produce better results than the ahead-of-time compilation used for C and C++ because it is more dynamic. The JVM can keep track of how often code is called and what the typical paths through the code are and use this information to generate more efficient code while the program is running. The JVM can switch to this new code just like when it initially switches from the interpreter to the JIT code.

                就像有其他语言可以编译为本机代码一样,例如 C、C++、Fortran;有其他语言的编译器可以输出 JVM 字节码.一个例子是 scala 语言.相信groovy和jruby也可以转换成java字节码.

                Just like there are other languages that compile to native code, like C, C++, Fortran; there are compilers for other languages that output JVM bytecode. One example is the scala language. I believe that groovy and jruby can also convert to java bytecode.

                这篇关于什么是字节码以及 JVM 如何处理它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Bytecode features not available in the Java language(Java 语言中不可用的字节码功能)
                ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                How can I add a Javaagent to a JVM without stopping the JVM?(如何在不停止 JVM 的情况下将 Javaagent 添加到 JVM?)
                Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                Encourage the JVM to GC rather than grow the heap?(鼓励 JVM 进行 GC 而不是增加堆?)
                Why a sawtooth shaped graph?(为什么是锯齿形图形?)

                    <bdo id='ieV81'></bdo><ul id='ieV81'></ul>
                    • <small id='ieV81'></small><noframes id='ieV81'>

                      1. <i id='ieV81'><tr id='ieV81'><dt id='ieV81'><q id='ieV81'><span id='ieV81'><b id='ieV81'><form id='ieV81'><ins id='ieV81'></ins><ul id='ieV81'></ul><sub id='ieV81'></sub></form><legend id='ieV81'></legend><bdo id='ieV81'><pre id='ieV81'><center id='ieV81'></center></pre></bdo></b><th id='ieV81'></th></span></q></dt></tr></i><div id='ieV81'><tfoot id='ieV81'></tfoot><dl id='ieV81'><fieldset id='ieV81'></fieldset></dl></div>
                        <legend id='ieV81'><style id='ieV81'><dir id='ieV81'><q id='ieV81'></q></dir></style></legend>
                        • <tfoot id='ieV81'></tfoot>
                            <tbody id='ieV81'></tbody>