interprocedural type specialization of javascript programs … · 2016-07-22 · commercial...
TRANSCRIPT
![Page 1: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/1.jpg)
Interprocedural Type Specialization ofJavaScript Programs Without
Type Analysis
Maxime Chevalier-Boisvertjoint work with Marc Feeley
ECOOP - July 20th, 2016
![Page 2: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/2.jpg)
Overview
● Previous work: Lazy Basic Block Versioning
– Single pass JIT code generation technique
– On-the-fly type-specialization, intraprocedural only
● Three interprocedural extensions to BBV:
– Typed object shapes
– Entry point versioning
– Call continuation specialization
● Prototyped and evaluated in Higgs
– Experimental JIT for JS, ~60KLOC
![Page 3: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/3.jpg)
3
Lazy Basic Block Versioning
● JIT code generation technique
– Fine granularity (basic block)
– Lightweight, single pass
– Lazy versioning
● As we compile code, accumulate facts
– Leverage implicit type checks
● Specialize BBs based on known types
– May compile multiple versions of blocks
– Not duplication, but specialization
![Page 4: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/4.jpg)
4
Dynamic Type Tests
● Focus: eliminating dynamic type checks
– Dynamic languages, JS in particular
● BBV uses implicit type tests to extract type info
– Implicit type-dispatch semantics of JS
● Type tests: primitives testing the type of a value
– e.g. x + y
– is_int32(x) : is x an integer or not?
![Page 5: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/5.jpg)
5
Higgs’ Type Tags
Tag Description
int32 32-bit integer
float64 64-bit floating-point value
undef JS undefined value
null JS null value
bool true and false
string Immutable JS string
object Plain JS object
array JS array
closure JS function/closure
In Higgs, all values have an associated type tag
![Page 6: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/6.jpg)
6
is_int32(n)?
CB
D
falsetrue
![Page 7: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/7.jpg)
7
is_int32(n)?
CB
D
falsetrue
n is int32
![Page 8: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/8.jpg)
8
is_int32(n)?
CB
D
falsetrue
n is not int32n is int32
![Page 9: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/9.jpg)
9
is_int32(n)?
CB
D
falsetrue
n is not int32n is int32
n is ???
![Page 10: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/10.jpg)
10
is_int32(n)?
CB
D'
falsetrue
n is not int32n is int32
D''
n is int32 n is not int32
![Page 11: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/11.jpg)
11
is_int32(n)?
CB
D'
falsetrue
n is not int32n is int32
D''
n is int32 n is not int32
![Page 12: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/12.jpg)
12
Lazy Basic Block Versioning
● Compile versions lazily: when first executed
– Only for types seen at run-time
– The program's behavior drives versioning
– Interleave compilation and execution
● Avoid compiling unneeded block versions
– unexecuted error handling is never compiled
![Page 13: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/13.jpg)
13
![Page 14: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/14.jpg)
14
![Page 15: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/15.jpg)
15
![Page 16: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/16.jpg)
16
![Page 17: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/17.jpg)
17
![Page 18: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/18.jpg)
18
![Page 19: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/19.jpg)
19
![Page 20: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/20.jpg)
20
![Page 21: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/21.jpg)
21
![Page 22: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/22.jpg)
23
Lazy BBV Results (2014)
● Intraprocedural lazy BBV (ECOOP 2015)
● 71% of dynamic type tests eliminated
● Measurable speedups, 21% on average
● Small, code size increase, 0.19% average
● But, can we do better?
![Page 23: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/23.jpg)
Interprocedural Extensions
![Page 24: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/24.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst){ if (lst == null) return 0 return lst.val + sumList(lst.next)}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 25: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/25.jpg)
Object Property Types
● Previous work treated objects like black boxes
– Property types tested over and over again
● Global vars are properties of the global object
– Every global function call involves dynamic tests
– Trying to call a non-function throws an exception
● Would like to propagate object property types
![Page 26: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/26.jpg)
Shapes aka “Hidden Classes”
5
1.5
“foo”
null
A
B
C
D
Property slots
Shape pointer
Shape nodes
empty
![Page 27: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/27.jpg)
Typed Shapes
5
1.5
“foo”
null
A
B
C
D
empty
float64
int32
string
null
A
B
C
D
![Page 28: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/28.jpg)
Typed Shapes
● Extend shapes to store property type info
– Type tags of properties, method identity
● Versioning based on shapes
– Implicit shape tests extract shape info
● Permits the elimination of:
– Missing property checks, getter/setter checks
– Property type checks, boxing/unboxing
– Dynamic dispatch on function calls
![Page 29: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/29.jpg)
Interprocedural Versioning
● Previous work: intraprocedural BBV
– Propagates info within function bodies only
● Wasted computations:
– Objects treated as black boxes
– Function parameters treated as unknown types
– Return values treated as unknown types
– Losing and re-testing value types
● Costly, particularly for recursive functions
![Page 30: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/30.jpg)
Entry Point Specialization
● Most argument types are known at call sites
● Goal: pass arg types to callee entry points
● Key: typed shapes give us identity of callees
● Generate specialized function entry points
– Easy: specialize the function entry blocks
– Jump directly to specialized entry
● When callee unknown, use generic entry
– Rare in practice and no worse than before
![Page 31: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/31.jpg)
Call Continuation Specialization
● Intraprocedural: test ret value type at each call
– Wasting cycles even when ret type is constant
● Would like to propagate ret types somehow
● Can't apply same strategy as entry point spec
– Calls and returns are asymmetric
– Most call sites are monomorphic (one callee)
– Most functions have multiple callers
![Page 32: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/32.jpg)
Speculative Optimization
● Issue: cost of testing return type is small
– It's just one dynamic type test
● Would like to pass return type info with zerodynamic overhead
– Avoid dynamic dispatch when returning
● Speculate that return types remain constant
– Specialize call continuations in consequence
– Invalidate continuations when ret types change
![Page 33: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/33.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst){ if (lst == null) return 0 return lst.val + sumList(lst.next)}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 34: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/34.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst){ if (lst == null) return 0 // int32 return lst.val + sumList(lst.next)}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 35: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/35.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst) // ret type int32{ if (lst == null) return 0 // int32 return lst.val + sumList(lst.next)}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 36: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/36.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst) // ret type int32{ if (lst == null) return 0 // int32 return lst.val + sumList(lst.next) // int32}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 37: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/37.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst) // ret type int32{ if (lst == null) return 0 // int32 return lst.val + // int32 sumList(lst.next) // int32}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 38: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/38.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst) // ret type int32 ^_^{ if (lst == null) return 0 // int32 return lst.val + // int32 sumList(lst.next) // int32}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 39: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/39.jpg)
function makeList(len){ if (len == 0) return null return { val: len, next: makeList(len-1) }}
function sumList(lst){ if (lst == null) return 0 return lst.val + sumList(lst.next)}
var lst = makeList(100)if (sumList(lst) != 5050) throw Error('incorrect sum')
![Page 40: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/40.jpg)
Experimental Results
![Page 41: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/41.jpg)
Evaluation Methodology
● Benchmarks: 26 programs from SunSpider & V8 bench
● Compared results with plain intraprocedural BBV
– BBV + typed shapes
– BBV + entry point versioning
– BBV + entry point versioning + cont spec
● Metrics:
– Type checks eliminated (precision/accuracy)
– Execution time, compilation time
– Total machine code size generated
– Callee identity known (dynamic)
● Interprocedural BBV vs static type analysis
● Higgs vs commercial JavaScript VMs
![Page 42: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/42.jpg)
Evaluation Summary
● Callee identity known for 97.5% of calls
● Return type propagated 72% of the time
● Dynamic type tests: 94.3% eliminated (vs 71%)
● Compared to intraprocedural BBV
– Code size: +5.5% worst case
– Compilation time: +3.7% worst case
– Execution time: -37.6% on average
![Page 43: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/43.jpg)
Percentage of dynamic type tests eliminated (higher is better)
![Page 44: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/44.jpg)
Type tests eliminated, BBV vs simulated perfect analysis (higher is better)
![Page 45: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/45.jpg)
Commercial JavaScript VMs
● Benchmarked Higgs against TraceMonkey, SpiderMonkey,V8 and Truffle/JS
● Disclaimer: Higgs lacks many opts found in commercial VMs
– Stop-the-world, single generation copying GC
– No LICM, GVN
– No SIMD auto-vectorization
– No bounds check elimination, inefficient array impl
– No method inlining
– No escape analysis or allocation sinking
– On the fly register allocation, floats in GPRs (lol)
![Page 46: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/46.jpg)
Comparative Performance
● Mozilla TraceMonkey (1.8.5+, 2011, last pre-retired)
– Higgs is 2.7x faster on average
– Higgs outperforms TM on 22/26 benchmarks
● Oracle’s Truffle/JS (v0.9, 2015)
– 1000 warmup itrs: 0.69x as fast as Truffle/JS
– No warmup: 2.2x as fast as Truffle/JS
● Mozilla SpiderMonkey (C40.0a1, 2015)
– 0.37x as fast on average
– Outperforms SM on 1/26
● Google’s V8 (3.29.66, 2015)
– 0.47x as fast on average
– Outperforms V8 on 3/26
![Page 47: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/47.jpg)
48
Future Work
● BBV extensions
– Closure variable types
– Array element types
● Lazy incremental inlining
– Natural way to inline with BBV
– Partially inlining callees
– Inlining without recompilation
● Optimizing Scheme code
– Saleil & Feeley
![Page 48: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/48.jpg)
Applications
● Baseline JIT
– V8 uses its baseline JIT to gather type info
– More precise information for optimizing JIT
● Reduce gradual typing overhead
● Static (AOT) program analysis
● Dynamic Binary Translation (DBT)
![Page 49: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/49.jpg)
Conclusion
● Three interprocedural extensions:
– Typed shapes, useful for JS & OO languages
– Entry point & call continuation specialization
● Results are promising
– 94.3% of dynamic type tests eliminated
– More than a “perfect” static analysis
– Large improvement over intraprocedural BBV
● Many possible extensions and applications
![Page 50: Interprocedural Type Specialization of JavaScript Programs … · 2016-07-22 · Commercial JavaScript VMs Benchmarked Higgs against TraceMonkey, SpiderMonkey, V8 and Truffle/JS Disclaimer:](https://reader034.vdocument.in/reader034/viewer/2022042808/5f85685d89206926302cf379/html5/thumbnails/50.jpg)
51
My ECOOP 2015 BBV talk is on YouTubewww.youtube.com/watch?v=S-aHBuoiYE0
github.com/maximecb/Higgs
Love2Code on twitter