Hello, today I’m going to share with you JVM. Take out your notebook and write it down

One JVM life cycle

Start the VM

The Java virtual machine is started by bootstrap Class Loader to create an initial class that is specified by the implementation of the virtual machine.

Vm execution

A running Java virtual machine has a clear job: executing Java programs.

He runs when the program begins and stops when it ends.

When a so-called Java program is executed, what is really being executed is a process called the Java Virtual Machine.

Exit the VM

There are several cases as follows:

The program completes normally

The program encounters an exception or error during execution and terminates abnormally

The Java virtual machine process was terminated due to an operating system error. Procedure

A thread calls the Exit method of the Runtime class or the System class, or the HALT method of the Runtime class, and the Java security manager also allows the exit or HALT operation.

In addition, the JNI (Java Native Interface) specification describes the Java Virtual machine exit when the Java Virtual machine is loaded or unloaded using the JNI Invocation API.

Ii. Development history of JVM

Sun Classic VM

Back in 1996, when Java1.0 was released, Sun released a Java virtual machine called Sun classic VM, which was also the world’s first commercial Java virtual machine. It was completely phased out in JDK1.4.

The virtual machine provides only an interpreter internally. There’s also a just-in-time compiler, so it’s inefficient, and the just-in-time compiler caches hot code, so it’s more efficient to use hot code in the future.

If you are using a JIT compiler, you need to do a plug-in. But once a JIT compiler is used, the JIT takes over the execution system of the virtual machine. The interpreter stops working. The interpreter and compiler do not work together.

This virtual machine is now built into hotspot.

Exact VM

To solve the previous virtual machine problem, sun provided this virtual machine in jdk1.2. Exact Memory Management: Exact Memory Management

Also called non-conservative /Accurate Memory Management

The virtual machine can know exactly what type of data is stored at a location in memory. |

Provides the dimensions of modern high-performance VMS

Hot spot detection (finding hot code for caching)

Compilers and interpreters mix working modes

It was only used briefly on Solaris, but on other platforms the Classic VM was short of breath and was eventually replaced by Hotspot VM

HotSpot VM

The HotSpot history

It was originally designed by a small company called Longview Technologies

The company was acquired by Sun in 1997; Sun was acquired by Oracle in 2009.

In JDK1.3, HotSpot VM becomes the default VM

At present Hotspot occupies the absolute market position and dominates the martial arts.

In both the still widely used JDK6 and the heavily used JDK8, the default VIRTUAL machine is HotSpot

Default virtual machine for Sun/ Oracle JDK and openJDK

Therefore, the default virtual machine introduced in this course is HotSpot, and the related mechanism mainly refers to HotSpot Gc mechanism. (For example, neither of the other two commercial virtual machines has the concept of a method area.)

From server, desktop to mobile terminal, embedded applications.

The name HotSpot refers to its HotSpot code detection technology.

The counter finds the code with the most compile value, triggering either just-in-time compilation or on-stack replacement

The compiler and interpreter work together to balance optimal program response time with optimal execution performance

JRockit

Focus on server-side applications

It doesn’t care much about startup speed, so JRockit doesn’t include a parser implementation, and all the code is compiled and executed by the just-in-time compiler.

Numerous industry benchmarks show that the JRockit JVM is the fastest JVM in the world.

Customers have experienced significant performance improvements (some over 70%) and hardware cost reductions (up to 50%) using JRockit products.

Advantages: Comprehensive Java runtime solution portfolio

JRockit Real Time provides JVM response times in milliseconds or microseconds for financial, military command, and telecommunications networks

MissionControl service suite, which is a set of tools for monitoring, managing, and analyzing applications in a production environment with minimal overhead.

In 2008, JRockit was acquired by Oracle.

Oracle expresses the work of integrating two great virtual machines, roughly done in JDK8. The way to integrate is to port the good features of JRockit on top of HotSpot.

Gosling: Currently works at Google, working on artificial intelligence and underwater robotics

The IBM J9

Full name: IBM Technology for Java Virtual Machine, IT4J for short, internal code: J9

Market positioning is similar to HotSpot, server side, desktop application, embedded and other multi-purpose VM is widely used in various IBM Java products.

Currently, one of the three most influential commercial virtual machines also claims to be the fastest Java virtual machine in the world.

Around 2017, IBM released the open source J9VM, named openJ9, and handed it over to the EClipse Foundation, also known as EClipse openJ9

OpenJDK -> is open source JDK, including virtual machines

KVM and CDC/CLDC Hotspot

CDC/CLDC HotSpot Implementation VM KVM (Kilobyte) was an early product of CLDC-HI and currently has an awkward position in the mobile space, with smartphones being split between Angroid and ioS.

KVM is simple, lightweight, and highly portable, maintaining its niche on lower-end devices

Intelligent controller, sensor

Mobile phones for the elderly and feature phones in economically underdeveloped areas

Rule for all virtual machines: Compile once, run anywhere.

Azul VM

The first three “high performance Java Virtual machines” are used on general hardware platforms. Here, Azu1VW and BEALiquid VM are proprietary VIRTUAL machines I bound to specific hardware platforms and coordinated with hardware and software

Fighter in high performance Java Virtual machine.

Azul VM is an AVA VIRTUAL machine that runs on Azul Systems’ proprietary hardware Vega system, a major improvement on HotSpot from Azul Systems.

Each Azu1VM instance can manage hardware resources with at least dozens of cpus and hundreds of GIGABytes of memory, and provides excellent features such as a garbage collector for manageable GC times in a large memory range, proprietary hardware-optimized thread scheduling, and more.

In 2010, AzulSystems began to shift from hardware to software, releasing its zing JVM, which provides nearly Vega features on the general-purpose x86 platform.

Liquid VM

Fighter in high performance Java Virtual machine.

Liquid VM is the JRockit VE (Virtual Edition) developed by BEA, which runs directly on its own Hypervisor.

Liquid VM does not require operating system support, or it itself implements the necessary functions of a dedicated operating system, such as thread scheduling, file systems, network support, and so on.

With the JRockit virtual machine being discontinued, the Liquid vM project was discontinued.

Apache Marmony

Apache has also launched Apache Harmony, a Java runtime platform compatible with JDK1.5 and JDK1.6.

It was an open source JVM jointly developed by IElf and Inte1. It was suppressed by the openJDK, which was also open source. Sun was determined not to allow Harmony to be JCP certified, and it was finally retired in 2011, with IBM joining the openJDK

While there are no large-scale commercial cases of Apache Harmony, its Java library code has been incorporated into the Android SDK.

Micorsoft JVM

Microsoft developed the Microsoft JVM to support Java Applets in IE3.

It only runs on Windows. But it was the best-performing Java VM on Windows at the time.

In 1997, Sun successfully sued Microsoft for trademark infringement and unfair competition, which cost Sun a lot of money. Microsoft erased its VM in windowsXPSP3. The JDK installed on Windows today is HotSpot.

Taobao JVM

Published by the AliJVM team. Ali, the most powerful Java company in China, covers cloud computing, finance, logistics, e-commerce and many other fields, and needs to solve the complex problems of high concurrency, high availability and distribution. There are plenty of open source products out there.

Based on openJDK, we developed our own customized version AlibabaJDK, or AJDK for short. Is the cornerstone of the entire Ali Java system.

The first optimized, deeply customized and open source high-performance server version Java VIRTUAL machine released based on openJDK Hotspot VM in China.

The innovative GCIH (GCinvisible Heap) technology implements off-heap, that is, Java objects with a long life cycle are moved from the heap to the outside of the heap, and the Gc cannot manage Java objects inside the GCIH, so as to reduce the recycle frequency of Gc and improve the recycle efficiency of Gc.

Objects in GCIH can also be shared across multiple Java virtual machine processes

Implement the JvM Intrinsic to reduce the overhead of JNI calls using crC32 instructions

Java Profiling Tool and diagnostic assistance for PMU Hardware

ZenGc for big data scenarios

Taobao VM application has high performance on Alibaba products. The hardware relies heavily on THE CPU of INTE1, resulting in loss of compatibility but improved performance

At present, it has been online on Taobao and Tmall and replaced all the official JvM versions of Oracle.

Dalvik VM

Developed by Google for Android and provided with JIT in Android2.2, it is growing rapidly.

Dalvik Y can only be called a virtual machine, not a “Java virtual machine,” because it does not follow the Java Virtual Machine specification

Java Class files cannot be executed directly

Register-based architecture, not the JVM’s stack architecture.

The compiled dex (Dalvik Executable) file is executed. Execution efficiency is relatively high.

It executes dex (Dalvik Executable) files that can be converted from class files, uses Java syntax to write applications, and can directly use most Java apis.

Android 5.0 replaces the Dalvik VM with an ART VM that supports Ahead of Time Compilation (AoT).

Graal VM

In April 2018, Oracle Labs unveiled GraalvM, an ambitious “Run Programs Faster Anywhere”. This echoes Java’s “Write once, Run Anywhere” in 1995.

GraalVM is a cross-language full-stack VIRTUAL machine enhanced on top of HotSpot VM and can be used as a platform for “any language”. Languages include: Java, Scala, Groovy, Kotlin; C, C++, Javascript, Ruby, Python, R, etc

Support for mixing interfaces and objects in different languages using native library files that are already written

It works by taking the source code of these languages, or the compiled intermediate format of the source code, and translating it through the interpreter into an intermediate representation that can be accepted by Graal VM. Graal VM provides the Truffle toolset to quickly build an interpreter for a new language. At run time, the compiler can be optimized on the fly, which is more efficient than the native compiler.

If HotSpot is ever to be replaced, Graalvm has the best hope. But the Java software ecosystem hasn’t changed at all.

conclusion

Depending on the implementation, the memory structure of a particular JVM may differ from one vendor to another, or from one vendor to another. The oracle HotSpot VM is the default virtual machine.

Well, this is the end of today’s article, I hope to help you confused in front of the screen