Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / v8 / src / compiler / js-context-specialization.cc
index bdf1427..cd8932b 100644 (file)
@@ -15,26 +15,6 @@ 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)
@@ -45,14 +25,16 @@ class ContextSpecializationVisitor : public NullNodeVisitor {
       case IrOpcode::kJSLoadContext: {
         Reduction r = spec_->ReduceJSLoadContext(node);
         if (r.Changed() && r.replacement() != node) {
-          ReplaceEffectfulWithValue(node, r.replacement());
+          NodeProperties::ReplaceWithValue(node, r.replacement());
+          node->RemoveAllInputs();
         }
         break;
       }
       case IrOpcode::kJSStoreContext: {
         Reduction r = spec_->ReduceJSStoreContext(node);
         if (r.Changed() && r.replacement() != node) {
-          ReplaceEffectfulWithValue(node, r.replacement());
+          NodeProperties::ReplaceWithValue(node, r.replacement());
+          node->RemoveAllInputs();
         }
         break;
       }
@@ -68,7 +50,8 @@ class ContextSpecializationVisitor : public NullNodeVisitor {
 
 
 void JSContextSpecializer::SpecializeToContext() {
-  ReplaceEffectfulWithValue(context_, jsgraph_->Constant(info_->context()));
+  NodeProperties::ReplaceWithValue(context_,
+                                   jsgraph_->Constant(info_->context()));
 
   ContextSpecializationVisitor visitor(this);
   jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor);
@@ -78,16 +61,16 @@ void JSContextSpecializer::SpecializeToContext() {
 Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) {
   DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode());
 
-  ValueMatcher<Handle<Context> > match(NodeProperties::GetValueInput(node, 0));
+  HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(node, 0));
   // If the context is not constant, no reduction can occur.
-  if (!match.HasValue()) {
+  if (!m.HasValue()) {
     return Reducer::NoChange();
   }
 
   ContextAccess access = OpParameter<ContextAccess>(node);
 
   // Find the right parent context.
-  Context* context = *match.Value();
+  Context* context = *m.Value().handle();
   for (int i = access.depth(); i > 0; --i) {
     context = context->previous();
   }
@@ -98,8 +81,8 @@ Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) {
     if (access.depth() == 0) {
       return Reducer::NoChange();
     }
-    Operator* op = jsgraph_->javascript()->LoadContext(0, access.index(),
-                                                       access.immutable());
+    const Operator* op = jsgraph_->javascript()->LoadContext(
+        0, access.index(), access.immutable());
     node->set_op(op);
     Handle<Object> context_handle = Handle<Object>(context, info_->isolate());
     node->ReplaceInput(0, jsgraph_->Constant(context_handle));
@@ -126,9 +109,9 @@ Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) {
 Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) {
   DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode());
 
-  ValueMatcher<Handle<Context> > match(NodeProperties::GetValueInput(node, 0));
+  HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(node, 0));
   // If the context is not constant, no reduction can occur.
-  if (!match.HasValue()) {
+  if (!m.HasValue()) {
     return Reducer::NoChange();
   }
 
@@ -140,18 +123,19 @@ Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) {
   }
 
   // Find the right parent context.
-  Context* context = *match.Value();
+  Context* context = *m.Value().handle();
   for (int i = access.depth(); i > 0; --i) {
     context = context->previous();
   }
 
-  Operator* op = jsgraph_->javascript()->StoreContext(0, access.index());
+  const Operator* op = jsgraph_->javascript()->StoreContext(0, access.index());
   node->set_op(op);
   Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate());
   node->ReplaceInput(0, jsgraph_->Constant(new_context_handle));
 
   return Reducer::Changed(node);
 }
-}
-}
-}  // namespace v8::internal::compiler
+
+}  // namespace compiler
+}  // namespace internal
+}  // namespace v8