Chromium Code Reviews| Index: src/compiler/ast-graph-builder.h |
| diff --git a/src/compiler/ast-graph-builder.h b/src/compiler/ast-graph-builder.h |
| index aa874be5bdff7122b26fb78568d49b8536d6eaf3..da30e14c57b93c9ebd8747317c67eb9e1d094dc0 100644 |
| --- a/src/compiler/ast-graph-builder.h |
| +++ b/src/compiler/ast-graph-builder.h |
| @@ -17,6 +17,8 @@ namespace compiler { |
| class ControlBuilder; |
| class Graph; |
| +class LivenessAnalyzer; |
| +class LivenessAnalyzerBlock; |
| class LoopAssignmentAnalysis; |
| class LoopBuilder; |
| class Node; |
| @@ -97,6 +99,9 @@ class AstGraphBuilder : public AstVisitor { |
| // Result of loop assignment analysis performed before graph creation. |
| LoopAssignmentAnalysis* loop_assignment_analysis_; |
| + // Analyzer of local variable liveness. |
| + LivenessAnalyzer* liveness_analyzer_; |
| + |
| // Growth increment for the temporary buffer used to construct input lists to |
| // new nodes. |
| static const int kInputBufferSizeIncrement = 64; |
| @@ -117,6 +122,7 @@ class AstGraphBuilder : public AstVisitor { |
| Scope* current_scope() const; |
| Node* current_context() const; |
| Node* exit_control() const { return exit_control_; } |
| + LivenessAnalyzer* liveness_analyzer() { return liveness_analyzer_; } |
| void set_environment(Environment* env) { environment_ = env; } |
| void set_ast_context(AstContext* ctx) { ast_context_ = ctx; } |
| @@ -262,6 +268,10 @@ class AstGraphBuilder : public AstVisitor { |
| // If so, record the stack height into the compilation and return {true}. |
| bool CheckOsrEntry(IterationStatement* stmt); |
| + // Computes local variable liveness and replaces dead variables in |
| + // frame states with the undefined values. |
| + void RelaxFrameStatesWithLiveness(); |
|
titzer
2015/02/27 21:09:55
Can we use another word than "Relax", here and els
|
| + |
| // Helper to wrap a Handle<T> into a Unique<T>. |
| template <class T> |
| Unique<T> MakeUnique(Handle<T> object) { |
| @@ -347,24 +357,9 @@ class AstGraphBuilder::Environment : public ZoneObject { |
| // Operations on parameter or local variables. The parameter indices are |
| // shifted by 1 (receiver is parameter index -1 but environment index 0). |
|
Michael Starzinger
2015/03/02 10:56:34
nit: I think the second sentence in the comment ma
Jarin
2015/03/16 21:30:12
Done.
|
| - void Bind(Variable* variable, Node* node) { |
| - DCHECK(variable->IsStackAllocated()); |
| - if (variable->IsParameter()) { |
| - values()->at(variable->index() + 1) = node; |
| - } else { |
| - DCHECK(variable->IsStackLocal()); |
| - values()->at(variable->index() + parameters_count_) = node; |
| - } |
| - } |
| - Node* Lookup(Variable* variable) { |
| - DCHECK(variable->IsStackAllocated()); |
| - if (variable->IsParameter()) { |
| - return values()->at(variable->index() + 1); |
| - } else { |
| - DCHECK(variable->IsStackLocal()); |
| - return values()->at(variable->index() + parameters_count_); |
| - } |
| - } |
| + void Bind(Variable* variable, Node* node); |
| + Node* Lookup(Variable* variable); |
| + void MakeAllLocalsLive(); |
| Node* Context() const { return contexts_.back(); } |
| void PushContext(Node* context) { contexts()->push_back(context); } |
| @@ -446,7 +441,7 @@ class AstGraphBuilder::Environment : public ZoneObject { |
| // Copies this environment at a loop header control-flow point. |
| Environment* CopyForLoop(BitVector* assigned, bool is_osr = false) { |
| PrepareForLoop(assigned, is_osr); |
| - return Copy(); |
| + return Snapshot(); |
| } |
| int ContextStackDepth() { return static_cast<int>(contexts_.size()); } |
| @@ -455,6 +450,7 @@ class AstGraphBuilder::Environment : public ZoneObject { |
| AstGraphBuilder* builder_; |
| int parameters_count_; |
| int locals_count_; |
| + LivenessAnalyzerBlock* liveness_block_; |
| NodeVector values_; |
| NodeVector contexts_; |
| Node* control_dependency_; |
| @@ -463,8 +459,9 @@ class AstGraphBuilder::Environment : public ZoneObject { |
| Node* locals_node_; |
| Node* stack_node_; |
| - explicit Environment(const Environment* copy); |
| + explicit Environment(Environment* copy); |
| Environment* Copy() { return new (zone()) Environment(this); } |
| + Environment* Snapshot(); |
| void UpdateStateValues(Node** state_values, int offset, int count); |
| Zone* zone() const { return builder_->local_zone(); } |
| Graph* graph() const { return builder_->graph(); } |
| @@ -472,6 +469,7 @@ class AstGraphBuilder::Environment : public ZoneObject { |
| CommonOperatorBuilder* common() { return builder_->common(); } |
| NodeVector* values() { return &values_; } |
| NodeVector* contexts() { return &contexts_; } |
| + LivenessAnalyzerBlock* liveness_block() { return liveness_block_; } |
| // Prepare environment to be used as loop header. |
| void PrepareForLoop(BitVector* assigned, bool is_osr = false); |