OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_AST_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ |
6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 void VisitNot(UnaryOperation* expr); | 165 void VisitNot(UnaryOperation* expr); |
166 | 166 |
167 // Dispatched from VisitBinaryOperation. | 167 // Dispatched from VisitBinaryOperation. |
168 void VisitComma(BinaryOperation* expr); | 168 void VisitComma(BinaryOperation* expr); |
169 void VisitLogicalExpression(BinaryOperation* expr); | 169 void VisitLogicalExpression(BinaryOperation* expr); |
170 void VisitArithmeticExpression(BinaryOperation* expr); | 170 void VisitArithmeticExpression(BinaryOperation* expr); |
171 | 171 |
172 // Dispatched from VisitForInStatement. | 172 // Dispatched from VisitForInStatement. |
173 void VisitForInAssignment(Expression* expr, Node* value); | 173 void VisitForInAssignment(Expression* expr, Node* value); |
174 | 174 |
175 // Flag that describes how to combine the current environment with | |
176 // the output of a node to obtain a framestate for lazy bailout. | |
177 enum OutputFrameStateCombine { | |
178 PUSH_OUTPUT, // Push the output on the expression stack. | |
179 IGNORE_OUTPUT // Use the frame state as-is. | |
180 }; | |
181 | |
182 // Builds deoptimization for a given node. | 175 // Builds deoptimization for a given node. |
183 void PrepareFrameState(Node* node, BailoutId ast_id, | 176 void PrepareFrameState(Node* node, BailoutId ast_id, |
184 OutputFrameStateCombine combine = IGNORE_OUTPUT); | 177 OutputFrameStateCombine combine = IGNORE_OUTPUT); |
185 | 178 |
186 OutputFrameStateCombine StateCombineFromAstContext(); | 179 OutputFrameStateCombine StateCombineFromAstContext(); |
187 | 180 |
188 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 181 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
189 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); | 182 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); |
190 }; | 183 }; |
191 | 184 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 int index = static_cast<int>(values()->size()) - depth - 1; | 251 int index = static_cast<int>(values()->size()) - depth - 1; |
259 return values()->at(index); | 252 return values()->at(index); |
260 } | 253 } |
261 void Drop(int depth) { | 254 void Drop(int depth) { |
262 DCHECK(depth >= 0 && depth <= stack_height()); | 255 DCHECK(depth >= 0 && depth <= stack_height()); |
263 values()->erase(values()->end() - depth, values()->end()); | 256 values()->erase(values()->end() - depth, values()->end()); |
264 } | 257 } |
265 | 258 |
266 // Preserve a checkpoint of the environment for the IR graph. Any | 259 // Preserve a checkpoint of the environment for the IR graph. Any |
267 // further mutation of the environment will not affect checkpoints. | 260 // further mutation of the environment will not affect checkpoints. |
268 Node* Checkpoint(BailoutId ast_id); | 261 Node* Checkpoint(BailoutId ast_id, OutputFrameStateCombine combine); |
269 | 262 |
270 private: | 263 private: |
271 void UpdateStateValues(Node** state_values, int offset, int count); | 264 void UpdateStateValues(Node** state_values, int offset, int count); |
272 | 265 |
273 int parameters_count_; | 266 int parameters_count_; |
274 int locals_count_; | 267 int locals_count_; |
275 Node* parameters_node_; | 268 Node* parameters_node_; |
276 Node* locals_node_; | 269 Node* locals_node_; |
277 Node* stack_node_; | 270 Node* stack_node_; |
278 }; | 271 }; |
279 | 272 |
280 | 273 |
281 // Each expression in the AST is evaluated in a specific context. This context | 274 // Each expression in the AST is evaluated in a specific context. This context |
282 // decides how the evaluation result is passed up the visitor. | 275 // decides how the evaluation result is passed up the visitor. |
283 class AstGraphBuilder::AstContext BASE_EMBEDDED { | 276 class AstGraphBuilder::AstContext BASE_EMBEDDED { |
284 public: | 277 public: |
285 bool IsEffect() const { return kind_ == Expression::kEffect; } | 278 bool IsEffect() const { return kind_ == Expression::kEffect; } |
286 bool IsValue() const { return kind_ == Expression::kValue; } | 279 bool IsValue() const { return kind_ == Expression::kValue; } |
287 bool IsTest() const { return kind_ == Expression::kTest; } | 280 bool IsTest() const { return kind_ == Expression::kTest; } |
288 | 281 |
289 // Determines how to combine the frame state with the value | 282 // Determines how to combine the frame state with the value |
290 // that is about to be plugged into this AstContext. | 283 // that is about to be plugged into this AstContext. |
291 AstGraphBuilder::OutputFrameStateCombine GetStateCombine() { | 284 OutputFrameStateCombine GetStateCombine() { |
292 return IsEffect() ? IGNORE_OUTPUT : PUSH_OUTPUT; | 285 return IsEffect() ? IGNORE_OUTPUT : PUSH_OUTPUT; |
293 } | 286 } |
294 | 287 |
295 // Plug a node into this expression context. Call this function in tail | 288 // Plug a node into this expression context. Call this function in tail |
296 // position in the Visit functions for expressions. | 289 // position in the Visit functions for expressions. |
297 virtual void ProduceValue(Node* value) = 0; | 290 virtual void ProduceValue(Node* value) = 0; |
298 | 291 |
299 // Unplugs a node from this expression context. Call this to retrieve the | 292 // Unplugs a node from this expression context. Call this to retrieve the |
300 // result of another Visit function that already plugged the context. | 293 // result of another Visit function that already plugged the context. |
301 virtual Node* ConsumeValue() = 0; | 294 virtual Node* ConsumeValue() = 0; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 }; | 415 }; |
423 | 416 |
424 Scope* AstGraphBuilder::current_scope() const { | 417 Scope* AstGraphBuilder::current_scope() const { |
425 return execution_context_->scope(); | 418 return execution_context_->scope(); |
426 } | 419 } |
427 } | 420 } |
428 } | 421 } |
429 } // namespace v8::internal::compiler | 422 } // namespace v8::internal::compiler |
430 | 423 |
431 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 424 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
OLD | NEW |