Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
V8
Search
dimko1
September 13, 2015
Programming
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
V8
How V8 Works
dimko1
September 13, 2015
Transcript
35 slides
V8 by @dimko1
What? • Googles Open Source Engine • Written on C++
• Compiles JS into Machine Code at execution (JIT) without producing byte code • Powers Chrome, Node, Opera • Can run standalone, or can be embedded into any C++ program
Made in Germany
None
So, why to know? • Have no idea:)
Demo
Hidden Classes • We don’t have types. (oh c’mon, not
about primitives) • To optimise we need types… • Types information is valuable for code generation • Remember: Compilation during Execution
Hidden Classes help to run faster • Creating hidden classes
for objects during run- time • Objects with same hidden class can use same optimised code
None
None
Summary • Initialise all members in construction function • Initialise
members in same order
Tagging • V8 represent JavaScript objects with 32 bits values
• Object has flag 1 • Integer has flag 0 and called SMI • If bigger - turning it into double and create new object
None
Summary • Prefer numeric values that can be represented as
31-bit integer
Arrays • We have arrays, huge array and sparse arrays
• Two ways of representing arrays: • Fast Elements • Dictionary Elements
Summary • Create arrays from 0 index :) • Don’t
pre-allocate large Arrays • Don’t delete element from array • Don't load uninitialized or deleted elements
None
None
None
Summary 2 • User Array Literal: var a = [77,
88, 0.5, true] • Don’t store non numeric values in numeric arrays
Compilers • “Full” compiler can generate good code for any
JavaScript • Optimizing compiler produces great code for most JavaScript
Full Compiler • Generate code quickly • Does do no
type analysis • Using Inline Caching. Gather type information in runtime
How Inline Cache Works • Type dependant code for operations
• Validate type assumptions first • Change at runtime as more types discovered
None
None
None
Monomorphic better than Polymorphic
Optimizing Compiler • Comes later and re-compiles “hot” functions •
Types taken form ICs • Monomorphic can be inlined • Inlining enables other optimizations
None
None
Deoptimization • Optimization are speculative • Throws away optimized code
• Resumes execution at the right place • Reoptimization might be triggered again later
Summary • Avoid changes in the hidden classes after functions
were optimised
What is a problem now? • Ensure problem is in
JS • Reduce to pure JS ( not DOM ) • Collect metrics
Demo
?
More Decks by dimko1
See All by dimko1
Anti-patterns
dimko1
0
67
JS under the hood
dimko1
0
200
Other Decks in Programming
See All in Programming
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
Jujutsu で毎日のバージョン管理に「安心」と「直感性」を
oukayuka
0
110
JavaScriptはシングルバイナリの夢を見るか / Does JavaScript Dream of a Single Binary?
ssssota
0
910
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
270
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
350
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
190
Going Full Circle with Virtual Graphs and Relational Databases
michaelsimons
1
120
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
490
How SRE Grew Out of Server-Side Work and Became the Team's Own / サーバサイドから始まったSREを チームに渡すまで
maaaato
1
340
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
850
エージェントの管理もエージェントに – herdr-core と自作バックログで作る司令塔 –
nearme_tech
PRO
2
160
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
1
630
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
570
Code Reviewing Like a Champion
maltzj
529
40k
New Earth Scene 8
popppiees
5
2.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
Why Our Code Smells
bkeepers
PRO
340
58k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380
The Pragmatic Product Professional
lauravandoore
37
7.5k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
620
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
470
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
650