Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
V8
Search
dimko1
September 13, 2015
Programming
0
270
V8
How V8 Works
dimko1
September 13, 2015
Tweet
Share
More Decks by dimko1
See All by dimko1
Anti-patterns
dimko1
0
56
JS under the hood
dimko1
0
190
Other Decks in Programming
See All in Programming
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
Oxlint JS plugins
kazupon
1
550
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
SourceGeneratorのススメ
htkym
0
190
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
20
6.7k
CSC307 Lecture 02
javiergs
PRO
1
770
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
dchart: charts from deck markup
ajstarks
3
990
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
610
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
160
AI & Enginnering
codelynx
0
110
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
160
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Facilitating Awesome Meetings
lara
57
6.7k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
54
Mind Mapping
helmedeiros
PRO
0
75
Art, The Web, and Tiny UX
lynnandtonic
304
21k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
Transcript
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
?