Trace based just in time type specialization for dynamic languages
Download
1 / 13

Trace-based Just-in-Time Type Specialization for Dynamic Languages - PowerPoint PPT Presentation


  • 107 Views
  • Uploaded on

Trace-based Just-in-Time Type Specialization for Dynamic Languages. Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R. Haghighat, Blake Kaplan, Graydon Hoare, Boris Zbarsky, Jason Orendorff,

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Trace-based Just-in-Time Type Specialization for Dynamic Languages' - nike


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Trace based just in time type specialization for dynamic languages

Trace-based Just-in-Time Type Specialization for Dynamic Languages

Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin,

Mohammad R. Haghighat, Blake Kaplan, Graydon Hoare, Boris Zbarsky, Jason Orendorff,

Jesse Ruderman, Edwin Smith, Rick Reitmaier, Michael Bebenita, Mason Chang, Michael Franz


Dynamic languages
Dynamic Languages Languages

JavaScript, Python, and Ruby

They are expressive, accessible to non-experts, and make deployment as easy as distributing a source file

JavaScript is the de facto standard for client-side web programming and is used for the application logic of browser-based productivity applications

Dynamically-typed (most of them, not all)

The types of expressions may vary during runtime

Traditional static analysis is too expensive

2


Solution trace based jit compiler
Solution: Trace-based Jit Compiler Languages

Jit Compiler: a hybrid approach that combines interpreter and static compiler

Trace-based compilation

- trace: an acyclic path through CFG

- schedule traces as if they were basic blocks

- need compensation code for off-trace path

TraceMonkey: starts running JavaScript in a fast-starting bytecode interpreter, and detects hot bytecode sequences (trace) as the program runs, recording and compiling them into native code.

Two assumptions

- programs spend most of their time in hot loops

- code in hot loops are type-stable


Outline
Outline Languages

Algorithm for dynamically forming trace trees to cover a program, representing nested loops as nested trace trees

How to speculatively generate efficient type-specialized code for traces from dynamic language programs

Implementation based on the SpiderMonkey JavaScript interpreter


Typed trace
Typed Trace Languages

  • A typed trace is a trace annotated with a type for every variable (including temporaries) on the trace. (type-stable)

  • Guard instructions to guarantee assumptions, side exit the trace if guards fail

  • Optimizations achieved:

    - type specialization

    - representation specialization: objects, numbers

    - function inlining

  • Abort a trace

    - unpredictable exits

    - limited memory


Trace tree
Trace Tree Languages

An extension of typed trace with branch traces

A tree always starts at a loop header

A tree closes the loop:

- at loop header as it started (type-stable)

- at a side exit (type-unstable)

- at break or return statements (end trace and exit to the trace monitor)

Extend a tree with branch starting at side exits (only control-flow branches)

Blacklist: avoid checking failed traces again and again


Trace tree cont
Trace Tree Cont. Languages

  • Unsolved problem

  • if a loop meets the following conditions

  • - The VM can form at least one root trace for the loop

  • - There is at least one hot side exit for which the VM cannot complete a trace

  • - The loop body is short

  • Then the overhead exceeds the optimization


Nested trace tree formation
Nested Trace Tree Formation Languages

1 for (var i = 2; i < 100; ++i) {

2 if (!primes[i])

3 continue;

4 for (var k = i + i; k < 100; k += i)

5 primes[k] = true;

6 }


Trace tree optimization
Trace Tree Optimization Languages

Front-end filters

- a soft-float filter converts floating-point LIR instructions to sequences of integer instructions

- CSE (constant sub-expression elimination)

- expression simplification: constant folding ..

- source language semantic-specific expression simplification

Back-end filters

Dead data-stack store elimination

Dead call-stack store elimination

Dead code elimination


Implementation
Implementation Languages

Calling Compiled Traces

Trace Stitching

Trace Recording

Preemption

Calling External Functions


Evaluation
Evaluation Languages


Evaluation cont
Evaluation cont. Languages

Outperform the fastest available JavaScript compiler (V8) and the fastest available JavaScript inline threaded interpreter (SFX) on 9 of 26 benchmarks


Related work
Related Work Languages

Trace optimization for dynamic languages

General trace optimization

Type specialization for dynamic languages

Native code generation by interpreters


ad