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
torque in V8
Search
Taketoshi Aono(青野健利 a.k.a brn)
May 22, 2018
Programming
1
3.3k
torque in V8
V8 javascript eingineのdslであるtorqueの話
Taketoshi Aono(青野健利 a.k.a brn)
May 22, 2018
Tweet
Share
More Decks by Taketoshi Aono(青野健利 a.k.a brn)
See All by Taketoshi Aono(青野健利 a.k.a brn)
document.write再考
brn
6
2.6k
Parsing Javascript
brn
12
7.4k
JSON & Object Tips
brn
1
300
CA 1Day Youth Bootcamp for Frontend LT
brn
0
690
Modern TypeScript
brn
2
680
javascript - behind the scene
brn
3
610
tc39 proposals
brn
0
660
プロダクト開発とTypeScript
brn
8
2.7k
React-Springでリッチなアニメーション
brn
1
520
Other Decks in Programming
See All in Programming
TypeScriptのパフォーマンス改善
yajihum
14
5.2k
Good first issues of TypeProf
mame
4
790
Try creating your own orderedmap
kazamori
1
290
勉強会4_アップデートされたAssistantsAPIを試す
milky04
0
110
Open standards for building event-driven applications in the cloud
meteatamel
0
230
How to implement a RubyVM with PHP?
memory1994
PRO
2
880
slow types ってなんだろう?
karad
0
210
TypeScript 関数型スタイルでバックエンド開発のリアル
naoya
49
16k
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
340
Direct Style Effect Systems The Print[A] ExampleA Comprehension Aid
philipschwarz
PRO
0
410
Exploring Type-Informed Lint Rules in Rust based TypeScript Linters
unvalley
3
650
RuboCop: LSP and Prism
koic
1
100
Featured
See All Featured
Teambox: Starting and Learning
jrom
128
8.4k
Product Roadmaps are Hard
iamctodd
45
9.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
9
1.3k
[RailsConf 2023] Rails as a piece of cake
palkan
29
4.1k
Become a Pro
speakerdeck
PRO
13
4.6k
The Invisible Side of Design
smashingmag
294
49k
Bash Introduction
62gerente
605
210k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
12
1.1k
It's Worth the Effort
3n
180
27k
jQuery: Nuts, Bolts and Bling
dougneiner
60
7.2k
The Pragmatic Product Professional
lauravandoore
26
5.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
22
6.5k
Transcript
V8 torque
Name @brn (ꫬꅿ⨳ⵃ) Occupation ؿٗٝزؒٝسؒٝآص،٥ط؎ذ؍ـؒٝآص، Company Cyberagent ،سذؙأةآؔ AI Messenger
OSS Contributor of V8 About http://info.b6n.ch
What is torque? V8ⰻ鿇דⵃ欽ׅח⡲DSL TypeScript괏ז俑岀ד葿ղ邌植ׅ
How does it works? torqueכ؝ٝػ؎ׁٕהCSA(CodeStubAssembler)ח㢌䳔ׁ կ CSAכفٓحزؿؓ٦يꬊ⣛㶷זIRד剑穄涸ח،إٝـٓח؝ٝػ ؎ׁٕկ
Why V8 need torque? CSAכ剅ְגהַָ穠圓הְֲַַז׃וְ - ✲佦װְׅ - 僓כ㘗ָⰋגNode㘗חꟼ׆ⰻ鿇涸חכSmiהַ IntPtrהַ㘗ָאְגְגծ♶侭さؒٓ٦ָ⳿װַׅկ
- ⵖ䖴圓俑ָ铣חְֻ
function add100() {! let value = 0;! for (let i
= 0; i < 100; i++) {! value += 1;! }! return value;! }!
TNode<IntPtrT> Add100(TNode<Context> context) {! TVARIABLE(var_value, MachineType::PointerRepresentation(), IntPtrConstant(0));! TVARIABLE(var_index, MachineType::PointerRepresentation(), IntPtrConstant(0));!
! Label loop(this), after_loop(this);! ! Branch(IntPtrGreaterThan(IntPtrConstant(100), var_index), &loop, &after_loop);! BIND(&loop);! {! var_a.Bind(IntPtrAdd(var_a, IntPtrConstant(1)));! Increment(&var_index, 1);! Branch(IntPtrGreaterThan(IntPtrConstant(100), var_index),! &loop, &after_loop);! }! BIND(&after_loop);! return var_value.value;! }!
macro Add100(): Smi {! let value: Smi = 0;! let
len: Smi = 100;! ! for (let i: Smi = 0; k < len; i = i + 1) {! value = value + 1;! }! return value;! }!
torque grammars 㛇劤涸חכ♧菙涸ז䩛竲ֹ㘗鎉铂הずׄ״ֲז俑岀 TypeScriptך㘗،ظذ٦ءّٝ罋ח׃גְ ָծDSLזךד׳ה暴婊ז俑岀㢳ְ
Type Definition TypeScriptך䕎ؒ؎ٔ،أה⡂גְָծֿכC++ך㘗ה torqueⰻ鿇ך䕎ׇ֮湡涸
type Object generates 'TNode<Object>';! type int32 generates 'TNode<Int32T>';!
External functions V8ⰻ鿇חכׅדח㣐ꆀךِ٦ذ؍ٔذ؍ꟼ侧ָ㹀纏ׁגֶծ ⵃ欽ׅחextern䭷㹀㶨ָ㹀纏ׁגְ - macro CSAⰻ鿇ד㹀纏ׁגְِ٦ذ؍ٔذ؍وؙٗ - builtin V8ךbuiltins⟃♴ח֮ꟼ侧纇
- runtime C++ד鎸鶢ׁًاحس
extern macro Print(Object);! ! extern builtin ToObject(Context, Number): Object;! !
extern runtime CreateDataProperty(! Context, Object, String, Object);!
Operators torqueכoperatorꟼ侧ה׃ג㹀纏ֿׅהָדֹ
extern operator "+" macro SmiAdd(Smi, Smi): Smi;! extern operator "-"
macro SmiSub(Smi, Smi): Smi;!
Cast CastכCSAךCastⵃ欽ָׅծ㣟侁׃㜥さחכGotoדٓكٕפ 굲ע
cast<Smi>(a) otherwise CastError!
Labels CSAכההַז⡚ٖكٕז邌植זךדծ if俑װfor俑瘝ךⵖ䖴圓俑גְזְկ ֿ邌植ׅךכׅץגLabelהGotoד֮կ
Branch(var_a, label1, label2)! ! BIND(&label1);! Print("A");! ! BIND(&label2);! Print("B");!
macro Foo(context: Context): Smi labels Bailout, CastError {! Goto Bailout;!
}!
compiler::TNode<Smi> FooFromDSLAssembler::Foo(! TNode<Context> p_context,! Label* label_Bailout_1,! Label* label_CastError_1) {! Goto(label_Bailout_1);!
}!
WriteBarrier V8כ؝ٖٝؕٝز٥؎ًؙٝٔٝةٕGC琎דְךדծ ؔـآؙؑزפך،ؙإأךꥷחכWriteBarrierָ䗳갭ָ ֿCSAך㜥さחכ荈ⴓדWriteBarrier⢪ֲַNoBarrierד遤ֻ ַ鼅䫛׃זֽלזזְկ torqueדכ㼛勻涸חֿֿ荈⹛⻉ׅ✮㹀׃ְ
Compilation 植㖈ךהֿػ٦؟٦כAntlrד剅ַגְ 俑岀涸חכLL(1)דػ٦أ〳腉 㼛勻涸חכ䩛剅ֹךػ٦؟ח׃ְ׃ְ
Compilation V8ךؽٕسفٗإأ⚥ח.tqؿ؋؎ٕךؽٕسָ饥ծ ך穠卓 <ر؍ؙٖزٔせ>-<ؿ؋؎ٕせ>-from-dsl-gen.h/cc הְֲC++ؿ؋؎ָٕ欰䧭ׁ ׁחךؿ؋؎ָٕؽٕسׁغ؎شٔך♧鿇חז
.tq ~-from-dsl-gen.h/cc V8
SourceMaps 植㖈ךהֿفٗزة؎فָծ--gdbjit-fullؔفءّٝדا٦أ⡘ 縧ךوحؾؚٝ׃גְ׃ְ
Summary ؝ٝػ؎ٓך⚥חDSLאֻךכ״ֻ֮鑧ָծ ֿֿתדֹ׃鎉铂כ穠圓棆׃ְ
Reference - https://docs.google.com/presentation/d/ 1PlQEjS5xyJA-0GY8mjB4wr-pLyzFtdMRfhXczJJ2wic/ edit#slide=id.g388aa7220e_2_348 - https://github.com/v8/v8/blob/master/src/builtins/typed- array.tq