This document provides an overview of the Hotspot Java Virtual Machine (JVM). It discusses the basics of virtual machines, the architecture and execution techniques of the Hotspot JVM, including interpreting, just-in-time compilation, and adaptive optimization. It also covers topics like class loading, garbage collection, and debugging the Hotspot source code. The presentation aims to help developers feel more comfortable with the Hotspot JVM source code.
My presentation in SDCC 2012 (http://sdcc.csdn.net/index_en.html). The video recording of this session is available at http://v.csdn.hudong.com/s/article.html?arcid=2810640
My presentation in SDCC 2012 (http://sdcc.csdn.net/index_en.html). The video recording of this session is available at http://v.csdn.hudong.com/s/article.html?arcid=2810640
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMULinaro
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
Speaker: Alex Bennée
Date: September 22, 2015
★ Session Description ★
While QEMU has continued to be optimised for KVM to make use of the growing number of cores on modern systems, TCG emulation has been stuck running in a single thread. This year there is another push to get a workable solution merged upstream. We shall present a review of the challenges that need to be addressed: locking, TLB and cache maintenance and generic solution for the various atomic/exclusive operations. We will discuss previous work that has been done in this field before presenting a design that addresses these requirements. Finally we shall look at the current proposed patches and the design decisions they have taken.
★ Resources ★
Video: https://www.youtube.com/watch?v=9xQGDTEmNtI
Presentation: http://www.slideshare.net/linaroorg/sfo15202-towards-multithreaded-tiny-code-generator-tcg-in-qemu
Etherpad: pad.linaro.org/p/sfo15-202
Pathable: https://sfo15.pathable.com/meetings/302833
★ Event Details ★
Linaro Connect San Francisco 2015 - #SFO15
September 21-25, 2015
Hyatt Regency Hotel
http://www.linaro.org
http://connect.linaro.org
Learn what a Java Virtual Machine (JVM) is and what it does for your Java applications in this webinar. Eva Andreasson of Azul Systems provides insights into the inner workings of a Java Virtual Machine and some drill down on what compilers and garbage collectors do, so that you don’t have to worry about it while programming your Java application. In particular, you will learn about common optimizations, well established garbage collection algorithms, and what the current biggest challenge with Java scalability is today.
Slides used for an internal training. This explains how to generate Flame Graphs using Java Flight Recorder dumps. There is also an example to use Linux "perf_events" to generate a Java Mixed-Mode Flame Graph.
Kotlin is new JVM language still cooking in Jetbrains kitchen. It looks awesome compared to Java 7, but now, with Java 8 in the field, the question arises: “Does Kotlin still have enough advantages over Java to attract Java developers?” Similar questions could be asked for other JVM languages like Scala, Ceylon, Clojure. We tried to compare new features of Java 8 with corresponding features of Kotlin and see what Kotlin offers beyond features existing in latest Java release.
Software Profiling: Java Performance, Profiling and FlamegraphsIsuru Perera
Guest lecture at University of Colombo School of Computing on 30th May 2018
Covers following topics:
Software Profiling
Measuring Performance
Java Garbage Collection
Sampling vs Instrumentation
Java Profilers. Java Flight Recorder
Java Just-in-Time (JIT) compilation
Flame Graphs
Linux Profiling
Objective of this article is to share internal architecture details of Java Virtual Machine. Focuses on:
- How many component does JVM has?
- How these component are integrated?
- How processing takes place at run time for classes?
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMULinaro
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
Speaker: Alex Bennée
Date: September 22, 2015
★ Session Description ★
While QEMU has continued to be optimised for KVM to make use of the growing number of cores on modern systems, TCG emulation has been stuck running in a single thread. This year there is another push to get a workable solution merged upstream. We shall present a review of the challenges that need to be addressed: locking, TLB and cache maintenance and generic solution for the various atomic/exclusive operations. We will discuss previous work that has been done in this field before presenting a design that addresses these requirements. Finally we shall look at the current proposed patches and the design decisions they have taken.
★ Resources ★
Video: https://www.youtube.com/watch?v=9xQGDTEmNtI
Presentation: http://www.slideshare.net/linaroorg/sfo15202-towards-multithreaded-tiny-code-generator-tcg-in-qemu
Etherpad: pad.linaro.org/p/sfo15-202
Pathable: https://sfo15.pathable.com/meetings/302833
★ Event Details ★
Linaro Connect San Francisco 2015 - #SFO15
September 21-25, 2015
Hyatt Regency Hotel
http://www.linaro.org
http://connect.linaro.org
Learn what a Java Virtual Machine (JVM) is and what it does for your Java applications in this webinar. Eva Andreasson of Azul Systems provides insights into the inner workings of a Java Virtual Machine and some drill down on what compilers and garbage collectors do, so that you don’t have to worry about it while programming your Java application. In particular, you will learn about common optimizations, well established garbage collection algorithms, and what the current biggest challenge with Java scalability is today.
Slides used for an internal training. This explains how to generate Flame Graphs using Java Flight Recorder dumps. There is also an example to use Linux "perf_events" to generate a Java Mixed-Mode Flame Graph.
Kotlin is new JVM language still cooking in Jetbrains kitchen. It looks awesome compared to Java 7, but now, with Java 8 in the field, the question arises: “Does Kotlin still have enough advantages over Java to attract Java developers?” Similar questions could be asked for other JVM languages like Scala, Ceylon, Clojure. We tried to compare new features of Java 8 with corresponding features of Kotlin and see what Kotlin offers beyond features existing in latest Java release.
Software Profiling: Java Performance, Profiling and FlamegraphsIsuru Perera
Guest lecture at University of Colombo School of Computing on 30th May 2018
Covers following topics:
Software Profiling
Measuring Performance
Java Garbage Collection
Sampling vs Instrumentation
Java Profilers. Java Flight Recorder
Java Just-in-Time (JIT) compilation
Flame Graphs
Linux Profiling
Objective of this article is to share internal architecture details of Java Virtual Machine. Focuses on:
- How many component does JVM has?
- How these component are integrated?
- How processing takes place at run time for classes?
Learn JAVA tutorial -This Java tutorial is specially prepared for the Beginners who wants to learn Java programming language from the basics. This tutorial is prepared by Easy Web Solutions by PSK Technologies located in Nagpur that provides best training in Java,PHP,Web Development Hardware and Networking and also provide Internship on all mentioned courses
How to implement a simple dalvik virtual machineChun-Yu Wang
This slide is an introduction to Android Dalvik Virtual Machine on a short course.
We use two hand-made JVM and DVM which called Simple JVM and Simple DVM respectively, to tell student how they work. A Foo Class was provided as a target for verifying the execution results of those VM. We hope it will help student to understand JVM and DVM quickly.
An introduction to the .NET Micro Framework and the type of devices it is designed to help implement. Uses the Device Solutions Tahoe development board for a couple of demonstrations which builds a kitchen timer.
Introduction to Java : Feature to Java, Java Virtual Machine, Differences between C++ and Java,
Part of Java, API Document, Starting a Java Program. Important Classes, Formatting the Output
The State of Managed Runtimes 2013, by Attila SzegediZeroTurnaround
There’s JVM, and that’s it, right? Well, not exactly. Even within JVM, there’s an increasing support for running all kinds of non-Java languages: we have invokedynamic, but it’s being improved, and new layers of functionality are emerging on top of it, making JVM a better home for all kinds of programming languages. There’s life outside of JVM too. JavaScript seems to be a new assembler-lever compilation target even for C programs (I’ll show some amusing examples of what exactly you can run these days in a browser) , and there are some independent efforts at managed runtimes in various stages of completion that seem promising – PyPy, Topaz, Rubinius, Parrot VM (it’s alive again!). This talk is admittedly a language-runtime-enthusiast’s walk-through the things he finds interesting happening this year. Recorded at GeekOut 2013.
Infocampus is one of the best institute that provides Advanced Java Training in Bangalore with the live project. Training on Java Course is provided in lesser fees and payment installament facility is available for java training.Learn OOPs concept, Packages,Spring, Servlet , Hibernate etc in core & advanced java classes. Join Infocampus and get 100% job support. Infocampus provides java/j2ee classes by the more than 10 years experienced trainers. For the best core java training ,mock test is conducted every weekend.
For the free demo classes call at: 9738001024 or to know about the syllabus for the java training enquire at : http://www.infocampus.co.in/java-training-bangalore.html
Infocampus is one of the best institute that provides Advanced Java Training in Bangalore with the live project. Training on Java Course is provided in lesser fees and payment installament facility is available for java training.Learn OOPs concept, Packages,Spring, Servlet , Hibernate etc in core & advanced java classes. Join Infocampus and get 100% job support. Infocampus provides java/j2ee classes by the more than 10 years experienced trainers. For the best core java training ,mock test is conducted every weekend.
For the free demo classes call at: 9738001024 or to know about the syllabus for the java training enquire at : http://www.infocampus.co.in/java-training-bangalore.html
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
4. Why this presentation ?
Feeling comfortable with the JVM source code allows
you to:
•
contribute to and improve the JVM itself
•
fork and customize the JVM for whatever reason you
want (experimental, commercial,
academic …)
5. Why this presentation ?
Feeling comfortable with the JVM source code allows
you to:
•
be a step ahead of Chuck Norris
6. Virtual Machine Basics
A typical virtual machine for an interpreted language
provides:
•
Compilation of source language into VM specific
bytecode
•
Data structures to contains instructions and operands
(the data the instructions process)
7. Virtual Machine Basics
A typical virtual machine for an interpreted language
provides:
•
A call stack for function call operations
•
An ‘Instruction Pointer’ (IP) pointing to the next
instruction to execute
8. Virtual Machine Basics
A typical virtual machine for an interpreted language
provides:
•
A virtual ‘CPU’ – the instruction dispatcher that:
o Fetches the next instruction (addressed by the
instruction pointer)
o Decodes the operands
o Executes the instruction
9. The Hotspot JVM
Provides:
•
bytecode execution - using an interpreter, two runtime
compilers or On-Stack Replacement
•
storage allocation and garbage collection
•
runtimes - start up, shut down, class loading, threads,
interaction with OS and others
22. The Hotspot JVM
Mark word contains:
–
–
–
–
–
Identity hash code
age
lock record address
monitor address
state (unlocked, light-weight locked, heavy-weight
locked, marked for GC)
– biased / biasable (includes other fields such as
thread ID)
24. The Hotspot JVM
Execution engine:
while(true) {
bytecode b = bytecodeStream[pc++];
switch(b) {
case iconst_1: push(1); break;
case iload_0: push(local(0)); break;
case iadd: push(pop() + pop()); break;
}
}
25. The Hotspot JVM
Execution engine:
while(true) {
bytecode b = bytecodeStream[pc++];
switch(b) {
case iconst_1: push(1); break;
case iload_0: push(local(0)); break;
case iadd: push(pop() + pop()); break;
}
}
NOT that simple …
26. The Hotspot JVM
Different execution techniques:
– interpreting
– just-in-time (JIT) compilation
– adaptive optimization (determines "hot spots" by
monitoring execution)
27. The Hotspot JVM
JIT compilation:
– triggered asynchronously by counter overflow for a
method/loop (interpreted counts method entries and
loopback branches)
– produces generated code and relocation info
(transferred on next method entry)
– in case JIT-compiled code calls not-yet-JIT-compiled
code control is transferred to the interpreter
28. The Hotspot JVM
JIT compilation:
– compiled code may be forced back into interpreted
bytecode (deoptimization)
– is complemented by On-Stack Replacement (turn
dynamically interpreted to JIT compiled code and viseversa - dynamic optimization/deoptimization)
– is more optimized for server VM (but hits start-up
time compared to client VM)
29. The Hotspot JVM
JIT compilation flow (performed during normal
bytecode execution):
1) bytecode is turned into a graph
2) the graph is turned into a linear sequence of
operations that manipulate an infinite loop of virtual
registers (each node places its result in a virtual register)
30. The Hotspot JVM
JIT compilation flow (performed during normal
bytecode execution):
3) physical registers are allocated for virtual registers
(the program stack might be used in case virtual
registers exceed physical registers)
4) code for each operation is generated using its
allocated registers
31. The Hotspot JVM
Typical execution flow (when using the java/javaw
launcher):
1. Parse the command line options
2. Establish the heap sizes and the compiler type (client or
server)
3. Establish the environment variables such as CLASSPATH
4. If the java Main-Class is not specified on the command
line fetch the Main-Class name from the JAR's manifest
5. Create the VM using JNI_CreateJavaVM in a newly
created thread (non primordial thread)
32. The Hotspot JVM
Typical execution flow (when using the java/javaw
launcher):
6. Once the VM is created and initialized, load the MainClass
7. Invoke the main method in the VM using
CallStaticVoidMethod
8. Once the main method completes check and clear any
pending exceptions that may have occurred and also pass
back the exit status
9. Detach the main thread using DetachCurrentThread,
by doing so we decrement the thread count so
the DestroyJavaVM can be called safely
37. Resources
Hacking Hotspot in Eclipse under Ubuntu 12.04
http://neomatrix369.wordpress.com/2013/03/12/hotspot-isin-focus-again-aka-hacking-hotspot-in-eclipse-juno-underubuntu-12-04/
Garner R., The Design and Construction of High Performance
Garbage Collectors, PhD thesis
https://digitalcollections.anu.edu.au/handle/1885/9053
38. Resources
Shi Y., Virtual Machine Shutdown: Stack versus Registers,
PhD Thesis
https://www.cs.tcd.ie/publications/techreports/reports.07/TCD-CS-2007-49.pdf
Compiler and JVM Research at JKU
http://www.ssw.uni-linz.ac.at/Research/Projects/JVM/
magicThe magic item supplies the magic number identifying the class file format;it has the value 0xCAFEBABE.minor_version, major_versionThe values of the minor_version and major_version items are the minor andmajor version numbers of this class file.constant_pool_countThe value of the constant_pool_count item is equal to the number of entriesin the constant_pool table plus one.constant_pool[]The constant_pool is a table of structures representing various stringconstants, class and interface names, field names, and other constants that arereferred to within the ClassFile structure and its substructures.access_flagsThe value of the access_flags item is a mask of flags used to denote accesspermissions to and properties of this class or interface.this_classThe value of the this_class item must be a valid index into theconstant_pool table.super_classFor a class, the value of the super_class item either must be zero ormust be a valid index into the constant_pool table.interfaces_countThe value of the interfaces_count item gives the number of directsuperinterfaces of this class or interface type.interfaces[]Each value in the interfaces array must be a valid index intothe constant_pool table.fields_countThe value of the fields_count item gives the number of field_infostructures in the fields table. The field_info structures represent allfields, both class variables and instance variables, declared by this class orinterface type.fields[]Each value in the fields table must be a field_info structure givinga complete description of a field in this class or interface.methods_countThe value of the methods_count item gives the number of method_infostructures in the methods table.methods[]Each value in the methods table must be a method_info structure givinga complete description of a method in this class or interface. attributes_countThe value of the attributes_count item gives the number of attributes in the attributes table of this class.attributes[]Each value of the attributes table must be an attribute_info (§4.7)structure.
Loading: finding and importing the binary data for a typeLinking: performing verification, preparation, and (optionally) resolutionVerification: ensuring the correctness of the imported typePreparation: allocating memory for class variables and initializing the memory to default valuesResolution: transforming symbolic references from the type into direct references.Initialization: Invoking Java code that initializes class variables to their proper starting values.
A new frame is created and added (pushed) to the top of stack for every method invocation. The frame is removed (popped) when the method returns normally or if an uncaught exception is thrown during the method invocation. Each frame contains:Local variable arrayReturn valueOperand stackReference to runtime constant pool for class of the current method
Some things to note here:In case the method is not static then this is passed as the first argument implicitly.The JVM is a stack-based virtual machine.
A compiled class file consists of the following structure:ClassFile{ u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_infocontant_pool[constant_pool_count – 1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; }
Objects that are logically considered as part of the JVM mechanics are not created on the Heap.The non-heap memory includes:Permanent Generation that contains the method area and interned stringsCode Cache used for compilation and storage of methods that have been compiled to native code by the JIT compilerThe method area stores per-class information such as:Class Loader ReferenceRun Time Constant PoolNumeric constantsField referencesMethod ReferencesAttributesField data(per field)NameTypeModifiersAttributesMethod data (per method)NameReturn TypeParameter Types (in order)ModifiersAttributesMethod code(Per method)BytecodesOperand stack sizeLocal variable sizeLocal variable tableException table (per exception handler - start point, end point,PC offset for handler code, constant pool index for exception class being caught)
The Heap is used to allocate class instances and arrays at runtime. Arrays and objects can never be stored on the stack because a frame is not designed to change in size after it has been created. The frame only stores references that point to objects or arrays on the heap. Unlike primitive variables and references in the local variable array (in each frame) objects are always stored on the heap so they are not removed when a method ends. Instead objects are only removed by the garbage collector.To support garbage collection the heap is divided into three sections:Young Generation - Often split between Eden and SurvivorOld Generation (also called Tenured Generation)Permanent GenerationObjects and Arrays are never explicitly de-allocated instead the garbage collector automatically reclaims them.Typically this works as follows:1) New objects and arrays are created into the young generation2) Minor garbage collection will operate in the young generation. Objects, that are still alive, will be moved from the eden space to the survivor space.3) Major garbage collection, which typically causes the application threads to pause, will move objects between generations. Objects, that are still alive, will be moved from the young generation to the old (tenured) generation.4) The permanent generation is collected every time the old generation is collected. They are both collected when either becomes full.mark word - The first word of every object header. Usually a set of bitfields including synchronization state and identity hash code. May also be a pointer (with characteristic low bit encoding) to synchronization related information. During GC, may contain GC state bits.klass pointer - The second word of every object header. Points to another object (a metaobject) which describes the layout and behavior of the original object. For Java objects, the "klass" contains a C++ style "vtable".Note that both Java objects and VM-internal objects have a common object header format.The Young GenerationThe young generation must support fast allocation, but we expect most of those objects to become unreachable fairly quickly. We would like not to have to expend any effort on the unreachable objects, since there are so many of them. So when our young generations need to be collected, we identify the lreachable objects in them and copy them out of the young generation. Once we've copied out the reachable objects, the objects remaining in the young generation are unreachable, and the space for them can be recovered without attention to each individual unreachable object. This operation of copying the reachable objects out of a generation we call “scavenging”, so we often refer to our young generation collectors as “scavengers”. An advantage of scavenging is that it is fast. A disadvantage is that it requires room of a second copy of all the reachable objects from the scavenged generation.The Old GenerationOnce objects have been scavenged out of the young generation we expect them to remain reachable for at least a while, and to reference and be referenced by other objects that remain reachable. To collect the space in the old generation we need algorithms that can't depend on high density of unreachable objects. In particular we can't count on having enough space to scavenge such objects somewhere else. Copying objects in the old generation can be expensive, both because one has to move the objects, and because one has to update all the references to the object to point to the new location of the object. On the other hand, copying objects means that one can accumulate the recovered space into one large region, from which allocation is faster (which speeds up scavenging of the young generation), and allows us to return excess storage to the operating system, which is polite.The Permanent GenerationIn addition to the objects created by the Java application, there are objects created and used by the HotSpot virtual machine whose storage it is convenient to have allocated and recovered by the storage manager. To avoid confusing things, such objects are allocated in a separate generation, the so-called “permanent” generation. In fact, the objects in it are not “permanent”, but that's what it has been called historically. For example, information about loaded classes is stored in the permanent generation, and recovered when those classes are no longer reachable from the application.Garbage collectors: concurrent: the ability to work while application threads are still running parallel: the ability to do work across multiple thread of execution=> collectors can be parallel but not concurrent;concurrent but not parallel or both concurrent and parallelSafepointing:at a safepoints threads cannot modify the Java heap or stackused to support GC, deoptimization, Java thread suspension, JVM Tool Interface operations (e.g. heap dumps)works by polling (VM thread poisons/un-poisons polling page and threads poll for a safepoint)
note 1: 'klass' is the Hotspot term for class metadata addressnote 2: array instances share the same 'klass' hierarchy (instead of fields have a field denoting the 'size' of the array and an array of itemsKlass (or Klass word):pointer to the metadata of the object’s classvtable of the methods of the classconstant vtable offset for methods
When object is locked, mark word copied into lock record in frame on thread stack. Lock records track objects locked by currently executing methods.Walk thread stack to find thread's locked objects.The monitor address is the address of the object's wait queue.
The bytecode is first interpreted while the JIT is translating it in the background. Once the JIT compilation is complete, the JVM switches to using that code instead of the interpreter.
The bytecode is first interpreted while the JIT is translating it in the background. Once the JIT compilation is complete, the JVM switches to using that code instead of the interpreter.
The bytecode is first interpreted while the JIT is translating it in the background. Once the JIT compilation is complete, the JVM switches to using that code instead of the interpreter.
The bytecode is first interpreted while the JIT is translating it in the background. Once the JIT compilation is complete, the JVM switches to using that code instead of the interpreter.
JNI_CreateJavaVMThe JNI invocation method performs, the following:Ensures that no two threads call this method at the same time and that no two VM instances are created in the same process. Noting that a VM cannot be created in the same process space once a point in initialization is reached, “point of no return”. This is so because the VM creates static data structures that cannot be re-initialized, at this time.Checks to make sure the JNI version is supported, and the ostream is initialized for gc logging. The OS modules are initialized such as the random number generator, the current pid, high-resolution time, memory page sizes, and the guard pages.The arguments and properties passed in are parsed and stored away for later use. The standard java system properties are initialized.The OS modules are further created and initialized, based on the parsed arguments and properties, are initialized for synchronization, stack, memory, and safepoint pages. At this time other libraries such as libzip, libhpi, libjava, libthread are loaded, signal handlers are initialized and set, and the thread library is initialized.The output stream logger is initialized. Any agent libraries (hprof, jdi) required are initialized and started.The thread states and the thread local storage (TLS), which holds several thread specific data required for the operation of threads, are initialized.The global data is initialized as part of the I phase, such as event log, OS synchronization primitives, perfMemory (performance memory), chunkPool (memory allocator).At this point, we can create Threads. The Java version of the main thread is created and attached to the current OS thread. However this thread will not be yet added to the known list of the Threads. The Java level synchronization is initialized and enabled.The rest of the global modules are initialized such as theBootClassLoader, CodeCache, Interpreter, Compiler, JNI, SystemDictionary, and Universe. Noting that, we have reached our “point of no return”, ie. We can no longer create another VM in the same process address space.The main thread is added to the list, by first locking the Thread_Lock. The Universe, a set of required global data structures, is sanity checked. The VMThread, which performs all the VM's critical functions, is created. At this point the appropriate JVMTI events are posted to notify the current state.The following classes java.lang.String, java.lang.System,java.lang.Thread, java.lang.ThreadGroup,java.lang.reflect.Method, java.lang.ref.Finalizer,java.lang.Class, and the rest of the System classes, are loaded and initialized. At this point, the VM is initialized and operational, but not yet fully functional.The Signal Handler thread is started, the compilers are initialized and the CompileBroker thread is started. The other helper threads StatSampler and WatcherThreads are started, at this time the VM is fully functional, the JNIEnv is populated and returned to the caller, and the VM is ready to service new JNI requests.
DestroyJavaVMThis method can be called from the launcher to tear down the VM, it can also be called by the VM itself when a very serious error occurs.The tear down of the VM takes the following steps:Wait until we are the last non-daemon thread to execute, noting that the VM is still functional.Call java.lang.Shutdown.shutdown(), which will invoke Java level shutdown hooks, run finalizers if finalization-on-exit.Call before_exit(), prepare for VM exit run VM level shutdown hooks (they are registered through JVM_OnExit()), stop the Profiler,StatSampler, Watcher and GC threads. Post the status events to JVMTI/PI, disable JVMPI, and stop the Signal thread.Call JavaThread::exit(), to release JNI handle blocks, remove stack guard pages, and remove this thread from Threads list. From this point on we cannot execute any more Java code.Stop VM thread, it will bring the remaining VM to a safepoint and stop the compiler threads. At a safepoint, care should that we should not use anything that could get blocked by a Safepoint.Disable tracing at JNI/JVM/JVMPI barriers.Set _vm_exited flag for threads that are still running native code.Delete this thread.Call exit_globals(), which deletes IO and PerfMemoryresources.Return to caller.