Small talk: in java bytecode

Before looking at the bytecode us first look at what is interpreted languages ​​and compiled languages.

1, interpreted languages ​​and compiled languages

        Our computer can not directly understand high-level language, it can only be understood in machine language (binary string 01), where there is translation , in fact, generally convert high-level language into assembly language, and then converted by the assembly instructions into machine language. Here's the translation generally contain two ways: interpreted and compiled.

       Interpreted language: enforcement mechanism here is to complete an interpreter, translating opportunity here is to run , here is the explanation of his party (translated into machine language) one line. After explaining the interpreter here it is formed intermediate code ( the source code is executed when the interpreter is translated into intermediate code in a platform-independent ). This intermediate code has a good cross-platform, but every time you need to run the source code, while low efficiency, for example, let's say .class file. Linux system and can be re-win system can run.

      Compiled language: all you need to compile the code here, then generates a binary file . Such as C language generation .exe file, here only you need to generate it once, after running the program do not need to recompile code. Advantages are: compiling a permanent executed, source code need not be provided.

2, java language features

       Features java language is that it is actually a semi-semi-compiled interpreted language. It generates compiled bytecode file before execution. After executing the process of interpretation performed line by line to generate a binary machine language interpreter.

     Compiled into byte code: a certain extent, solve the low efficiency of traditional interpreted language problems.

     A bytecode interpreter: Since the bytecode is not directed to a particular machine, retains the transplant characteristics.

 

3, JIT compiler

        In this step JVM class loader to load the first byte code files, and interpreted line by line by the interpreter, the execution speed in this way would be relatively slow. Also, some methods and code blocks are (so-called hot spots of code) often need to be called, so the back of the introduction of JIT compiler, and run-time JIT compiler belong. After the completion of the first JIT compiler compiler, which will preserve the bytecode corresponding to the machine code, the next can be used directly. And we know that the operating efficiency of the machine code is definitely higher than the Java interpreter. This also explains why we often say Java is compiled and interpreted languages ​​coexist.

 

 

Published 134 original articles · won praise 91 · views 160 000 +

Guess you like

Origin blog.csdn.net/weixin_44588495/article/details/104081190