Java related compilation technology

xiaoxiao2021-03-06  43

In addition to the Java compiler and virtual machine, there are some related compilation techniques, this article tries to make a simple description.

JIT compiler

The traditional Java virtual machine is very stupid. After translating a Bytecode directive into a machine code, the machine code is executed immediately. After performing this batch of machine code, then the machine code is lost, then translate the instructions of the next Bytecode, continue.... Even if the BYTECODE instruction to be performed next time, still want to re-translate into a machine code to execute, so, the efficiency is of course not good.

The virtual machine using the Just-in-Time Compiler technology is relatively clever, and the part of the frequent execution will be implemented in the first time. When you first translate it, you will do it again, you don't have to translate, directly from The memory removes the machine code. In this way, as long as your memory is big enough, the JIT compiler is well technologically enough, your Java Bytecode execution speed can also approach the pure compiler.

Compiler of other program languages

Any file can be executed by the Java virtual machine as long as you meet the format of Java Bytecode. There are many ways to make Java Bytecode, do not have to use Java language to write programs to compile into Java Bytecode. Java is the language is also a platform, you can use Java languages ​​(that is, Java Compiler), only Java platforms (that is, Java virtual machines). As long as a language provides a compiler, you can compile the original code of the language into a Java Bytecode format, you can execute on the Java platform.

As far as I know, there are already the following languages ​​offer complaints compatible with the Java platform (in English alphabetical order): Aardappel, Ada, Agora 98, Bamboo, Basic, Bistro, Bolero, C, C , CLIPS, COBOL, CORRELATE , Dawn, E, Ecmascript, Eiffel, Foo, Forth, Fortran, Funnel, Haskel, Hojo, Javascript, Jickle, JIF, JINNI, LISP, LL, LLP, LOGO, LUCK, MINERVA, MINI, ML, MODULA-2, NetRexx , Nice, Oberon-2, Pascal, Plan, Pnuts, Prolog, PS3i, Python, Sather, Scheme, Self, Simkin, Small Talk, TCL, Webl, Yassl, YOIX, YOYO.

Native compiler

If you don't care if the Java program can cross the platform, you want the Java program to be compiled into a machine code as C / C , so you can use the Java native compiler (Native Compiler). There are already many products that have been available. The Java native compiler has two categories. One class can compile the original code of Java into machine code, and the other can compile Java Bytecode into a machine code.

Contact compilation and obfuscator

Java bytecode is easy to compile (DE-Compilation) because of the simple file format, and the information is complete, and the instruction is the simplest stack-based architecture. The anti-compilation refers to the opposite process, for Java, the anti-compilation is the process of converting Java Bytecode into Java original code.

In order to prevent you from developing Java bytecode by others into the original code, you can convert your Java Bytecode into a more confusing Java Bytecode through the obfuscator, but confused Java Bytecode is not easy to be compiled. You usually have to pay for this, because the confusing program is usually slowed down. And the obfuscator can only increase the difficulty of anti-compilation, and you cannot guarantee that your program must not be successfully compiled. After all, the road is tall, the magic is high, if someone is willing to spend a lot of time and energy, you can't stop it.

Compile translation and reverse group translation

Assembly Language is a language that is very close to the machine code. The tool to convert the assembly language is called the Compiler (Assembler), which in turn refers to the tool that converts the machine code to assembly language is called an anti-group translator (DISSEMBLER)

For Java virtual machines, Java Bytecode is like its machine code, is there a language is very close to Java Bytecode? In other words, is Java's assembly language? Basically, Sun does not define the standard assembly language of Java, but some people define their own Java assembly language and provide Java's group translators (even anti-group translators). For example, JASMIN and Javaa are Java group translators.

Pre-processor

Pre-Processor is also called a pre-compiler (pre-translator), with a destination to convert a part of a language specification in the source code into a language specification. For example, we may be inserted in the Java language in addition to using Java language, we also insert the syntax of the custom. These custom syntax cannot be processed by the Java compiler, so we must first turn the self-binding syntax into a Java language through a pre-processor, and then handle the Java compiler.

There are currently many Java pre-processors, such as IContract, SQLJ, are used to expand the Java language.

Optimization tool software

In general, there are two types:

1. Let the file volume becomes small, save storage space and speed up the network transmission speed.

2. Let the execution speed become fast.

For Java, there is also a third optimization:

3. Let the program structure mess, it is not easy to be compiled. It is also an obfuscation mentioned earlier. These three objects are often exclusive: structural messs, usually make the program slower, and the volume becomes large; the volume becomes smaller, usually slowed down, and the structure is changed; the speed is changed, usually makes the volume change Big, and the structure is changed.

转载请注明原文地址:https://www.9cbs.com/read-73014.html

New Post(0)