SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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 - ...
 

Kürzlich hochgeladen

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

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

Hinweis der Redaktion

  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