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.4k
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.9k
Parsing Javascript
brn
12
9k
JSON & Object Tips
brn
1
400
CA 1Day Youth Bootcamp for Frontend LT
brn
0
790
Modern TypeScript
brn
2
750
javascript - behind the scene
brn
3
680
tc39 proposals
brn
0
780
プロダクト開発とTypeScript
brn
8
2.8k
React-Springでリッチなアニメーション
brn
1
600
Other Decks in Programming
See All in Programming
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
Click-free releases & the making of a CLI app
oheyadam
2
110
Jakarta EE meets AI
ivargrimstad
0
130
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
660
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
250
Featured
See All Featured
Side Projects
sachag
452
42k
Rails Girls Zürich Keynote
gr2m
94
13k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Producing Creativity
orderedlist
PRO
341
39k
Being A Developer After 40
akosma
86
590k
Adopting Sorbet at Scale
ufuk
73
9.1k
Bash Introduction
62gerente
608
210k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
KATA
mclloyd
29
14k
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