Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Oop Maps means in Hotspot VM exactly

I read from some documents that Hotspot VM utilizes a data structure called Oop Maps to manage all OOPs in VM. My question is that when does this Oop Map data structure generated? At compile time or runtime? Any further detailed documents regarding to this will be more than welcomed. Thank you guys.

like image 589
Bill Randerson Avatar asked Sep 25 '14 02:09

Bill Randerson


People also ask

What is JDK with HotSpot?

The JDK provides one or more implementations of the Java virtual machine (VM): On platforms typically used for client applications, the JDK comes with a VM implementation called the Java HotSpot Client VM (client VM). The client VM is tuned for reducing start-up time and memory footprint.

How does Java HotSpot work?

HotSpot is a dynamic compiler. It combines the best features of a JIT compiler and an interpreter, combining the two in a single package. That two-in-one combination provides a number of important benefits for code performance, as you will shortly see.

What is GraalVM and HotSpot?

GraalVM is based on Java HotSpot VM, but integrates an advanced just-in-time (JIT) compiler, written in Java - the Graal compiler. At runtime, the application is loaded and executed normally on the JVM. The JVM passes bytecode to the Graal compiler, which compiles that to the machine code and returns it to the JVM.

How do I download Java HotSpot?

In order try the HotSpot JVM, I downloaded and installed JDK 17 (Java SE 17) on my Windows computer: Open the Java SE Download page with this URL: https://www.oracle.com/java/technologies/downloads/. Click the "Windows" tab under the "Java SE Development Kit 17.0. 1 downloads".


1 Answers

OopMap is a structure that records where object references (OOPs) are located on the Java stack. Its primary purpose is to find GC roots on Java stacks and to update the references whenever objects are moved within the Heap.

There are three kinds of OopMaps:

  1. OopMaps for interpreted methods. They are computed lazily, i.e. when GC happens, by analyzing bytecode flow. The best reference is the source code (with lots of comments), see generateOopMap.cpp. InterpreterOopMaps are stored in OopMapCache.
  2. OopMaps for JIT-compiled methods. They are generated during JIT-compilation and kept along with the compiled code so that VM can quickly find by instruction address the stack locations and the registers where the object references are held.
  3. OopMaps for generated shared runtime stubs. These maps are constructed manually by the developers - authors of these runtime stubs.

During GC JVM walks through all thread stacks. Each stack is parsed as a stream of stack frames. The frames are either interpreted or compiled or stubs. Interpreted frames contain information about Java method and bci (bytecode index). OopMapCache helps to find an OopMap corresponding to the given method and bci. The method of a compiled frame is discovered by instruction address lookup.

like image 65
apangin Avatar answered Sep 20 '22 13:09

apangin