| 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_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_GRAPH_BUILDER_H_ |
| 6 #define V8_COMPILER_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_GRAPH_BUILDER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 void set_environment(Environment* env) { environment_ = env; } | 115 void set_environment(Environment* env) { environment_ = env; } |
| 116 | 116 |
| 117 Node* current_context() const { return current_context_; } | 117 Node* current_context() const { return current_context_; } |
| 118 void set_current_context(Node* context) { current_context_ = context; } | 118 void set_current_context(Node* context) { current_context_ = context; } |
| 119 | 119 |
| 120 Node* exit_control() const { return exit_control_; } | 120 Node* exit_control() const { return exit_control_; } |
| 121 void set_exit_control(Node* node) { exit_control_ = node; } | 121 void set_exit_control(Node* node) { exit_control_ = node; } |
| 122 | 122 |
| 123 Node* dead_control(); | 123 Node* dead_control(); |
| 124 | 124 |
| 125 // TODO(mstarzinger): Use phase-local zone instead! | 125 Zone* graph_zone() const { return graph()->zone(); } |
| 126 Zone* zone() const { return graph()->zone(); } | 126 Zone* local_zone() { return &local_zone_; } |
| 127 Isolate* isolate() const { return zone()->isolate(); } | 127 Isolate* isolate() const { return graph_zone()->isolate(); } |
| 128 CommonOperatorBuilder* common() const { return common_; } | 128 CommonOperatorBuilder* common() const { return common_; } |
| 129 | 129 |
| 130 // Helper to wrap a Handle<T> into a Unique<T>. | 130 // Helper to wrap a Handle<T> into a Unique<T>. |
| 131 template <class T> | 131 template <class T> |
| 132 Unique<T> MakeUnique(Handle<T> object) { | 132 Unique<T> MakeUnique(Handle<T> object) { |
| 133 return Unique<T>::CreateUninitialized(object); | 133 return Unique<T>::CreateUninitialized(object); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Support for control flow builders. The concrete type of the environment | 136 // Support for control flow builders. The concrete type of the environment |
| 137 // depends on the graph builder, but environments themselves are not virtual. | 137 // depends on the graph builder, but environments themselves are not virtual. |
| 138 virtual Environment* CopyEnvironment(Environment* env); | 138 virtual Environment* CopyEnvironment(Environment* env); |
| 139 | 139 |
| 140 // Helper to indicate a node exits the function body. | 140 // Helper to indicate a node exits the function body. |
| 141 void UpdateControlDependencyToLeaveFunction(Node* exit); | 141 void UpdateControlDependencyToLeaveFunction(Node* exit); |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 CommonOperatorBuilder* common_; | 144 CommonOperatorBuilder* common_; |
| 145 Environment* environment_; | 145 Environment* environment_; |
| 146 | 146 |
| 147 // Zone local to the builder for data not leaking into the graph. |
| 148 Zone local_zone_; |
| 149 |
| 147 // Node representing the control dependency for dead code. | 150 // Node representing the control dependency for dead code. |
| 148 SetOncePointer<Node> dead_control_; | 151 SetOncePointer<Node> dead_control_; |
| 149 | 152 |
| 150 // Node representing the current context within the function body. | 153 // Node representing the current context within the function body. |
| 151 Node* current_context_; | 154 Node* current_context_; |
| 152 | 155 |
| 153 // Merge of all control nodes that exit the function body. | 156 // Merge of all control nodes that exit the function body. |
| 154 Node* exit_control_; | 157 Node* exit_control_; |
| 155 | 158 |
| 156 DISALLOW_COPY_AND_ASSIGN(StructuredGraphBuilder); | 159 DISALLOW_COPY_AND_ASSIGN(StructuredGraphBuilder); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 203 |
| 201 // Copies this environment at a loop header control-flow point. | 204 // Copies this environment at a loop header control-flow point. |
| 202 Environment* CopyForLoop() { | 205 Environment* CopyForLoop() { |
| 203 PrepareForLoop(); | 206 PrepareForLoop(); |
| 204 return builder()->CopyEnvironment(this); | 207 return builder()->CopyEnvironment(this); |
| 205 } | 208 } |
| 206 | 209 |
| 207 Node* GetContext() { return builder_->current_context(); } | 210 Node* GetContext() { return builder_->current_context(); } |
| 208 | 211 |
| 209 protected: | 212 protected: |
| 210 // TODO(mstarzinger): Use phase-local zone instead! | 213 Zone* zone() const { return builder_->local_zone(); } |
| 211 Zone* zone() const { return graph()->zone(); } | |
| 212 Graph* graph() const { return builder_->graph(); } | 214 Graph* graph() const { return builder_->graph(); } |
| 213 StructuredGraphBuilder* builder() const { return builder_; } | 215 StructuredGraphBuilder* builder() const { return builder_; } |
| 214 CommonOperatorBuilder* common() { return builder_->common(); } | 216 CommonOperatorBuilder* common() { return builder_->common(); } |
| 215 NodeVector* values() { return &values_; } | 217 NodeVector* values() { return &values_; } |
| 216 | 218 |
| 217 // Prepare environment to be used as loop header. | 219 // Prepare environment to be used as loop header. |
| 218 void PrepareForLoop(); | 220 void PrepareForLoop(); |
| 219 | 221 |
| 220 private: | 222 private: |
| 221 StructuredGraphBuilder* builder_; | 223 StructuredGraphBuilder* builder_; |
| 222 Node* control_dependency_; | 224 Node* control_dependency_; |
| 223 Node* effect_dependency_; | 225 Node* effect_dependency_; |
| 224 NodeVector values_; | 226 NodeVector values_; |
| 225 }; | 227 }; |
| 226 } | 228 } |
| 227 } | 229 } |
| 228 } // namespace v8::internal::compiler | 230 } // namespace v8::internal::compiler |
| 229 | 231 |
| 230 #endif // V8_COMPILER_GRAPH_BUILDER_H__ | 232 #endif // V8_COMPILER_GRAPH_BUILDER_H__ |
| OLD | NEW |