Upgrade V8 to version 4.9.385.28

https://chromium.googlesource.com/v8/v8/+/4.9.385.28

FPIIM-449

Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/test/cctest/compiler/test-js-context-specialization.cc b/test/cctest/compiler/test-js-context-specialization.cc
index fb7bd94..43b7665 100644
--- a/test/cctest/compiler/test-js-context-specialization.cc
+++ b/test/cctest/compiler/test-js-context-specialization.cc
@@ -3,50 +3,56 @@
 // found in the LICENSE file.
 
 #include "src/compiler/js-context-specialization.h"
+#include "src/compiler/js-graph.h"
 #include "src/compiler/js-operator.h"
 #include "src/compiler/node-matchers.h"
-#include "src/compiler/node-properties-inl.h"
+#include "src/compiler/node-properties.h"
 #include "src/compiler/source-position.h"
 #include "test/cctest/cctest.h"
 #include "test/cctest/compiler/function-tester.h"
 #include "test/cctest/compiler/graph-builder-tester.h"
 
-using namespace v8::internal;
-using namespace v8::internal::compiler;
+namespace v8 {
+namespace internal {
+namespace compiler {
 
-class ContextSpecializationTester : public HandleAndZoneScope,
-                                    public DirectGraphBuilder {
+class ContextSpecializationTester : public HandleAndZoneScope {
  public:
   ContextSpecializationTester()
-      : DirectGraphBuilder(new (main_zone()) Graph(main_zone())),
+      : graph_(new (main_zone()) Graph(main_zone())),
         common_(main_zone()),
         javascript_(main_zone()),
         machine_(main_zone()),
         simplified_(main_zone()),
-        jsgraph_(graph(), common(), &javascript_, &machine_),
-        info_(main_isolate(), main_zone()) {}
+        jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_,
+                 &machine_),
+        reducer_(main_zone(), graph()),
+        spec_(&reducer_, jsgraph(), MaybeHandle<Context>()) {}
 
+  JSContextSpecialization* spec() { return &spec_; }
   Factory* factory() { return main_isolate()->factory(); }
   CommonOperatorBuilder* common() { return &common_; }
   JSOperatorBuilder* javascript() { return &javascript_; }
   SimplifiedOperatorBuilder* simplified() { return &simplified_; }
   JSGraph* jsgraph() { return &jsgraph_; }
-  CompilationInfo* info() { return &info_; }
+  Graph* graph() { return graph_; }
 
  private:
+  Graph* graph_;
   CommonOperatorBuilder common_;
   JSOperatorBuilder javascript_;
   MachineOperatorBuilder machine_;
   SimplifiedOperatorBuilder simplified_;
   JSGraph jsgraph_;
-  CompilationInfo info_;
+  GraphReducer reducer_;
+  JSContextSpecialization spec_;
 };
 
 
 TEST(ReduceJSLoadContext) {
   ContextSpecializationTester t;
 
-  Node* start = t.NewNode(t.common()->Start(0));
+  Node* start = t.graph()->NewNode(t.common()->Start(0));
   t.graph()->SetStart(start);
 
   // Make a context and initialize it a bit for this test.
@@ -56,41 +62,40 @@
   subcontext2->set_previous(*subcontext1);
   subcontext1->set_previous(*native);
   Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!");
-  const int slot = Context::GLOBAL_OBJECT_INDEX;
+  const int slot = Context::NATIVE_CONTEXT_INDEX;
   native->set(slot, *expected);
 
   Node* const_context = t.jsgraph()->Constant(native);
   Node* deep_const_context = t.jsgraph()->Constant(subcontext2);
-  Node* param_context = t.NewNode(t.common()->Parameter(0), start);
-  JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
+  Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start);
 
   {
     // Mutable slot, constant context, depth = 0 => do nothing.
-    Node* load = t.NewNode(t.javascript()->LoadContext(0, 0, false),
-                           const_context, const_context, start);
-    Reduction r = spec.ReduceJSLoadContext(load);
+    Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, 0, false),
+                                    const_context, const_context, start);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(!r.Changed());
   }
 
   {
     // Mutable slot, non-constant context, depth = 0 => do nothing.
-    Node* load = t.NewNode(t.javascript()->LoadContext(0, 0, false),
-                           param_context, param_context, start);
-    Reduction r = spec.ReduceJSLoadContext(load);
+    Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, 0, false),
+                                    param_context, param_context, start);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(!r.Changed());
   }
 
   {
     // Mutable slot, constant context, depth > 0 => fold-in parent context.
-    Node* load = t.NewNode(
+    Node* load = t.graph()->NewNode(
         t.javascript()->LoadContext(2, Context::GLOBAL_EVAL_FUN_INDEX, false),
         deep_const_context, deep_const_context, start);
-    Reduction r = spec.ReduceJSLoadContext(load);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(r.Changed());
     Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
     CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
-    HeapObjectMatcher<Context> match(new_context_input);
-    CHECK_EQ(*native, *match.Value().handle());
+    HeapObjectMatcher match(new_context_input);
+    CHECK_EQ(*native, *match.Value());
     ContextAccess access = OpParameter<ContextAccess>(r.replacement());
     CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index()));
     CHECK_EQ(0, static_cast<int>(access.depth()));
@@ -99,15 +104,15 @@
 
   {
     // Immutable slot, constant context, depth = 0 => specialize.
-    Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
-                           const_context, const_context, start);
-    Reduction r = spec.ReduceJSLoadContext(load);
+    Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, slot, true),
+                                    const_context, const_context, start);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(r.Changed());
     CHECK(r.replacement() != load);
 
-    HeapObjectMatcher<Object> match(r.replacement());
+    HeapObjectMatcher match(r.replacement());
     CHECK(match.HasValue());
-    CHECK_EQ(*expected, *match.Value().handle());
+    CHECK_EQ(*expected, *match.Value());
   }
 
   // TODO(titzer): test with other kinds of contexts, e.g. a function context.
@@ -118,7 +123,7 @@
 TEST(ReduceJSStoreContext) {
   ContextSpecializationTester t;
 
-  Node* start = t.NewNode(t.common()->Start(0));
+  Node* start = t.graph()->NewNode(t.common()->Start(0));
   t.graph()->SetStart(start);
 
   // Make a context and initialize it a bit for this test.
@@ -128,49 +133,51 @@
   subcontext2->set_previous(*subcontext1);
   subcontext1->set_previous(*native);
   Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!");
-  const int slot = Context::GLOBAL_OBJECT_INDEX;
+  const int slot = Context::NATIVE_CONTEXT_INDEX;
   native->set(slot, *expected);
 
   Node* const_context = t.jsgraph()->Constant(native);
   Node* deep_const_context = t.jsgraph()->Constant(subcontext2);
-  Node* param_context = t.NewNode(t.common()->Parameter(0), start);
-  JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
+  Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start);
 
   {
     // Mutable slot, constant context, depth = 0 => do nothing.
-    Node* load = t.NewNode(t.javascript()->StoreContext(0, 0), const_context,
-                           const_context, start);
-    Reduction r = spec.ReduceJSStoreContext(load);
+    Node* load =
+        t.graph()->NewNode(t.javascript()->StoreContext(0, 0), const_context,
+                           const_context, const_context, start, start);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(!r.Changed());
   }
 
   {
     // Mutable slot, non-constant context, depth = 0 => do nothing.
-    Node* load = t.NewNode(t.javascript()->StoreContext(0, 0), param_context,
-                           param_context, start);
-    Reduction r = spec.ReduceJSStoreContext(load);
+    Node* load =
+        t.graph()->NewNode(t.javascript()->StoreContext(0, 0), param_context,
+                           param_context, const_context, start, start);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(!r.Changed());
   }
 
   {
     // Immutable slot, constant context, depth = 0 => do nothing.
-    Node* load = t.NewNode(t.javascript()->StoreContext(0, slot), const_context,
-                           const_context, start);
-    Reduction r = spec.ReduceJSStoreContext(load);
+    Node* load =
+        t.graph()->NewNode(t.javascript()->StoreContext(0, slot), const_context,
+                           const_context, const_context, start, start);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(!r.Changed());
   }
 
   {
     // Mutable slot, constant context, depth > 0 => fold-in parent context.
-    Node* load = t.NewNode(
+    Node* load = t.graph()->NewNode(
         t.javascript()->StoreContext(2, Context::GLOBAL_EVAL_FUN_INDEX),
-        deep_const_context, deep_const_context, start);
-    Reduction r = spec.ReduceJSStoreContext(load);
+        deep_const_context, deep_const_context, const_context, start, start);
+    Reduction r = t.spec()->Reduce(load);
     CHECK(r.Changed());
     Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
     CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
-    HeapObjectMatcher<Context> match(new_context_input);
-    CHECK_EQ(*native, *match.Value().handle());
+    HeapObjectMatcher match(new_context_input);
+    CHECK_EQ(*native, *match.Value());
     ContextAccess access = OpParameter<ContextAccess>(r.replacement());
     CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, static_cast<int>(access.index()));
     CHECK_EQ(0, static_cast<int>(access.depth()));
@@ -188,40 +195,43 @@
 TEST(SpecializeToContext) {
   ContextSpecializationTester t;
 
-  Node* start = t.NewNode(t.common()->Start(0));
+  Node* start = t.graph()->NewNode(t.common()->Start(0));
   t.graph()->SetStart(start);
 
   // Make a context and initialize it a bit for this test.
   Handle<Context> native = t.factory()->NewNativeContext();
   Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!");
-  const int slot = Context::GLOBAL_OBJECT_INDEX;
+  const int slot = Context::NATIVE_CONTEXT_INDEX;
   native->set(slot, *expected);
-  t.info()->SetContext(native);
 
   Node* const_context = t.jsgraph()->Constant(native);
-  Node* param_context = t.NewNode(t.common()->Parameter(0), start);
-  JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
+  Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start);
 
   {
     // Check that specialization replaces values and forwards effects
     // correctly, and folds values from constant and non-constant contexts
     Node* effect_in = start;
-    Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
-                           const_context, const_context, effect_in);
+    Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, slot, true),
+                                    const_context, const_context, effect_in);
 
 
-    Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load);
-    Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
-                                 param_context, param_context, load);
+    Node* value_use =
+        t.graph()->NewNode(t.simplified()->ChangeTaggedToInt32(), load);
+    Node* other_load =
+        t.graph()->NewNode(t.javascript()->LoadContext(0, slot, true),
+                           param_context, param_context, load);
     Node* effect_use = other_load;
     Node* other_use =
-        t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load);
+        t.graph()->NewNode(t.simplified()->ChangeTaggedToInt32(), other_load);
 
-    Node* add = t.NewNode(t.javascript()->Add(), value_use, other_use,
-                          param_context, other_load, start);
+    Node* add = t.graph()->NewNode(
+        t.javascript()->Add(LanguageMode::SLOPPY, BinaryOperationHints::Any()),
+        value_use, other_use, param_context, t.jsgraph()->EmptyFrameState(),
+        t.jsgraph()->EmptyFrameState(), other_load, start);
 
-    Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start);
-    Node* end = t.NewNode(t.common()->End(), ret);
+    Node* ret =
+        t.graph()->NewNode(t.common()->Return(), add, effect_use, start);
+    Node* end = t.graph()->NewNode(t.common()->End(1), ret);
     USE(end);
     t.graph()->SetEnd(end);
 
@@ -230,7 +240,9 @@
     CheckEffectInput(load, effect_use);
 
     // Perform the reduction on the entire graph.
-    GraphReducer graph_reducer(t.graph(), t.main_zone());
+    GraphReducer graph_reducer(t.main_zone(), t.graph());
+    JSContextSpecialization spec(&graph_reducer, t.jsgraph(),
+                                 MaybeHandle<Context>());
     graph_reducer.AddReducer(&spec);
     graph_reducer.ReduceGraph();
 
@@ -241,9 +253,9 @@
     CHECK_EQ(other_load, other_use->InputAt(0));
 
     Node* replacement = value_use->InputAt(0);
-    HeapObjectMatcher<Object> match(replacement);
+    HeapObjectMatcher match(replacement);
     CHECK(match.HasValue());
-    CHECK_EQ(*expected, *match.Value().handle());
+    CHECK_EQ(*expected, *match.Value());
   }
   // TODO(titzer): clean up above test and test more complicated effects.
 }
@@ -304,3 +316,7 @@
     CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN());
   }
 }
+
+}  // namespace compiler
+}  // namespace internal
+}  // namespace v8