OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_COMPILER_CONTROL_BUILDERS_H_ | 5 #ifndef V8_COMPILER_CONTROL_BUILDERS_H_ |
6 #define V8_COMPILER_CONTROL_BUILDERS_H_ | 6 #define V8_COMPILER_CONTROL_BUILDERS_H_ |
7 | 7 |
8 #include "src/compiler/ast-graph-builder.h" | 8 #include "src/compiler/ast-graph-builder.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 | 10 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 void Break() final; | 138 void Break() final; |
139 | 139 |
140 // Compound control commands for conditional break. | 140 // Compound control commands for conditional break. |
141 void BreakWhen(Node* condition, BranchHint = BranchHint::kNone); | 141 void BreakWhen(Node* condition, BranchHint = BranchHint::kNone); |
142 void BreakUnless(Node* condition, BranchHint hint = BranchHint::kNone); | 142 void BreakUnless(Node* condition, BranchHint hint = BranchHint::kNone); |
143 | 143 |
144 private: | 144 private: |
145 Environment* break_environment_; // Environment after the block exits. | 145 Environment* break_environment_; // Environment after the block exits. |
146 }; | 146 }; |
147 | 147 |
148 | |
149 // Tracks control flow for a try-catch statement. | |
150 class TryCatchBuilder final : public ControlBuilder { | |
151 public: | |
152 explicit TryCatchBuilder(AstGraphBuilder* builder) | |
153 : ControlBuilder(builder), | |
154 catch_environment_(nullptr), | |
155 exit_environment_(nullptr), | |
156 exception_node_(nullptr) {} | |
157 | |
158 // Primitive control commands. | |
159 void BeginTry(); | |
160 void Throw(Node* exception); | |
161 void EndTry(); | |
162 void EndCatch(); | |
163 | |
164 // Returns the exception value inside the 'catch' body. | |
165 Node* GetExceptionNode() const { return exception_node_; } | |
166 | |
167 private: | |
168 Environment* catch_environment_; // Environment for the 'catch' body. | |
169 Environment* exit_environment_; // Environment after the statement. | |
170 Node* exception_node_; // Node for exception in 'catch' body. | |
171 }; | |
172 | |
173 | |
174 // Tracks control flow for a try-finally statement. | |
175 class TryFinallyBuilder final : public ControlBuilder { | |
176 public: | |
177 explicit TryFinallyBuilder(AstGraphBuilder* builder) | |
178 : ControlBuilder(builder), | |
179 finally_environment_(nullptr), | |
180 token_node_(nullptr), | |
181 value_node_(nullptr) {} | |
182 | |
183 // Primitive control commands. | |
184 void BeginTry(); | |
185 void LeaveTry(Node* token, Node* value); | |
186 void EndTry(Node* token, Node* value); | |
187 void EndFinally(); | |
188 | |
189 // Returns the dispatch token value inside the 'finally' body. | |
190 Node* GetDispatchTokenNode() const { return token_node_; } | |
191 | |
192 // Returns the saved result value inside the 'finally' body. | |
193 Node* GetResultValueNode() const { return value_node_; } | |
194 | |
195 private: | |
196 Environment* finally_environment_; // Environment for the 'finally' body. | |
197 Node* token_node_; // Node for token in 'finally' body. | |
198 Node* value_node_; // Node for value in 'finally' body. | |
199 }; | |
200 | |
201 } // namespace compiler | 148 } // namespace compiler |
202 } // namespace internal | 149 } // namespace internal |
203 } // namespace v8 | 150 } // namespace v8 |
204 | 151 |
205 #endif // V8_COMPILER_CONTROL_BUILDERS_H_ | 152 #endif // V8_COMPILER_CONTROL_BUILDERS_H_ |
OLD | NEW |