| 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/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/liveness-analyzer.h" | 10 #include "src/compiler/liveness-analyzer.h" |
| 11 #include "src/compiler/state-values-utils.h" | 11 #include "src/compiler/state-values-utils.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 class BitVector; | 16 class BitVector; |
| 17 | 17 |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 class ControlBuilder; | 20 class ControlBuilder; |
| 21 class Graph; | 21 class Graph; |
| 22 class JSTypeFeedbackTable; | |
| 23 class LoopAssignmentAnalysis; | 22 class LoopAssignmentAnalysis; |
| 24 class LoopBuilder; | 23 class LoopBuilder; |
| 25 class Node; | 24 class Node; |
| 26 | 25 |
| 27 // The AstGraphBuilder produces a high-level IR graph, based on an | 26 // The AstGraphBuilder produces a high-level IR graph, based on an |
| 28 // underlying AST. The produced graph can either be compiled into a | 27 // underlying AST. The produced graph can either be compiled into a |
| 29 // stand-alone function or be wired into another graph for the purposes | 28 // stand-alone function or be wired into another graph for the purposes |
| 30 // of function inlining. | 29 // of function inlining. |
| 31 class AstGraphBuilder : public AstVisitor { | 30 class AstGraphBuilder : public AstVisitor { |
| 32 public: | 31 public: |
| 33 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, | 32 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, |
| 34 LoopAssignmentAnalysis* loop_assignment = NULL, | 33 LoopAssignmentAnalysis* loop_assignment = NULL); |
| 35 JSTypeFeedbackTable* js_type_feedback = NULL); | |
| 36 | 34 |
| 37 // Creates a graph by visiting the entire AST. | 35 // Creates a graph by visiting the entire AST. |
| 38 bool CreateGraph(bool stack_check = true); | 36 bool CreateGraph(bool stack_check = true); |
| 39 | 37 |
| 40 // Helpers to create new control nodes. | 38 // Helpers to create new control nodes. |
| 41 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } | 39 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } |
| 42 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } | 40 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } |
| 43 Node* NewMerge() { return NewNode(common()->Merge(1), true); } | 41 Node* NewMerge() { return NewNode(common()->Merge(1), true); } |
| 44 Node* NewLoop() { return NewNode(common()->Loop(1), true); } | 42 Node* NewLoop() { return NewNode(common()->Loop(1), true); } |
| 45 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { | 43 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 107 |
| 110 // Cache for StateValues nodes for frame states. | 108 // Cache for StateValues nodes for frame states. |
| 111 StateValuesCache state_values_cache_; | 109 StateValuesCache state_values_cache_; |
| 112 | 110 |
| 113 // Analyzer of local variable liveness. | 111 // Analyzer of local variable liveness. |
| 114 LivenessAnalyzer liveness_analyzer_; | 112 LivenessAnalyzer liveness_analyzer_; |
| 115 | 113 |
| 116 // Function info for frame state construction. | 114 // Function info for frame state construction. |
| 117 const FrameStateFunctionInfo* const frame_state_function_info_; | 115 const FrameStateFunctionInfo* const frame_state_function_info_; |
| 118 | 116 |
| 119 // Type feedback table. | |
| 120 JSTypeFeedbackTable* js_type_feedback_; | |
| 121 | |
| 122 // Growth increment for the temporary buffer used to construct input lists to | 117 // Growth increment for the temporary buffer used to construct input lists to |
| 123 // new nodes. | 118 // new nodes. |
| 124 static const int kInputBufferSizeIncrement = 64; | 119 static const int kInputBufferSizeIncrement = 64; |
| 125 | 120 |
| 126 Zone* local_zone() const { return local_zone_; } | 121 Zone* local_zone() const { return local_zone_; } |
| 127 Environment* environment() const { return environment_; } | 122 Environment* environment() const { return environment_; } |
| 128 AstContext* ast_context() const { return ast_context_; } | 123 AstContext* ast_context() const { return ast_context_; } |
| 129 ControlScope* execution_control() const { return execution_control_; } | 124 ControlScope* execution_control() const { return execution_control_; } |
| 130 ContextScope* execution_context() const { return execution_context_; } | 125 ContextScope* execution_context() const { return execution_context_; } |
| 131 CommonOperatorBuilder* common() const { return jsgraph_->common(); } | 126 CommonOperatorBuilder* common() const { return jsgraph_->common(); } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 const VectorSlotPair& feedback, | 274 const VectorSlotPair& feedback, |
| 280 OutputFrameStateCombine framestate_combine, | 275 OutputFrameStateCombine framestate_combine, |
| 281 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); | 276 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); |
| 282 | 277 |
| 283 // Builders for property loads and stores. | 278 // Builders for property loads and stores. |
| 284 Node* BuildKeyedLoad(Node* receiver, Node* key, | 279 Node* BuildKeyedLoad(Node* receiver, Node* key, |
| 285 const VectorSlotPair& feedback); | 280 const VectorSlotPair& feedback); |
| 286 Node* BuildNamedLoad(Node* receiver, Handle<Name> name, | 281 Node* BuildNamedLoad(Node* receiver, Handle<Name> name, |
| 287 const VectorSlotPair& feedback); | 282 const VectorSlotPair& feedback); |
| 288 Node* BuildKeyedStore(Node* receiver, Node* key, Node* value, | 283 Node* BuildKeyedStore(Node* receiver, Node* key, Node* value, |
| 289 const VectorSlotPair& feedback, TypeFeedbackId id); | 284 const VectorSlotPair& feedback); |
| 290 Node* BuildNamedStore(Node* receiver, Handle<Name> name, Node* value, | 285 Node* BuildNamedStore(Node* receiver, Handle<Name> name, Node* value, |
| 291 const VectorSlotPair& feedback, TypeFeedbackId id); | 286 const VectorSlotPair& feedback); |
| 292 | 287 |
| 293 // Builders for super property loads and stores. | 288 // Builders for super property loads and stores. |
| 294 Node* BuildKeyedSuperStore(Node* receiver, Node* home_object, Node* key, | 289 Node* BuildKeyedSuperStore(Node* receiver, Node* home_object, Node* key, |
| 295 Node* value, TypeFeedbackId id); | 290 Node* value); |
| 296 Node* BuildNamedSuperStore(Node* receiver, Node* home_object, | 291 Node* BuildNamedSuperStore(Node* receiver, Node* home_object, |
| 297 Handle<Name> name, Node* value, TypeFeedbackId id); | 292 Handle<Name> name, Node* value); |
| 298 Node* BuildNamedSuperLoad(Node* receiver, Node* home_object, | 293 Node* BuildNamedSuperLoad(Node* receiver, Node* home_object, |
| 299 Handle<Name> name, const VectorSlotPair& feedback); | 294 Handle<Name> name, const VectorSlotPair& feedback); |
| 300 Node* BuildKeyedSuperLoad(Node* receiver, Node* home_object, Node* key, | 295 Node* BuildKeyedSuperLoad(Node* receiver, Node* home_object, Node* key, |
| 301 const VectorSlotPair& feedback); | 296 const VectorSlotPair& feedback); |
| 302 | 297 |
| 303 // Builders for global variable loads and stores. | 298 // Builders for global variable loads and stores. |
| 304 Node* BuildGlobalLoad(Handle<Name> name, const VectorSlotPair& feedback, | 299 Node* BuildGlobalLoad(Handle<Name> name, const VectorSlotPair& feedback, |
| 305 TypeofMode typeof_mode); | 300 TypeofMode typeof_mode); |
| 306 Node* BuildGlobalStore(Handle<Name> name, Node* value, | 301 Node* BuildGlobalStore(Handle<Name> name, Node* value, |
| 307 const VectorSlotPair& feedback, TypeFeedbackId id); | 302 const VectorSlotPair& feedback); |
| 308 | 303 |
| 309 // Builders for accessing the function context. | 304 // Builders for accessing the function context. |
| 310 Node* BuildLoadGlobalObject(); | 305 Node* BuildLoadGlobalObject(); |
| 311 Node* BuildLoadNativeContextField(int index); | 306 Node* BuildLoadNativeContextField(int index); |
| 312 Node* BuildLoadGlobalProxy(); | 307 Node* BuildLoadGlobalProxy(); |
| 313 Node* BuildLoadFeedbackVector(); | 308 Node* BuildLoadFeedbackVector(); |
| 314 | 309 |
| 315 // Builder for accessing a (potentially immutable) object field. | 310 // Builder for accessing a (potentially immutable) object field. |
| 316 Node* BuildLoadObjectField(Node* object, int offset); | 311 Node* BuildLoadObjectField(Node* object, int offset); |
| 317 Node* BuildLoadImmutableObjectField(Node* object, int offset); | 312 Node* BuildLoadImmutableObjectField(Node* object, int offset); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 | 553 |
| 559 // Prepare environment to be used as loop header. | 554 // Prepare environment to be used as loop header. |
| 560 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 555 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
| 561 }; | 556 }; |
| 562 | 557 |
| 563 } // namespace compiler | 558 } // namespace compiler |
| 564 } // namespace internal | 559 } // namespace internal |
| 565 } // namespace v8 | 560 } // namespace v8 |
| 566 | 561 |
| 567 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 562 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| OLD | NEW |