More Related Content Similar to V8 javascript engine for フロントエンドデベロッパー (20) More from Taketoshi 青野健利 (10) V8 javascript engine for フロントエンドデベロッパー2. : @brn ( )
:
: Cyberagent RightSegment AI Messenger
: http://abcdef.gets.b6n.ch/
Twitter: https://twitter.com/brn227
4. V8
V8
•
• Hidden Class
• Inline Caching
• GC
• 2016
• CPU Mips Arm X64 X86 7
17. Dive into Parsing
V8 Parsing
https://docs.google.com/presentation/d/1b-
ALt6W01nIxutFVFmXMOyd_6ou_6qqP6S0Prmb1iDs/present?
slide=id.p
31. Igniton
Dispatch Table
00 01 02 04 08 0f 10 10
Node
Node
Node
MachineCode
MachineCode
IGNITION_HANDLER
Entry Function(Machine Code)
グラフからコードを生成
生成したコードを、
DispatchTableの対応する
バイトコードのインデックスへ
登録
38. IGNITION_HANDLER(JumpIfToBooleanFalse, InterpreterAssembler) {!
Node* value = GetAccumulator();!
// Accumulatorの値を取得!
Node* relative_jump = BytecodeOperandUImmWord(0);!
// 引数のoperandを取得!
Label if_true(this), if_false(this);!
BranchIfToBooleanIsTrue(value, &if_true, &if_false);!
// valueがtrueならif_true、falseならif_false!
Bind(&if_true);!
Dispatch();!
Bind(&if_false);!
// operandのbytecodeまでjump!
Jump(relative_jump);!
}!
43. #define __ ACCESS_MASM(masm)!
!
static void Generate_StackOverflowCheck(...) {!
!
__ LoadRoot(kScratchRegister, Heap::kRealStackLimitRootIndex);!
__ movp(scratch, rsp);!
!
__ subp(scratch, kScratchRegister);!
__ sarp(scratch, Immediate(kPointerSizeLog2));!
!
__ cmpp(scratch, num_args);!
!
__ j(less_equal, stack_overflow, stack_overflow_distance);!
}!
57. class X {add() {return 1}}!
class Y {add() {return 2}}!
var m = [new X(), new X(), new Y()];!
for (let i = 0; i < m.length; i++) {!
m[i].add();!
}!
!
74. TurboFan
TurboFan
• Loop peeling / Loop elimination
• Escape analysis
• Lowering
• Effect and control linearize
• Dead code elimination
• Control flow optimization
• Memory optimization