Shallow talking about Java VM discovery
Jim Huang <jimchyun @ ccns.ncku.edu.tw>
<jserv @ kaffe.org>
In the second half of this article, the author's experience with the Java VM actually, and the bit-sharing, will be focused on several
Open Source Java VM dedicated discussion, the pen itself is KAFFEVM [1] developers, very much hope that this article
can help to see, but also look forward to your letter advice, with technical exchange, so that KAFFEVM have better
Show.
[1] http://www.kaffe.org/
JVM (Java Virtual Machine) and Java firmware
Java VM is a virtual platform, the platform to be hard, that is, after materialized, is
Java chip. In short, it's a real CPU, and if we don't need a complete CPU complex
Design, you can make it into a co-processor, so you don't have to be in x86 or Sun Sparc
Using Java VM to simulate, but directly to the Java bytecode"feed to"java chip on the Execute line. This
The technology that Sun called Picojava, and, of course, with the input of the software manufacturers, the introduction of a more complex
Sophisticated technique, but the original idea is still the same.
"Simulation" since it is not true, of course, in the efficiency of the more thanks, so it is often for the Java run super slow, super consumption
The impression of resources, in fact, refers to the effectiveness of Virtual Machine. To change JVM performance, use a number of
Technical acceleration, the most important of which is the JIT (Just in time) Compiler (and time translator, note:
Do not mix with "instant"[realtime "and HotSpot adaptive Compiler dynamic
Compilation technology.
Java Chip is optimized for Java OOP, exption-handling, Memory/garbage
Collection's special chip, and x86 (the traditional CPU) does not have the translation of C + + translated machine
New/exception-handling/memory allocation/late-binding in code for hard support
Optimal motion.
Thanks to the VLSI, memory allocation and Garabage collection can be handed over to the hard body
In fact. In a modem or TV, a DSP that is used to convert the number of digits to a digital processor, chip
, something called bit-reverse (FFT [rapid Fourier transform]), if it is done in general x86
This motion, the code is 10 times times slower than the password. And as with the previous floating point, it's 20 to 30 times times slower than the whole number.
, but because of the floating point accelerator, the speed of the floating point can be 1.3 times times that of the whole number!
The foregoing mentions the way in which the JVM is co-processor in the form of a reference to Nazomi communica-
tions [2] company products, they introduced a set of Java accelerator chip, this generation of JA108 products
Dedicated to the use of 2g/2.5g or 3G of the hand machine. You don't need to install extra memory, just put this JA 208
IC implanted in the original system design, you can significantly improve the Java application efficiency of 15 to 60 times times.
[2] http://www.nazomi.com/
Then the pen ms-windows 2000 in Pentium III to perform the following experiments: (the original code and
Machine code.
Virtaul method calling for C + +:
┌──────────────────────────┐
│21:testx-> Setx (20); TESTX is a marker object │
│──────────────────────────│
│00401091 Push 00000014│
│00401093 mov eax,dword ptr [testx]│
│00401096 mov eax,dword ptr [eax]│
│00401098 mov ecx,dword ptr [testx]│
│0040109b call DWORD ptr [eax]│
└──────────────────────────┘
Not counting argument 4 instructions.
General Call of C:
┌───────────────────────────┐
│good () │
│───────────────────────────│
│0040109f call @ILT +0 (? good@ @YAXH @z) (00401000) │
│004010A4 Add esp,00000004│
└───────────────────────────┘
Not counting argument 2 instructions.
It can be found that, for the operation of an active configuration object, Java is a method to call as long as one
Machine code, but with x86, it takes 4, which is directly supported by Java at the instruction set level.
We can easily see a advantage of Java-─ the destination is small and easily accessible to resource-embarrassed home devices
, plus a number of existing APIs that can be used to call and inherit, a simple code can be powerful
of power.
The engine is executed.
The core of the Java VM is the JLS engine, which acts according to the definition of the instruction set, the Java Language
Specification) Details of what happens when the bytecode instruction is executed, but not how
In fact, because this is the author's responsibility. Execute the engine in the form of a line of thread
, so that it can be translated directly into bytecode or through the JIT Compiler to produce native code
。 The execute engine takes the opcode and operant from the bytecode, according to the JLS specifications.
Action, and then remove a opcode until the method returns or drops the exception. This Part
The pen is not going to mention too much, because there is already a Aleppo of many outstanding books available for reference, a book for reference:
Explore the general Java VM system:
1. "Java Virtual Machine" O ' Reilly published
Author: Jon Meyer & Troy dwning
Translation: Java Virtual machine, translated by the Java authority of the state of Cai 鏞
2. "Inside the Java 2 Virtual Machine" Mcgraw-hill published
Author: Bill Venners
If you feel that the last one was an abstraction, the book that Venners wrote should be in your stomach, please read
With CD-ROM, there are JVM concepts in the interactive Java applet solution, author's web page [3]
With rich data. Although the book is translated in Chinese, it is strongly recommended that you do not spend money, because absurd
Mistakes
[3] Http://www.artima.com/insidejvm/resources/
Focus on embedded JVM design:
"Deep embedded Java Virtual machine-inside KVM"
Author: Hu Yue (Mango Hu)
Almost the only thing in the world to talk about Java KVM actually, it's a precious reference. But
, it should be noted that the author directly dug out the KVM's original code, whether it was fully granted, is worth
Discussion.
Discussion on Java VM effectiveness
The most prominent product of the current business Java VM is BEA's JRockit [4]. JRockit mainly
Server-side should be used for a number of improvements, and Intel helps IA32 and IA64 platform optimization,
So, on a number of benchmark (SPECJBB and Specjappserver), JRockit a distant leader
Warlords. BEA is a heavyweight manufacturer leading the technology of Java, with the exception of the Enterprise in the area of technology
And, of course, there is a powerful Java VM, and BEA buys JRockit, and at many high
You can see the JRockit VM's traces. There is an article on the BEA website by Joakim Dahlstedt
Chapter, makes the performance of Java VM can actually break many people's glasses: [Java-a slow
Language? It depends on What for you ' re talking about] [5].
[4] http://www.jrockit.com/
[5] Http://dev2dev.bea.com/products/wljrockit81/articles/Dahlstedt.jsp
Joakim Dahlstedt is not small, is the main design of the JRockit VM, now BEA System
The technology of Java Runtime Group, this article is not the old Wang sell melon, on the contrary, Joakim to
We understand that the way the Java VM "benchmark" (performance evaluation) needs to be adjusted, mainly based on
Next couple:
1. The general benchmark is only micro-benchmark level and cannot be pushed to system-
Level
2. Software production development has changed a lot, using Class library, framework,
Application server, even Web services. Invoking the old benchmark can only be a needle against which
A software stack, but not a comprehensive analysis of system-level, so the measure of this
There is a problem with the body.
The Dynamic optimization of the 3.Java VM itself can be adjusted according to the most authentic profiling data
Component so that it can be made into a group of efficiency.
4. Finally, the new CPU structure, like Intel EPIC, may be more suitable for Dynamic optimization
, rather than the traditional static compiler. In EPIC's frame, compiler's influence on effectiveness
As large, compiler has the responsibility to choose a parallel processing instruction set rather than the traditional Pentium to introduce the automatic
Out-of-order, which means that software dominates the performance of EPIC, which
Static compiler are detrimental because they can only obtain a fixed number of symbols from bytecode, but
Failed to make plans for real profiling.
Joakim's theory gives us a good revelation:
"In conclusion, ..., but I hope I ' ve convinced you using runtime
Systems like Sun Microsystems ' HotSpot or BEA WebLogic JRockit Java
Is isn't slow or inefficient, and that the performance of a large-scale
System built with Java May is superior to that of the same system
Built using C. "
IBM's JDK Zengjin was once the best performance Java VM, but Sun JDK 1. 4 performance has been with the IBM JDK
In the 1.3 phase, its server edition uses more active JIT and GC (garbage Collection) techniques, especially
It is the application of SMP that provides the GC that best fits the hard structure and the multiple-handle.
On the other hand, IBM will give the results of the internal Jalapeno JVM research project [6] with Open Source
The JIKESRVM plan [7], which provides a test for many techniques and algorithms such as JIT and GC,
Test reality as a platform. IBM Rearch a JIKESRVM for the JIT aspect infrastru-
Cture, on the Web site, is a rich text to be included in the study. The pen person has participated in the research direction of JIKESRVM
That the JIT Compiler development trend can be listed as follows:
1. Similar to Hotspot [8] Integrating base interpreter, profiling, and adaptive
Compiler three technical pathways.
2. Motion profiling technology, from simple counter-based algorithm to
Performance monitoring event.
3. More aggressive translation techniques in the meditation compiler (for JIT compiler,
Translation time is a secondary problem, producing the best native code (native).
4. Application of inter-procedural analysis, such as escape analyses can remove synchro-
Nization and in fact stack allocation.
5. The information gained by the Runtime (mainly metadata and dynamic allocation) produces
Live to optimize the primary code.
Next, let's look at Sun's Hotspot technology. Mentioning Hotspot, Henry Massalin.
This first driver, Henry's ph. D. In the HotSpot of Java Glossary [9] is known as
"The mother of all self-modifying code", at the same time, HotSpot is also "builds heavily
On work do in a PhD thesis by Henry Massalin.
[9] Http://mindprod.com/jgloss/hotspot.html
Java's original reality was through the interpreter, but that does not mean Java must be translated
It's OK. The early Java VM was the interpreter of one instruction, so it was extremely inefficient and introduced
JIT and other key technologies, while HotSpot can say the next generation of JIT. According to Sun's official contribution, the use
HotSpot Java VM is hard to tell whether Java bytecode is being solved by JVM in Runtime time
So, because HotSpot is actually translating Java bytecode into the original code for the line.
In fact, in HotSpot design, there are two techniques that are important, namely the dynamic
Compilation and profiling. HotSpot to bytecode, not before the program is executed.
Translated (this conventional approach is called static compilation), in contrast to the program
In the course of the process, with the HotSpot built-in translator to do the translation, the early JIT (Just in time) its
In fact, this concept is not HotSpot to be comprehensive.
So, how does HotSpot translate the Java bytecode?hotspot a highly flexible
design, the internal maintenance of profile Monitor, the focus of the monitoring program, the sentence used in the program fragment
The frequency is high and is delivered to several algorithms depending on the degree of performance impact. HotSpot for those who
A code fragment that is more efficient at the time of the program is called Hot Spot (especially written in small writing to avoid
Confused with HotSpot), the HotSpot will translate these fragments into the original code, and at the same time, according to
The results of the profiling, which are optimized for these native codes, increase efficiency. Conversely, if the
With a lower-frequency code fragment, the HotSpot does not have to spend time doing motion translation, just by using a direct translator
Yes, you can.
Overall, in the HotSpot, the Java bytecode is loaded into the JAVAVM in the form of translations,
But HotSpot immediately depends on the state of some code fragment, which is known to affect the performance of the most
Part, through the dynamic translation and optimization of the processing, to build a native code, and, then, the next execute process can be
To the degree of effectiveness of the lift. We can tell that there are three kinds of HotSpot for bytecode
Way:
-Direct translation (not to be translated)
-Partial motion translations
-Follow the results of profiling and optimize the processing
As to which part of the program is only for direct translation, partial motion translation, and which part of the optimal processing, the whole
Profile Monitor decides.
What's the advantage of using dynamic compilation over traditional static compilation? Apostrophe
The need for Cross-platform, dynamic compilation in many ways more than the traditional path, particularly
The ability to profiling. The past static compilation It's hard to know exactly what's going on in the program.
Is the part that needs the most optimal processing, and can build micro-level through the built template
Optimize the code. On the contrary, dynamic compilation can obtain the most authentic profiling table,
Depending on the need for dynamic tuning, this is even more important in the context of the software development trend in the end of the day, because
The compiler optimization's responsibility was particularly heavy as the work of the hard body shifted gradually to the software.
, such as the Intel EPIC structure mentioned above.
Another typical example is called method inlining. Whether in C + + or Java, call
(Invoke) method is a very consuming system resource, and the system must maintain stack operations to meet the expected
calling convention. So, someone suggested that the processing that was supposed to be a method invocation,
Instead of inline, "embed" to the place where it was originally called, so it's just a simple sequential
Rows, and there is no stack operation. But, method inlining to C + + and Java one kind of thing
In the language, the translator is difficult to do in a good way, because it needs to take care of the characteristics of the object, especially
It is maintained dynamic binding quality. The static compiler can actually make the C++/java of the
Make method inlinng for private and static method, but once there is overridden or
Dynamic binding, static compiler can not know the actual state of the state, it will be conservative not
To actually apply inlining. This problem happens to be HotSpot a dynamic compilation
is solved because Profiling Monitor is able to control the state of method invocation, when
However, it is accurate to know that in Runtime, RTTI (run-time Type identification) can help
HotSpot processing method inlining, therefore, in server-side should use this kind of duplicate to do an item
When it is performed, it is able to obtain the Aleppo of large efficiency lift.
Sun's contribution also points out that, in some cases, Java applications can be even faster than traditional C programs.
At present, the cost of JIT Compiler is mainly in profiling and dynamic compila-
tion Two. Ideally, these two costs should be viewed as constantant time, so many research papers
To move forward in order to be effective. Special JIT Compiler for use, precision does not require a high Java
Runtime profiling can participate in 〈a portable samplling-based Profiler for Java
Virtual machines〉[10], the thesis proposes to use the sampling method to do approximate analysis. and to
Dynamic compilation overhead can be reduced in a way that is progressively optimized, in Sun's
HotSpot has a detailed introduction to the white books.
Overall, Java performance issues are mainly discussed in the following layers:
-General
Interaction between VM and JIT, bytecode to IR translation, IR to machine IR
Translation, and Code generation/formatting
-Optimization of the platform structure (machine-independent)
CSE, loop invariant code motion, inlining, speculative inlining,
Method specialization, and Multiversion code
-The optimization of the platform structure (machine-dependent)
Local/global register allocation, instruction selection, instruction
scheduling, and Code/data alignment
-Optimization of the Java language layer
Rangecheck elimination, checkcast/instanceof removal, type propagation
, optimizations enabled due to strong typing
-Parallel to quantitative processing (vectorization)
Parallel processing instructions for RISC workstations, or MMX and SSE instruction sets as presented by Intel
Java VM for Linux platform
In the early days of the Sun Java VM Reality, the support of the light-was mainly through the Green Thread
Weight thread, which ensures that the Java VM can still be limited in its heterogeneity operating system
Line support, however, this inefficiency is not the direct use of the multi-thread-system
ing machine.
Currently, the Sun Linux JDK has been written with native thread, and Linux's multi-threadded
The ability to invest in big factories such as IBM has two main forms:
1. Ngpt─next Generation Posix Threads
Multiple Java thread mappings (mapping) to less Kernael thread
2. nptl─native Posix Thread Library
Take each Java thread map (mapping) to a kernel thread to optimize
Kernel thread
Of these, ngpt [11] is an Open Source project from IBM, derived from the GNU Pth project [12],
NGPT provides support through patch Linux Kernel 2.4 and glibc. NPTL is
Important design in Linux Kernel 2.6, 〈the Native POSIX Thread Library for
LINUX〉[13] and 〈linux:native POSIX Threading Library (NPTL) 〉[14] These two
The Canon of literature.
Next, the pen will introduce the Open Source JAVAVM that has been connected.
-Kaffe (http://www.kaffe.org/)
Kaffe is a specialized case for the old word in this field, from 1996 Tim Wilkinson completed the original structure
Has been seven years of history. Kaffe was the beginning of Tim Wilkinson's clean-room in the UK.
JAVAVM in fact, the so-called cleanroom, is not to participate in the Sun JDK reality, under the premise of their own to develop another
A compatible actual work, when the Kaffe was bsd-like by way of Grant. 1997, Tim
Wilkinson and Peter Mehlitz a company focused on JAVAVM, transvirtual
Technologies (TVT), the successful Kaffe business, from the beginning, Kaffe have two versions
: One is the GPL-licensed Open Source, which is kaffe.org, in addition to the internal TVT
The Custom Edition, which lays out the code for Open Source and commercial development.
The concept of Kaffe VM design is highly portable and open (Clean-room is not limited to
The development of Sun's rights, as Transvirtual Kaffe's success, many KAFFEVM
The brand of research has suggested that many new concepts can be realized by Kaffe. The transplant ability of KAFFEVM
How good is the force? has proven to support more than 70 platforms, even including the JIT engine.
Transvirtual Technologies was established in 1997 and has been active in the field of embedded devices.
, and in 2000 began to integrate Debian Linux with its Kaffe VM, designed a
Pocketlinux's platform, its core structure is the Linux and Kaffe VM (Language Engine
, running above, can be a real-value Java program. Pocketlinux is a special operation system.
System, with the GNU Debian/linux as the main structure, running Kaffe VM and 3rd-party Open source
Library's integrated environment, providing WEB Browser, synchronization, Media for handheld devices
Player, as well as Peer-to-peer solutions, besides, pocketlinux another special point is through
XML Kaffe and Linux system services, the developers only need through XML to call the department
The function provided by the system.
Despite being a handheld device, the Kaffe VM is the closest to the full functionality of a Java VM, almost as much as the JDK
1.2 compatibility, also supports Personal Java specification, but does not support J2ME's Profiles. Kaffe VM
Positioning is not only the small footprint Java VM, but also the fully functional embedded JAVAVM, thereby fully
The power of Java in a decentralized environment.
Unfortunately, in the 2001 and 2002 years, the Transvirtual company faces a tremendous transformation. First of all
Edouard Parmelan, the main kaffe.org, died in 2001, the year after, Tim
Wilkinson, the CEO of Transvirtual, decides to leave the company. The momentary presence of technical staff and money
Short, Peter Mehlitz the CEO, decided to abandon Open Source to develop the route, and change it to pure
The commercial company, then, renamed Pocketlinux as Xoe, and no longer Open Source,
Kaffe.org became an orphan, and the version of Kaffe 1.0.6. However, Peter
Mehlitz's movement still doesn't save the company's wealth.
On the eve of the dissolution of Transvirtual, the employee Jim Pick <jim@kaffe.org> in March 12, 2002
Announced that it would take over the maintenance of kaffe.org, and would be committed to the Kaffe Custom Edition (also known as Kaffe
Pro) and the Open Source version of the integration, call the developers to help the next release, that is, 1.0.7
of the present. In 2002 years, Transvirtual ended up running, but it does not mean that kaffe, on the contrary
, under Jim Pick's leadership, Kaffe.org succeeded in being reborn, and with other Open source
Java VM Expertise shares development resources, such as GNU Classpath and GCJ.
As of today, a number of heavyweight applications have been available in KAFFEVM, such as JBoss, Tomcat,
Jetty, and the Eclipse IDE.
-Japhar (http://www.japhar.org/)
Japher does most of the JDK 1.1 features, but does not contain JIT Compiler. Since June 19, 2002
After releasing the 0.11 version, there was no development and the original inventor was transferred to the GNU Classpath.
-GNU Classpath (http://www.classpath.org)
The 1998-Year-old GNU Classpath today has become a number of Open Source JAVAVM
's standard. The GNU Classpath is not actually a Java VM, but rather provides the API that Java VMS need to actually
, the GNU Classpath is a Java VM, like LIBC's C program. Over 2000 years ago
, the GNU Classpath (0.00 Edition) only supports Japhar, and it is very slow, almost the same
Time, Redhat/cygnus developed the GCJ (GCC for Java) case, and many of the developers ' efforts began
The integration is done. After Mark Wielaard the task of taking over the defender, the GNU Classpath is maturing.
, CLASSPATH::JVM [13] has an exclusive list of the current GNU Classpath results.
IBM JIKESRVM derivative is an in-house research project, Jalapeno. Jalapeno is built in AIX/POWERPC
, Linux/powerpc, OS X/powerpc, and linux/ia-32 platform's experimental Java VM reality
After that, IBM has granted the results of the internal Jalapeno JVM research project as Open Source,
and set up a JIKESRVM plan that provides a test of many techniques and algorithms, such as JIT and GC
As a platform. JIKESRVM has always been unique in its structure, the traditional Java VM is actually, the core
The main is still in the main, but the core of JIKESRVM in addition to the platform dependent parts, the other absolutely most
Numbers are actually in Java language, which means that JIKESRVM can be self-contained, as
As mentioned in the FAQ:
"Jikes RVM is unique in, it is the"
Machine written entirely in the Java programming language, i.e.
Java code runs on itself, without requiring a second virtual machine. "
In the early stages of development, JIKESRVM still uses IBM's internal core Java APIs class library, which
is not Open Source, it also 詬 the ill IBM's half-adjustment. But since JIKESRVM
2.2.1 Started (April 7, 2003), JIKESRVM can directly use the GNU Classpath results, which also
is to transform a Java VM research program with full Open Source. However, since the JIKESRVM is absolutely large
Part of the core construction, still need a Java Runtime, so the developers also need to install the Sun JDK
A type of non-Open Source Java VM, but has recently been changed. From 2.3.2 Edition (March 17,
2004) We can start by using the GPL-licensed KAFFEVM as a JIKESRVM boot-straping
Java VM, this is the Open Source Java VM Another result of the show, can be a reference to JIKESRVM
User Guide [14].
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.