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
410
CA 1Day Youth Bootcamp for Frontend LT
brn
0
810
Modern TypeScript
brn
2
750
javascript - behind the scene
brn
3
690
tc39 proposals
brn
0
790
プロダクト開発とTypeScript
brn
8
2.8k
React-Springでリッチなアニメーション
brn
1
620
Other Decks in Programming
See All in Programming
Cursorでアプリケーションの追加開発や保守をどこまでできるか試したら得るものが多かった話
drumnistnakano
0
290
HTTP compression in PHP and Symfony apps
dunglas
2
1.5k
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
180
layerx_20241129.pdf
kyoheig3
2
260
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
11
4.1k
DevTools extensions で 独自の DevTool を開発する | FlutterKaigi 2024
kokiyoshida
0
460
Recoilを剥がしている話
kirik
4
6k
新規学習のハードルを下げる方法とは?/ How to Make Learning Something New Easier?
nobuoooo
1
140
Symfony Mapper Component
soyuka
2
630
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.1k
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
620
Missing parts when designing and implementing Android UI
ericksli
0
400
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
GitHub's CSS Performance
jonrohan
1030
460k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
260
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Making Projects Easy
brettharned
116
5.9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
160
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