Chromium Code Reviews| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 void VisitNot(UnaryOperation* expr); | 164 void VisitNot(UnaryOperation* expr); |
| 165 | 165 |
| 166 // Dispatched from VisitBinaryOperation. | 166 // Dispatched from VisitBinaryOperation. |
| 167 void VisitComma(BinaryOperation* expr); | 167 void VisitComma(BinaryOperation* expr); |
| 168 void VisitLogicalExpression(BinaryOperation* expr); | 168 void VisitLogicalExpression(BinaryOperation* expr); |
| 169 void VisitArithmeticExpression(BinaryOperation* expr); | 169 void VisitArithmeticExpression(BinaryOperation* expr); |
| 170 | 170 |
| 171 // Dispatched from VisitForInStatement. | 171 // Dispatched from VisitForInStatement. |
| 172 void VisitForInAssignment(Expression* expr, Node* value); | 172 void VisitForInAssignment(Expression* expr, Node* value); |
| 173 | 173 |
| 174 void BuildLazyBailout(Node* node, BailoutId ast_id); | 174 enum OutputFrameStateCombine { PUSH_OUTPUT, IGNORE_OUTPUT }; |
|
Michael Starzinger
2014/08/12 21:17:40
nit: Can we add a comment describing the semantics
| |
| 175 void BuildLazyBailoutWithPushedNode(Node* node, BailoutId ast_id); | 175 |
| 176 void BuildLazyBailout(Node* node, BailoutId ast_id, | |
|
Michael Starzinger
2014/08/12 21:17:41
nit: Since the BuildFoo methods all have a clear s
| |
| 177 OutputFrameStateCombine combine = IGNORE_OUTPUT); | |
|
Michael Starzinger
2014/08/12 21:27:40
nit: Also, there seems to be no caller relying on
| |
| 178 OutputFrameStateCombine StateCombineFromAstContext(); | |
|
Michael Starzinger
2014/08/12 21:17:40
suggestion: I would be fine with moving this into
| |
| 176 | 179 |
| 177 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 180 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 178 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); | 181 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); |
| 179 }; | 182 }; |
| 180 | 183 |
| 181 | 184 |
| 182 // The abstract execution environment for generated code consists of | 185 // The abstract execution environment for generated code consists of |
| 183 // parameter variables, local variables and the operand stack. The | 186 // parameter variables, local variables and the operand stack. The |
| 184 // environment will perform proper SSA-renaming of all tracked nodes | 187 // environment will perform proper SSA-renaming of all tracked nodes |
| 185 // at split and merge points in the control flow. Internally all the | 188 // at split and merge points in the control flow. Internally all the |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 // decides how the evaluation result is passed up the visitor. | 281 // decides how the evaluation result is passed up the visitor. |
| 279 class AstGraphBuilder::AstContext BASE_EMBEDDED { | 282 class AstGraphBuilder::AstContext BASE_EMBEDDED { |
| 280 public: | 283 public: |
| 281 bool IsEffect() const { return kind_ == Expression::kEffect; } | 284 bool IsEffect() const { return kind_ == Expression::kEffect; } |
| 282 bool IsValue() const { return kind_ == Expression::kValue; } | 285 bool IsValue() const { return kind_ == Expression::kValue; } |
| 283 bool IsTest() const { return kind_ == Expression::kTest; } | 286 bool IsTest() const { return kind_ == Expression::kTest; } |
| 284 | 287 |
| 285 // 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 |
| 286 // position in the Visit functions for expressions. | 289 // position in the Visit functions for expressions. |
| 287 virtual void ProduceValue(Node* value) = 0; | 290 virtual void ProduceValue(Node* value) = 0; |
| 288 virtual void ProduceValueWithLazyBailout(Node* value) = 0; | |
| 289 | 291 |
| 290 // 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 |
| 291 // result of another Visit function that already plugged the context. | 293 // result of another Visit function that already plugged the context. |
| 292 virtual Node* ConsumeValue() = 0; | 294 virtual Node* ConsumeValue() = 0; |
| 293 | 295 |
| 294 // Shortcut for "context->ProduceValue(context->ConsumeValue())". | 296 // Shortcut for "context->ProduceValue(context->ConsumeValue())". |
| 295 void ReplaceValue() { ProduceValue(ConsumeValue()); } | 297 void ReplaceValue() { ProduceValue(ConsumeValue()); } |
| 296 | 298 |
| 297 protected: | 299 protected: |
| 298 AstContext(AstGraphBuilder* owner, Expression::Context kind, | 300 AstContext(AstGraphBuilder* owner, Expression::Context kind); |
| 299 BailoutId bailout_id); | |
| 300 virtual ~AstContext(); | 301 virtual ~AstContext(); |
| 301 | 302 |
| 302 AstGraphBuilder* owner() const { return owner_; } | 303 AstGraphBuilder* owner() const { return owner_; } |
| 303 Environment* environment() const { return owner_->environment(); } | 304 Environment* environment() const { return owner_->environment(); } |
| 304 | 305 |
| 305 // We want to be able to assert, in a context-specific way, that the stack | 306 // We want to be able to assert, in a context-specific way, that the stack |
| 306 // height makes sense when the context is filled. | 307 // height makes sense when the context is filled. |
| 307 #ifdef DEBUG | 308 #ifdef DEBUG |
| 308 int original_height_; | 309 int original_height_; |
| 309 #endif | 310 #endif |
| 310 | 311 |
| 311 BailoutId bailout_id_; | |
| 312 | |
| 313 private: | 312 private: |
| 314 Expression::Context kind_; | 313 Expression::Context kind_; |
| 315 AstGraphBuilder* owner_; | 314 AstGraphBuilder* owner_; |
| 316 AstContext* outer_; | 315 AstContext* outer_; |
| 317 }; | 316 }; |
| 318 | 317 |
| 319 | 318 |
| 320 // Context to evaluate expression for its side effects only. | 319 // Context to evaluate expression for its side effects only. |
| 321 class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext { | 320 class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext { |
| 322 public: | 321 public: |
| 323 explicit AstEffectContext(AstGraphBuilder* owner, BailoutId bailout_id) | 322 explicit AstEffectContext(AstGraphBuilder* owner) |
| 324 : AstContext(owner, Expression::kEffect, bailout_id) {} | 323 : AstContext(owner, Expression::kEffect) {} |
| 325 virtual ~AstEffectContext(); | 324 virtual ~AstEffectContext(); |
| 326 virtual void ProduceValue(Node* value) V8_OVERRIDE; | 325 virtual void ProduceValue(Node* value) V8_OVERRIDE; |
| 327 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE; | |
| 328 virtual Node* ConsumeValue() V8_OVERRIDE; | 326 virtual Node* ConsumeValue() V8_OVERRIDE; |
| 329 }; | 327 }; |
| 330 | 328 |
| 331 | 329 |
| 332 // Context to evaluate expression for its value (and side effects). | 330 // Context to evaluate expression for its value (and side effects). |
| 333 class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext { | 331 class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext { |
| 334 public: | 332 public: |
| 335 explicit AstValueContext(AstGraphBuilder* owner, BailoutId bailout_id) | 333 explicit AstValueContext(AstGraphBuilder* owner) |
| 336 : AstContext(owner, Expression::kValue, bailout_id) {} | 334 : AstContext(owner, Expression::kValue) {} |
| 337 virtual ~AstValueContext(); | 335 virtual ~AstValueContext(); |
| 338 virtual void ProduceValue(Node* value) V8_OVERRIDE; | 336 virtual void ProduceValue(Node* value) V8_OVERRIDE; |
| 339 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE; | |
| 340 virtual Node* ConsumeValue() V8_OVERRIDE; | 337 virtual Node* ConsumeValue() V8_OVERRIDE; |
| 341 }; | 338 }; |
| 342 | 339 |
| 343 | 340 |
| 344 // Context to evaluate expression for a condition value (and side effects). | 341 // Context to evaluate expression for a condition value (and side effects). |
| 345 class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext { | 342 class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext { |
| 346 public: | 343 public: |
| 347 explicit AstTestContext(AstGraphBuilder* owner, BailoutId bailout_id) | 344 explicit AstTestContext(AstGraphBuilder* owner) |
| 348 : AstContext(owner, Expression::kTest, bailout_id) {} | 345 : AstContext(owner, Expression::kTest) {} |
| 349 virtual ~AstTestContext(); | 346 virtual ~AstTestContext(); |
| 350 virtual void ProduceValue(Node* value) V8_OVERRIDE; | 347 virtual void ProduceValue(Node* value) V8_OVERRIDE; |
| 351 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE; | |
| 352 virtual Node* ConsumeValue() V8_OVERRIDE; | 348 virtual Node* ConsumeValue() V8_OVERRIDE; |
| 353 }; | 349 }; |
| 354 | 350 |
| 355 | 351 |
| 356 // Scoped class tracking breakable statements entered by the visitor. Allows to | 352 // Scoped class tracking breakable statements entered by the visitor. Allows to |
| 357 // properly 'break' and 'continue' iteration statements as well as to 'break' | 353 // properly 'break' and 'continue' iteration statements as well as to 'break' |
| 358 // from blocks within switch statements. | 354 // from blocks within switch statements. |
| 359 class AstGraphBuilder::BreakableScope BASE_EMBEDDED { | 355 class AstGraphBuilder::BreakableScope BASE_EMBEDDED { |
| 360 public: | 356 public: |
| 361 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target, | 357 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 }; | 415 }; |
| 420 | 416 |
| 421 Scope* AstGraphBuilder::current_scope() const { | 417 Scope* AstGraphBuilder::current_scope() const { |
| 422 return execution_context_->scope(); | 418 return execution_context_->scope(); |
| 423 } | 419 } |
| 424 } | 420 } |
| 425 } | 421 } |
| 426 } // namespace v8::internal::compiler | 422 } // namespace v8::internal::compiler |
| 427 | 423 |
| 428 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 424 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| OLD | NEW |