| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 BreakableScope* breakable() const { return breakable_; } | 50 BreakableScope* breakable() const { return breakable_; } |
| 51 ContextScope* execution_context() const { return execution_context_; } | 51 ContextScope* execution_context() const { return execution_context_; } |
| 52 | 52 |
| 53 void set_ast_context(AstContext* ctx) { ast_context_ = ctx; } | 53 void set_ast_context(AstContext* ctx) { ast_context_ = ctx; } |
| 54 void set_breakable(BreakableScope* brk) { breakable_ = brk; } | 54 void set_breakable(BreakableScope* brk) { breakable_ = brk; } |
| 55 void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; } | 55 void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; } |
| 56 | 56 |
| 57 // Support for control flow builders. The concrete type of the environment | 57 // Support for control flow builders. The concrete type of the environment |
| 58 // depends on the graph builder, but environments themselves are not virtual. | 58 // depends on the graph builder, but environments themselves are not virtual. |
| 59 typedef StructuredGraphBuilder::Environment BaseEnvironment; | 59 typedef StructuredGraphBuilder::Environment BaseEnvironment; |
| 60 virtual BaseEnvironment* CopyEnvironment(BaseEnvironment* env) OVERRIDE; | 60 BaseEnvironment* CopyEnvironment(BaseEnvironment* env) OVERRIDE; |
| 61 | 61 |
| 62 // Getters for values in the activation record. | 62 // Getters for values in the activation record. |
| 63 Node* GetFunctionClosure(); | 63 Node* GetFunctionClosure(); |
| 64 Node* GetFunctionContext(); | 64 Node* GetFunctionContext(); |
| 65 | 65 |
| 66 // | 66 // |
| 67 // The following build methods all generate graph fragments and return one | 67 // The following build methods all generate graph fragments and return one |
| 68 // resulting node. The operand stack height remains the same, variables and | 68 // resulting node. The operand stack height remains the same, variables and |
| 69 // other dependencies tracked by the environment might be mutated though. | 69 // other dependencies tracked by the environment might be mutated though. |
| 70 // | 70 // |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 // Builder for stack-check guards. | 114 // Builder for stack-check guards. |
| 115 Node* BuildStackCheck(); | 115 Node* BuildStackCheck(); |
| 116 | 116 |
| 117 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; | 117 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; |
| 118 // Visiting functions for AST nodes make this an AstVisitor. | 118 // Visiting functions for AST nodes make this an AstVisitor. |
| 119 AST_NODE_LIST(DECLARE_VISIT) | 119 AST_NODE_LIST(DECLARE_VISIT) |
| 120 #undef DECLARE_VISIT | 120 #undef DECLARE_VISIT |
| 121 | 121 |
| 122 // Visiting function for declarations list is overridden. | 122 // Visiting function for declarations list is overridden. |
| 123 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations) OVERRIDE; | 123 void VisitDeclarations(ZoneList<Declaration*>* declarations) OVERRIDE; |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 CompilationInfo* info_; | 126 CompilationInfo* info_; |
| 127 AstContext* ast_context_; | 127 AstContext* ast_context_; |
| 128 JSGraph* jsgraph_; | 128 JSGraph* jsgraph_; |
| 129 | 129 |
| 130 // List of global declarations for functions and variables. | 130 // List of global declarations for functions and variables. |
| 131 ZoneVector<Handle<Object>> globals_; | 131 ZoneVector<Handle<Object>> globals_; |
| 132 | 132 |
| 133 // Stack of breakable statements entered by the visitor. | 133 // Stack of breakable statements entered by the visitor. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 AstContext* outer_; | 341 AstContext* outer_; |
| 342 }; | 342 }; |
| 343 | 343 |
| 344 | 344 |
| 345 // Context to evaluate expression for its side effects only. | 345 // Context to evaluate expression for its side effects only. |
| 346 class AstGraphBuilder::AstEffectContext FINAL : public AstContext { | 346 class AstGraphBuilder::AstEffectContext FINAL : public AstContext { |
| 347 public: | 347 public: |
| 348 explicit AstEffectContext(AstGraphBuilder* owner) | 348 explicit AstEffectContext(AstGraphBuilder* owner) |
| 349 : AstContext(owner, Expression::kEffect) {} | 349 : AstContext(owner, Expression::kEffect) {} |
| 350 virtual ~AstEffectContext(); | 350 virtual ~AstEffectContext(); |
| 351 virtual void ProduceValue(Node* value) OVERRIDE; | 351 void ProduceValue(Node* value) OVERRIDE; |
| 352 virtual Node* ConsumeValue() OVERRIDE; | 352 Node* ConsumeValue() OVERRIDE; |
| 353 }; | 353 }; |
| 354 | 354 |
| 355 | 355 |
| 356 // Context to evaluate expression for its value (and side effects). | 356 // Context to evaluate expression for its value (and side effects). |
| 357 class AstGraphBuilder::AstValueContext FINAL : public AstContext { | 357 class AstGraphBuilder::AstValueContext FINAL : public AstContext { |
| 358 public: | 358 public: |
| 359 explicit AstValueContext(AstGraphBuilder* owner) | 359 explicit AstValueContext(AstGraphBuilder* owner) |
| 360 : AstContext(owner, Expression::kValue) {} | 360 : AstContext(owner, Expression::kValue) {} |
| 361 virtual ~AstValueContext(); | 361 virtual ~AstValueContext(); |
| 362 virtual void ProduceValue(Node* value) OVERRIDE; | 362 void ProduceValue(Node* value) OVERRIDE; |
| 363 virtual Node* ConsumeValue() OVERRIDE; | 363 Node* ConsumeValue() OVERRIDE; |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 | 366 |
| 367 // Context to evaluate expression for a condition value (and side effects). | 367 // Context to evaluate expression for a condition value (and side effects). |
| 368 class AstGraphBuilder::AstTestContext FINAL : public AstContext { | 368 class AstGraphBuilder::AstTestContext FINAL : public AstContext { |
| 369 public: | 369 public: |
| 370 explicit AstTestContext(AstGraphBuilder* owner) | 370 explicit AstTestContext(AstGraphBuilder* owner) |
| 371 : AstContext(owner, Expression::kTest) {} | 371 : AstContext(owner, Expression::kTest) {} |
| 372 virtual ~AstTestContext(); | 372 virtual ~AstTestContext(); |
| 373 virtual void ProduceValue(Node* value) OVERRIDE; | 373 void ProduceValue(Node* value) OVERRIDE; |
| 374 virtual Node* ConsumeValue() OVERRIDE; | 374 Node* ConsumeValue() OVERRIDE; |
| 375 }; | 375 }; |
| 376 | 376 |
| 377 | 377 |
| 378 // Scoped class tracking breakable statements entered by the visitor. Allows to | 378 // Scoped class tracking breakable statements entered by the visitor. Allows to |
| 379 // properly 'break' and 'continue' iteration statements as well as to 'break' | 379 // properly 'break' and 'continue' iteration statements as well as to 'break' |
| 380 // from blocks within switch statements. | 380 // from blocks within switch statements. |
| 381 class AstGraphBuilder::BreakableScope BASE_EMBEDDED { | 381 class AstGraphBuilder::BreakableScope BASE_EMBEDDED { |
| 382 public: | 382 public: |
| 383 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target, | 383 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target, |
| 384 ControlBuilder* control, int drop_extra) | 384 ControlBuilder* control, int drop_extra) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 442 |
| 443 Scope* AstGraphBuilder::current_scope() const { | 443 Scope* AstGraphBuilder::current_scope() const { |
| 444 return execution_context_->scope(); | 444 return execution_context_->scope(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace compiler | 447 } // namespace compiler |
| 448 } // namespace internal | 448 } // namespace internal |
| 449 } // namespace v8 | 449 } // namespace v8 |
| 450 | 450 |
| 451 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 451 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| OLD | NEW |