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" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 // Effect dependency tracked by this environment. | 453 // Effect dependency tracked by this environment. |
454 Node* GetEffectDependency() { return effect_dependency_; } | 454 Node* GetEffectDependency() { return effect_dependency_; } |
455 void UpdateEffectDependency(Node* dependency) { | 455 void UpdateEffectDependency(Node* dependency) { |
456 effect_dependency_ = dependency; | 456 effect_dependency_ = dependency; |
457 } | 457 } |
458 | 458 |
459 // Mark this environment as being unreachable. | 459 // Mark this environment as being unreachable. |
460 void MarkAsUnreachable() { | 460 void MarkAsUnreachable() { |
461 UpdateControlDependency(builder()->jsgraph()->DeadControl()); | 461 UpdateControlDependency(builder()->jsgraph()->DeadControl()); |
| 462 liveness_block_ = nullptr; |
462 } | 463 } |
463 bool IsMarkedAsUnreachable() { | 464 bool IsMarkedAsUnreachable() { |
464 return GetControlDependency()->opcode() == IrOpcode::kDead; | 465 return GetControlDependency()->opcode() == IrOpcode::kDead; |
465 } | 466 } |
466 | 467 |
467 // Merge another environment into this one. | 468 // Merge another environment into this one. |
468 void Merge(Environment* other); | 469 void Merge(Environment* other); |
469 | 470 |
470 // Copies this environment at a control-flow split point. | 471 // Copies this environment at a control-flow split point. |
471 Environment* CopyForConditional() { return Copy(); } | 472 Environment* CopyForConditional(); |
472 | 473 |
473 // Copies this environment to a potentially unreachable control-flow point. | 474 // Copies this environment to a potentially unreachable control-flow point. |
474 Environment* CopyAsUnreachable() { | 475 Environment* CopyAsUnreachable(); |
475 Environment* env = Copy(); | |
476 env->MarkAsUnreachable(); | |
477 return env; | |
478 } | |
479 | 476 |
480 // Copies this environment at a loop header control-flow point. | 477 // Copies this environment at a loop header control-flow point. |
481 Environment* CopyForLoop(BitVector* assigned, bool is_osr = false) { | 478 Environment* CopyForLoop(BitVector* assigned, bool is_osr = false); |
482 PrepareForLoop(assigned, is_osr); | |
483 return CopyAndShareLiveness(); | |
484 } | |
485 | 479 |
486 private: | 480 private: |
487 AstGraphBuilder* builder_; | 481 AstGraphBuilder* builder_; |
488 int parameters_count_; | 482 int parameters_count_; |
489 int locals_count_; | 483 int locals_count_; |
490 LivenessAnalyzerBlock* liveness_block_; | 484 LivenessAnalyzerBlock* liveness_block_; |
491 NodeVector values_; | 485 NodeVector values_; |
492 NodeVector contexts_; | 486 NodeVector contexts_; |
493 Node* control_dependency_; | 487 Node* control_dependency_; |
494 Node* effect_dependency_; | 488 Node* effect_dependency_; |
495 Node* parameters_node_; | 489 Node* parameters_node_; |
496 Node* locals_node_; | 490 Node* locals_node_; |
497 Node* stack_node_; | 491 Node* stack_node_; |
498 | 492 |
499 explicit Environment(Environment* copy); | 493 explicit Environment(Environment* copy, |
500 Environment* Copy() { return new (zone()) Environment(this); } | 494 LivenessAnalyzerBlock* liveness_block); |
501 Environment* CopyAndShareLiveness(); | 495 Environment* CopyAndShareLiveness(); |
502 void UpdateStateValues(Node** state_values, int offset, int count); | 496 void UpdateStateValues(Node** state_values, int offset, int count); |
503 void UpdateStateValuesWithCache(Node** state_values, int offset, int count); | 497 void UpdateStateValuesWithCache(Node** state_values, int offset, int count); |
504 Zone* zone() const { return builder_->local_zone(); } | 498 Zone* zone() const { return builder_->local_zone(); } |
505 Graph* graph() const { return builder_->graph(); } | 499 Graph* graph() const { return builder_->graph(); } |
506 AstGraphBuilder* builder() const { return builder_; } | 500 AstGraphBuilder* builder() const { return builder_; } |
507 CommonOperatorBuilder* common() { return builder_->common(); } | 501 CommonOperatorBuilder* common() { return builder_->common(); } |
508 NodeVector* values() { return &values_; } | 502 NodeVector* values() { return &values_; } |
509 NodeVector* contexts() { return &contexts_; } | 503 NodeVector* contexts() { return &contexts_; } |
510 LivenessAnalyzerBlock* liveness_block() { return liveness_block_; } | 504 LivenessAnalyzerBlock* liveness_block() { return liveness_block_; } |
| 505 bool IsLivenessAnalysisEnabled(); |
| 506 bool IsLivenessBlockConsistent(); |
511 | 507 |
512 // Prepare environment to be used as loop header. | 508 // Prepare environment to be used as loop header. |
513 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 509 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
514 }; | 510 }; |
515 | 511 |
516 } // namespace compiler | 512 } // namespace compiler |
517 } // namespace internal | 513 } // namespace internal |
518 } // namespace v8 | 514 } // namespace v8 |
519 | 515 |
520 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 516 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
OLD | NEW |