| Index: src/compiler/js-context-specialization.cc
|
| diff --git a/src/compiler/js-context-specialization.cc b/src/compiler/js-context-specialization.cc
|
| index b54d5d99c2058cf17d1674b5f9cc7e3e01953741..bdf142763a8887ca3db22cdda719b94eae24f86a 100644
|
| --- a/src/compiler/js-context-specialization.cc
|
| +++ b/src/compiler/js-context-specialization.cc
|
| @@ -15,6 +15,26 @@ namespace v8 {
|
| namespace internal {
|
| namespace compiler {
|
|
|
| +// TODO(titzer): factor this out to a common routine with js-typed-lowering.
|
| +static void ReplaceEffectfulWithValue(Node* node, Node* value) {
|
| + Node* effect = NULL;
|
| + if (OperatorProperties::HasEffectInput(node->op())) {
|
| + effect = NodeProperties::GetEffectInput(node);
|
| + }
|
| +
|
| + // Requires distinguishing between value and effect edges.
|
| + UseIter iter = node->uses().begin();
|
| + while (iter != node->uses().end()) {
|
| + if (NodeProperties::IsEffectEdge(iter.edge())) {
|
| + DCHECK_NE(NULL, effect);
|
| + iter = iter.UpdateToAndIncrement(effect);
|
| + } else {
|
| + iter = iter.UpdateToAndIncrement(value);
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| class ContextSpecializationVisitor : public NullNodeVisitor {
|
| public:
|
| explicit ContextSpecializationVisitor(JSContextSpecializer* spec)
|
| @@ -25,16 +45,14 @@ class ContextSpecializationVisitor : public NullNodeVisitor {
|
| case IrOpcode::kJSLoadContext: {
|
| Reduction r = spec_->ReduceJSLoadContext(node);
|
| if (r.Changed() && r.replacement() != node) {
|
| - NodeProperties::ReplaceWithValue(node, r.replacement());
|
| - node->RemoveAllInputs();
|
| + ReplaceEffectfulWithValue(node, r.replacement());
|
| }
|
| break;
|
| }
|
| case IrOpcode::kJSStoreContext: {
|
| Reduction r = spec_->ReduceJSStoreContext(node);
|
| if (r.Changed() && r.replacement() != node) {
|
| - NodeProperties::ReplaceWithValue(node, r.replacement());
|
| - node->RemoveAllInputs();
|
| + ReplaceEffectfulWithValue(node, r.replacement());
|
| }
|
| break;
|
| }
|
| @@ -50,8 +68,7 @@ class ContextSpecializationVisitor : public NullNodeVisitor {
|
|
|
|
|
| void JSContextSpecializer::SpecializeToContext() {
|
| - NodeProperties::ReplaceWithValue(context_,
|
| - jsgraph_->Constant(info_->context()));
|
| + ReplaceEffectfulWithValue(context_, jsgraph_->Constant(info_->context()));
|
|
|
| ContextSpecializationVisitor visitor(this);
|
| jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor);
|
|
|