Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: src/compiler/ast-graph-builder.h

Issue 949743002: [turbofan] Variable liveness analysis for deopt (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address review comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.h
diff --git a/src/compiler/ast-graph-builder.h b/src/compiler/ast-graph-builder.h
index 4739e034c8f6faba009a4d603104fb4441cf601c..85d493076ef0ed9a035a2b584c3e2c082e2495fa 100644
--- a/src/compiler/ast-graph-builder.h
+++ b/src/compiler/ast-graph-builder.h
@@ -7,6 +7,7 @@
#include "src/ast.h"
#include "src/compiler/js-graph.h"
+#include "src/compiler/liveness-analyzer.h"
#include "src/compiler/state-values-utils.h"
namespace v8 {
@@ -101,6 +102,9 @@ class AstGraphBuilder : public AstVisitor {
// Cache for StateValues nodes for frame states.
StateValuesCache state_values_cache_;
+ // 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;
@@ -121,6 +125,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; }
@@ -212,6 +217,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 ClearNonLiveSlotsInFrameStates();
+
// Helper to wrap a Handle<T> into a Unique<T>.
template <class T>
Unique<T> MakeUnique(Handle<T> object) {
@@ -372,26 +381,10 @@ class AstGraphBuilder::Environment : public ZoneObject {
locals_count_;
}
- // Operations on parameter or local variables. The parameter indices are
- // shifted by 1 (receiver is parameter index -1 but environment index 0).
- 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_);
- }
- }
+ // Operations on parameter or local variables.
+ void Bind(Variable* variable, Node* node);
+ Node* Lookup(Variable* variable);
+ void MarkAllLocalsLive();
Node* Context() const { return contexts_.back(); }
void PushContext(Node* context) { contexts()->push_back(context); }
@@ -474,7 +467,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 CopyAndShareLiveness();
}
int ContextStackDepth() { return static_cast<int>(contexts_.size()); }
@@ -483,6 +476,7 @@ class AstGraphBuilder::Environment : public ZoneObject {
AstGraphBuilder* builder_;
int parameters_count_;
int locals_count_;
+ LivenessAnalyzerBlock* liveness_block_;
NodeVector values_;
NodeVector contexts_;
Node* control_dependency_;
@@ -491,8 +485,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* CopyAndShareLiveness();
void UpdateStateValues(Node** state_values, int offset, int count);
void UpdateStateValuesWithCache(Node** state_values, int offset, int count);
Zone* zone() const { return builder_->local_zone(); }
@@ -501,6 +496,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);
« no previous file with comments | « BUILD.gn ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698