Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/interpreter/control-flow-builders.h

Issue 1502243002: [Interpreter] Local flow control in the bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate comments by mstarzinger on patchet 10. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | src/interpreter/control-flow-builders.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ 5 #ifndef V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_
6 #define V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ 6 #define V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_
7 7
8 #include "src/interpreter/bytecode-array-builder.h" 8 #include "src/interpreter/bytecode-array-builder.h"
9 9
10 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 26 matching lines...) Expand all
37 37
38 // This method should be called by the control flow owner before 38 // This method should be called by the control flow owner before
39 // destruction to update sites that emit jumps for break. 39 // destruction to update sites that emit jumps for break.
40 void SetBreakTarget(const BytecodeLabel& break_target); 40 void SetBreakTarget(const BytecodeLabel& break_target);
41 41
42 // This method is called when visiting break statements in the AST. 42 // This method is called when visiting break statements in the AST.
43 // Inserts a jump to a unbound label that is patched when the corresponding 43 // Inserts a jump to a unbound label that is patched when the corresponding
44 // SetBreakTarget is called. 44 // SetBreakTarget is called.
45 void Break() { EmitJump(&break_sites_); } 45 void Break() { EmitJump(&break_sites_); }
46 void BreakIfTrue() { EmitJumpIfTrue(&break_sites_); } 46 void BreakIfTrue() { EmitJumpIfTrue(&break_sites_); }
47 void BreakIfFalse() { EmitJumpIfFalse(&break_sites_); }
47 void BreakIfUndefined() { EmitJumpIfUndefined(&break_sites_); } 48 void BreakIfUndefined() { EmitJumpIfUndefined(&break_sites_); }
48 void BreakIfNull() { EmitJumpIfNull(&break_sites_); } 49 void BreakIfNull() { EmitJumpIfNull(&break_sites_); }
49 50
50 protected: 51 protected:
51 void EmitJump(ZoneVector<BytecodeLabel>* labels); 52 void EmitJump(ZoneVector<BytecodeLabel>* labels);
52 void EmitJump(ZoneVector<BytecodeLabel>* labels, int index); 53 void EmitJump(ZoneVector<BytecodeLabel>* labels, int index);
53 void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels); 54 void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels);
54 void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels, int index); 55 void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels, int index);
56 void EmitJumpIfFalse(ZoneVector<BytecodeLabel>* labels);
57 void EmitJumpIfFalse(ZoneVector<BytecodeLabel>* labels, int index);
55 void EmitJumpIfUndefined(ZoneVector<BytecodeLabel>* labels); 58 void EmitJumpIfUndefined(ZoneVector<BytecodeLabel>* labels);
56 void EmitJumpIfNull(ZoneVector<BytecodeLabel>* labels); 59 void EmitJumpIfNull(ZoneVector<BytecodeLabel>* labels);
57 60
58 void BindLabels(const BytecodeLabel& target, ZoneVector<BytecodeLabel>* site); 61 void BindLabels(const BytecodeLabel& target, ZoneVector<BytecodeLabel>* site);
59 62
60 private: 63 private:
61 // Unbound labels that identify jumps for break statements in the code. 64 // Unbound labels that identify jumps for break statements in the code.
62 ZoneVector<BytecodeLabel> break_sites_; 65 ZoneVector<BytecodeLabel> break_sites_;
63 }; 66 };
64 67
65 // A class to help with co-ordinating break and continue statements with 68 // A class to help with co-ordinating break and continue statements with
66 // their loop. 69 // their loop.
67 // TODO(oth): add support for TF branch/merge info.
68 class LoopBuilder final : public BreakableControlFlowBuilder { 70 class LoopBuilder final : public BreakableControlFlowBuilder {
69 public: 71 public:
70 explicit LoopBuilder(BytecodeArrayBuilder* builder) 72 explicit LoopBuilder(BytecodeArrayBuilder* builder)
71 : BreakableControlFlowBuilder(builder), 73 : BreakableControlFlowBuilder(builder),
72 continue_sites_(builder->zone()) {} 74 continue_sites_(builder->zone()) {}
73 ~LoopBuilder(); 75 ~LoopBuilder();
74 76
75 // This methods should be called by the LoopBuilder owner before 77 void LoopHeader() { builder()->Bind(&loop_header_); }
76 // destruction to update sites that emit jumps for continue. 78 void Condition() { builder()->Bind(&condition_); }
77 void SetContinueTarget(const BytecodeLabel& continue_target); 79 void Next() { builder()->Bind(&next_); }
80 void JumpToHeader() { builder()->Jump(&loop_header_); }
81 void JumpToHeaderIfTrue() { builder()->JumpIfTrue(&loop_header_); }
82 void LoopEnd();
78 83
79 // This method is called when visiting continue statements in the AST. 84 // This method is called when visiting continue statements in the AST.
80 // Inserts a jump to a unbound label that is patched when the corresponding 85 // Inserts a jump to a unbound label that is patched when the corresponding
81 // SetContinueTarget is called. 86 // SetContinueTarget is called.
82 void Continue() { EmitJump(&continue_sites_); } 87 void Continue() { EmitJump(&continue_sites_); }
83 void ContinueIfTrue() { EmitJumpIfTrue(&continue_sites_); } 88 void ContinueIfTrue() { EmitJumpIfTrue(&continue_sites_); }
84 void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_sites_); } 89 void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_sites_); }
85 void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); } 90 void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); }
86 91
87 private: 92 private:
93 void SetContinueTarget(const BytecodeLabel& continue_target);
94
95 BytecodeLabel loop_header_;
96 BytecodeLabel condition_;
97 BytecodeLabel next_;
98 BytecodeLabel loop_end_;
99
88 // Unbound labels that identify jumps for continue statements in the code. 100 // Unbound labels that identify jumps for continue statements in the code.
89 ZoneVector<BytecodeLabel> continue_sites_; 101 ZoneVector<BytecodeLabel> continue_sites_;
90 }; 102 };
91 103
92 // A class to help with co-ordinating break statements with their switch. 104 // A class to help with co-ordinating break statements with their switch.
93 // TODO(oth): add support for TF branch/merge info. 105 // TODO(oth): add support for TF branch/merge info.
94 class SwitchBuilder final : public BreakableControlFlowBuilder { 106 class SwitchBuilder final : public BreakableControlFlowBuilder {
95 public: 107 public:
96 explicit SwitchBuilder(BytecodeArrayBuilder* builder, int number_of_cases) 108 explicit SwitchBuilder(BytecodeArrayBuilder* builder, int number_of_cases)
97 : BreakableControlFlowBuilder(builder), 109 : BreakableControlFlowBuilder(builder),
(...skipping 19 matching lines...) Expand all
117 private: 129 private:
118 // Unbound labels that identify jumps for case statements in the code. 130 // Unbound labels that identify jumps for case statements in the code.
119 ZoneVector<BytecodeLabel> case_sites_; 131 ZoneVector<BytecodeLabel> case_sites_;
120 }; 132 };
121 133
122 } // namespace interpreter 134 } // namespace interpreter
123 } // namespace internal 135 } // namespace internal
124 } // namespace v8 136 } // namespace v8
125 137
126 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ 138 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | src/interpreter/control-flow-builders.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698