SlideShare a Scribd company logo
1 of 39
Download to read offline
Lifecycle of a JIT compiled code
Ivan Krylov
Azul Systems
2 Ivan Krylov
Is this the right talk?
• JVM Internals and Performance Talk:
• General Interest
• Got a performance critical app
• You have a reproducible case
• Have a way to collect JVM logs
3
Scope and Agenda
• Code flow inside JVM
• Profiles that JVM collects
• Deoptimization
• Four ways to control compilation
4
Ivan Krylov
Code Pipeline in JVM
5
Sources
in .java
Bytecodes
Machine
code from
the
Interpreter
Machine code
from a
compiler
Javac

1) Static verification

2) Compilation with near-0 opts
Runtime

1) Dynamic verification

2) Linking
One of N compilers

Governed by runtime


next tierdeoptimization
live

profile data
JAOT in JDK9

• Bytecodes coming not from javac

• Any JVM language; jasm-like tools; Byte Buddy
• May be no interpreter

• JRockit VM
• May be only interpreter

• Zero-port or -Xint
• May be a pure AOT (no bytecodes, no JIT)

• Pure AOT can’t implement the entire Java SE standard

• Hence a hybrid approach : Excelsior JET, Graal-based AOT (in works)
Everything can be different
6
Template Interpreter - a tier 0 compiler
• Machine code creation

• From asm(masm) templates

• Populated with addresses in VM

• Generated at start-up
• Maintains invocation and Back branch C-rs
• Mixed native/java stack frame
• All bytescodes in a single blob with GoTo-s
7
Template Interpreter - ladd example
8
0x000000010a59a920: mov (%rsp),%rax
0x000000010a59a924: add $0x10,%rsp
0x000000010a59a928: mov (%rsp),%rdx
0x000000010a59a92c: add $0x10,%rsp
0x000000010a59a930: add %rdx,%rax
0 0x000000010a590933: movzbl 0x1(%r13),%ebx
0x000000010a59a938: inc %r13
0x000000010a59a93b: movabs $0x10a0f6600,%r10
0x000000010a59a945: jmpq *(%r10,%rbx,8)
Entry if %RAX
doesn’t contain
first operand
Entry otherwise
Read next
bytecode

& dispatch
№1
№2
return value
bytecode cntr next bytecode
method start
0x000000010a0f6600:
What is a profile ?
• It is all about counters
• Inaccurate but indicative
• If overflows - stays at 

saturated level
• Some counters with properties
• Actual types observed, etc..
9
https://www.flickr.com/photos/icemanphoto/1739731523
Profile is.. methodCounters.hpp
• interpreter_invocation_count &
invocation_counter 

• interpreter_throwout_count 

• backedge_counter 

• number_of_breakpoints (4 dbg)

• nmethod_age

• interpreter_invocation_limit &
interpreter_backward_branch_limit

• interpreter_profile_limit

• invoke_mask

• backedge_mask

• rate & prev_time

• highest_comp_level &
highest_osr_comp_level
10
Anything else needed?
11
class A {
static List<String> list = new LinkedList<>();
static {
DateFormat dateFormat = new
SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
list.add(dateFormat.format(new Date()));
}
static List<String> getList() {
return list;
}
}
class B
{
String process(String s, int i)
{
if (i < A.list.size())
return s.concat( A.list.get(i) );
else
return s;
}
}
B.process() may 

be compiled 

only after A is initialized
A may be initialized only at first
invocation of B.process()

(If B.process() is the only user of A)
Is SimpleEnum simple?
12
public enum SimpleEnum {
One
};
>ll SimpleEnum.java
-rw-r--r-- 1 ivan staff 35 Feb 23 21:30 SimpleEnum.java
>ll SimpleEnum.class
-rw-r--r-- 1 ivan staff 732 Feb 23 21:30 SimpleEnum.class
Is SimpleEnum simple?
12
public enum SimpleEnum {
One
};
Compiled from "SimpleEnum.java"
public final class SimpleEnum extends java.lang.Enum<SimpleEnum> {
public static final SimpleEnum One;
public static SimpleEnum[] values();
Code:
0: getstatic #1 // Field $VALUES:[LSimpleEnum;
3: invokevirtual #2 // Method "[LSimpleEnum;".clone:()Ljava/lang/Object;
6: checkcast #3 // class "[LSimpleEnum;"
9: areturn
public static SimpleEnum valueOf(java.lang.String);
Code:
0: ldc #4 // class SimpleEnum
2: aload_0
3: invokestatic #5 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
6: checkcast #4 // class SimpleEnum
9: areturn
static {};
Code:
0: new #4 // class SimpleEnum
3: dup
4: ldc #7 // String One
6: iconst_0
7: invokespecial #8 // Method "<init>":(Ljava/lang/String;I)V
10: putstatic #9 // Field One:LSimpleEnum;
13: iconst_1
14: anewarray #4 // class SimpleEnum
17: dup
18: iconst_0
19: getstatic #9 // Field One:LSimpleEnum;
22: aastore
23: putstatic #1 // Field $VALUES:[LSimpleEnum;
26: return
}
2: aload_0
3: invokestatic #5 // Method java/lang/Enum.valueOf:(Ljava/lang/C
6: checkcast #4 // class SimpleEnum
9: areturn
static {};
Code:
0: new #4 // class SimpleEnum
3: dup
4: ldc #7 // String One
6: iconst_0
7: invokespecial #8 // Method "<init>":(Ljava/lang/String;I)V
10: putstatic #9 // Field One:LSimpleEnum;
13: iconst_1
14: anewarray #4 // class SimpleEnum
17: dup
18: iconst_0
19: getstatic #9 // Field One:LSimpleEnum;
22: aastore
23: putstatic #1 // Field $VALUES:[LSimpleEnum;
26: return
}
Is SimpleEnum simple?
13
public enum SimpleEnum {
One
};
The Rumor:Inlining is important
14
• Hide the costs of preparing arguments
• Hide the costs of marshaling the result
• Code is co-located (I-cache friendly)
• Makes executable smaller in some cases
• Unlocks a bunch of optimizations
• Because the scope of a compilation block is bigger
• Easy to test: disable Inlining with -XX:-Inline - and observe XX% perf loss
• -XX:+PrintInlining to see what methods’re inlined and where
Inlining that didn’t happen
15
• Inlining Callee makes a caller too big
• Inlining too deep / recursive inlining
• Callee has exception handlers? (InlineMethodsWithExceptionHandlers)
• Callee is synchronized (InlineSynchronizedMethods )
• Class of Callee is not initialized
• Callee has unbalanced monitors
• Caller has jsr bytecode (!)
}
http://cliffhacks.blogspot.ru/2008/02/java-6-tryfinally-compilation-without.html
Overrulable
Did you see tiers?
16
495 7 n 0 jdk.internal.reflect.Reflection::getCallerClass (native) (static)
495 8 b 2 java.util.Properties::getProperty (49 bytes)
497 9 b 2 java.util.concurrent.ConcurrentHashMap::get (162 bytes)
500 10 b 3 java.lang.String::hashCode (48 bytes)
503 11 b 4 java.lang.String::hashCode (48 bytes)
507 10 3 java.lang.String::hashCode (48 bytes) made not entrant
507 12 b 2 java.lang.StringLatin1::hashCode (42 bytes)
509 13 b 3 java.lang.Boolean::<clinit> (31 bytes)
510 14 b 4 java.lang.Boolean::<clinit> (31 bytes)
510 13 3 java.lang.Boolean::<clinit> (31 bytes) made not entrant
511 15 b 3 java.lang.Boolean::<init> (10 bytes)
511 16 b 4 java.lang.Boolean::<init> (10 bytes)
513 15 3 java.lang.Boolean::<init> (10 bytes) made not entrant
513 17 b 2 java.lang.Object::<init> (1 bytes)
513 18 n 0 java.lang.Class::getPrimitiveClass (native) (static)
514 19 b 3 java.lang.Boolean::parseBoolean (19 bytes)
514 20 b 4 java.lang.Boolean::parseBoolean (19 bytes)
516 19 3 java.lang.Boolean::parseBoolean (19 bytes) made not entrant
516 21 b 2 java.lang.String::isLatin1 (19 bytes)
517 22 b 2 java.lang.Integer::parseInt (259 bytes)
533 23 b 3 java.lang.Character::<clinit> (25 bytes)
4 - Full Optimisation - C2
Tiered compilation
Fastest
Slow
Mediocre
Fast
Slowest
3 - Full Profile - C1
(incl. MethodData)
2 - Limited Profile - C1

(+ invocation & backed counters)
1 - Simple Profile - C1
0 - Interpreter
17
• … Compiler does
“optimistic” (or “heroic”)
optimizations
• … Something AOT can’t
do
• & “Whole World” is not
developed at time of
compilation
Deoptimizations happen because…
18
19
Not all opts or speculative
• Constant
propagation

• Loop invariant

• …
• Bias locking

• NUMA-aware
allocation

• TSX transactions

• Uncommon trap

• …
Deterministic opts Speculative
w/fallback
Speculative
w/hard stop
• CHA invalidation

• Effectively final
fields modified

• …
Implicit code
• Mandatory operations from JVMLS
• Zeroing of Objects
• Out of boundary checks
• Divide by 0 in math
• Null Pointer protection
• Checkcasts
• ….
20
class C {
int val;
C[] kInverseVector(int k, C[] v) {
C[] result = new C[v.length];
for (int i=0; i < v.length; i++){
result[i] = new C();
result[i].val = k / v[i].val ;
}
return result;
}
}
Per bci deoptimization reasons
• Null Check (null object or div 0)

• Null Assert

• Range Check (OOB)

• Class Check (Unexpected class)

• Array Check (Unexpected array class)

• Intrinsic operand

• Bimorphic inlining failed
21
Per method deoptimization reasons
• Unloaded class

• Uninitialized class

• Unreached code

• Unhandled exception

• Unexpected Constraint 

• Div0 check

• Age (tier threshold reached)

• Predicate failed

• Loop limit check

• Speculate class check

• Speculate Null Check

• Rm state change

• Unstable if

• Reason unstable fused if
22
Uncommon trap happened. Now what?
• 1-off event?
• A change in a pattern?
• Keep old around?
• Recompile? Never compile?
• What the next invocation will be like?
23
class C {
int val;
C[] kInverseVector(int k, C[] v) {
C[] result = new C[v.length];
for (int i=0; i < v.length; i++){
result[i]=new C();
result[i].val = k / v[i].val ;
}
return result;
}
}
How to control a compiler?
24
I. Legacy CompileCommand
25
• Provided statically via

• Command line: -XX:HotspotCompile

• .hotspot_compiler or 

-XX:CompileCommandFile=/path/to/thefile
• Dynamically

• jcmd Compiler.directives_add
• Syntax: 

command package/Class methodName
• Actions: 

• dontinline or exclude or excludec2 or excludec1
exclude java/lang/Thread setPriority
dontinline java/lang/String charAt
II. Compiler Control in Java 9
26
{
// matching several patterns require an array
match: ["steve.*","alex.*"]
c2: {
Enable: false, // Ignore this directive for c2.
BreakAtExecute: true // This will not be applied since Enable is false above
}
// applies to all compilers
// + force inline, - dont inline
inline : [ "+java/util.*", "-com/sun.*"],
PrintInlining: true
}
Common Compiler Control Directives
27
• Enable
• bool Exclude
• bool Inline
• bool BreakAtExecute
• bool BreakAtCompile
• bool Log
• bool PrintAssembly
Common Compiler Control Directives
27
• Enable
• bool Exclude
• bool Inline
• bool BreakAtExecute
• bool BreakAtCompile
• bool Log
• bool PrintAssembly
• bool PrintInlining
• bool PrintNMethods
• bool ReplayInline
• bool DumpReplay
• bool DumpInline
• bool
CompilerDirectivesIgnoreCompileCommands
• bool PrintOptoAssembly
• bool PrintIntrinsics
• bool TraceOptoOutput
• bool TraceSpilling
• bool CloneMapDebug
• bool IGVPrintLevel
C2 Compiler Control Directives
28
• BlockLayoutByFrequency
• bool raceOptoPipelining
• bool Vectorize
• bool VectorizeDebug
• intx MaxNodeLimit
• intx DisableIntrinsics

III. java.lang.Compiler
29
• OpenJDK / Oracle don’t support it.
• IBM J9 supports it 

http://www.ibm.com/support/knowledgecenter/en/
SSSTCZ_2.0.0/com.ibm.rt.doc.20/realtime/rt_jit.html
• Zing has a slight different flavour

http://docs.azul.com/zing/Zing_UserGuide/
#Zing_UserGuide/
Zing_AT_ReadyNow_EnsureCriticalMethodsareCom
piled_CompilerAPI.htm

• Oracle wants to deprecate

See https://bugs.openjdk.java.net/browse/
JDK-4285505
{
Compiler.enable(); // ensure compiler is active
Compiler.command("{com.mycompany.*}(compile)");
System.out.println("Now let’s wait till compilation is done");
Compiler.command("waitOnCompilationQueue");
System.out.println("Compilation is complete");
Compiler.disable(); // turn the compiler off
}
IV. ReadyNow
30
• Between AOT and JIT 

• Designed to compile sooner than normal JIT
• “Your JIT’s yesterday’s mistakes wont hurt you today”

• Designed to deoptimize less often than normal JIT
• Works well in good “scenarios”

• Designed to never produce an invalid code
• The fallback is the normal JIT
Three requirements of ReadyNow
31
I. Profiles must be adequate
II. Profile needs to be applicable
III. All necessary types are initialized or …

1. all the ones we need for fastpath

2. can force eager initialization 

in case of no/trivial static initializers
32
Recording a profile
CT1 CT2 CT3
profile
Using a profile
33
CT1 CT2 CT3
ReadyNow
34
Bonus: JDK9 Ahead of Time Compilation
35
• Targeting Fast startup

• Can interoperate with JIT

• Only Linux x64

• Only java.base is guaranteed

• Must use the same JVM flags

• Not for dynamically generated classes

• No reflection support

• No instrumentation support
jaotc --output libjava.base.so --module java.base

jaotc --output libHelloWorld.so HelloWorld.class
java -XX:AOTLibrary=./libHelloWorld.so HelloWorld
36
• Zing: A better JVM for the enterprise
• Azul’s enterprise JVM focused on better metrics
• Consistent performance - not just fast, always fast
• Eliminate GC as a concern for enterprise apps
• Very wide operating range
• From human-sensitive app responsiveness to low-latency
trading
• From microservices to huge in-memory apps
• Eliminates an entire class of engineering workarounds common in
Java
•Zulu Embedded: When you need embedded Support
• 100% open source, based on OpenJDK
• Certified Java SE compliant and compatible
• Verified “non-contaminating” open source license
• Identical metrics to OpenJDK and Oracle Java SE
• World-class support offerings
• Support for Linux & Windows; x86, ARM32, ARM64, PPC32,
MIPS
36
Ivan Krylov www.azul.com

Azul Systems ivan @ azul.com


More Related Content

What's hot

Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeKenneth Geisshirt
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 
PHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacyPHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacyDamien Seguy
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpAll Things Open
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMMin-Yih Hsu
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Anton Arhipov
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...Nikita Lipsky
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programmingEric Polerecky
 
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Anton Arhipov
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGSylvain Wallez
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015Charles Nutter
 

What's hot (20)

Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
PHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacyPHP 7.1 : elegance of our legacy
PHP 7.1 : elegance of our legacy
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
 
effective_r27
effective_r27effective_r27
effective_r27
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVM
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
JVM
JVMJVM
JVM
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programming
 
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 

Viewers also liked

Thirty months of microservices. Stairway to heaven or highway to hell
Thirty months of microservices. Stairway to heaven or highway to hellThirty months of microservices. Stairway to heaven or highway to hell
Thirty months of microservices. Stairway to heaven or highway to hellSander Hoogendoorn
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaFrank Lyaruu
 
Beyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessonsBeyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessonsSander Hoogendoorn
 
Memory Leaks on Android
Memory Leaks on AndroidMemory Leaks on Android
Memory Leaks on AndroidOmri Erez
 
Moved to https://slidr.io/azzazzel/what-s-not-new-in-modular-java
Moved to https://slidr.io/azzazzel/what-s-not-new-in-modular-javaMoved to https://slidr.io/azzazzel/what-s-not-new-in-modular-java
Moved to https://slidr.io/azzazzel/what-s-not-new-in-modular-javaMilen Dyankov
 
Geecon Prague 2016 - Thirty months of microservices
Geecon Prague 2016 - Thirty months of microservicesGeecon Prague 2016 - Thirty months of microservices
Geecon Prague 2016 - Thirty months of microservicesSander Hoogendoorn
 
Just-in-time compiler (March, 2017)
Just-in-time compiler (March, 2017)Just-in-time compiler (March, 2017)
Just-in-time compiler (March, 2017)Rachel M. Carmena
 
Alluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed Storage
Alluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed StorageAlluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed Storage
Alluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed StorageAlluxio, Inc.
 
Intel CPU Manufacturing Process
Intel CPU Manufacturing ProcessIntel CPU Manufacturing Process
Intel CPU Manufacturing ProcessA B Shinde
 
Apache kylin 2.0: from classic olap to real-time data warehouse
Apache kylin 2.0: from classic olap to real-time data warehouseApache kylin 2.0: from classic olap to real-time data warehouse
Apache kylin 2.0: from classic olap to real-time data warehouseYang Li
 
Hoodie: Incremental processing on hadoop
Hoodie: Incremental processing on hadoopHoodie: Incremental processing on hadoop
Hoodie: Incremental processing on hadoopPrasanna Rajaperumal
 
Hdl based simulators
Hdl based simulatorsHdl based simulators
Hdl based simulatorsPrachi Pandey
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseSpeedment, Inc.
 
Open Source Memory Speed Virtual Distributed Storage
Open Source Memory Speed Virtual Distributed StorageOpen Source Memory Speed Virtual Distributed Storage
Open Source Memory Speed Virtual Distributed StorageAlluxio, Inc.
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Simon Ritter
 

Viewers also liked (20)

Thirty months of microservices. Stairway to heaven or highway to hell
Thirty months of microservices. Stairway to heaven or highway to hellThirty months of microservices. Stairway to heaven or highway to hell
Thirty months of microservices. Stairway to heaven or highway to hell
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
 
Beyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessonsBeyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessons
 
Memory Leaks on Android
Memory Leaks on AndroidMemory Leaks on Android
Memory Leaks on Android
 
Moved to https://slidr.io/azzazzel/what-s-not-new-in-modular-java
Moved to https://slidr.io/azzazzel/what-s-not-new-in-modular-javaMoved to https://slidr.io/azzazzel/what-s-not-new-in-modular-java
Moved to https://slidr.io/azzazzel/what-s-not-new-in-modular-java
 
Geecon Prague 2016 - Thirty months of microservices
Geecon Prague 2016 - Thirty months of microservicesGeecon Prague 2016 - Thirty months of microservices
Geecon Prague 2016 - Thirty months of microservices
 
Just-in-time compiler (March, 2017)
Just-in-time compiler (March, 2017)Just-in-time compiler (March, 2017)
Just-in-time compiler (March, 2017)
 
系統程式 -- 第 9 章
系統程式 -- 第 9 章系統程式 -- 第 9 章
系統程式 -- 第 9 章
 
系統程式 -- 第 8 章
系統程式 -- 第 8 章系統程式 -- 第 8 章
系統程式 -- 第 8 章
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Alluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed Storage
Alluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed StorageAlluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed Storage
Alluxio (formerly Tachyon): Open Source Memory Speed Virtual Distributed Storage
 
Browser-level testing
Browser-level testingBrowser-level testing
Browser-level testing
 
Intel CPU Manufacturing Process
Intel CPU Manufacturing ProcessIntel CPU Manufacturing Process
Intel CPU Manufacturing Process
 
Building Better Software Faster
Building Better Software FasterBuilding Better Software Faster
Building Better Software Faster
 
Apache kylin 2.0: from classic olap to real-time data warehouse
Apache kylin 2.0: from classic olap to real-time data warehouseApache kylin 2.0: from classic olap to real-time data warehouse
Apache kylin 2.0: from classic olap to real-time data warehouse
 
Hoodie: Incremental processing on hadoop
Hoodie: Incremental processing on hadoopHoodie: Incremental processing on hadoop
Hoodie: Incremental processing on hadoop
 
Hdl based simulators
Hdl based simulatorsHdl based simulators
Hdl based simulators
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Open Source Memory Speed Virtual Distributed Storage
Open Source Memory Speed Virtual Distributed StorageOpen Source Memory Speed Virtual Distributed Storage
Open Source Memory Speed Virtual Distributed Storage
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?
 

Similar to Code lifecycle in the jvm - TopConf Linz

Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceESUG
 
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JITEclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JITEclipse Day India
 
Behat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfBehat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfseleniumbootcamp
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoValeriia Maliarenko
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel modecorehard_by
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Kenneth Geisshirt
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaWei-Bo Chen
 
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CanSecWest
 
GCC Summit 2010
GCC Summit 2010GCC Summit 2010
GCC Summit 2010regehr
 
White and Black Magic on the JVM
White and Black Magic on the JVMWhite and Black Magic on the JVM
White and Black Magic on the JVMIvaylo Pashov
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveAmiq Consulting
 
"JS: the right way" by Mykyta Semenistyi
"JS: the right way" by Mykyta Semenistyi"JS: the right way" by Mykyta Semenistyi
"JS: the right way" by Mykyta SemenistyiBinary Studio
 
Speed geeking-lotusscript
Speed geeking-lotusscriptSpeed geeking-lotusscript
Speed geeking-lotusscriptBill Buchan
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic libraryAdaCore
 

Similar to Code lifecycle in the jvm - TopConf Linz (20)

Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
 
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JITEclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JIT
 
In Vogue Dynamic
In Vogue DynamicIn Vogue Dynamic
In Vogue Dynamic
 
Behat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfBehat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdf
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey Kovalenko
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel mode
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++
 
JAVA BYTE CODE
JAVA BYTE CODEJAVA BYTE CODE
JAVA BYTE CODE
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON China
 
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
 
Java On CRaC
Java On CRaCJava On CRaC
Java On CRaC
 
GCC Summit 2010
GCC Summit 2010GCC Summit 2010
GCC Summit 2010
 
White and Black Magic on the JVM
White and Black Magic on the JVMWhite and Black Magic on the JVM
White and Black Magic on the JVM
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
 
"JS: the right way" by Mykyta Semenistyi
"JS: the right way" by Mykyta Semenistyi"JS: the right way" by Mykyta Semenistyi
"JS: the right way" by Mykyta Semenistyi
 
Speed geeking-lotusscript
Speed geeking-lotusscriptSpeed geeking-lotusscript
Speed geeking-lotusscript
 
CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic library
 

Recently uploaded

USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 

Recently uploaded (20)

USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 

Code lifecycle in the jvm - TopConf Linz

  • 1. Lifecycle of a JIT compiled code Ivan Krylov Azul Systems
  • 3. Is this the right talk? • JVM Internals and Performance Talk: • General Interest • Got a performance critical app • You have a reproducible case • Have a way to collect JVM logs 3
  • 4. Scope and Agenda • Code flow inside JVM • Profiles that JVM collects • Deoptimization • Four ways to control compilation 4 Ivan Krylov
  • 5. Code Pipeline in JVM 5 Sources in .java Bytecodes Machine code from the Interpreter Machine code from a compiler Javac
 1) Static verification
 2) Compilation with near-0 opts Runtime
 1) Dynamic verification
 2) Linking One of N compilers
 Governed by runtime 
 next tierdeoptimization live
 profile data JAOT in JDK9

  • 6. • Bytecodes coming not from javac • Any JVM language; jasm-like tools; Byte Buddy • May be no interpreter • JRockit VM • May be only interpreter • Zero-port or -Xint • May be a pure AOT (no bytecodes, no JIT) • Pure AOT can’t implement the entire Java SE standard • Hence a hybrid approach : Excelsior JET, Graal-based AOT (in works) Everything can be different 6
  • 7. Template Interpreter - a tier 0 compiler • Machine code creation • From asm(masm) templates • Populated with addresses in VM • Generated at start-up • Maintains invocation and Back branch C-rs • Mixed native/java stack frame • All bytescodes in a single blob with GoTo-s 7
  • 8. Template Interpreter - ladd example 8 0x000000010a59a920: mov (%rsp),%rax 0x000000010a59a924: add $0x10,%rsp 0x000000010a59a928: mov (%rsp),%rdx 0x000000010a59a92c: add $0x10,%rsp 0x000000010a59a930: add %rdx,%rax 0 0x000000010a590933: movzbl 0x1(%r13),%ebx 0x000000010a59a938: inc %r13 0x000000010a59a93b: movabs $0x10a0f6600,%r10 0x000000010a59a945: jmpq *(%r10,%rbx,8) Entry if %RAX doesn’t contain first operand Entry otherwise Read next bytecode
 & dispatch №1 №2 return value bytecode cntr next bytecode method start 0x000000010a0f6600:
  • 9. What is a profile ? • It is all about counters • Inaccurate but indicative • If overflows - stays at 
 saturated level • Some counters with properties • Actual types observed, etc.. 9 https://www.flickr.com/photos/icemanphoto/1739731523
  • 10. Profile is.. methodCounters.hpp • interpreter_invocation_count & invocation_counter • interpreter_throwout_count • backedge_counter • number_of_breakpoints (4 dbg) • nmethod_age • interpreter_invocation_limit & interpreter_backward_branch_limit • interpreter_profile_limit • invoke_mask • backedge_mask • rate & prev_time • highest_comp_level & highest_osr_comp_level 10
  • 11. Anything else needed? 11 class A { static List<String> list = new LinkedList<>(); static { DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); list.add(dateFormat.format(new Date())); } static List<String> getList() { return list; } } class B { String process(String s, int i) { if (i < A.list.size()) return s.concat( A.list.get(i) ); else return s; } } B.process() may 
 be compiled 
 only after A is initialized A may be initialized only at first invocation of B.process()
 (If B.process() is the only user of A)
  • 12. Is SimpleEnum simple? 12 public enum SimpleEnum { One }; >ll SimpleEnum.java -rw-r--r-- 1 ivan staff 35 Feb 23 21:30 SimpleEnum.java >ll SimpleEnum.class -rw-r--r-- 1 ivan staff 732 Feb 23 21:30 SimpleEnum.class
  • 13. Is SimpleEnum simple? 12 public enum SimpleEnum { One }; Compiled from "SimpleEnum.java" public final class SimpleEnum extends java.lang.Enum<SimpleEnum> { public static final SimpleEnum One; public static SimpleEnum[] values(); Code: 0: getstatic #1 // Field $VALUES:[LSimpleEnum; 3: invokevirtual #2 // Method "[LSimpleEnum;".clone:()Ljava/lang/Object; 6: checkcast #3 // class "[LSimpleEnum;" 9: areturn public static SimpleEnum valueOf(java.lang.String); Code: 0: ldc #4 // class SimpleEnum 2: aload_0 3: invokestatic #5 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum; 6: checkcast #4 // class SimpleEnum 9: areturn static {}; Code: 0: new #4 // class SimpleEnum 3: dup 4: ldc #7 // String One 6: iconst_0 7: invokespecial #8 // Method "<init>":(Ljava/lang/String;I)V 10: putstatic #9 // Field One:LSimpleEnum; 13: iconst_1 14: anewarray #4 // class SimpleEnum 17: dup 18: iconst_0 19: getstatic #9 // Field One:LSimpleEnum; 22: aastore 23: putstatic #1 // Field $VALUES:[LSimpleEnum; 26: return }
  • 14. 2: aload_0 3: invokestatic #5 // Method java/lang/Enum.valueOf:(Ljava/lang/C 6: checkcast #4 // class SimpleEnum 9: areturn static {}; Code: 0: new #4 // class SimpleEnum 3: dup 4: ldc #7 // String One 6: iconst_0 7: invokespecial #8 // Method "<init>":(Ljava/lang/String;I)V 10: putstatic #9 // Field One:LSimpleEnum; 13: iconst_1 14: anewarray #4 // class SimpleEnum 17: dup 18: iconst_0 19: getstatic #9 // Field One:LSimpleEnum; 22: aastore 23: putstatic #1 // Field $VALUES:[LSimpleEnum; 26: return } Is SimpleEnum simple? 13 public enum SimpleEnum { One };
  • 15. The Rumor:Inlining is important 14 • Hide the costs of preparing arguments • Hide the costs of marshaling the result • Code is co-located (I-cache friendly) • Makes executable smaller in some cases • Unlocks a bunch of optimizations • Because the scope of a compilation block is bigger • Easy to test: disable Inlining with -XX:-Inline - and observe XX% perf loss • -XX:+PrintInlining to see what methods’re inlined and where
  • 16. Inlining that didn’t happen 15 • Inlining Callee makes a caller too big • Inlining too deep / recursive inlining • Callee has exception handlers? (InlineMethodsWithExceptionHandlers) • Callee is synchronized (InlineSynchronizedMethods ) • Class of Callee is not initialized • Callee has unbalanced monitors • Caller has jsr bytecode (!) } http://cliffhacks.blogspot.ru/2008/02/java-6-tryfinally-compilation-without.html Overrulable
  • 17. Did you see tiers? 16 495 7 n 0 jdk.internal.reflect.Reflection::getCallerClass (native) (static) 495 8 b 2 java.util.Properties::getProperty (49 bytes) 497 9 b 2 java.util.concurrent.ConcurrentHashMap::get (162 bytes) 500 10 b 3 java.lang.String::hashCode (48 bytes) 503 11 b 4 java.lang.String::hashCode (48 bytes) 507 10 3 java.lang.String::hashCode (48 bytes) made not entrant 507 12 b 2 java.lang.StringLatin1::hashCode (42 bytes) 509 13 b 3 java.lang.Boolean::<clinit> (31 bytes) 510 14 b 4 java.lang.Boolean::<clinit> (31 bytes) 510 13 3 java.lang.Boolean::<clinit> (31 bytes) made not entrant 511 15 b 3 java.lang.Boolean::<init> (10 bytes) 511 16 b 4 java.lang.Boolean::<init> (10 bytes) 513 15 3 java.lang.Boolean::<init> (10 bytes) made not entrant 513 17 b 2 java.lang.Object::<init> (1 bytes) 513 18 n 0 java.lang.Class::getPrimitiveClass (native) (static) 514 19 b 3 java.lang.Boolean::parseBoolean (19 bytes) 514 20 b 4 java.lang.Boolean::parseBoolean (19 bytes) 516 19 3 java.lang.Boolean::parseBoolean (19 bytes) made not entrant 516 21 b 2 java.lang.String::isLatin1 (19 bytes) 517 22 b 2 java.lang.Integer::parseInt (259 bytes) 533 23 b 3 java.lang.Character::<clinit> (25 bytes)
  • 18. 4 - Full Optimisation - C2 Tiered compilation Fastest Slow Mediocre Fast Slowest 3 - Full Profile - C1 (incl. MethodData) 2 - Limited Profile - C1
 (+ invocation & backed counters) 1 - Simple Profile - C1 0 - Interpreter 17
  • 19. • … Compiler does “optimistic” (or “heroic”) optimizations • … Something AOT can’t do • & “Whole World” is not developed at time of compilation Deoptimizations happen because… 18
  • 20. 19 Not all opts or speculative • Constant propagation • Loop invariant • … • Bias locking • NUMA-aware allocation • TSX transactions • Uncommon trap • … Deterministic opts Speculative w/fallback Speculative w/hard stop • CHA invalidation • Effectively final fields modified • …
  • 21. Implicit code • Mandatory operations from JVMLS • Zeroing of Objects • Out of boundary checks • Divide by 0 in math • Null Pointer protection • Checkcasts • …. 20 class C { int val; C[] kInverseVector(int k, C[] v) { C[] result = new C[v.length]; for (int i=0; i < v.length; i++){ result[i] = new C(); result[i].val = k / v[i].val ; } return result; } }
  • 22. Per bci deoptimization reasons • Null Check (null object or div 0) • Null Assert • Range Check (OOB) • Class Check (Unexpected class) • Array Check (Unexpected array class) • Intrinsic operand • Bimorphic inlining failed 21
  • 23. Per method deoptimization reasons • Unloaded class • Uninitialized class • Unreached code • Unhandled exception • Unexpected Constraint • Div0 check • Age (tier threshold reached) • Predicate failed • Loop limit check • Speculate class check • Speculate Null Check • Rm state change • Unstable if • Reason unstable fused if 22
  • 24. Uncommon trap happened. Now what? • 1-off event? • A change in a pattern? • Keep old around? • Recompile? Never compile? • What the next invocation will be like? 23 class C { int val; C[] kInverseVector(int k, C[] v) { C[] result = new C[v.length]; for (int i=0; i < v.length; i++){ result[i]=new C(); result[i].val = k / v[i].val ; } return result; } }
  • 25. How to control a compiler? 24
  • 26. I. Legacy CompileCommand 25 • Provided statically via • Command line: -XX:HotspotCompile • .hotspot_compiler or 
 -XX:CompileCommandFile=/path/to/thefile • Dynamically • jcmd Compiler.directives_add • Syntax: 
 command package/Class methodName • Actions: • dontinline or exclude or excludec2 or excludec1 exclude java/lang/Thread setPriority dontinline java/lang/String charAt
  • 27. II. Compiler Control in Java 9 26 { // matching several patterns require an array match: ["steve.*","alex.*"] c2: { Enable: false, // Ignore this directive for c2. BreakAtExecute: true // This will not be applied since Enable is false above } // applies to all compilers // + force inline, - dont inline inline : [ "+java/util.*", "-com/sun.*"], PrintInlining: true }
  • 28. Common Compiler Control Directives 27 • Enable • bool Exclude • bool Inline • bool BreakAtExecute • bool BreakAtCompile • bool Log • bool PrintAssembly
  • 29. Common Compiler Control Directives 27 • Enable • bool Exclude • bool Inline • bool BreakAtExecute • bool BreakAtCompile • bool Log • bool PrintAssembly • bool PrintInlining • bool PrintNMethods • bool ReplayInline • bool DumpReplay • bool DumpInline • bool CompilerDirectivesIgnoreCompileCommands
  • 30. • bool PrintOptoAssembly • bool PrintIntrinsics • bool TraceOptoOutput • bool TraceSpilling • bool CloneMapDebug • bool IGVPrintLevel C2 Compiler Control Directives 28 • BlockLayoutByFrequency • bool raceOptoPipelining • bool Vectorize • bool VectorizeDebug • intx MaxNodeLimit • intx DisableIntrinsics

  • 31. III. java.lang.Compiler 29 • OpenJDK / Oracle don’t support it. • IBM J9 supports it 
 http://www.ibm.com/support/knowledgecenter/en/ SSSTCZ_2.0.0/com.ibm.rt.doc.20/realtime/rt_jit.html • Zing has a slight different flavour
 http://docs.azul.com/zing/Zing_UserGuide/ #Zing_UserGuide/ Zing_AT_ReadyNow_EnsureCriticalMethodsareCom piled_CompilerAPI.htm
 • Oracle wants to deprecate
 See https://bugs.openjdk.java.net/browse/ JDK-4285505 { Compiler.enable(); // ensure compiler is active Compiler.command("{com.mycompany.*}(compile)"); System.out.println("Now let’s wait till compilation is done"); Compiler.command("waitOnCompilationQueue"); System.out.println("Compilation is complete"); Compiler.disable(); // turn the compiler off }
  • 32. IV. ReadyNow 30 • Between AOT and JIT • Designed to compile sooner than normal JIT • “Your JIT’s yesterday’s mistakes wont hurt you today” • Designed to deoptimize less often than normal JIT • Works well in good “scenarios” • Designed to never produce an invalid code • The fallback is the normal JIT
  • 33. Three requirements of ReadyNow 31 I. Profiles must be adequate II. Profile needs to be applicable III. All necessary types are initialized or … 1. all the ones we need for fastpath 2. can force eager initialization 
 in case of no/trivial static initializers
  • 34. 32 Recording a profile CT1 CT2 CT3 profile
  • 37. Bonus: JDK9 Ahead of Time Compilation 35 • Targeting Fast startup • Can interoperate with JIT • Only Linux x64 • Only java.base is guaranteed • Must use the same JVM flags • Not for dynamically generated classes • No reflection support • No instrumentation support jaotc --output libjava.base.so --module java.base
 jaotc --output libHelloWorld.so HelloWorld.class java -XX:AOTLibrary=./libHelloWorld.so HelloWorld
  • 38. 36 • Zing: A better JVM for the enterprise • Azul’s enterprise JVM focused on better metrics • Consistent performance - not just fast, always fast • Eliminate GC as a concern for enterprise apps • Very wide operating range • From human-sensitive app responsiveness to low-latency trading • From microservices to huge in-memory apps • Eliminates an entire class of engineering workarounds common in Java •Zulu Embedded: When you need embedded Support • 100% open source, based on OpenJDK • Certified Java SE compliant and compatible • Verified “non-contaminating” open source license • Identical metrics to OpenJDK and Oracle Java SE • World-class support offerings • Support for Linux & Windows; x86, ARM32, ARM64, PPC32, MIPS 36
  • 39. Ivan Krylov www.azul.com
 Azul Systems ivan @ azul.com