SlideShare a Scribd company logo
1 of 31
Download to read offline
A Formal Foundation for
Trace-Based JIT Compilation
A Formal Foundation for Trace-Based JIT Compilers
Maarten Vandercammen* Jens Nicolay* Stefan Marr† Joeri De Koster*
Theo D’Hondt* Coen De Roover*
*Vrije Universiteit Brussel, Belgium
† Johannes Kepler University Linz, Austria
*firstname.lastname@vub.ac.be † stefan.marr@jku.at
Abstract
Trace-based JIT compilers identify frequently executed pro-
gram paths at run-time and subsequently record, compile
and optimize their execution. In order to improve the per-
formance of the generated machine instructions, JIT com-
pilers heavily rely on dynamic analysis of the code. Existing
work treats the components of a JIT compiler as a monolithic
whole, tied to particular execution semantics. We propose a
formal framework that facilitates the design and implemen-
tation of a tracing JIT compiler and its accompanying dy-
namic analyses by decoupling the tracing, optimization, and
interpretation processes. This results in a framework that is
more configurable and extensible than existing formal trac-
ing models. We formalize the tracer and interpreter as two
abstract state machines that communicate through a mini-
mal, well-defined interface. Developing a tracing JIT com-
piler becomes possible for arbitrary interpreters that imple-
ment this interface. The abstract machines also provide the
necessary hooks to plug in custom analyses and optimiza-
tions.
Categories and Subject Descriptors D.3.1 [Formal Defini-
tions and Theory]: semantics; D.3.4 [Processors]: compil-
ers, optimization
Keywords tracing JIT compilation, operational semantics,
dynamic analysis
1. Introduction
Just-in-time (JIT) compilation is a technique where, instead
of statically compiling and optimizing an entire program up-
front, an execution engine observes the program’s execution
and a JIT compiler emits machine code at run-time. Doing so
allows the compiler to take into account specific character-
istics of the program’s execution when generating machine
instructions, such as the values or types of the expressions
that are executed. Dynamic analysis is therefore essential to
the process of JIT compilation, since JIT compilers use these
kinds of analyses to optimize the instructions that they gen-
erate at run-time [6].
The few formal models that exist on tracing compilation
[2, 5] are irreversibly tied to one particular execution model
for one particular programming language and treat the dif-
ferent components of a tracing JIT compiler – interpreter,
tracer, compilers, and optimizers – as a monolithic whole
with strong coupling between them. Investigating different
execution models requires extensive changes to the language
semantics used by these models. They are geared more to-
ward exploring soundness of trace optimizations instead of
enabling experiments in dynamic analysis.
We propose a formal framework that facilitates the de-
sign and implementation of a tracing JIT compiler and the
dynamic analyses on which it relies by decoupling the trac-
ing, optimization and interpretation processes, resulting in
a complete framework that is more configurable and exten-
sible than existing formal tracing models. The main benefit
of our model is that it enables applying tracing compilation
to, and subsequent dynamic analysis of, any arbitrary inter-
preter that satisfies a small, fixed interface (Section 3.2). Ex-
cept for this minimal interface, the interpreter is otherwise
treated as a black box and no particular implementation is
specified. Our model also provides the necessary hooks to
plug in custom analyses and optimizations. We do not define
any concrete trace optimizations, but because of the strong
decoupling of components, trace optimizations can be added
in a modular way without being tied to any particular tracer
or interpreter.
2. Trace-Based JIT Compilation
Trace-based JIT compilation is a variant of JIT compilation
that builds on two basic assumptions: most of the execution
time of a program is spent in loops, and several iterations
of the same loop are likely to take the same path through
the program [1]. Starting from these two premises, tracing
Maarten Vandercammen, Jens Nicolay,
Stefan Marr, Joeri De Koster,
Theo D’Hondt, Coen De Roover
mvdcamme@vub.ac.be
Trace-Based JIT Compilation
2
(define (fac n)
(if (< n 2)
1
(* n
(fac (- n 1)))))
(label ‘fac-loop)
(literal-value 2)
(save-val)
(lookup-var 'x)
(save-val)
(lookup-var '<)
(apply-native 2)
(guard-false)
(literal-value 1)
(save-val)
(lookup-var 'x)
(save-val)
(lookup-var '-)
(apply-native 2)
. . .
(goto 'fac-loop)
Trace-Based JIT Compilation
2
(define (fac n)
(if (< n 2)
1
(* n
(fac (- n 1)))))
(label ‘fac-loop)
(literal-value 2)
(save-val)
(lookup-var 'x)
(save-val)
(lookup-var '<)
(apply-native 2)
(guard-false)
(literal-value 1)
(save-val)
(lookup-var 'x)
(save-val)
(lookup-var '-)
(apply-native 2)
. . .
(goto 'fac-loop)
Traces are always linear!

Use guards to protect against changes in control flow
(label ‘fac-loop)
(literal-value 2)
(save-val)
(lookup-var 'x)
(save-val)
(lookup-var '<)
(apply-native 2)
(guard-false)
(literal-value 1)
(save-val)
(lookup-var 'x)
(save-val)
(lookup-var '-)
(apply-native 2)
. . .
(goto 'fac-loop)
Existing formalisms
3
Guo and Palsberg (2011)
Dissegna et al. (2014)
Framework for proving
soundness of optimisations
Existing formalisms
3
Guo and Palsberg (2011)
Dissegna et al. (2014)
Framework for proving
soundness of optimisations
But:
• Tied to specific execution model
• No general description of tracing
• Implicit assumptions
Existing formalisms
3
Guo and Palsberg (2011)
Dissegna et al. (2014)
Framework for proving
soundness of optimisations
But:
• Tied to specific execution model
• No general description of tracing
• Implicit assumptions
No general frameworks!
Research goal
4
Tracing of arbitrary execution model
Enable dynamic analysis
and
Enable reasoning about JIT execution
and
Research goal
5
Language
semantics
(interpreter)
Traced
language semantics
(TJIT Compiler)
Specialises in
interpretation
Specialises in
tracing semantics
+
Optimisation
Approach
6
Tracing machine
Interpreter
machine
Approach
6
Tracing machine
Interpreter
machine
Master
Tracer/Interpreter interface
7
step : ProgramState → InterpreterReturn
restart : RestartPoint × ProgramState → ProgramState
optimise : Trace → Trace
Interpreter as state machine (e.g. CEK machine)
And
Tracing machine
8
Normal
interpretation
Trace
recording
Trace
optimisation
Trace
execution
Loop starts
[untraced]
Loop ends
Loop starts
[traced]
Guard failed
Store trace
Trace finished
Tracing machine
9
Normal
interpretation
Trace
recording
Trace
optimisation
Trace
execution
Loop starts
[untraced]
Loop ends
Loop starts
[traced]
Guard failed
Store trace
Trace finished
Tracing machine
10
Normal
interpretation
Trace
recording
Trace
optimisation
Trace
execution
Loop starts
[untraced]
Loop ends
Loop starts
[traced]
Guard failed
Store trace
Trace finished
Tracing machine
11
Normal
interpretation
Trace
recording
Trace
optimisation
Trace
execution
Loop starts
[untraced]
Loop ends
Loop starts
[traced]
Guard failed
Store trace
Trace finished
optimise : Trace → Trace
Tracing machine
12
Normal
interpretation
Trace
recording
Trace
optimisation
Trace
execution
Loop starts
[untraced]
Loop ends
Loop starts
[traced]
Guard failed
Store trace
Trace finished
Tracer/Interpreter
interface
13
step : ProgramState → InterpreterReturn
Trace
recording
Normal
interpretation
Tracer/Interpreter
interface
13
step : ProgramState → InterpreterReturn
InterpreterReturn: < State2,
{ LLT1, … , LLT3 },
Signal (loop or no loop) >
Trace
recording
Normal
interpretation
State 1 State 2
Intermediate
state 1
Intermediate
state 2
High-level
transition
Low-level
transition 1
LLT 2
LLT 3
Tracing machine
14
ς0 ς1 ς2 ς3 ς4
Executing trace = Replaying LLT’s on current program state
lookup-var(<) apply-native(2) guard-false(consequent) push-continuation(…)
. . .
lookup-var(<)
apply-native(2)
guard-false((< n 2),
consequent)
push-continuation(…)
. . .
Trace
execution
(define (fac n)
(if (< n 2)
1
(* n
(fac (- n 1)))))
Guard failure
15
ς0 ς1 ς2
Executing trace = Replaying LLT’s on current program state
lookup-var(<) apply-native(2)
ς3
’guard-false(consequent)
Trace
execution
(define (fac n)
(if (< n 2)
1
(* n
(fac (- n 1)))))
. . .
lookup-var(<)
apply-native(2)
guard-false((< n 2),
consequent)
push-continuation(…)
. . .
Guard failure
16
restart : RestartPoint × ProgramState → ProgramState
ς2
guard-false((< n 2),
consequent)
ς3
ς3
’
LLT : ProgramState → ProgramState | RestartPoint
Trace
execution
(if (< n 2)
1
. . .)
Guard failure
16
restart : RestartPoint × ProgramState → ProgramState
ς3
’ = restart(consequent, ς2)
ς2
guard-false((< n 2),
consequent)
ς3
ς3
’
LLT : ProgramState → ProgramState | RestartPoint
Trace
execution
(if (< n 2)
1
. . .)
Implementation
17
Formal semantics Implementation
Tracing
machine
Experiment
18
Scheme-like language using
CESK-style interpreter
Tracing
machine
Apply transformation on
set of interpreters
(match program-state
. . .
((ifk condition consequent alternative) ρ σ κ))
(if condition
(interpreter-return
program-state
(ev consequent)
#f
(restore-env)
(pop-continuation)
(guard-true alternative))
. . .)
Experimentation
19
Tracing
machine
meta-interpreter
meta-tracing JIT compiler
Tracing framework
User program
Language interpreter
Underlying runtime
Contribution
Language
semantics
(interpreter)
Traced
language semantics
(TJIT Compiler)
Recording/executing traces
Handling guard failures
Hook for dynamic analysis
20
Contribution
Language
semantics
(interpreter)
Traced
language semantics
(TJIT Compiler)
Recording/executing traces
Handling guard failures
Hook for dynamic analysis
20
But…
Transformation manual
Interpreter modelled as state machine
Future work
21
Automatic transformation?
Future work
21
Current:
Local optimisation:
individual traces
Future:
Global optimisation:
also optimise paths
between traces
Automatic transformation?
JIT compilation
Future work
21
Current:
Local optimisation:
individual traces
Future:
Global optimisation:
also optimise paths
between traces
Common framework for expressing
execution of traces and untraced code
Automatic transformation?
JIT compilation
Conclusion
22
Motivation Approach Contribution

More Related Content

What's hot

Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyIván López Martín
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gcexsuns
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI IntroductionRohit Banga
 
iFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature ImplementationsiFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature ImplementationsShinpei Hayashi
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with GroovyAli Tanwir
 
MPI message passing interface
MPI message passing interfaceMPI message passing interface
MPI message passing interfaceMohit Raghuvanshi
 
Static Analysis of Computer programs
Static Analysis of Computer programs Static Analysis of Computer programs
Static Analysis of Computer programs Arvind Devaraj
 
Performance improvement techniques for software distributed shared memory
Performance improvement techniques for software distributed shared memoryPerformance improvement techniques for software distributed shared memory
Performance improvement techniques for software distributed shared memoryZongYing Lyu
 

What's hot (13)

Mpi Test Suite Multi Threaded
Mpi Test Suite Multi ThreadedMpi Test Suite Multi Threaded
Mpi Test Suite Multi Threaded
 
Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovy
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gc
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 
iFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature ImplementationsiFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature Implementations
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with Groovy
 
MPI message passing interface
MPI message passing interfaceMPI message passing interface
MPI message passing interface
 
Static Analysis of Computer programs
Static Analysis of Computer programs Static Analysis of Computer programs
Static Analysis of Computer programs
 
Security Tools Foss
Security Tools FossSecurity Tools Foss
Security Tools Foss
 
O25074078
O25074078O25074078
O25074078
 
MPI
MPIMPI
MPI
 
Performance improvement techniques for software distributed shared memory
Performance improvement techniques for software distributed shared memoryPerformance improvement techniques for software distributed shared memory
Performance improvement techniques for software distributed shared memory
 
Chapter 6 pc
Chapter 6 pcChapter 6 pc
Chapter 6 pc
 

Viewers also liked

How to Create a Buzz About New Technologies
How to Create a Buzz About New TechnologiesHow to Create a Buzz About New Technologies
How to Create a Buzz About New TechnologiesFast Track Marketing
 
Essential trace elements
Essential trace elementsEssential trace elements
Essential trace elementsDr Manju prasad
 
Visual field testing and interpretation
Visual field testing and interpretationVisual field testing and interpretation
Visual field testing and interpretationRaman Gupta
 
Optometry2017 brochure
Optometry2017 brochureOptometry2017 brochure
Optometry2017 brochureLisa Anderson
 

Viewers also liked (6)

How to Create a Buzz About New Technologies
How to Create a Buzz About New TechnologiesHow to Create a Buzz About New Technologies
How to Create a Buzz About New Technologies
 
Optical abberations pp
Optical abberations ppOptical abberations pp
Optical abberations pp
 
Occupational optometry
Occupational optometryOccupational optometry
Occupational optometry
 
Essential trace elements
Essential trace elementsEssential trace elements
Essential trace elements
 
Visual field testing and interpretation
Visual field testing and interpretationVisual field testing and interpretation
Visual field testing and interpretation
 
Optometry2017 brochure
Optometry2017 brochureOptometry2017 brochure
Optometry2017 brochure
 

Similar to Presentation slides for "A formal foundation for trace-based JIT compilation"

compressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdfcompressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdfGinaMartinezTacuchi
 
compressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdfcompressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdfMaherEmad1
 
just in time JIT compiler
just in time JIT compilerjust in time JIT compiler
just in time JIT compilerMohit kumar
 
Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...
Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...
Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...IRJET Journal
 
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...ijnlc
 
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIO...
ANALYZING ARCHITECTURES FOR NEURAL  MACHINE TRANSLATION USING LOW  COMPUTATIO...ANALYZING ARCHITECTURES FOR NEURAL  MACHINE TRANSLATION USING LOW  COMPUTATIO...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIO...kevig
 
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...kevig
 
LTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space TracingLTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space TracingChristian Babeux
 
Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & ProfilingIsuru Perera
 
A Practical Approach to Creation and Analysis of FSM Designs
A Practical Approach to Creation and Analysis of FSM Designs A Practical Approach to Creation and Analysis of FSM Designs
A Practical Approach to Creation and Analysis of FSM Designs IJCSIS Research Publications
 
FPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation Platform
FPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation PlatformFPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation Platform
FPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation PlatformFlexTiles Team
 
Attention mechanisms with tensorflow
Attention mechanisms with tensorflowAttention mechanisms with tensorflow
Attention mechanisms with tensorflowKeon Kim
 
Accelerating system verilog uvm based vip to improve methodology for verifica...
Accelerating system verilog uvm based vip to improve methodology for verifica...Accelerating system verilog uvm based vip to improve methodology for verifica...
Accelerating system verilog uvm based vip to improve methodology for verifica...VLSICS Design
 
EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!melbats
 
Parallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MPParallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MPIJSRED
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerMarina Kolpakova
 
Architecture of a morphological malware detector
Architecture of a morphological malware detectorArchitecture of a morphological malware detector
Architecture of a morphological malware detectorUltraUploader
 

Similar to Presentation slides for "A formal foundation for trace-based JIT compilation" (20)

compressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdfcompressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdf
 
compressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdfcompressed.tracemonkey-pldi-09.pdf
compressed.tracemonkey-pldi-09.pdf
 
just in time JIT compiler
just in time JIT compilerjust in time JIT compiler
just in time JIT compiler
 
Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...
Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...
Text Summarization of Food Reviews using AbstractiveSummarization and Recurre...
 
PID2143641
PID2143641PID2143641
PID2143641
 
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
 
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIO...
ANALYZING ARCHITECTURES FOR NEURAL  MACHINE TRANSLATION USING LOW  COMPUTATIO...ANALYZING ARCHITECTURES FOR NEURAL  MACHINE TRANSLATION USING LOW  COMPUTATIO...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIO...
 
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
ANALYZING ARCHITECTURES FOR NEURAL MACHINE TRANSLATION USING LOW COMPUTATIONA...
 
LTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space TracingLTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space Tracing
 
Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & Profiling
 
A Practical Approach to Creation and Analysis of FSM Designs
A Practical Approach to Creation and Analysis of FSM Designs A Practical Approach to Creation and Analysis of FSM Designs
A Practical Approach to Creation and Analysis of FSM Designs
 
FPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation Platform
FPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation PlatformFPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation Platform
FPL'2014 - FlexTiles Workshop - 5 - FlexTiles Simulation Platform
 
Attention mechanisms with tensorflow
Attention mechanisms with tensorflowAttention mechanisms with tensorflow
Attention mechanisms with tensorflow
 
Accelerating system verilog uvm based vip to improve methodology for verifica...
Accelerating system verilog uvm based vip to improve methodology for verifica...Accelerating system verilog uvm based vip to improve methodology for verifica...
Accelerating system verilog uvm based vip to improve methodology for verifica...
 
EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!
 
Parallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MPParallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MP
 
43
4343
43
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
 
Architecture of a morphological malware detector
Architecture of a morphological malware detectorArchitecture of a morphological malware detector
Architecture of a morphological malware detector
 
An Introduction to OMNeT++ 5.1
An Introduction to OMNeT++ 5.1An Introduction to OMNeT++ 5.1
An Introduction to OMNeT++ 5.1
 

Recently uploaded

My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Baileyhlharris
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfSkillCertProExams
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...David Celestin
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfMahamudul Hasan
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...amilabibi1
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfSenaatti-kiinteistöt
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaKayode Fayemi
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar TrainingKylaCullinane
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatmentnswingard
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalFabian de Rijk
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lodhisaajjda
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIINhPhngng3
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxraffaeleoman
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoKayode Fayemi
 

Recently uploaded (15)

My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 

Presentation slides for "A formal foundation for trace-based JIT compilation"

  • 1. A Formal Foundation for Trace-Based JIT Compilation A Formal Foundation for Trace-Based JIT Compilers Maarten Vandercammen* Jens Nicolay* Stefan Marr† Joeri De Koster* Theo D’Hondt* Coen De Roover* *Vrije Universiteit Brussel, Belgium † Johannes Kepler University Linz, Austria *firstname.lastname@vub.ac.be † stefan.marr@jku.at Abstract Trace-based JIT compilers identify frequently executed pro- gram paths at run-time and subsequently record, compile and optimize their execution. In order to improve the per- formance of the generated machine instructions, JIT com- pilers heavily rely on dynamic analysis of the code. Existing work treats the components of a JIT compiler as a monolithic whole, tied to particular execution semantics. We propose a formal framework that facilitates the design and implemen- tation of a tracing JIT compiler and its accompanying dy- namic analyses by decoupling the tracing, optimization, and interpretation processes. This results in a framework that is more configurable and extensible than existing formal trac- ing models. We formalize the tracer and interpreter as two abstract state machines that communicate through a mini- mal, well-defined interface. Developing a tracing JIT com- piler becomes possible for arbitrary interpreters that imple- ment this interface. The abstract machines also provide the necessary hooks to plug in custom analyses and optimiza- tions. Categories and Subject Descriptors D.3.1 [Formal Defini- tions and Theory]: semantics; D.3.4 [Processors]: compil- ers, optimization Keywords tracing JIT compilation, operational semantics, dynamic analysis 1. Introduction Just-in-time (JIT) compilation is a technique where, instead of statically compiling and optimizing an entire program up- front, an execution engine observes the program’s execution and a JIT compiler emits machine code at run-time. Doing so allows the compiler to take into account specific character- istics of the program’s execution when generating machine instructions, such as the values or types of the expressions that are executed. Dynamic analysis is therefore essential to the process of JIT compilation, since JIT compilers use these kinds of analyses to optimize the instructions that they gen- erate at run-time [6]. The few formal models that exist on tracing compilation [2, 5] are irreversibly tied to one particular execution model for one particular programming language and treat the dif- ferent components of a tracing JIT compiler – interpreter, tracer, compilers, and optimizers – as a monolithic whole with strong coupling between them. Investigating different execution models requires extensive changes to the language semantics used by these models. They are geared more to- ward exploring soundness of trace optimizations instead of enabling experiments in dynamic analysis. We propose a formal framework that facilitates the de- sign and implementation of a tracing JIT compiler and the dynamic analyses on which it relies by decoupling the trac- ing, optimization and interpretation processes, resulting in a complete framework that is more configurable and exten- sible than existing formal tracing models. The main benefit of our model is that it enables applying tracing compilation to, and subsequent dynamic analysis of, any arbitrary inter- preter that satisfies a small, fixed interface (Section 3.2). Ex- cept for this minimal interface, the interpreter is otherwise treated as a black box and no particular implementation is specified. Our model also provides the necessary hooks to plug in custom analyses and optimizations. We do not define any concrete trace optimizations, but because of the strong decoupling of components, trace optimizations can be added in a modular way without being tied to any particular tracer or interpreter. 2. Trace-Based JIT Compilation Trace-based JIT compilation is a variant of JIT compilation that builds on two basic assumptions: most of the execution time of a program is spent in loops, and several iterations of the same loop are likely to take the same path through the program [1]. Starting from these two premises, tracing Maarten Vandercammen, Jens Nicolay, Stefan Marr, Joeri De Koster, Theo D’Hondt, Coen De Roover mvdcamme@vub.ac.be
  • 2. Trace-Based JIT Compilation 2 (define (fac n) (if (< n 2) 1 (* n (fac (- n 1))))) (label ‘fac-loop) (literal-value 2) (save-val) (lookup-var 'x) (save-val) (lookup-var '<) (apply-native 2) (guard-false) (literal-value 1) (save-val) (lookup-var 'x) (save-val) (lookup-var '-) (apply-native 2) . . . (goto 'fac-loop)
  • 3. Trace-Based JIT Compilation 2 (define (fac n) (if (< n 2) 1 (* n (fac (- n 1))))) (label ‘fac-loop) (literal-value 2) (save-val) (lookup-var 'x) (save-val) (lookup-var '<) (apply-native 2) (guard-false) (literal-value 1) (save-val) (lookup-var 'x) (save-val) (lookup-var '-) (apply-native 2) . . . (goto 'fac-loop) Traces are always linear!
 Use guards to protect against changes in control flow (label ‘fac-loop) (literal-value 2) (save-val) (lookup-var 'x) (save-val) (lookup-var '<) (apply-native 2) (guard-false) (literal-value 1) (save-val) (lookup-var 'x) (save-val) (lookup-var '-) (apply-native 2) . . . (goto 'fac-loop)
  • 4. Existing formalisms 3 Guo and Palsberg (2011) Dissegna et al. (2014) Framework for proving soundness of optimisations
  • 5. Existing formalisms 3 Guo and Palsberg (2011) Dissegna et al. (2014) Framework for proving soundness of optimisations But: • Tied to specific execution model • No general description of tracing • Implicit assumptions
  • 6. Existing formalisms 3 Guo and Palsberg (2011) Dissegna et al. (2014) Framework for proving soundness of optimisations But: • Tied to specific execution model • No general description of tracing • Implicit assumptions No general frameworks!
  • 7. Research goal 4 Tracing of arbitrary execution model Enable dynamic analysis and Enable reasoning about JIT execution and
  • 8. Research goal 5 Language semantics (interpreter) Traced language semantics (TJIT Compiler) Specialises in interpretation Specialises in tracing semantics + Optimisation
  • 11. Tracer/Interpreter interface 7 step : ProgramState → InterpreterReturn restart : RestartPoint × ProgramState → ProgramState optimise : Trace → Trace Interpreter as state machine (e.g. CEK machine) And
  • 15. Tracing machine 11 Normal interpretation Trace recording Trace optimisation Trace execution Loop starts [untraced] Loop ends Loop starts [traced] Guard failed Store trace Trace finished optimise : Trace → Trace
  • 17. Tracer/Interpreter interface 13 step : ProgramState → InterpreterReturn Trace recording Normal interpretation
  • 18. Tracer/Interpreter interface 13 step : ProgramState → InterpreterReturn InterpreterReturn: < State2, { LLT1, … , LLT3 }, Signal (loop or no loop) > Trace recording Normal interpretation State 1 State 2 Intermediate state 1 Intermediate state 2 High-level transition Low-level transition 1 LLT 2 LLT 3
  • 19. Tracing machine 14 ς0 ς1 ς2 ς3 ς4 Executing trace = Replaying LLT’s on current program state lookup-var(<) apply-native(2) guard-false(consequent) push-continuation(…) . . . lookup-var(<) apply-native(2) guard-false((< n 2), consequent) push-continuation(…) . . . Trace execution (define (fac n) (if (< n 2) 1 (* n (fac (- n 1)))))
  • 20. Guard failure 15 ς0 ς1 ς2 Executing trace = Replaying LLT’s on current program state lookup-var(<) apply-native(2) ς3 ’guard-false(consequent) Trace execution (define (fac n) (if (< n 2) 1 (* n (fac (- n 1))))) . . . lookup-var(<) apply-native(2) guard-false((< n 2), consequent) push-continuation(…) . . .
  • 21. Guard failure 16 restart : RestartPoint × ProgramState → ProgramState ς2 guard-false((< n 2), consequent) ς3 ς3 ’ LLT : ProgramState → ProgramState | RestartPoint Trace execution (if (< n 2) 1 . . .)
  • 22. Guard failure 16 restart : RestartPoint × ProgramState → ProgramState ς3 ’ = restart(consequent, ς2) ς2 guard-false((< n 2), consequent) ς3 ς3 ’ LLT : ProgramState → ProgramState | RestartPoint Trace execution (if (< n 2) 1 . . .)
  • 24. Experiment 18 Scheme-like language using CESK-style interpreter Tracing machine Apply transformation on set of interpreters (match program-state . . . ((ifk condition consequent alternative) ρ σ κ)) (if condition (interpreter-return program-state (ev consequent) #f (restore-env) (pop-continuation) (guard-true alternative)) . . .)
  • 25. Experimentation 19 Tracing machine meta-interpreter meta-tracing JIT compiler Tracing framework User program Language interpreter Underlying runtime
  • 27. Contribution Language semantics (interpreter) Traced language semantics (TJIT Compiler) Recording/executing traces Handling guard failures Hook for dynamic analysis 20 But… Transformation manual Interpreter modelled as state machine
  • 29. Future work 21 Current: Local optimisation: individual traces Future: Global optimisation: also optimise paths between traces Automatic transformation? JIT compilation
  • 30. Future work 21 Current: Local optimisation: individual traces Future: Global optimisation: also optimise paths between traces Common framework for expressing execution of traces and untraced code Automatic transformation? JIT compilation