SlideShare una empresa de Scribd logo
1 de 19
JSX Optimizer
    DeNA Co., Ltd.
     Kazuho Oku
The Basic Idea of the JSX Optimizer




    perform optimizations that JavaScript VMs
                     cannot




Jul 19 2012             JSX Optimizer       2
Benchmark Scores

   Box2D.jsx
         +13.5% (iOS 5.0, iPhone 4)
         +11.8% (iOS 5.1, iPhone 4S)
         +28.7% (Android 2.3, Xperia ray)
         numbers are increase in fps
   ToDo: post the details



Jul 19 2012                 JSX Optimizer    3
The Nature of JavaScript

   a dynamic language
         primitives are untyped
              a + 1 becomes "a1" if a is "a", 2 if a is 1
         objects are untyped
              a.p may point to whatever

   solution: inline caching
         V8, JavaScriptCore, SpiderMonkey



Jul 19 2012                        JSX Optimizer             4
Inline Caching

   The idea:
         most of the code will be called with the same
          types of arguments
         cache the expectation at the call site
   Example: point.x
         type of point will be { x: ?, y: ? }
         thus if the expectation succeeded, point.x will be:
              load point_addr[offset_of_x]


Jul 19 2012                     JSX Optimizer                   5
Guards in Inline Caching

   Example: a = b.p + 1
         typeof(b) is as expected
         load b.p
         typeof(b.p) is number
         add one
         store the result




Jul 19 2012                 JSX Optimizer   6
Guards in Inline Caching (cont'd)

   Example: f()
         typeof(f) is function
         setup stack frame
         jump to the code of f




Jul 19 2012                 JSX Optimizer   7
Guards in Inline Caching (cont'd)

   Example: f() // after inlined
         typeof(f) is function
          f has not been altered
         execute the code expanded in-line




Jul 19 2012                 JSX Optimizer     8
Guards in Inline Caching (cont'd)

   Example: o.f()
         typeof(o) is as expected
         load o.prototype
         typeof (o.prototype) is as expected
         load o.prototype.f
         typeof(f) is function
         setup stack frame
         jump to the code of f


Jul 19 2012                  JSX Optimizer      9
Guards in Inline Caching (cont'd)

   Example: o.f() // after inlined
         typeof(o) is as expected
         load o.prototype
         typeof (o.prototype) is as expected
         load o.prototype.f
         typeof(f) is function
          f has not been altered
         execute the code expanded in-line


Jul 19 2012                  JSX Optimizer      10
What interpreters do / do not

   inter-statement optimization
         V8 does
         SpiderMonkey and JavaScriptCore seem not
   inline-expand the JavaScript functions
         at least V8 does




Jul 19 2012                  JSX Optimizer           11
JSX optimizer

   minimizes the need for IC
         caches property access
              JSX does not have accessors (Object.defineProperty)
         inline-expands the functions
         converts member methods to static functions
   generates IC-friendly code
         always initializes the properties in same order
              Note: { x: 0, y: 0 } and { y: 1, x: 1 } are different
               types

Jul 19 2012                        JSX Optimizer                       12
JSX optimizer

   minimizes the pressure on GC
         unboxing
   folds constants
         JavaScript does not have a true const




Jul 19 2012                 JSX Optimizer         13
Example: affine transformation

   input:
         new Matrix(1, 0, 0, 0, 2, 0).transform(new Point(x, y))

   output:
         {x: x + 0 * y, y: 0 * x + 2 * y}

         Note: 0 * n cannot be optimized to 0, since it becomes NaN if n is NaN




Jul 19 2012                                 JSX Optimizer                         14
Current Optimization Subcommands

      lto
      no-assert
      no-log
      unclassify
      fold-const
      inline
      dce
      return-if
      lcse
      unbox
      array-length
Jul 19 2012             JSX Optimizer     15
Diffs. from an ordinary optimizing compiler

   ordinary compiler
         generate a low-level non-redundant code
   JSX compiler
         most code are left as is
         while optimizing the code wherever possible




Jul 19 2012                 JSX Optimizer               16
The Difficulties and Considerations

   switch to SSA-based code?
         might end-up in generating a very different code
          from source
              would be difficult to debug (by the users)
              may become slow (than the same-looking code in
               JavaScript); GCC has the problem
         it is troublesome to optimize the code while
          maintaining the original code structure
              example. support various kind of loops: do-while, for,
               for..in, while

Jul 19 2012                       JSX Optimizer                         17
The Difficulties and Considerations (cont'd)

   Other optimization techniques?
         inline allocation?
         more powerful dce / dse
         reduce the number of locals?




Jul 19 2012                 JSX Optimizer            18
Some Microbenchmarks
   http://jsperf.com/local-vs-member/2
   http://jsperf.com/construct-object-vs-array/3
   http://jsperf.com/inherit-object-vs-array-set
   http://jsperf.com/vars-in-nested-closure




Jul 19 2012                            JSX Optimizer   19

Más contenido relacionado

La actualidad más candente

Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!Tim Geisler
 
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...Nuxeo
 
openCPQ - A React-Based Product-Configuration Toolkit
openCPQ - A React-Based Product-Configuration ToolkitopenCPQ - A React-Based Product-Configuration Toolkit
openCPQ - A React-Based Product-Configuration ToolkitTim Geisler
 
Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyGuillaume Laforge
 
PHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success StoryPHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success StoryMichael Spector
 
CSS :has() - The story so far and the path ahead
CSS :has() - The story so far and the path aheadCSS :has() - The story so far and the path ahead
CSS :has() - The story so far and the path aheadIgalia
 
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...elliando dias
 
.Net framework interview questions
.Net framework interview questions.Net framework interview questions
.Net framework interview questionsMir Majid
 
Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)jbandi
 

La actualidad más candente (9)

Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!
 
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
 
openCPQ - A React-Based Product-Configuration Toolkit
openCPQ - A React-Based Product-Configuration ToolkitopenCPQ - A React-Based Product-Configuration Toolkit
openCPQ - A React-Based Product-Configuration Toolkit
 
Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in Groovy
 
PHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success StoryPHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success Story
 
CSS :has() - The story so far and the path ahead
CSS :has() - The story so far and the path aheadCSS :has() - The story so far and the path ahead
CSS :has() - The story so far and the path ahead
 
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
 
.Net framework interview questions
.Net framework interview questions.Net framework interview questions
.Net framework interview questions
 
Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)Professional JavaScript Development (An Introduction for Java Developers)
Professional JavaScript Development (An Introduction for Java Developers)
 

Destacado

JSX Design Overview (日本語)
JSX Design Overview (日本語)JSX Design Overview (日本語)
JSX Design Overview (日本語)Kazuho Oku
 
Test Engineering on Mobage
Test Engineering on MobageTest Engineering on Mobage
Test Engineering on MobageMasaki Nakagawa
 
OpenVis Conference Report Part 1 (and Introduction to D3.js)
OpenVis Conference Report Part 1 (and Introduction to D3.js)OpenVis Conference Report Part 1 (and Introduction to D3.js)
OpenVis Conference Report Part 1 (and Introduction to D3.js)Keiichiro Ono
 
Sprawne Smoki 2010-2011
Sprawne Smoki 2010-2011Sprawne Smoki 2010-2011
Sprawne Smoki 2010-2011Maria Ptak
 
Lyddie: Unit2 lesson1
Lyddie: Unit2 lesson1Lyddie: Unit2 lesson1
Lyddie: Unit2 lesson1Terri Weiss
 
Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...
Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...
Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...Guy Haviv
 
102報稅懶人包
102報稅懶人包102報稅懶人包
102報稅懶人包olivertw
 
Chef - the second presentation
Chef - the second presentationChef - the second presentation
Chef - the second presentationRobert Postill
 
Lyddie: Unit3 lesson9
Lyddie: Unit3 lesson9Lyddie: Unit3 lesson9
Lyddie: Unit3 lesson9Terri Weiss
 
Overview for Technical Nearshore Investment in Costa Rica
Overview for Technical Nearshore Investment in Costa RicaOverview for Technical Nearshore Investment in Costa Rica
Overview for Technical Nearshore Investment in Costa RicaAndrea Tanzi
 
Donde esta el Dios de justicia
Donde esta el Dios de justiciaDonde esta el Dios de justicia
Donde esta el Dios de justiciaPaulo Arieu
 
What's in a habitat?
What's in a habitat?What's in a habitat?
What's in a habitat?Russell Ogden
 
Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42
Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42
Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42Maria Podolyak
 
A Tour of Google Earth
A Tour of Google EarthA Tour of Google Earth
A Tour of Google EarthHeather Dowd
 
ruchome miejsca i etnografia translokalności
ruchome miejsca i etnografia translokalnościruchome miejsca i etnografia translokalności
ruchome miejsca i etnografia translokalnościagata stanisz
 

Destacado (20)

JSX Design Overview (日本語)
JSX Design Overview (日本語)JSX Design Overview (日本語)
JSX Design Overview (日本語)
 
Test Engineering on Mobage
Test Engineering on MobageTest Engineering on Mobage
Test Engineering on Mobage
 
OpenVis Conference Report Part 1 (and Introduction to D3.js)
OpenVis Conference Report Part 1 (and Introduction to D3.js)OpenVis Conference Report Part 1 (and Introduction to D3.js)
OpenVis Conference Report Part 1 (and Introduction to D3.js)
 
Sprawne Smoki 2010-2011
Sprawne Smoki 2010-2011Sprawne Smoki 2010-2011
Sprawne Smoki 2010-2011
 
EDiNEB 2010
EDiNEB 2010EDiNEB 2010
EDiNEB 2010
 
Lyddie: Unit2 lesson1
Lyddie: Unit2 lesson1Lyddie: Unit2 lesson1
Lyddie: Unit2 lesson1
 
Sprawozdanie
SprawozdanieSprawozdanie
Sprawozdanie
 
Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...
Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...
Bezalel: Introduction to Interactive Design: ב4 - מבוא לעיצוב אינטראקטיבי - ה...
 
102報稅懶人包
102報稅懶人包102報稅懶人包
102報稅懶人包
 
Chef - the second presentation
Chef - the second presentationChef - the second presentation
Chef - the second presentation
 
Lyddie: Unit3 lesson9
Lyddie: Unit3 lesson9Lyddie: Unit3 lesson9
Lyddie: Unit3 lesson9
 
Overview for Technical Nearshore Investment in Costa Rica
Overview for Technical Nearshore Investment in Costa RicaOverview for Technical Nearshore Investment in Costa Rica
Overview for Technical Nearshore Investment in Costa Rica
 
The Roots of Innovation
The Roots of InnovationThe Roots of Innovation
The Roots of Innovation
 
Donde esta el Dios de justicia
Donde esta el Dios de justiciaDonde esta el Dios de justicia
Donde esta el Dios de justicia
 
What's in a habitat?
What's in a habitat?What's in a habitat?
What's in a habitat?
 
Origen, filosofía
Origen, filosofíaOrigen, filosofía
Origen, filosofía
 
Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42
Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42
Электронные журналы для планшетов. Новые возможности в Magtoapp Editor 1.42
 
A Tour of Google Earth
A Tour of Google EarthA Tour of Google Earth
A Tour of Google Earth
 
Clientbridge
ClientbridgeClientbridge
Clientbridge
 
ruchome miejsca i etnografia translokalności
ruchome miejsca i etnografia translokalnościruchome miejsca i etnografia translokalności
ruchome miejsca i etnografia translokalności
 

Similar a JSX Optimizer

Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part IIEugene Lazutkin
 
Advanced Node.JS Meetup
Advanced Node.JS MeetupAdvanced Node.JS Meetup
Advanced Node.JS MeetupLINAGORA
 
Performance #5 cpu and battery
Performance #5  cpu and batteryPerformance #5  cpu and battery
Performance #5 cpu and batteryVitali Pekelis
 
How to develop an iOS application
How to develop an iOS applicationHow to develop an iOS application
How to develop an iOS applicationLe Quang
 
Modern server side development with node.js - Benjamin gruenbaum
Modern server side development with node.js - Benjamin gruenbaumModern server side development with node.js - Benjamin gruenbaum
Modern server side development with node.js - Benjamin gruenbaumgeektimecoil
 
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)Igalia
 
Decorating code (Research Paper)
Decorating code (Research Paper)Decorating code (Research Paper)
Decorating code (Research Paper)Jenna Pederson
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 
Dojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspectiveDojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspectivecjolif
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemGuardSquare
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !Ritesh Kumar
 
High performance web programming with C++14
High performance web programming with C++14High performance web programming with C++14
High performance web programming with C++14Matthieu Garrigues
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application DevelopmentRamesh Prasad
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8Phil Eaton
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Paris Android User Group
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
Integrate Spring MVC with RequireJS & Backbone.js & Spring Data JPA
Integrate Spring MVC with RequireJS & Backbone.js & Spring Data JPAIntegrate Spring MVC with RequireJS & Backbone.js & Spring Data JPA
Integrate Spring MVC with RequireJS & Backbone.js & Spring Data JPACheng Ta Yeh
 
Ajax for-coldfusion-developers
Ajax for-coldfusion-developersAjax for-coldfusion-developers
Ajax for-coldfusion-developersSudhakar Ganta
 

Similar a JSX Optimizer (20)

Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
 
Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
 
Advanced Node.JS Meetup
Advanced Node.JS MeetupAdvanced Node.JS Meetup
Advanced Node.JS Meetup
 
Performance #5 cpu and battery
Performance #5  cpu and batteryPerformance #5  cpu and battery
Performance #5 cpu and battery
 
How to develop an iOS application
How to develop an iOS applicationHow to develop an iOS application
How to develop an iOS application
 
Modern server side development with node.js - Benjamin gruenbaum
Modern server side development with node.js - Benjamin gruenbaumModern server side development with node.js - Benjamin gruenbaum
Modern server side development with node.js - Benjamin gruenbaum
 
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
 
Decorating code (Research Paper)
Decorating code (Research Paper)Decorating code (Research Paper)
Decorating code (Research Paper)
 
I os
I osI os
I os
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
Dojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspectiveDojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspective
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !
 
High performance web programming with C++14
High performance web programming with C++14High performance web programming with C++14
High performance web programming with C++14
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Integrate Spring MVC with RequireJS & Backbone.js & Spring Data JPA
Integrate Spring MVC with RequireJS & Backbone.js & Spring Data JPAIntegrate Spring MVC with RequireJS & Backbone.js & Spring Data JPA
Integrate Spring MVC with RequireJS & Backbone.js & Spring Data JPA
 
Ajax for-coldfusion-developers
Ajax for-coldfusion-developersAjax for-coldfusion-developers
Ajax for-coldfusion-developers
 

Más de Kazuho Oku

HTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないときHTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないときKazuho Oku
 
QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7Kazuho Oku
 
HTTP/2の課題と将来
HTTP/2の課題と将来HTTP/2の課題と将来
HTTP/2の課題と将来Kazuho Oku
 
TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話Kazuho Oku
 
Reorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondReorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondKazuho Oku
 
Recent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using rubyRecent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using rubyKazuho Oku
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsivenessKazuho Oku
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsivenessKazuho Oku
 
Developing the fastest HTTP/2 server
Developing the fastest HTTP/2 serverDeveloping the fastest HTTP/2 server
Developing the fastest HTTP/2 serverKazuho Oku
 
TLS & LURK @ IETF 95
TLS & LURK @ IETF 95TLS & LURK @ IETF 95
TLS & LURK @ IETF 95Kazuho Oku
 
HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向Kazuho Oku
 
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先Kazuho Oku
 
Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5Kazuho Oku
 
HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計Kazuho Oku
 
H2O - making the Web faster
H2O - making the Web fasterH2O - making the Web faster
H2O - making the Web fasterKazuho Oku
 
H2O - making HTTP better
H2O - making HTTP betterH2O - making HTTP better
H2O - making HTTP betterKazuho Oku
 
H2O - the optimized HTTP server
H2O - the optimized HTTP serverH2O - the optimized HTTP server
H2O - the optimized HTTP serverKazuho Oku
 
JSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons LearnedJSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons LearnedKazuho Oku
 
JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法Kazuho Oku
 
JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013Kazuho Oku
 

Más de Kazuho Oku (20)

HTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないときHTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないとき
 
QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7
 
HTTP/2の課題と将来
HTTP/2の課題と将来HTTP/2の課題と将来
HTTP/2の課題と将来
 
TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話
 
Reorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondReorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and Beyond
 
Recent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using rubyRecent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using ruby
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsiveness
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsiveness
 
Developing the fastest HTTP/2 server
Developing the fastest HTTP/2 serverDeveloping the fastest HTTP/2 server
Developing the fastest HTTP/2 server
 
TLS & LURK @ IETF 95
TLS & LURK @ IETF 95TLS & LURK @ IETF 95
TLS & LURK @ IETF 95
 
HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向
 
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
 
Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5
 
HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計
 
H2O - making the Web faster
H2O - making the Web fasterH2O - making the Web faster
H2O - making the Web faster
 
H2O - making HTTP better
H2O - making HTTP betterH2O - making HTTP better
H2O - making HTTP better
 
H2O - the optimized HTTP server
H2O - the optimized HTTP serverH2O - the optimized HTTP server
H2O - the optimized HTTP server
 
JSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons LearnedJSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons Learned
 
JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法
 
JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013
 

Último

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

JSX Optimizer

  • 1. JSX Optimizer DeNA Co., Ltd. Kazuho Oku
  • 2. The Basic Idea of the JSX Optimizer perform optimizations that JavaScript VMs cannot Jul 19 2012 JSX Optimizer 2
  • 3. Benchmark Scores Box2D.jsx +13.5% (iOS 5.0, iPhone 4) +11.8% (iOS 5.1, iPhone 4S) +28.7% (Android 2.3, Xperia ray) numbers are increase in fps ToDo: post the details Jul 19 2012 JSX Optimizer 3
  • 4. The Nature of JavaScript a dynamic language primitives are untyped a + 1 becomes "a1" if a is "a", 2 if a is 1 objects are untyped a.p may point to whatever solution: inline caching V8, JavaScriptCore, SpiderMonkey Jul 19 2012 JSX Optimizer 4
  • 5. Inline Caching The idea: most of the code will be called with the same types of arguments cache the expectation at the call site Example: point.x type of point will be { x: ?, y: ? } thus if the expectation succeeded, point.x will be: load point_addr[offset_of_x] Jul 19 2012 JSX Optimizer 5
  • 6. Guards in Inline Caching Example: a = b.p + 1 typeof(b) is as expected load b.p typeof(b.p) is number add one store the result Jul 19 2012 JSX Optimizer 6
  • 7. Guards in Inline Caching (cont'd) Example: f() typeof(f) is function setup stack frame jump to the code of f Jul 19 2012 JSX Optimizer 7
  • 8. Guards in Inline Caching (cont'd) Example: f() // after inlined typeof(f) is function  f has not been altered execute the code expanded in-line Jul 19 2012 JSX Optimizer 8
  • 9. Guards in Inline Caching (cont'd) Example: o.f() typeof(o) is as expected load o.prototype typeof (o.prototype) is as expected load o.prototype.f typeof(f) is function setup stack frame jump to the code of f Jul 19 2012 JSX Optimizer 9
  • 10. Guards in Inline Caching (cont'd) Example: o.f() // after inlined typeof(o) is as expected load o.prototype typeof (o.prototype) is as expected load o.prototype.f typeof(f) is function  f has not been altered execute the code expanded in-line Jul 19 2012 JSX Optimizer 10
  • 11. What interpreters do / do not inter-statement optimization V8 does SpiderMonkey and JavaScriptCore seem not inline-expand the JavaScript functions at least V8 does Jul 19 2012 JSX Optimizer 11
  • 12. JSX optimizer minimizes the need for IC caches property access JSX does not have accessors (Object.defineProperty) inline-expands the functions converts member methods to static functions generates IC-friendly code always initializes the properties in same order Note: { x: 0, y: 0 } and { y: 1, x: 1 } are different types Jul 19 2012 JSX Optimizer 12
  • 13. JSX optimizer minimizes the pressure on GC unboxing folds constants JavaScript does not have a true const Jul 19 2012 JSX Optimizer 13
  • 14. Example: affine transformation input: new Matrix(1, 0, 0, 0, 2, 0).transform(new Point(x, y)) output: {x: x + 0 * y, y: 0 * x + 2 * y} Note: 0 * n cannot be optimized to 0, since it becomes NaN if n is NaN Jul 19 2012 JSX Optimizer 14
  • 15. Current Optimization Subcommands  lto  no-assert  no-log  unclassify  fold-const  inline  dce  return-if  lcse  unbox  array-length Jul 19 2012 JSX Optimizer 15
  • 16. Diffs. from an ordinary optimizing compiler ordinary compiler generate a low-level non-redundant code JSX compiler most code are left as is while optimizing the code wherever possible Jul 19 2012 JSX Optimizer 16
  • 17. The Difficulties and Considerations switch to SSA-based code? might end-up in generating a very different code from source would be difficult to debug (by the users) may become slow (than the same-looking code in JavaScript); GCC has the problem it is troublesome to optimize the code while maintaining the original code structure example. support various kind of loops: do-while, for, for..in, while Jul 19 2012 JSX Optimizer 17
  • 18. The Difficulties and Considerations (cont'd) Other optimization techniques? inline allocation? more powerful dce / dse reduce the number of locals? Jul 19 2012 JSX Optimizer 18
  • 19. Some Microbenchmarks http://jsperf.com/local-vs-member/2 http://jsperf.com/construct-object-vs-array/3 http://jsperf.com/inherit-object-vs-array-set http://jsperf.com/vars-in-nested-closure Jul 19 2012 JSX Optimizer 19