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,
}
if (has_framestate) {
// 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.
*current_input++ = dead_control();
*current_input++ = jsgraph()->DeadControl();
}
if (has_effect) {
*current_input++ = environment_->GetEffectDependency();
......@@ -3157,16 +3157,6 @@ Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) {
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 internal
} // namespace v8
......@@ -94,9 +94,6 @@ class AstGraphBuilder : public AstVisitor {
int input_buffer_size_;
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.
Node* exit_control_;
......@@ -122,7 +119,6 @@ class AstGraphBuilder : public AstVisitor {
ZoneVector<Handle<Object>>* globals() { return &globals_; }
Scope* current_scope() const;
Node* current_context() const;
Node* dead_control();
Node* exit_control() const { return exit_control_; }
void set_environment(Environment* env) { environment_ = env; }
......@@ -411,7 +407,7 @@ class AstGraphBuilder::Environment : public ZoneObject {
// Mark this environment as being unreachable.
void MarkAsUnreachable() {
UpdateControlDependency(builder()->dead_control());
UpdateControlDependency(builder()->jsgraph()->DeadControl());
}
bool IsMarkedAsUnreachable() {
return GetControlDependency()->opcode() == IrOpcode::kDead;
......
......@@ -54,8 +54,7 @@ class ControlReducerImpl {
common_(common),
state_(jsgraph->graph()->NodeCount(), kUnvisited, zone_),
stack_(zone_),
revisit_(zone_),
dead_(NULL) {}
revisit_(zone_) {}
Zone* zone_;
JSGraph* jsgraph_;
......@@ -63,7 +62,6 @@ class ControlReducerImpl {
ZoneVector<VisitState> state_;
ZoneDeque<Node*> stack_;
ZoneDeque<Node*> revisit_;
Node* dead_;
void Reduce() {
Push(graph()->end());
......@@ -380,10 +378,7 @@ class ControlReducerImpl {
state_[id] = kVisited;
}
Node* dead() {
if (dead_ == NULL) dead_ = graph()->NewNode(common_->Dead());
return dead_;
}
Node* dead() { return jsgraph_->DeadControl(); }
//===========================================================================
// Reducer implementation: perform reductions on a node.
......
......@@ -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() {
if (!empty_frame_state_.is_set()) {
Node* values = graph()->NewNode(common()->StateValues(0));
......@@ -204,12 +213,12 @@ Node* JSGraph::EmptyFrameState() {
}
Node* JSGraph::ExternalConstant(ExternalReference reference) {
Node** loc = cache_.FindExternalConstant(reference);
if (*loc == NULL) {
*loc = graph()->NewNode(common()->ExternalConstant(reference));
Node* JSGraph::DeadControl() {
if (!dead_control_.is_set()) {
Node* dead_node = graph()->NewNode(common()->Dead());
dead_control_.set(dead_node);
}
return *loc;
return dead_control_.get();
}
......
......@@ -114,6 +114,9 @@ class JSGraph : public ZoneObject {
// cannot deopt.
Node* EmptyFrameState();
// Create a control node that serves as control dependency for dead nodes.
Node* DeadControl();
JSOperatorBuilder* javascript() const { return javascript_; }
CommonOperatorBuilder* common() const { return common_; }
MachineOperatorBuilder* machine() const { return machine_; }
......@@ -142,6 +145,7 @@ class JSGraph : public ZoneObject {
SetOncePointer<Node> one_constant_;
SetOncePointer<Node> nan_constant_;
SetOncePointer<Node> empty_frame_state_;
SetOncePointer<Node> dead_control_;
CommonNodeCache cache_;
......
......@@ -207,7 +207,7 @@ bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common,
// Analyze the graph to determine how deeply nested the OSR loop is.
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);
if (loop->depth() > 0) {
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