JavaScript Implementations



JavaScript Implementations

0 0


talk-jsengines-cphjs-2012

Presentation at CopenhagenJS about JavaScript implementations

On Github rasmuserik / talk-jsengines-cphjs-2012

JavaScript Implementations

12.12.12CopenhagenJS talk by Rasmus Erik

The Talk

  • How:   interactive - interrupt, ask questions
  • Why:   brush up on state of JavaScript engines

Rasmus Erik

  • CS / programming language geek, LightScript
  • Work includes bugfixes in Rhino and SpiderMonkey

Outline

Major open source implementations

(SpiderMonkey, JavaScriptCore, v8, Nashorn/Rhino)

Selected engine features

(inline cache, hidden classes, values, gc)

SpiderMonkey

  • JavaScript engine for Firefox
  • Used in Adobe Acrobat, CouchDB, MongoDB, Riak, ...
  • Trace-, Jäger-, and IonMonkey

JavaScriptCore

  • JavaScript engine for Safari
  • Used in Qt 4.7+, ...
  • Low-level interpreter, Baseline JIT, DFG JIT

v8

  • JavaScript engine for Chrome
  • Used in node.js, CouchBase, ...
  • Full compiler, optimising compiler

Nashorn/Rhino

  • JavaScript engine for Java
  • Used in Java-scripting, node.js-api in progress.
  • Piggybacking on JVM (jit, gc, ...)

Outline

Major open source implementations

(SpiderMonkey, JavaScriptCore, v8, Nashorn/Rhino)

Selected engine features

(inline cache, hidden classes, values, gc)

Inline cache

  • Cache type information at execution point
  • v8 fast monomorphic, SpiderMonkey PICs, LLIN external, invoke dynamic
  • Fast when same type at code

Hidden classes and types

  • Add property to object → change class
  • Fast property access
  • Initialise objects in same order

Values and unboxing

  • SMI (small int), v8
  • NaN-boxing, JSC and SpiderMonkey
  • Java objects, Rhino/Nashorn

Generational Garbage Collection

  • Young generation: copying GC. Older: mark'n'compact
  • In v8 and JVM, not in JSC(on its way) or SpiderMonkey
  • Fast for short lived objects

Outline

Major open source implementations

(SpiderMonkey, JavaScriptCore, v8, Nashorn/Rhino)

Selected engine features

(inline cache, hidden classes, values, gc)

Questions...

Feedback on the presentation is very welcome, Rasmus Erik @ solsort.dk