| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_BYTECODE_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
| 6 #define V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
| 7 | 7 |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/compiler/bytecode-branch-analysis.h" | 9 #include "src/compiler/bytecode-branch-analysis.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 // Optimization to cache loaded feedback vector. | 273 // Optimization to cache loaded feedback vector. |
| 274 SetOncePointer<Node> feedback_vector_; | 274 SetOncePointer<Node> feedback_vector_; |
| 275 | 275 |
| 276 // Control nodes that exit the function body. | 276 // Control nodes that exit the function body. |
| 277 ZoneVector<Node*> exit_controls_; | 277 ZoneVector<Node*> exit_controls_; |
| 278 | 278 |
| 279 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); | 279 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 | |
| 283 class BytecodeGraphBuilder::Environment : public ZoneObject { | |
| 284 public: | |
| 285 Environment(BytecodeGraphBuilder* builder, int register_count, | |
| 286 int parameter_count, Node* control_dependency, Node* context); | |
| 287 | |
| 288 int parameter_count() const { return parameter_count_; } | |
| 289 int register_count() const { return register_count_; } | |
| 290 | |
| 291 Node* LookupAccumulator() const; | |
| 292 Node* LookupRegister(interpreter::Register the_register) const; | |
| 293 | |
| 294 void ExchangeRegisters(interpreter::Register reg0, | |
| 295 interpreter::Register reg1); | |
| 296 | |
| 297 void BindAccumulator(Node* node, FrameStateBeforeAndAfter* states = nullptr); | |
| 298 void BindRegister(interpreter::Register the_register, Node* node, | |
| 299 FrameStateBeforeAndAfter* states = nullptr); | |
| 300 void BindRegistersToProjections(interpreter::Register first_reg, Node* node, | |
| 301 FrameStateBeforeAndAfter* states = nullptr); | |
| 302 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states); | |
| 303 | |
| 304 bool IsMarkedAsUnreachable() const; | |
| 305 void MarkAsUnreachable(); | |
| 306 | |
| 307 // Effect dependency tracked by this environment. | |
| 308 Node* GetEffectDependency() { return effect_dependency_; } | |
| 309 void UpdateEffectDependency(Node* dependency) { | |
| 310 effect_dependency_ = dependency; | |
| 311 } | |
| 312 | |
| 313 // Preserve a checkpoint of the environment for the IR graph. Any | |
| 314 // further mutation of the environment will not affect checkpoints. | |
| 315 Node* Checkpoint(BailoutId bytecode_offset, OutputFrameStateCombine combine); | |
| 316 | |
| 317 // Returns true if the state values are up to date with the current | |
| 318 // environment. | |
| 319 bool StateValuesAreUpToDate(int output_poke_offset, int output_poke_count); | |
| 320 | |
| 321 // Control dependency tracked by this environment. | |
| 322 Node* GetControlDependency() const { return control_dependency_; } | |
| 323 void UpdateControlDependency(Node* dependency) { | |
| 324 control_dependency_ = dependency; | |
| 325 } | |
| 326 | |
| 327 Node* Context() const { return context_; } | |
| 328 void SetContext(Node* new_context) { context_ = new_context; } | |
| 329 | |
| 330 Environment* CopyForConditional() const; | |
| 331 Environment* CopyForLoop(); | |
| 332 void Merge(Environment* other); | |
| 333 | |
| 334 private: | |
| 335 explicit Environment(const Environment* copy); | |
| 336 void PrepareForLoop(); | |
| 337 bool StateValuesAreUpToDate(Node** state_values, int offset, int count, | |
| 338 int output_poke_start, int output_poke_end); | |
| 339 bool StateValuesRequireUpdate(Node** state_values, int offset, int count); | |
| 340 void UpdateStateValues(Node** state_values, int offset, int count); | |
| 341 | |
| 342 int RegisterToValuesIndex(interpreter::Register the_register) const; | |
| 343 | |
| 344 Zone* zone() const { return builder_->local_zone(); } | |
| 345 Graph* graph() const { return builder_->graph(); } | |
| 346 CommonOperatorBuilder* common() const { return builder_->common(); } | |
| 347 BytecodeGraphBuilder* builder() const { return builder_; } | |
| 348 const NodeVector* values() const { return &values_; } | |
| 349 NodeVector* values() { return &values_; } | |
| 350 int register_base() const { return register_base_; } | |
| 351 int accumulator_base() const { return accumulator_base_; } | |
| 352 | |
| 353 BytecodeGraphBuilder* builder_; | |
| 354 int register_count_; | |
| 355 int parameter_count_; | |
| 356 Node* context_; | |
| 357 Node* control_dependency_; | |
| 358 Node* effect_dependency_; | |
| 359 NodeVector values_; | |
| 360 Node* parameters_state_values_; | |
| 361 Node* registers_state_values_; | |
| 362 Node* accumulator_state_values_; | |
| 363 int register_base_; | |
| 364 int accumulator_base_; | |
| 365 }; | |
| 366 | |
| 367 } // namespace compiler | 282 } // namespace compiler |
| 368 } // namespace internal | 283 } // namespace internal |
| 369 } // namespace v8 | 284 } // namespace v8 |
| 370 | 285 |
| 371 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 286 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
| OLD | NEW |