Commit 03cad07a authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Move DeadControl into the JSGraph so that it can be reused.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/929123002

Cr-Commit-Position: refs/heads/master@{#26672}
parent 868470dd
...@@ -2970,9 +2970,9 @@ Node* AstGraphBuilder::MakeNode(const Operator* op, int value_input_count, ...@@ -2970,9 +2970,9 @@ Node* AstGraphBuilder::MakeNode(const Operator* op, int value_input_count,
} }
if (has_framestate) { if (has_framestate) {
// The frame state will be inserted later. Here we misuse // The frame state will be inserted later. Here we misuse
// the dead_control node as a sentinel to be later overwritten // the {DeadControl} node as a sentinel to be later overwritten
// with the real frame state. // with the real frame state.
*current_input++ = dead_control(); *current_input++ = jsgraph()->DeadControl();
} }
if (has_effect) { if (has_effect) {
*current_input++ = environment_->GetEffectDependency(); *current_input++ = environment_->GetEffectDependency();
...@@ -3157,16 +3157,6 @@ Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) { ...@@ -3157,16 +3157,6 @@ Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) {
return value; return value;
} }
Node* AstGraphBuilder::dead_control() {
if (!dead_control_.is_set()) {
Node* dead_node = graph()->NewNode(common()->Dead());
dead_control_.set(dead_node);
return dead_node;
}
return dead_control_.get();
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -94,9 +94,6 @@ class AstGraphBuilder : public AstVisitor { ...@@ -94,9 +94,6 @@ class AstGraphBuilder : public AstVisitor {
int input_buffer_size_; int input_buffer_size_;
Node** input_buffer_; Node** input_buffer_;
// Node representing the control dependency for dead code.
SetOncePointer<Node> dead_control_;
// Merge of all control nodes that exit the function body. // Merge of all control nodes that exit the function body.
Node* exit_control_; Node* exit_control_;
...@@ -122,7 +119,6 @@ class AstGraphBuilder : public AstVisitor { ...@@ -122,7 +119,6 @@ class AstGraphBuilder : public AstVisitor {
ZoneVector<Handle<Object>>* globals() { return &globals_; } ZoneVector<Handle<Object>>* globals() { return &globals_; }
Scope* current_scope() const; Scope* current_scope() const;
Node* current_context() const; Node* current_context() const;
Node* dead_control();
Node* exit_control() const { return exit_control_; } Node* exit_control() const { return exit_control_; }
void set_environment(Environment* env) { environment_ = env; } void set_environment(Environment* env) { environment_ = env; }
...@@ -411,7 +407,7 @@ class AstGraphBuilder::Environment : public ZoneObject { ...@@ -411,7 +407,7 @@ class AstGraphBuilder::Environment : public ZoneObject {
// Mark this environment as being unreachable. // Mark this environment as being unreachable.
void MarkAsUnreachable() { void MarkAsUnreachable() {
UpdateControlDependency(builder()->dead_control()); UpdateControlDependency(builder()->jsgraph()->DeadControl());
} }
bool IsMarkedAsUnreachable() { bool IsMarkedAsUnreachable() {
return GetControlDependency()->opcode() == IrOpcode::kDead; return GetControlDependency()->opcode() == IrOpcode::kDead;
......
...@@ -54,8 +54,7 @@ class ControlReducerImpl { ...@@ -54,8 +54,7 @@ class ControlReducerImpl {
common_(common), common_(common),
state_(jsgraph->graph()->NodeCount(), kUnvisited, zone_), state_(jsgraph->graph()->NodeCount(), kUnvisited, zone_),
stack_(zone_), stack_(zone_),
revisit_(zone_), revisit_(zone_) {}
dead_(NULL) {}
Zone* zone_; Zone* zone_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
...@@ -63,7 +62,6 @@ class ControlReducerImpl { ...@@ -63,7 +62,6 @@ class ControlReducerImpl {
ZoneVector<VisitState> state_; ZoneVector<VisitState> state_;
ZoneDeque<Node*> stack_; ZoneDeque<Node*> stack_;
ZoneDeque<Node*> revisit_; ZoneDeque<Node*> revisit_;
Node* dead_;
void Reduce() { void Reduce() {
Push(graph()->end()); Push(graph()->end());
...@@ -380,10 +378,7 @@ class ControlReducerImpl { ...@@ -380,10 +378,7 @@ class ControlReducerImpl {
state_[id] = kVisited; state_[id] = kVisited;
} }
Node* dead() { Node* dead() { return jsgraph_->DeadControl(); }
if (dead_ == NULL) dead_ = graph()->NewNode(common_->Dead());
return dead_;
}
//=========================================================================== //===========================================================================
// Reducer implementation: perform reductions on a node. // Reducer implementation: perform reductions on a node.
......
...@@ -191,6 +191,15 @@ Node* JSGraph::Float64Constant(double value) { ...@@ -191,6 +191,15 @@ Node* JSGraph::Float64Constant(double value) {
} }
Node* JSGraph::ExternalConstant(ExternalReference reference) {
Node** loc = cache_.FindExternalConstant(reference);
if (*loc == NULL) {
*loc = graph()->NewNode(common()->ExternalConstant(reference));
}
return *loc;
}
Node* JSGraph::EmptyFrameState() { Node* JSGraph::EmptyFrameState() {
if (!empty_frame_state_.is_set()) { if (!empty_frame_state_.is_set()) {
Node* values = graph()->NewNode(common()->StateValues(0)); Node* values = graph()->NewNode(common()->StateValues(0));
...@@ -204,12 +213,12 @@ Node* JSGraph::EmptyFrameState() { ...@@ -204,12 +213,12 @@ Node* JSGraph::EmptyFrameState() {
} }
Node* JSGraph::ExternalConstant(ExternalReference reference) { Node* JSGraph::DeadControl() {
Node** loc = cache_.FindExternalConstant(reference); if (!dead_control_.is_set()) {
if (*loc == NULL) { Node* dead_node = graph()->NewNode(common()->Dead());
*loc = graph()->NewNode(common()->ExternalConstant(reference)); dead_control_.set(dead_node);
} }
return *loc; return dead_control_.get();
} }
......
...@@ -114,6 +114,9 @@ class JSGraph : public ZoneObject { ...@@ -114,6 +114,9 @@ class JSGraph : public ZoneObject {
// cannot deopt. // cannot deopt.
Node* EmptyFrameState(); Node* EmptyFrameState();
// Create a control node that serves as control dependency for dead nodes.
Node* DeadControl();
JSOperatorBuilder* javascript() const { return javascript_; } JSOperatorBuilder* javascript() const { return javascript_; }
CommonOperatorBuilder* common() const { return common_; } CommonOperatorBuilder* common() const { return common_; }
MachineOperatorBuilder* machine() const { return machine_; } MachineOperatorBuilder* machine() const { return machine_; }
...@@ -142,6 +145,7 @@ class JSGraph : public ZoneObject { ...@@ -142,6 +145,7 @@ class JSGraph : public ZoneObject {
SetOncePointer<Node> one_constant_; SetOncePointer<Node> one_constant_;
SetOncePointer<Node> nan_constant_; SetOncePointer<Node> nan_constant_;
SetOncePointer<Node> empty_frame_state_; SetOncePointer<Node> empty_frame_state_;
SetOncePointer<Node> dead_control_;
CommonNodeCache cache_; CommonNodeCache cache_;
......
...@@ -207,7 +207,7 @@ bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, ...@@ -207,7 +207,7 @@ bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common,
// Analyze the graph to determine how deeply nested the OSR loop is. // Analyze the graph to determine how deeply nested the OSR loop is.
LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone);
Node* dead = graph->NewNode(common->Dead()); Node* dead = jsgraph->DeadControl();
LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop);
if (loop->depth() > 0) { if (loop->depth() > 0) {
PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment