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.2k
JSON & Object Tips
brn
1
290
CA 1Day Youth Bootcamp for Frontend LT
brn
0
680
Modern TypeScript
brn
2
680
javascript - behind the scene
brn
3
600
tc39 proposals
brn
0
650
プロダクト開発とTypeScript
brn
8
2.7k
React-Springでリッチなアニメーション
brn
1
500
Other Decks in Programming
See All in Programming
⼤規模⾔語モデルの拡張(RAG)が 終わったかも知れない件について
nearme_tech
22
15k
Git Lint
bkuhlmann
4
740
What We Can Learn From OSS
inouehi
0
400
CQRS/ES avec Symfony, c’est (trop) bien !
jeremyfreeagent
1
630
Ruby Function Composition
bkuhlmann
1
330
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
340
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
490
[技育CAMPアカデミア]アイディアを形に!【超入門】スマホアプリ開発〜リリースまでの流れをご紹介
teamlab
PRO
0
350
HUIT新歓2024「競技プログラミング、やってみませんか?」
slephy2784
1
250
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
120
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
230
雑に思考を整理する技術と効能
konifar
55
25k
Featured
See All Featured
Building Applications with DynamoDB
mza
88
5.6k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
GraphQLの誤解/rethinking-graphql
sonatard
50
9.2k
The Power of CSS Pseudo Elements
geoffreycrofte
59
5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Designing the Hi-DPI Web
ddemaree
276
33k
Debugging Ruby Performance
tmm1
70
11k
GitHub's CSS Performance
jonrohan
1023
450k
Why You Should Never Use an ORM
jnunemaker
PRO
50
8.6k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Producing Creativity
orderedlist
PRO
336
39k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
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