[フレーム]

JSX Optimizer

The document discusses the JSX Optimizer, which performs optimizations on JavaScript code that JavaScript VMs cannot. It aims to minimize the need for inline caching, pressure on the garbage collector, and maintain the original code structure while optimizing. Some optimizations included are constant folding, inlining functions, and unboxing. Challenges include switching to SSA form and maintaining debuggability of the original code. Benchmark results show a 13.5-28.7% increase in frames per second for the Box2D game engine.

Embed presentation

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

More Related Content

JSX
PPTX
JSX - developing a statically-typed programming language for the Web
PDF
JSX - developing a statically-typed programming language for the Web
Groovy Finesse
PDF
Groovy Finesse
Rcs project Training Bangalore
PDF
Rcs project Training Bangalore
Core java
PPTX
Core java
00_VB_Intro
ODP
00_VB_Intro
HTTP Potpourri
PDF
HTTP Potpourri
Internationalize your JavaScript Application: Prepare for "the next billion" ...
PDF
Internationalize your JavaScript Application: Prepare for "the next billion" ...
JSX
JSX - developing a statically-typed programming language for the Web
JSX - developing a statically-typed programming language for the Web
Groovy Finesse
Groovy Finesse
Rcs project Training Bangalore
Rcs project Training Bangalore
Core java
Core java
00_VB_Intro
00_VB_Intro
HTTP Potpourri
HTTP Potpourri
Internationalize your JavaScript Application: Prepare for "the next billion" ...
Internationalize your JavaScript Application: Prepare for "the next billion" ...

What's hot

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

Viewers also liked

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

Similar to JSX Optimizer

Javascript Performance
PDF
Javascript Performance
How much performance can you get out of Javascript? - Massimiliano Mantione -...
PDF
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Kevin Whinnery: Write Better JavaScript
PDF
Kevin Whinnery: Write Better JavaScript
Understanding Javascript Engines
PPTX
Understanding Javascript Engines
Turbo charging v8 engine
PPTX
Turbo charging v8 engine
High quality Front-End
PDF
High quality Front-End
Object Oriented Programming In JavaScript
PPTX
Object Oriented Programming In JavaScript
IWT presentation121232112122222225556+556.pptx
PPTX
IWT presentation121232112122222225556+556.pptx
Run-time of Node.js : V8 JavaScript Engine
PDF
Run-time of Node.js : V8 JavaScript Engine
You Don t Know JS ES6 Beyond Kyle Simpson
PDF
You Don t Know JS ES6 Beyond Kyle Simpson
FRONTEND BOOTCAMP Session 2.pptx
PPTX
FRONTEND BOOTCAMP Session 2.pptx
JavaScript Core
PDF
JavaScript Core
Javascript best practices
PPTX
Javascript best practices
Write Better JavaScript
PPTX
Write Better JavaScript
Write Better JavaScript
PPTX
Write Better JavaScript
Javascript the New Parts v2
PDF
Javascript the New Parts v2
The Future of JavaScript (Ajax Exp '07)
PDF
The Future of JavaScript (Ajax Exp '07)
Awesomeness of JavaScript...almost
PPTX
Awesomeness of JavaScript...almost
Introduction to Javascript
PPT
Introduction to Javascript
Tamarin And Ecmascript 4
PDF
Tamarin And Ecmascript 4
Javascript Performance
Javascript Performance
How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScript
Understanding Javascript Engines
Understanding Javascript Engines
Turbo charging v8 engine
Turbo charging v8 engine
High quality Front-End
High quality Front-End
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
IWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptx
Run-time of Node.js : V8 JavaScript Engine
Run-time of Node.js : V8 JavaScript Engine
You Don t Know JS ES6 Beyond Kyle Simpson
You Don t Know JS ES6 Beyond Kyle Simpson
FRONTEND BOOTCAMP Session 2.pptx
FRONTEND BOOTCAMP Session 2.pptx
JavaScript Core
JavaScript Core
Javascript best practices
Javascript best practices
Write Better JavaScript
Write Better JavaScript
Write Better JavaScript
Write Better JavaScript
Javascript the New Parts v2
Javascript the New Parts v2
The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)
Awesomeness of JavaScript...almost
Awesomeness of JavaScript...almost
Introduction to Javascript
Introduction to Javascript
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4

More from Kazuho Oku

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

Recently uploaded

HCI and Its Impact on individual quality of life.pdf
PDF
HCI and Its Impact on individual quality of life.pdf
Generative AI in UiPath: Mastering the Generative Extractor for Intelligent D...
PDF
Generative AI in UiPath: Mastering the Generative Extractor for Intelligent D...
Innovative AI Solutions for Business Growth.pdf
PDF
Innovative AI Solutions for Business Growth.pdf
Digital Transformation in Entertainment Industry Bangladesh 2025
PPTX
Digital Transformation in Entertainment Industry Bangladesh 2025
Basics of Identity Access Management In mordern Infrastructure
PPTX
Basics of Identity Access Management In mordern Infrastructure
Generative AI in 2026: Hype, Bubble, Winter or The Real Deal?
PDF
Generative AI in 2026: Hype, Bubble, Winter or The Real Deal?
eResource Scheduler Enterprise Resource Management and Scheduling Software.pdf
PDF
eResource Scheduler Enterprise Resource Management and Scheduling Software.pdf
Safeguarding AI-Based Financial Infrastructure
PDF
Safeguarding AI-Based Financial Infrastructure
Agentic Automation for Testers – A Hands-On Deep Dive
PDF
Agentic Automation for Testers – A Hands-On Deep Dive
Engineering AI Systems - A Summary of Architecture and DevOps Essentials
PDF
Engineering AI Systems - A Summary of Architecture and DevOps Essentials
Mobile-Computing-A-Revolution-in-Our-Hands.pdf
PDF
Mobile-Computing-A-Revolution-in-Our-Hands.pdf
Incident Response Planning with a Foundation Model
PDF
Incident Response Planning with a Foundation Model
The Future of Search: Why LLM Optimization Matters for Every Website
PDF
The Future of Search: Why LLM Optimization Matters for Every Website
Digit Expo 2025 - EICC Edinburgh 27th November
PDF
Digit Expo 2025 - EICC Edinburgh 27th November
Igniting the Future: Copilot trends, agentic transformation and product roadm...
PDF
Igniting the Future: Copilot trends, agentic transformation and product roadm...
CompTIA Cybersecurity Analyst (CySA+) CS0-003: Unit 4
PDF
CompTIA Cybersecurity Analyst (CySA+) CS0-003: Unit 4
Tracing the Thread: Decoding the Decision-Making Process with GraphRAG
PDF
Tracing the Thread: Decoding the Decision-Making Process with GraphRAG
API206-S: Transforming Supply Chains with Amazon Bedrock AgentCore - AWS re:I...
PDF
API206-S: Transforming Supply Chains with Amazon Bedrock AgentCore - AWS re:I...
The Ultimate Guide to Problem Management Dashboards for IT Teams.pdf
PDF
The Ultimate Guide to Problem Management Dashboards for IT Teams.pdf
Recursive Self Improvement vs Continuous Learning
PDF
Recursive Self Improvement vs Continuous Learning
HCI and Its Impact on individual quality of life.pdf
HCI and Its Impact on individual quality of life.pdf
Generative AI in UiPath: Mastering the Generative Extractor for Intelligent D...
Generative AI in UiPath: Mastering the Generative Extractor for Intelligent D...
Innovative AI Solutions for Business Growth.pdf
Innovative AI Solutions for Business Growth.pdf
Digital Transformation in Entertainment Industry Bangladesh 2025
Digital Transformation in Entertainment Industry Bangladesh 2025
Basics of Identity Access Management In mordern Infrastructure
Basics of Identity Access Management In mordern Infrastructure
Generative AI in 2026: Hype, Bubble, Winter or The Real Deal?
Generative AI in 2026: Hype, Bubble, Winter or The Real Deal?
eResource Scheduler Enterprise Resource Management and Scheduling Software.pdf
eResource Scheduler Enterprise Resource Management and Scheduling Software.pdf
Safeguarding AI-Based Financial Infrastructure
Safeguarding AI-Based Financial Infrastructure
Agentic Automation for Testers – A Hands-On Deep Dive
Agentic Automation for Testers – A Hands-On Deep Dive
Engineering AI Systems - A Summary of Architecture and DevOps Essentials
Engineering AI Systems - A Summary of Architecture and DevOps Essentials
Mobile-Computing-A-Revolution-in-Our-Hands.pdf
Mobile-Computing-A-Revolution-in-Our-Hands.pdf
Incident Response Planning with a Foundation Model
Incident Response Planning with a Foundation Model
The Future of Search: Why LLM Optimization Matters for Every Website
The Future of Search: Why LLM Optimization Matters for Every Website
Digit Expo 2025 - EICC Edinburgh 27th November
Digit Expo 2025 - EICC Edinburgh 27th November
Igniting the Future: Copilot trends, agentic transformation and product roadm...
Igniting the Future: Copilot trends, agentic transformation and product roadm...
CompTIA Cybersecurity Analyst (CySA+) CS0-003: Unit 4
CompTIA Cybersecurity Analyst (CySA+) CS0-003: Unit 4
Tracing the Thread: Decoding the Decision-Making Process with GraphRAG
Tracing the Thread: Decoding the Decision-Making Process with GraphRAG
API206-S: Transforming Supply Chains with Amazon Bedrock AgentCore - AWS re:I...
API206-S: Transforming Supply Chains with Amazon Bedrock AgentCore - AWS re:I...
The Ultimate Guide to Problem Management Dashboards for IT Teams.pdf
The Ultimate Guide to Problem Management Dashboards for IT Teams.pdf
Recursive Self Improvement vs Continuous Learning
Recursive Self Improvement vs Continuous Learning

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

AltStyle によって変換されたページ (->オリジナル) /