Professional Documents
Culture Documents
V8: The Javascript Engine Inside Google Chrome: by Lars Bak, Google Aarhus
V8: The Javascript Engine Inside Google Chrome: by Lars Bak, Google Aarhus
Web has evolved from early days of text pages to richer, more
interactive web applications
Gmail
Flickr
Amazon
•Original idea from Self where maps were used for shared state
Class0
function Point(x, y) { Δx
this.x = x;
this.y = y; Class1
Point p Point q
{x:0}
}
Δy
⊥
1 ⊥
3
⊥
2 ⊥
4
var p = new Point(1, 2);
⊥ Class2 ⊥
var q = new Point(3, 4); {x:0, y:1}
•Backing storage for the object is then converted into slow dictionary
implementation
• Adding or deleting properties will not change its map
Roughly 90% of all code points only see objects with the same
hidden class
Conclusion
JavaScript is NOT as dynamic at runtime as you would think
Opens up for class based object-oriented optimizations
•Design goals:
• Fast object allocation
• Make the object heap scalable
• Make most garbage collection pauses small
• Young Generation
• New space: newly allocated objects, collected frequently
• Old Generation
• Code space: executable code objects
• Old data space: objects with no pointers to the young gen.
• Large object space: to avoid moving objects > 8KB
• Hidden class space: requires special GC processing
• Old pointer space: the rest of the old objects
•Richards
• OS kernel simulation benchmark, originally written in BCPL by Martin Richards
(539 lines)
•DeltaBlue
• One-way constraint solver, originally written in Smalltalk by John Maloney and
Mario Wolczko (880 lines)
•Crypto
• Encryption and decryption benchmark based on code by Tom Wu (1689 lines)
•RayTrace
• Ray tracer benchmark based on code by Adam Burmister (3418 lines)
•EarleyBoyer
• Classic Scheme benchmarks, translated to JavaScript by Florian Loitsch's
Scheme2JS compiler (4682 lines)