SlideShare a Scribd company logo
1 of 35
IonMonkey
                               One JIT To Rule Them All




Mozilla All-Hands 2011, San Jose Convention Center
Why?


• Existing JITs too specialized
function f(x, y) {
   var ret = 0;
   for (var i = 0; i < 100000; i++) {
       if (...)
           ...
       ret += x + y;
   }
   ...
}
TraceMonkey
function f(x, y) {
   var ret = 0;
   for (var i = 0; i < 100000; i++) {
       if (...)
           ...
       ret += x + y;
   }
   ...
}               typeof(x, y, i, ret) == int32
TraceMonkey

• Nanojit is too limited
 • Immutable IR
 • Poor regalloc
• Difficult to capture traces
TraceMonkey

• x+y
 • Store x to stack
 • Store y to stack
 • Add x, y
 • Check overflow
JägerMonkey
function f(x, y) {
   var ret = 0;
   for (var i = 0; i < 100000; i++) {
       if (...)
           ...
       ret += x + y;
   }
   ...
}
JägerMonkey


• No real IR or pipeline, just splats assembly
• Untyped
JägerMonkey
• x+y
 • Is x int32?
   • Yes: Is y int32?
     • Yes: add, check overflow
   • No: Is y double?
     • Yes: Convert x to double, add
     • No: ...
IonMonkey Goals

• Clean architecture
• Typed compilation
• Fastest JS
• Shoot lasers from space
Architecture Goals

• Ion looks like a textbook compiler
 • IRs, CFGs, blah blah
 • Passes are easy to add, remove, debug
 • Platform for future research and
    experimentation
Typed Compilation


• Any granularity!
• Type guards are hoisted as far as they can
  go
IonMonkey
function f(x, y) {
   var ret = 0;
   for (var i = 0; i < 100000; i++) {
       if (...)
           ...
       ret += x + y;
   }
   ...
}               typeof(x, y, i, ret) == int32
IonMonkey

• x+y
 • add
 • check overflow
Astronaut View
          IR

    Optimization

  Register Allocation

   Code Generation
MIR

• Middle-level IR in SSA form
• Actual control-flow graph built from
  SpiderMonkey bytecode
 • Single pass, yields semi-pruned SSA
 • Φs pruned in second pass
MIR Typing

• Ion has a “type oracle” interface
• MIR builds SSA based on oracle results
• TypeInference provides an oracle
  implementation
MIR Pre-Optimization
• MIR is untyped, but annotated with hints
              x               y

                  add(x, y)
MIR Pre-Optimization
• MIR is untyped, but annotated with hints
              x               y

                  add(x, y)       integer
MIR Pre-Optimization
• MIR is untyped, but annotated with hints
                x                  y

           Unbox(x, INT32) Unbox(x, INT32)



                 add-i32(x2, y2)
MIR Optimizations

• Global Value Numbering
 • Constant folding
 • Redundancy elimination
• Loop Invariant Code Motion
LIR

• Low-level IR, also SSA
• Per-architecture differentiation
• MIR is transformed to LIR in a single pass
• LIR specifies register policies
Two Register Allocators
• Greedy
 • Fast runtime, poor results
• Linear Scan
 • Slow runtime, good results
 •   “Linear Scan Register Allocation on SSA
     Form” (Wimmer et al)
Code Generation

• New macro assembler interface
• One codegen function per LIR, per $ARCH
• Code is managed by GC
Ion Frames

• Ion code runs in its own frames, on the C
  stack - no js::StackFrame!
• VM has limited interface to ask questions
  about Ion frames
Example

function (x, y) {
    return x + y;
}
Example LIR
v0   =   param0
v1   =   param1
i2   =   unbox(v0, INT32)
i3   =   unbox(v1, INT32)
i4   =   addi(v2, v3)
v5   =   box(v4)
--       return(v5)
Example Codegen
           cmp [esp+0x10], INT32
Unbox      jne _bailout
           mov [esp+0x14] -> ecx

           cmp [esp+0x18], INT32
Unbox      jne _bailout
           mov [esp+0x1C] -> edx

 Add       add edx -> ecx
           jo _bailout

Return     mov INT32 -> edx
           ret
Bailouts

• Guards indicate an assumption that must
  hold for JIT code to continue running
• If a guard fails, the current Ion frame is
  converted to a js::StackFrame
• Execution continues in the interpreter
Resume Points
• Can only resume at certain points:
 • Beginning of a basic block
 • After the result of a non-idempotent
    operation has been pushed
• We might re-run a few idempotent
  operations
Resume Points
function f(x, y) {
   var ret = 0;
   for (var i = 0; i < 100000; i++) {
       if (...)
           ...
       ret += x + y;
   }
   ...
}
Resume Points
function f(x, y) {
   var ret = 0;
   for (var i = 0; i < 100000; i++) {
       if (...)
           ...
       ret += x + y;
   }
   ...
}
Snapshots

• Describe how to convert an Ion frame to
  an interpreter frame
  • Compressed map of registers/stack
• No need to actively maintain interpreter
  state
On the Horizon

• ARM
• Type Inference
• Method Inlining
• Inline Caching
• On-Stack Replacement
IonMonkey Mozilla All-Hands 2011

More Related Content

What's hot

Railroading into Scala
Railroading into ScalaRailroading into Scala
Railroading into ScalaNehal Shah
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msanYandex
 
25 лет истории C++, пролетевшей на моих глазах
25 лет истории C++, пролетевшей на моих глазах25 лет истории C++, пролетевшей на моих глазах
25 лет истории C++, пролетевшей на моих глазахcorehard_by
 
Improving Android Performance at Mobiconf 2014
Improving Android Performance at Mobiconf 2014Improving Android Performance at Mobiconf 2014
Improving Android Performance at Mobiconf 2014Raimon Ràfols
 
Address/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerAddress/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerPlatonov Sergey
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеPlatonov Sergey
 
Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMDWei-Ta Wang
 
TMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVMTMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVMIosif Itkin
 
Introduction to idris
Introduction to idrisIntroduction to idris
Introduction to idrisConor Farrell
 
zkStudyClub: CirC and Compiling Programs to Circuits
zkStudyClub: CirC and Compiling Programs to CircuitszkStudyClub: CirC and Compiling Programs to Circuits
zkStudyClub: CirC and Compiling Programs to CircuitsAlex Pruden
 
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...MITSUNARI Shigeo
 
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and LearnPaul Irwin
 
Q4.11: Using GCC Auto-Vectorizer
Q4.11: Using GCC Auto-VectorizerQ4.11: Using GCC Auto-Vectorizer
Q4.11: Using GCC Auto-VectorizerLinaro
 
Patterns of 64-bit errors in games
Patterns of 64-bit errors in gamesPatterns of 64-bit errors in games
Patterns of 64-bit errors in gamesAndrey Karpov
 
A Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingA Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingMatsuo and Tsumura lab.
 
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov
 
TMPA-2015: A Need To Specify and Verify Standard Functions
TMPA-2015: A Need To Specify and Verify Standard FunctionsTMPA-2015: A Need To Specify and Verify Standard Functions
TMPA-2015: A Need To Specify and Verify Standard FunctionsIosif Itkin
 

What's hot (19)

Railroading into Scala
Railroading into ScalaRailroading into Scala
Railroading into Scala
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
 
25 лет истории C++, пролетевшей на моих глазах
25 лет истории C++, пролетевшей на моих глазах25 лет истории C++, пролетевшей на моих глазах
25 лет истории C++, пролетевшей на моих глазах
 
Improving Android Performance at Mobiconf 2014
Improving Android Performance at Mobiconf 2014Improving Android Performance at Mobiconf 2014
Improving Android Performance at Mobiconf 2014
 
Address/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerAddress/Thread/Memory Sanitizer
Address/Thread/Memory Sanitizer
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
 
Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMD
 
TMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVMTMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVM
 
Introduction to idris
Introduction to idrisIntroduction to idris
Introduction to idris
 
zkStudyClub: CirC and Compiling Programs to Circuits
zkStudyClub: CirC and Compiling Programs to CircuitszkStudyClub: CirC and Compiling Programs to Circuits
zkStudyClub: CirC and Compiling Programs to Circuits
 
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
 
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and Learn
 
Q4.11: Using GCC Auto-Vectorizer
Q4.11: Using GCC Auto-VectorizerQ4.11: Using GCC Auto-Vectorizer
Q4.11: Using GCC Auto-Vectorizer
 
Exploiting vectorization with ISPC
Exploiting vectorization with ISPCExploiting vectorization with ISPC
Exploiting vectorization with ISPC
 
Patterns of 64-bit errors in games
Patterns of 64-bit errors in gamesPatterns of 64-bit errors in games
Patterns of 64-bit errors in games
 
A Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingA Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with Multithreading
 
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
 
TMPA-2015: A Need To Specify and Verify Standard Functions
TMPA-2015: A Need To Specify and Verify Standard FunctionsTMPA-2015: A Need To Specify and Verify Standard Functions
TMPA-2015: A Need To Specify and Verify Standard Functions
 
Towards hasktorch 1.0
Towards hasktorch 1.0Towards hasktorch 1.0
Towards hasktorch 1.0
 

Viewers also liked

Davis Thayer - Math Program
 Davis Thayer - Math Program Davis Thayer - Math Program
Davis Thayer - Math ProgramFranklin Matters
 
Franklin High School - School Committee Update
Franklin High School - School Committee UpdateFranklin High School - School Committee Update
Franklin High School - School Committee UpdateFranklin Matters
 
Hands on Math for Early Elementary
Hands on Math for Early ElementaryHands on Math for Early Elementary
Hands on Math for Early Elementarymflaming
 
Old dogs new math
Old dogs new mathOld dogs new math
Old dogs new mathmaxwelljl
 
Groovy Grammar! Interesting ways to learn grammar!
Groovy Grammar! Interesting ways to learn grammar!Groovy Grammar! Interesting ways to learn grammar!
Groovy Grammar! Interesting ways to learn grammar!Shelly Sanchez Terrell
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Viewers also liked (6)

Davis Thayer - Math Program
 Davis Thayer - Math Program Davis Thayer - Math Program
Davis Thayer - Math Program
 
Franklin High School - School Committee Update
Franklin High School - School Committee UpdateFranklin High School - School Committee Update
Franklin High School - School Committee Update
 
Hands on Math for Early Elementary
Hands on Math for Early ElementaryHands on Math for Early Elementary
Hands on Math for Early Elementary
 
Old dogs new math
Old dogs new mathOld dogs new math
Old dogs new math
 
Groovy Grammar! Interesting ways to learn grammar!
Groovy Grammar! Interesting ways to learn grammar!Groovy Grammar! Interesting ways to learn grammar!
Groovy Grammar! Interesting ways to learn grammar!
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similar to IonMonkey Mozilla All-Hands 2011

JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsJonathan Salwan
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVModnoklassniki.ru
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itSergey Platonov
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines Parashuram N
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...JAX London
 
Powering a live escape game with ecf and efxclipse
Powering a live escape game with ecf and efxclipsePowering a live escape game with ecf and efxclipse
Powering a live escape game with ecf and efxclipseChristoph Keimel
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Charles Nutter
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS EngineChengHui Weng
 
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
 
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)Tech in Asia ID
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassSam Thomas
 
Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++Satalia
 
Understanding the Disruptor
Understanding the DisruptorUnderstanding the Disruptor
Understanding the DisruptorTrisha Gee
 
Everybody be cool, this is a roppery!
Everybody be cool, this is a roppery!Everybody be cool, this is a roppery!
Everybody be cool, this is a roppery!zynamics GmbH
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software DevelopmentNaveenkumar Muguda
 
OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...
OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...
OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...NECST Lab @ Politecnico di Milano
 

Similar to IonMonkey Mozilla All-Hands 2011 (20)

Jvm memory model
Jvm memory modelJvm memory model
Jvm memory model
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protections
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVM
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
 
Powering a live escape game with ecf and efxclipse
Powering a live escape game with ecf and efxclipsePowering a live escape game with ecf and efxclipse
Powering a live escape game with ecf and efxclipse
 
Session 3#
Session 3#Session 3#
Session 3#
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine
 
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
 
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
"Practical Machine Learning With Ruby" by Iqbal Farabi (ID Ruby Community)
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypass
 
Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++
 
Understanding the Disruptor
Understanding the DisruptorUnderstanding the Disruptor
Understanding the Disruptor
 
Clojure intro
Clojure introClojure intro
Clojure intro
 
Everybody be cool, this is a roppery!
Everybody be cool, this is a roppery!Everybody be cool, this is a roppery!
Everybody be cool, this is a roppery!
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
 
OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...
OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...
OXiGen: Automated FPGA design flow from C applications to dataflow kernels - ...
 

Recently uploaded

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Recently uploaded (20)

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

IonMonkey Mozilla All-Hands 2011

  • 1. IonMonkey One JIT To Rule Them All Mozilla All-Hands 2011, San Jose Convention Center
  • 2. Why? • Existing JITs too specialized
  • 3. function f(x, y) { var ret = 0; for (var i = 0; i < 100000; i++) { if (...) ... ret += x + y; } ... }
  • 4. TraceMonkey function f(x, y) { var ret = 0; for (var i = 0; i < 100000; i++) { if (...) ... ret += x + y; } ... } typeof(x, y, i, ret) == int32
  • 5. TraceMonkey • Nanojit is too limited • Immutable IR • Poor regalloc • Difficult to capture traces
  • 6. TraceMonkey • x+y • Store x to stack • Store y to stack • Add x, y • Check overflow
  • 7. JägerMonkey function f(x, y) { var ret = 0; for (var i = 0; i < 100000; i++) { if (...) ... ret += x + y; } ... }
  • 8. JägerMonkey • No real IR or pipeline, just splats assembly • Untyped
  • 9. JägerMonkey • x+y • Is x int32? • Yes: Is y int32? • Yes: add, check overflow • No: Is y double? • Yes: Convert x to double, add • No: ...
  • 10. IonMonkey Goals • Clean architecture • Typed compilation • Fastest JS • Shoot lasers from space
  • 11. Architecture Goals • Ion looks like a textbook compiler • IRs, CFGs, blah blah • Passes are easy to add, remove, debug • Platform for future research and experimentation
  • 12. Typed Compilation • Any granularity! • Type guards are hoisted as far as they can go
  • 13. IonMonkey function f(x, y) { var ret = 0; for (var i = 0; i < 100000; i++) { if (...) ... ret += x + y; } ... } typeof(x, y, i, ret) == int32
  • 14. IonMonkey • x+y • add • check overflow
  • 15. Astronaut View IR Optimization Register Allocation Code Generation
  • 16. MIR • Middle-level IR in SSA form • Actual control-flow graph built from SpiderMonkey bytecode • Single pass, yields semi-pruned SSA • Φs pruned in second pass
  • 17. MIR Typing • Ion has a “type oracle” interface • MIR builds SSA based on oracle results • TypeInference provides an oracle implementation
  • 18. MIR Pre-Optimization • MIR is untyped, but annotated with hints x y add(x, y)
  • 19. MIR Pre-Optimization • MIR is untyped, but annotated with hints x y add(x, y) integer
  • 20. MIR Pre-Optimization • MIR is untyped, but annotated with hints x y Unbox(x, INT32) Unbox(x, INT32) add-i32(x2, y2)
  • 21. MIR Optimizations • Global Value Numbering • Constant folding • Redundancy elimination • Loop Invariant Code Motion
  • 22. LIR • Low-level IR, also SSA • Per-architecture differentiation • MIR is transformed to LIR in a single pass • LIR specifies register policies
  • 23. Two Register Allocators • Greedy • Fast runtime, poor results • Linear Scan • Slow runtime, good results • “Linear Scan Register Allocation on SSA Form” (Wimmer et al)
  • 24. Code Generation • New macro assembler interface • One codegen function per LIR, per $ARCH • Code is managed by GC
  • 25. Ion Frames • Ion code runs in its own frames, on the C stack - no js::StackFrame! • VM has limited interface to ask questions about Ion frames
  • 26. Example function (x, y) { return x + y; }
  • 27. Example LIR v0 = param0 v1 = param1 i2 = unbox(v0, INT32) i3 = unbox(v1, INT32) i4 = addi(v2, v3) v5 = box(v4) -- return(v5)
  • 28. Example Codegen cmp [esp+0x10], INT32 Unbox jne _bailout mov [esp+0x14] -> ecx cmp [esp+0x18], INT32 Unbox jne _bailout mov [esp+0x1C] -> edx Add add edx -> ecx jo _bailout Return mov INT32 -> edx ret
  • 29. Bailouts • Guards indicate an assumption that must hold for JIT code to continue running • If a guard fails, the current Ion frame is converted to a js::StackFrame • Execution continues in the interpreter
  • 30. Resume Points • Can only resume at certain points: • Beginning of a basic block • After the result of a non-idempotent operation has been pushed • We might re-run a few idempotent operations
  • 31. Resume Points function f(x, y) { var ret = 0; for (var i = 0; i < 100000; i++) { if (...) ... ret += x + y; } ... }
  • 32. Resume Points function f(x, y) { var ret = 0; for (var i = 0; i < 100000; i++) { if (...) ... ret += x + y; } ... }
  • 33. Snapshots • Describe how to convert an Ion frame to an interpreter frame • Compressed map of registers/stack • No need to actively maintain interpreter state
  • 34. On the Horizon • ARM • Type Inference • Method Inlining • Inline Caching • On-Stack Replacement

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n