SlideShare a Scribd company logo
1 of 48
Download to read offline
1
What’s New in HotSpot JVM 8
Vladimir Ivanov
HotSpot JVM Compiler team
Oracle Corp.
2
What’s New in HotSpot JVM 8
§  Java 8 features support
–  Project Lambda, Nashorn, Type annotations
§  Oracle implementation-specific improvements
–  won’t be backported into 7
§  PermGen removal
–  will be/already backported into 7
§  numerous functional & performance enhancements
Categorization
3
4
Project Lambda
x -> x+1
(s,i) -> s.substring(0,i)
() -> System.out.print(“x”)
Predicate<String> pred = s -> s.length() < 100;
Lambda expressions in Java
5
Project Lambda
Function<Integer,Integer> f = x -> x+1
compiles to
invokedynamic [ j.l.i.LambdaMetafactory.metafactory,
MethodType(Function.apply),
MethodHandle(lambda$0) ] ()
Lambda expressions in Java
6
Project Lambda
interface I {
default void m() { /* do smth */ }
}
class T implements I {}
invokevirtual T.m()V => ?
Default methods
interface I
void m() {…}
class T
7
Project Lambda
interface I {
default void m() { /* do smth */ }
}
class T implements I {
void m() { /* do smth */ }
}
invokevirtual T.m()V => ?
Default methods
interface I
void m() {…}
class T
void m() {…}
8
Project Lambda
interface I {
default void m() { /* do smth */ }
}
class T1 implements I {
void m() { /* do smth */ }
}
class T extends T1 implements I {}
invokevirtual T.m()V => ?
Superclass overrides superinterface
interface I
void m() {…}
class T
class T1
void m() {…}
9
Project Lambda
interface I {
default void m() { /* do smth */ }
}
interface J extends I {
default void m() { /* do smth */ }
}
class T implements I,J {}
invokevirtual T.m()V => ?
Prefer most specific interface
interface J
void m() {…}
class T
class I
void m() {…}
10
Project Lambda
interface I {
default void m() { /* do smth */ }
}
interface J {
default void m() { /* do smth */ }
}
class T implements I,J {}
invokevirtual T.m()V => ?
Conflicting defaults
interface J
void m() {…}
class T
class I
void m() {…}
11
Project Lambda
interface I {
static void m() { /* do smth */ }
}
invokestatic I.m();
Static interface methods
12
Project Lambda
interface I {
private ... void m() { /* do smth */ }
}
Not allowed in Java.
Only on bytecode level.
Private interface methods
13
Project Lambda
class A { A get() {} }
class B extends A { B get() {} }
Javac adds the following:
synthetic bridge A get() { return ((B)this).get(); }
Bridge methods: Covariant overrides
14
Project Lambda
§  Attempted to:
–  use invokedynamic
–  generate bridges by VM
§  Finally:
–  continue to generate bridge methods by javac
Bridge methods: roads not taken
15
16
java.lang.OutOfMemoryError: PermGen space
17
What was “PermGen”?
§  “Permanent” Generation
§  Region of Java heap for JVM Class Metadata
§  Representation of Java classes
–  Class hierarchy information, fields, names
–  Method compilation information and bytecodes
–  Vtables
–  Constant pool and symbolic resolution
–  Interned strings (moved out of PermGen in 7)
18
Java Memory Layout with PermGen
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.6
Java Memory Layout with PermGen
Eden
Old Generation for older objects
Permanent Generation for VM metadata
Survivor Survivor
19
Where did JVM Metadata go?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.9
Where did JVM Metadata go?
Eden
Old Generation for older objects
Permanent Generation for VM metadata
Survivor Survivor
Metaspace
VM
Metadata in
native
memory
20
PermGen size
§  Limited to MaxPermSize – default ~64M - 85M
§  Contiguous with Java Heap
–  Identifying young references from old gen and permgen would be more
expensive and complicated with a non-contiguous heap – card table
§  Once exhausted throws OutOfMemoryError “PermGen space”
–  Application could clear references to cause class unloading
–  Restart with larger MaxPermSize
§  Hard to predict
–  Size needed depends on number of classes, size of methods, size of
constant pools, etc
21
Why was PermGen Eliminated?
§  Fixed size at startup – applications ran out
–  -XX:MaxPermSize=… was hard to size
§  Improve GC performance
–  Special iterators for metadata
–  Deallocate class data concurrently and not during GC pause
§  Enable future improvements
–  were limited by PermGen (e.g. G1 concurrent class unloading)
22
Improving GC Performance
§  During full collection, metadata to metadata pointers are not scanned
–  A lot of complex code (particularly for CMS) for metadata scanning was
removed
§  Metaspace contains few pointers into the Java heap
–  Pointer to java/lang/Class instance in class metadata
–  A component java/lang/Class pointer in array class metadata
§  No compaction costs for metadata
23
Metaspace
§  Take advantage of Java Language Specification property
–  Class metadata lifetime same as their class loader’s
§  Per loader storage area – Metaspace (collectively called Metaspace)
–  Linear (bump) allocation only
–  No individual reclamation (except for RedefineClasses and class loading
failure)
–  Not scanned by GC and not compacted
–  Metaspace-allocated objects never relocate
–  Reclamation en-masse when class loader found dead by GC
24
Metaspace Allocation
§  Multiple mmap/VirtualAlloc virtual memory spaces
§  Allocate per-class loader chunk lists
–  Chunk sizes depend on type of class loader
–  Smaller chunks for sun/reflect/DelegatingClassLoader,
JSR292 anonymous classes
§  Return chunks to free chunk lists
§  Virtual memory spaces returned when emptied
§  Strategies to minimize fragmentation
25
Metaspace Allocation
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.12
Metaspace Allocation
● Metachunks in virtual spaces (vs1, vs2, vs3...)
Boot CL
CL 3
CL 1
CL 2
vs1 vs3vs2
§  Metachunks in virtual spaces (vs1, vs2, vs3...)
26
Java Object Memory Layout
class Message {
String text;
void add(String s) { ...}
…
}
Java Heap Layout
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.13
Java Object Memory Layout
class Message {
// JVM adds _mark and
//_klass pointer
String text;
void add(String s) { …}
String get() { … }
}
Java Heap Layout
_mark
_klass
text
_mark
_klass
count
value
Metaspace
Klass
Klass
27
Java Object Memory Layout
class Message {
String text;
void add(String s) { ...}
…
}
with compressed class pointers
Java Heap Layout
28
How to tune Metaspace?
§  -XX:MaxMetaspaceSize={unlimited}
§  Limit the memory used by class metadata before excess swapping and
native allocation failure occurs
–  Use if suspected class loader memory leaks
–  Use if on 32-bit
29
How to tune Metaspace?
§  -XX:MetaspaceSize={21M}
§  Set to a higher limit if application loads more
§  Possibly use same value set by PermSize to delay initial GC
§  High water mark increases with subsequent collections for a
reasonable amount of head room before next Metaspace GC
30
How to tune Metaspace?
§  -XX:CompressedClassSpaceSize={1G}
§  Only valid if -XX:+UseCompressedClassPointers (default on 64 bit)
§  Not committed until used
31
Metaspace Monitoring and Management
§  MemoryManagerMXBean with name MetaspaceManager
§  MemoryPoolMXBeans
–  “Metaspace”
–  “Compressed Class Space”
§  $ jmap -clstats <pid>
§  $ jstat -gc <pid>
§  $ jcmd <pid> GC.class_stats
§  Java Mission Control (bundled with Oracle JDK 8)
32
PermGen removal
§  Hotspot metadata is now allocated in Metaspace
–  Chunks in mmap spaces based on liveness of class loader
§  Compressed class pointer space is still fixed size but large
§  Tuning flags available but not required
§  Change enables other optimizations and features in the future
–  Application class data sharing
–  Young collection optimizations, G1 class unloading
–  Metadata size reductions and internal JVM footprint projects
Summary
33
Nashorn
JavaScript engine for Java Platform
34
Nashorn
§  Nashorn is written completely in Java
§  Extensively uses JSR292
§  Required numerous performance improvements
–  LambdaForms (JEP 160)
–  incremental inlining
–  exact math intrinsics
§  Math.addExact, Math.substractExact, etc
–  improved type profiling & type speculation
JVM support for dynamic languages
35
JVM support for dynamic languages
public static long addExact(long x, long y) {
long r = x + y;
if (((x ^ r) & (y ^ r)) < 0) {
throw new ArithmeticException("long overflow");
}
return r;
}
Exact Math intrinsics
36
JVM support for dynamic languages
Math.addExact(l1, Integer.MAX_VALUE)
Compiled version:
0x0...5d: add $0x7fffffff,%r8
0x0...64: mov %r8,%r9
0x0...67: xor %r11,%r9
0x0...6a: mov %r8,%r11
0x0...6d: xor $0x7fffffff,%r11
0x0...74: and %r11,%r9
0x0...77: test %r9,%r9
0x0...7a: jl 0x0000000102c70e95 // slow path: throw exception
Exact Math intrinsics
37
JVM support for dynamic languages
Math.addExact(l1, Integer.MAX_VALUE)
Intrinsified version:
0x…1d: add $0x7fffffff,%rax
0x…24: jo 0x000000010c044b3f // slow path: overflow
Exact Math intrinsics
38
Smaller features
§  JSR 308: Annotations on Java Types
–  new class file attributes
§  JEP 171: Fence Intrinsics
–  sun.misc.Unsafe: loadFence, storeFence & fullFence
§  JEP 136: Enhanced Verification Errors
–  VerifyError with detailed error message
§  JEP 142: Reduce Cache Contention on Specified Fields
–  @Contended
39
JSR 308: Annotations on Java Types
Map<@Interned Key, @NonNull Value> = new HashMap<>();
40
JSR 308: Annotations on Java Types
§  New attributes:
–  RuntimeVisibleTypeAnnotations
–  RuntimeInvisibleTypeAnnotations
§  Stored on the smallest enclosing class, field, method, or Code
§  How to access:
–  javax.lang.model
–  javax.ide
–  com.sun.source.tree
Class File Attributes
41
JEP 171: Fence Intrinsics
§  How to express memory model:
–  happens-before relations
–  memory barriers/fences
§  Happens-before in Java Memory Model (JMM)
§  sun.misc.Unsafe.[load|store|full]Fence introduces memory barriers
§  Why:
–  some relations aren’t possible to express in JMM at the moment
§  consider StoreStore
42
JEP 142: Reduce Cache Contention on …
§  What is cache contention and false
sharing?
–  adjacent memory accesses can produce
unnecessary memory traffic on
SMP systems
43
JEP 142: Reduce Cache Contention on …
§  How to avoid it?
–  manually “pad” contended fields
public class A {
int x;
int i01, i02, …, i16;
int y;
int i17, i18, …, i32;
}
44
JEP 142: Reduce Cache Contention on …
§  How to avoid it?
–  mark them @Contended
public class A {
int x;
@Contended int y;
}
45
JEP 142: Reduce Cache Contention on …
§  sun.misc.Contended
§  How to use: -XX:-RestrictContended
–  by default, has effect only in privileged context (on boot class path)
46
JEP 136: Enhanced Verification Errors
Before
Exception in thread "main" java.lang.VerifyError:
Bad instruction in method Test.main([Ljava/lang/String;)V at offset 0
47
JEP 136: Enhanced Verification Errors
Now
Exception in thread "main" java.lang.VerifyError: Bad instruction
Exception Details:
Location:
Test.main([Ljava/lang/String;)V @0: <illegal>
Reason:
Error exists in the bytecode
Bytecode:
0000000: ff00 0200 004c 2b04 b800 03b9 0004 0200
0000010: 57b1
48
Graphic Section Divider

More Related Content

What's hot

Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlLeon Chen
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunningguest1f2740
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Applicationguest1f2740
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderIsuru Perera
 
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotВладимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotVolha Banadyseva
 
Towards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainTowards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainAttila Szegedi
 
Introduction to Real Time Java
Introduction to Real Time JavaIntroduction to Real Time Java
Introduction to Real Time JavaDeniz Oguz
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoringSimon Ritter
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020Joseph Kuo
 
Tiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVMTiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVMIgor Veresov
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Dinakar Guniguntala
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924yohanbeschi
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvmPrem Kuppumani
 
Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016aragozin
 

What's hot (20)

Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission Control
 
JVM Internals (2015)
JVM Internals (2015)JVM Internals (2015)
JVM Internals (2015)
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Application
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight Recorder
 
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotВладимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
 
Towards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainTowards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages Toolchain
 
Introduction to Real Time Java
Introduction to Real Time JavaIntroduction to Real Time Java
Introduction to Real Time Java
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoring
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020
 
Tiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVMTiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVM
 
JVM++: The Graal VM
JVM++: The Graal VMJVM++: The Graal VM
JVM++: The Graal VM
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
 
Java GC, Off-heap workshop
Java GC, Off-heap workshopJava GC, Off-heap workshop
Java GC, Off-heap workshop
 
Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016
 

Similar to "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia

Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New FeaturesNaveen Hegde
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
7 jvm-arguments-v1
7 jvm-arguments-v17 jvm-arguments-v1
7 jvm-arguments-v1Tier1 app
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHoward Lewis Ship
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance TunningTerry Cho
 
JavaScript code academy - introduction
JavaScript code academy - introductionJavaScript code academy - introduction
JavaScript code academy - introductionJaroslav Kubíček
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationAjax Experience 2009
 
7 jvm-arguments-Confoo
7 jvm-arguments-Confoo7 jvm-arguments-Confoo
7 jvm-arguments-ConfooTier1 app
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 itiAhmed mar3y
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeOmar Bashir
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeFederico Tomassetti
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Petr Zapletal
 

Similar to "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia (20)

Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
7 jvm-arguments-v1
7 jvm-arguments-v17 jvm-arguments-v1
7 jvm-arguments-v1
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
JavaScript code academy - introduction
JavaScript code academy - introductionJavaScript code academy - introduction
JavaScript code academy - introduction
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
 
7 jvm-arguments-Confoo
7 jvm-arguments-Confoo7 jvm-arguments-Confoo
7 jvm-arguments-Confoo
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
 
Java 7 & 8 - A&BP CC
Java 7 & 8 - A&BP CCJava 7 & 8 - A&BP CC
Java 7 & 8 - A&BP CC
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java code
 
Full Stack Scala
Full Stack ScalaFull Stack Scala
Full Stack Scala
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018
 
Java
JavaJava
Java
 

More from Vladimir Ivanov

"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,..."Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...Vladimir Ivanov
 
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine "Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine Vladimir Ivanov
 
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013Vladimir Ivanov
 
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012Vladimir Ivanov
 
Управление памятью в Java: Footprint
Управление памятью в Java: FootprintУправление памятью в Java: Footprint
Управление памятью в Java: FootprintVladimir Ivanov
 
Многоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVMМногоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVMVladimir Ivanov
 
G1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage CollectorG1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage CollectorVladimir Ivanov
 
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)Vladimir Ivanov
 

More from Vladimir Ivanov (8)

"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,..."Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
 
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine "Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
 
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
 
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
 
Управление памятью в Java: Footprint
Управление памятью в Java: FootprintУправление памятью в Java: Footprint
Управление памятью в Java: Footprint
 
Многоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVMМногоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVM
 
G1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage CollectorG1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage Collector
 
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
 

Recently uploaded

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Recently uploaded (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia

  • 1. 1 What’s New in HotSpot JVM 8 Vladimir Ivanov HotSpot JVM Compiler team Oracle Corp.
  • 2. 2 What’s New in HotSpot JVM 8 §  Java 8 features support –  Project Lambda, Nashorn, Type annotations §  Oracle implementation-specific improvements –  won’t be backported into 7 §  PermGen removal –  will be/already backported into 7 §  numerous functional & performance enhancements Categorization
  • 3. 3
  • 4. 4 Project Lambda x -> x+1 (s,i) -> s.substring(0,i) () -> System.out.print(“x”) Predicate<String> pred = s -> s.length() < 100; Lambda expressions in Java
  • 5. 5 Project Lambda Function<Integer,Integer> f = x -> x+1 compiles to invokedynamic [ j.l.i.LambdaMetafactory.metafactory, MethodType(Function.apply), MethodHandle(lambda$0) ] () Lambda expressions in Java
  • 6. 6 Project Lambda interface I { default void m() { /* do smth */ } } class T implements I {} invokevirtual T.m()V => ? Default methods interface I void m() {…} class T
  • 7. 7 Project Lambda interface I { default void m() { /* do smth */ } } class T implements I { void m() { /* do smth */ } } invokevirtual T.m()V => ? Default methods interface I void m() {…} class T void m() {…}
  • 8. 8 Project Lambda interface I { default void m() { /* do smth */ } } class T1 implements I { void m() { /* do smth */ } } class T extends T1 implements I {} invokevirtual T.m()V => ? Superclass overrides superinterface interface I void m() {…} class T class T1 void m() {…}
  • 9. 9 Project Lambda interface I { default void m() { /* do smth */ } } interface J extends I { default void m() { /* do smth */ } } class T implements I,J {} invokevirtual T.m()V => ? Prefer most specific interface interface J void m() {…} class T class I void m() {…}
  • 10. 10 Project Lambda interface I { default void m() { /* do smth */ } } interface J { default void m() { /* do smth */ } } class T implements I,J {} invokevirtual T.m()V => ? Conflicting defaults interface J void m() {…} class T class I void m() {…}
  • 11. 11 Project Lambda interface I { static void m() { /* do smth */ } } invokestatic I.m(); Static interface methods
  • 12. 12 Project Lambda interface I { private ... void m() { /* do smth */ } } Not allowed in Java. Only on bytecode level. Private interface methods
  • 13. 13 Project Lambda class A { A get() {} } class B extends A { B get() {} } Javac adds the following: synthetic bridge A get() { return ((B)this).get(); } Bridge methods: Covariant overrides
  • 14. 14 Project Lambda §  Attempted to: –  use invokedynamic –  generate bridges by VM §  Finally: –  continue to generate bridge methods by javac Bridge methods: roads not taken
  • 15. 15
  • 17. 17 What was “PermGen”? §  “Permanent” Generation §  Region of Java heap for JVM Class Metadata §  Representation of Java classes –  Class hierarchy information, fields, names –  Method compilation information and bytecodes –  Vtables –  Constant pool and symbolic resolution –  Interned strings (moved out of PermGen in 7)
  • 18. 18 Java Memory Layout with PermGen Copyright © 2013, Oracle and/or its affiliates. All rights reserved.6 Java Memory Layout with PermGen Eden Old Generation for older objects Permanent Generation for VM metadata Survivor Survivor
  • 19. 19 Where did JVM Metadata go? Copyright © 2013, Oracle and/or its affiliates. All rights reserved.9 Where did JVM Metadata go? Eden Old Generation for older objects Permanent Generation for VM metadata Survivor Survivor Metaspace VM Metadata in native memory
  • 20. 20 PermGen size §  Limited to MaxPermSize – default ~64M - 85M §  Contiguous with Java Heap –  Identifying young references from old gen and permgen would be more expensive and complicated with a non-contiguous heap – card table §  Once exhausted throws OutOfMemoryError “PermGen space” –  Application could clear references to cause class unloading –  Restart with larger MaxPermSize §  Hard to predict –  Size needed depends on number of classes, size of methods, size of constant pools, etc
  • 21. 21 Why was PermGen Eliminated? §  Fixed size at startup – applications ran out –  -XX:MaxPermSize=… was hard to size §  Improve GC performance –  Special iterators for metadata –  Deallocate class data concurrently and not during GC pause §  Enable future improvements –  were limited by PermGen (e.g. G1 concurrent class unloading)
  • 22. 22 Improving GC Performance §  During full collection, metadata to metadata pointers are not scanned –  A lot of complex code (particularly for CMS) for metadata scanning was removed §  Metaspace contains few pointers into the Java heap –  Pointer to java/lang/Class instance in class metadata –  A component java/lang/Class pointer in array class metadata §  No compaction costs for metadata
  • 23. 23 Metaspace §  Take advantage of Java Language Specification property –  Class metadata lifetime same as their class loader’s §  Per loader storage area – Metaspace (collectively called Metaspace) –  Linear (bump) allocation only –  No individual reclamation (except for RedefineClasses and class loading failure) –  Not scanned by GC and not compacted –  Metaspace-allocated objects never relocate –  Reclamation en-masse when class loader found dead by GC
  • 24. 24 Metaspace Allocation §  Multiple mmap/VirtualAlloc virtual memory spaces §  Allocate per-class loader chunk lists –  Chunk sizes depend on type of class loader –  Smaller chunks for sun/reflect/DelegatingClassLoader, JSR292 anonymous classes §  Return chunks to free chunk lists §  Virtual memory spaces returned when emptied §  Strategies to minimize fragmentation
  • 25. 25 Metaspace Allocation Copyright © 2013, Oracle and/or its affiliates. All rights reserved.12 Metaspace Allocation ● Metachunks in virtual spaces (vs1, vs2, vs3...) Boot CL CL 3 CL 1 CL 2 vs1 vs3vs2 §  Metachunks in virtual spaces (vs1, vs2, vs3...)
  • 26. 26 Java Object Memory Layout class Message { String text; void add(String s) { ...} … } Java Heap Layout Copyright © 2013, Oracle and/or its affiliates. All rights reserved.13 Java Object Memory Layout class Message { // JVM adds _mark and //_klass pointer String text; void add(String s) { …} String get() { … } } Java Heap Layout _mark _klass text _mark _klass count value Metaspace Klass Klass
  • 27. 27 Java Object Memory Layout class Message { String text; void add(String s) { ...} … } with compressed class pointers Java Heap Layout
  • 28. 28 How to tune Metaspace? §  -XX:MaxMetaspaceSize={unlimited} §  Limit the memory used by class metadata before excess swapping and native allocation failure occurs –  Use if suspected class loader memory leaks –  Use if on 32-bit
  • 29. 29 How to tune Metaspace? §  -XX:MetaspaceSize={21M} §  Set to a higher limit if application loads more §  Possibly use same value set by PermSize to delay initial GC §  High water mark increases with subsequent collections for a reasonable amount of head room before next Metaspace GC
  • 30. 30 How to tune Metaspace? §  -XX:CompressedClassSpaceSize={1G} §  Only valid if -XX:+UseCompressedClassPointers (default on 64 bit) §  Not committed until used
  • 31. 31 Metaspace Monitoring and Management §  MemoryManagerMXBean with name MetaspaceManager §  MemoryPoolMXBeans –  “Metaspace” –  “Compressed Class Space” §  $ jmap -clstats <pid> §  $ jstat -gc <pid> §  $ jcmd <pid> GC.class_stats §  Java Mission Control (bundled with Oracle JDK 8)
  • 32. 32 PermGen removal §  Hotspot metadata is now allocated in Metaspace –  Chunks in mmap spaces based on liveness of class loader §  Compressed class pointer space is still fixed size but large §  Tuning flags available but not required §  Change enables other optimizations and features in the future –  Application class data sharing –  Young collection optimizations, G1 class unloading –  Metadata size reductions and internal JVM footprint projects Summary
  • 34. 34 Nashorn §  Nashorn is written completely in Java §  Extensively uses JSR292 §  Required numerous performance improvements –  LambdaForms (JEP 160) –  incremental inlining –  exact math intrinsics §  Math.addExact, Math.substractExact, etc –  improved type profiling & type speculation JVM support for dynamic languages
  • 35. 35 JVM support for dynamic languages public static long addExact(long x, long y) { long r = x + y; if (((x ^ r) & (y ^ r)) < 0) { throw new ArithmeticException("long overflow"); } return r; } Exact Math intrinsics
  • 36. 36 JVM support for dynamic languages Math.addExact(l1, Integer.MAX_VALUE) Compiled version: 0x0...5d: add $0x7fffffff,%r8 0x0...64: mov %r8,%r9 0x0...67: xor %r11,%r9 0x0...6a: mov %r8,%r11 0x0...6d: xor $0x7fffffff,%r11 0x0...74: and %r11,%r9 0x0...77: test %r9,%r9 0x0...7a: jl 0x0000000102c70e95 // slow path: throw exception Exact Math intrinsics
  • 37. 37 JVM support for dynamic languages Math.addExact(l1, Integer.MAX_VALUE) Intrinsified version: 0x…1d: add $0x7fffffff,%rax 0x…24: jo 0x000000010c044b3f // slow path: overflow Exact Math intrinsics
  • 38. 38 Smaller features §  JSR 308: Annotations on Java Types –  new class file attributes §  JEP 171: Fence Intrinsics –  sun.misc.Unsafe: loadFence, storeFence & fullFence §  JEP 136: Enhanced Verification Errors –  VerifyError with detailed error message §  JEP 142: Reduce Cache Contention on Specified Fields –  @Contended
  • 39. 39 JSR 308: Annotations on Java Types Map<@Interned Key, @NonNull Value> = new HashMap<>();
  • 40. 40 JSR 308: Annotations on Java Types §  New attributes: –  RuntimeVisibleTypeAnnotations –  RuntimeInvisibleTypeAnnotations §  Stored on the smallest enclosing class, field, method, or Code §  How to access: –  javax.lang.model –  javax.ide –  com.sun.source.tree Class File Attributes
  • 41. 41 JEP 171: Fence Intrinsics §  How to express memory model: –  happens-before relations –  memory barriers/fences §  Happens-before in Java Memory Model (JMM) §  sun.misc.Unsafe.[load|store|full]Fence introduces memory barriers §  Why: –  some relations aren’t possible to express in JMM at the moment §  consider StoreStore
  • 42. 42 JEP 142: Reduce Cache Contention on … §  What is cache contention and false sharing? –  adjacent memory accesses can produce unnecessary memory traffic on SMP systems
  • 43. 43 JEP 142: Reduce Cache Contention on … §  How to avoid it? –  manually “pad” contended fields public class A { int x; int i01, i02, …, i16; int y; int i17, i18, …, i32; }
  • 44. 44 JEP 142: Reduce Cache Contention on … §  How to avoid it? –  mark them @Contended public class A { int x; @Contended int y; }
  • 45. 45 JEP 142: Reduce Cache Contention on … §  sun.misc.Contended §  How to use: -XX:-RestrictContended –  by default, has effect only in privileged context (on boot class path)
  • 46. 46 JEP 136: Enhanced Verification Errors Before Exception in thread "main" java.lang.VerifyError: Bad instruction in method Test.main([Ljava/lang/String;)V at offset 0
  • 47. 47 JEP 136: Enhanced Verification Errors Now Exception in thread "main" java.lang.VerifyError: Bad instruction Exception Details: Location: Test.main([Ljava/lang/String;)V @0: <illegal> Reason: Error exists in the bytecode Bytecode: 0000000: ff00 0200 004c 2b04 b800 03b9 0004 0200 0000010: 57b1