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/unittests/compiler/machine-operator-unittest.cc b/test/unittests/compiler/machine-operator-unittest.cc
index 6e0df2a..59eb484 100644
--- a/test/unittests/compiler/machine-operator-unittest.cc
+++ b/test/unittests/compiler/machine-operator-unittest.cc
@@ -17,26 +17,38 @@
 template <typename T>
 class MachineOperatorTestWithParam
     : public TestWithZone,
-      public ::testing::WithParamInterface< ::testing::tuple<MachineType, T> > {
+      public ::testing::WithParamInterface<
+          ::testing::tuple<MachineRepresentation, T> > {
  protected:
-  MachineType type() const { return ::testing::get<0>(B::GetParam()); }
+  MachineRepresentation representation() const {
+    return ::testing::get<0>(B::GetParam());
+  }
   const T& GetParam() const { return ::testing::get<1>(B::GetParam()); }
 
  private:
-  typedef ::testing::WithParamInterface< ::testing::tuple<MachineType, T> > B;
+  typedef ::testing::WithParamInterface<
+      ::testing::tuple<MachineRepresentation, T> > B;
 };
 
 
 namespace {
 
-const MachineType kMachineReps[] = {kRepWord32, kRepWord64};
+const MachineRepresentation kMachineReps[] = {MachineRepresentation::kWord32,
+                                              MachineRepresentation::kWord64};
 
 
-const MachineType kMachineTypes[] = {
-    kMachFloat32, kMachFloat64,   kMachInt8,   kMachUint8,  kMachInt16,
-    kMachUint16,  kMachInt32,     kMachUint32, kMachInt64,  kMachUint64,
-    kMachPtr,     kMachAnyTagged, kRepBit,     kRepWord8,   kRepWord16,
-    kRepWord32,   kRepWord64,     kRepFloat32, kRepFloat64, kRepTagged};
+const MachineType kMachineTypesForAccess[] = {
+    MachineType::Float32(), MachineType::Float64(),  MachineType::Int8(),
+    MachineType::Uint8(),   MachineType::Int16(),    MachineType::Uint16(),
+    MachineType::Int32(),   MachineType::Uint32(),   MachineType::Int64(),
+    MachineType::Uint64(),  MachineType::AnyTagged()};
+
+
+const MachineRepresentation kRepresentationsForStore[] = {
+    MachineRepresentation::kFloat32, MachineRepresentation::kFloat64,
+    MachineRepresentation::kWord8,   MachineRepresentation::kWord16,
+    MachineRepresentation::kWord32,  MachineRepresentation::kWord64,
+    MachineRepresentation::kTagged};
 
 }  // namespace
 
@@ -50,14 +62,14 @@
 
 
 TEST_P(MachineLoadOperatorTest, InstancesAreGloballyShared) {
-  MachineOperatorBuilder machine1(zone(), type());
-  MachineOperatorBuilder machine2(zone(), type());
+  MachineOperatorBuilder machine1(zone(), representation());
+  MachineOperatorBuilder machine2(zone(), representation());
   EXPECT_EQ(machine1.Load(GetParam()), machine2.Load(GetParam()));
 }
 
 
 TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) {
-  MachineOperatorBuilder machine(zone(), type());
+  MachineOperatorBuilder machine(zone(), representation());
   const Operator* op = machine.Load(GetParam());
 
   EXPECT_EQ(2, op->ValueInputCount());
@@ -72,21 +84,22 @@
 
 
 TEST_P(MachineLoadOperatorTest, OpcodeIsCorrect) {
-  MachineOperatorBuilder machine(zone(), type());
+  MachineOperatorBuilder machine(zone(), representation());
   EXPECT_EQ(IrOpcode::kLoad, machine.Load(GetParam())->opcode());
 }
 
 
 TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) {
-  MachineOperatorBuilder machine(zone(), type());
+  MachineOperatorBuilder machine(zone(), representation());
   EXPECT_EQ(GetParam(),
             OpParameter<LoadRepresentation>(machine.Load(GetParam())));
 }
 
 
-INSTANTIATE_TEST_CASE_P(MachineOperatorTest, MachineLoadOperatorTest,
-                        ::testing::Combine(::testing::ValuesIn(kMachineReps),
-                                           ::testing::ValuesIn(kMachineTypes)));
+INSTANTIATE_TEST_CASE_P(
+    MachineOperatorTest, MachineLoadOperatorTest,
+    ::testing::Combine(::testing::ValuesIn(kMachineReps),
+                       ::testing::ValuesIn(kMachineTypesForAccess)));
 
 
 // -----------------------------------------------------------------------------
@@ -95,27 +108,29 @@
 
 class MachineStoreOperatorTest
     : public MachineOperatorTestWithParam<
-          ::testing::tuple<MachineType, WriteBarrierKind> > {
+          ::testing::tuple<MachineRepresentation, WriteBarrierKind> > {
  protected:
   StoreRepresentation GetParam() const {
     return StoreRepresentation(
-        ::testing::get<0>(MachineOperatorTestWithParam<
-            ::testing::tuple<MachineType, WriteBarrierKind> >::GetParam()),
-        ::testing::get<1>(MachineOperatorTestWithParam<
-            ::testing::tuple<MachineType, WriteBarrierKind> >::GetParam()));
+        ::testing::get<0>(
+            MachineOperatorTestWithParam< ::testing::tuple<
+                MachineRepresentation, WriteBarrierKind> >::GetParam()),
+        ::testing::get<1>(
+            MachineOperatorTestWithParam< ::testing::tuple<
+                MachineRepresentation, WriteBarrierKind> >::GetParam()));
   }
 };
 
 
 TEST_P(MachineStoreOperatorTest, InstancesAreGloballyShared) {
-  MachineOperatorBuilder machine1(zone(), type());
-  MachineOperatorBuilder machine2(zone(), type());
+  MachineOperatorBuilder machine1(zone(), representation());
+  MachineOperatorBuilder machine2(zone(), representation());
   EXPECT_EQ(machine1.Store(GetParam()), machine2.Store(GetParam()));
 }
 
 
 TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) {
-  MachineOperatorBuilder machine(zone(), type());
+  MachineOperatorBuilder machine(zone(), representation());
   const Operator* op = machine.Store(GetParam());
 
   EXPECT_EQ(3, op->ValueInputCount());
@@ -130,13 +145,13 @@
 
 
 TEST_P(MachineStoreOperatorTest, OpcodeIsCorrect) {
-  MachineOperatorBuilder machine(zone(), type());
+  MachineOperatorBuilder machine(zone(), representation());
   EXPECT_EQ(IrOpcode::kStore, machine.Store(GetParam())->opcode());
 }
 
 
 TEST_P(MachineStoreOperatorTest, ParameterIsCorrect) {
-  MachineOperatorBuilder machine(zone(), type());
+  MachineOperatorBuilder machine(zone(), representation());
   EXPECT_EQ(GetParam(),
             OpParameter<StoreRepresentation>(machine.Store(GetParam())));
 }
@@ -146,125 +161,208 @@
     MachineOperatorTest, MachineStoreOperatorTest,
     ::testing::Combine(
         ::testing::ValuesIn(kMachineReps),
-        ::testing::Combine(::testing::ValuesIn(kMachineTypes),
+        ::testing::Combine(::testing::ValuesIn(kRepresentationsForStore),
                            ::testing::Values(kNoWriteBarrier,
                                              kFullWriteBarrier))));
-
+#endif
 
 // -----------------------------------------------------------------------------
 // Pure operators.
 
-
 namespace {
 
 struct PureOperator {
   const Operator* (MachineOperatorBuilder::*constructor)();
-  IrOpcode::Value opcode;
+  char const* const constructor_name;
   int value_input_count;
   int control_input_count;
   int value_output_count;
 };
 
 
-std::ostream& operator<<(std::ostream& os, const PureOperator& pop) {
-  return os << IrOpcode::Mnemonic(pop.opcode);
+std::ostream& operator<<(std::ostream& os, PureOperator const& pop) {
+  return os << pop.constructor_name;
 }
 
-
 const PureOperator kPureOperators[] = {
 #define PURE(Name, value_input_count, control_input_count, value_output_count) \
   {                                                                            \
-    &MachineOperatorBuilder::Name, IrOpcode::k##Name, value_input_count,       \
+    &MachineOperatorBuilder::Name, #Name, value_input_count,                   \
         control_input_count, value_output_count                                \
   }
-    PURE(Word32And, 2, 0, 1), PURE(Word32Or, 2, 0, 1), PURE(Word32Xor, 2, 0, 1),
-    PURE(Word32Shl, 2, 0, 1), PURE(Word32Shr, 2, 0, 1),
-    PURE(Word32Sar, 2, 0, 1), PURE(Word32Ror, 2, 0, 1),
-    PURE(Word32Equal, 2, 0, 1), PURE(Word64And, 2, 0, 1),
-    PURE(Word64Or, 2, 0, 1), PURE(Word64Xor, 2, 0, 1), PURE(Word64Shl, 2, 0, 1),
-    PURE(Word64Shr, 2, 0, 1), PURE(Word64Sar, 2, 0, 1),
-    PURE(Word64Ror, 2, 0, 1), PURE(Word64Equal, 2, 0, 1),
-    PURE(Int32Add, 2, 0, 1), PURE(Int32AddWithOverflow, 2, 0, 2),
-    PURE(Int32Sub, 2, 0, 1), PURE(Int32SubWithOverflow, 2, 0, 2),
-    PURE(Int32Mul, 2, 0, 1), PURE(Int32MulHigh, 2, 0, 1),
-    PURE(Int32Div, 2, 1, 1), PURE(Uint32Div, 2, 1, 1), PURE(Int32Mod, 2, 1, 1),
-    PURE(Uint32Mod, 2, 1, 1), PURE(Int32LessThan, 2, 0, 1),
-    PURE(Int32LessThanOrEqual, 2, 0, 1), PURE(Uint32LessThan, 2, 0, 1),
-    PURE(Uint32LessThanOrEqual, 2, 0, 1), PURE(Int64Add, 2, 0, 1),
-    PURE(Int64Sub, 2, 0, 1), PURE(Int64Mul, 2, 0, 1), PURE(Int64Div, 2, 0, 1),
-    PURE(Uint64Div, 2, 0, 1), PURE(Int64Mod, 2, 0, 1), PURE(Uint64Mod, 2, 0, 1),
-    PURE(Int64LessThan, 2, 0, 1), PURE(Int64LessThanOrEqual, 2, 0, 1),
-    PURE(Uint64LessThan, 2, 0, 1), PURE(ChangeFloat32ToFloat64, 1, 0, 1),
-    PURE(ChangeFloat64ToInt32, 1, 0, 1), PURE(ChangeFloat64ToUint32, 1, 0, 1),
-    PURE(ChangeInt32ToInt64, 1, 0, 1), PURE(ChangeUint32ToFloat64, 1, 0, 1),
-    PURE(ChangeUint32ToUint64, 1, 0, 1),
-    PURE(TruncateFloat64ToFloat32, 1, 0, 1),
-    PURE(TruncateFloat64ToInt32, 1, 0, 1), PURE(TruncateInt64ToInt32, 1, 0, 1),
-    PURE(Float64Add, 2, 0, 1), PURE(Float64Sub, 2, 0, 1),
-    PURE(Float64Mul, 2, 0, 1), PURE(Float64Div, 2, 0, 1),
-    PURE(Float64Mod, 2, 0, 1), PURE(Float64Sqrt, 1, 0, 1),
-    PURE(Float64Equal, 2, 0, 1), PURE(Float64LessThan, 2, 0, 1),
-    PURE(Float64LessThanOrEqual, 2, 0, 1), PURE(LoadStackPointer, 0, 0, 1),
-    PURE(Float64Floor, 1, 0, 1), PURE(Float64Ceil, 1, 0, 1),
-    PURE(Float64RoundTruncate, 1, 0, 1), PURE(Float64RoundTiesAway, 1, 0, 1)
+    PURE(Word32And, 2, 0, 1),                 // --
+    PURE(Word32Or, 2, 0, 1),                  // --
+    PURE(Word32Xor, 2, 0, 1),                 // --
+    PURE(Word32Shl, 2, 0, 1),                 // --
+    PURE(Word32Shr, 2, 0, 1),                 // --
+    PURE(Word32Sar, 2, 0, 1),                 // --
+    PURE(Word32Ror, 2, 0, 1),                 // --
+    PURE(Word32Equal, 2, 0, 1),               // --
+    PURE(Word32Clz, 1, 0, 1),                 // --
+    PURE(Word64And, 2, 0, 1),                 // --
+    PURE(Word64Or, 2, 0, 1),                  // --
+    PURE(Word64Xor, 2, 0, 1),                 // --
+    PURE(Word64Shl, 2, 0, 1),                 // --
+    PURE(Word64Shr, 2, 0, 1),                 // --
+    PURE(Word64Sar, 2, 0, 1),                 // --
+    PURE(Word64Ror, 2, 0, 1),                 // --
+    PURE(Word64Equal, 2, 0, 1),               // --
+    PURE(Int32Add, 2, 0, 1),                  // --
+    PURE(Int32AddWithOverflow, 2, 0, 2),      // --
+    PURE(Int32Sub, 2, 0, 1),                  // --
+    PURE(Int32SubWithOverflow, 2, 0, 2),      // --
+    PURE(Int32Mul, 2, 0, 1),                  // --
+    PURE(Int32MulHigh, 2, 0, 1),              // --
+    PURE(Int32Div, 2, 1, 1),                  // --
+    PURE(Uint32Div, 2, 1, 1),                 // --
+    PURE(Int32Mod, 2, 1, 1),                  // --
+    PURE(Uint32Mod, 2, 1, 1),                 // --
+    PURE(Int32LessThan, 2, 0, 1),             // --
+    PURE(Int32LessThanOrEqual, 2, 0, 1),      // --
+    PURE(Uint32LessThan, 2, 0, 1),            // --
+    PURE(Uint32LessThanOrEqual, 2, 0, 1),     // --
+    PURE(Int64Add, 2, 0, 1),                  // --
+    PURE(Int64Sub, 2, 0, 1),                  // --
+    PURE(Int64Mul, 2, 0, 1),                  // --
+    PURE(Int64Div, 2, 1, 1),                  // --
+    PURE(Uint64Div, 2, 1, 1),                 // --
+    PURE(Int64Mod, 2, 1, 1),                  // --
+    PURE(Uint64Mod, 2, 1, 1),                 // --
+    PURE(Int64LessThan, 2, 0, 1),             // --
+    PURE(Int64LessThanOrEqual, 2, 0, 1),      // --
+    PURE(Uint64LessThan, 2, 0, 1),            // --
+    PURE(Uint64LessThanOrEqual, 2, 0, 1),     // --
+    PURE(ChangeFloat32ToFloat64, 1, 0, 1),    // --
+    PURE(ChangeFloat64ToInt32, 1, 0, 1),      // --
+    PURE(ChangeFloat64ToUint32, 1, 0, 1),     // --
+    PURE(ChangeInt32ToInt64, 1, 0, 1),        // --
+    PURE(ChangeUint32ToFloat64, 1, 0, 1),     // --
+    PURE(ChangeUint32ToUint64, 1, 0, 1),      // --
+    PURE(TruncateFloat64ToFloat32, 1, 0, 1),  // --
+    PURE(TruncateInt64ToInt32, 1, 0, 1),      // --
+    PURE(Float32Abs, 1, 0, 1),                // --
+    PURE(Float32Add, 2, 0, 1),                // --
+    PURE(Float32Sub, 2, 0, 1),                // --
+    PURE(Float32Mul, 2, 0, 1),                // --
+    PURE(Float32Div, 2, 0, 1),                // --
+    PURE(Float32Sqrt, 1, 0, 1),               // --
+    PURE(Float32Equal, 2, 0, 1),              // --
+    PURE(Float32LessThan, 2, 0, 1),           // --
+    PURE(Float32LessThanOrEqual, 2, 0, 1),    // --
+    PURE(Float64Abs, 1, 0, 1),                // --
+    PURE(Float64Add, 2, 0, 1),                // --
+    PURE(Float64Sub, 2, 0, 1),                // --
+    PURE(Float64Mul, 2, 0, 1),                // --
+    PURE(Float64Div, 2, 0, 1),                // --
+    PURE(Float64Mod, 2, 0, 1),                // --
+    PURE(Float64Sqrt, 1, 0, 1),               // --
+    PURE(Float64Equal, 2, 0, 1),              // --
+    PURE(Float64LessThan, 2, 0, 1),           // --
+    PURE(Float64LessThanOrEqual, 2, 0, 1),    // --
+    PURE(LoadStackPointer, 0, 0, 1),          // --
+    PURE(Float64ExtractLowWord32, 1, 0, 1),   // --
+    PURE(Float64ExtractHighWord32, 1, 0, 1),  // --
+    PURE(Float64InsertLowWord32, 2, 0, 1),    // --
+    PURE(Float64InsertHighWord32, 2, 0, 1),   // --
 #undef PURE
 };
 
+}  // namespace
 
-typedef MachineOperatorTestWithParam<PureOperator> MachinePureOperatorTest;
+class MachinePureOperatorTest : public TestWithZone {
+ protected:
+  MachineRepresentation word_type() {
+    return MachineType::PointerRepresentation();
+  }
+};
 
+
+TEST_F(MachinePureOperatorTest, PureOperators) {
+  TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) {
+    MachineOperatorBuilder machine1(zone(), machine_rep1);
+    TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) {
+      MachineOperatorBuilder machine2(zone(), machine_rep2);
+      TRACED_FOREACH(PureOperator, pop, kPureOperators) {
+        const Operator* op1 = (machine1.*pop.constructor)();
+        const Operator* op2 = (machine2.*pop.constructor)();
+        EXPECT_EQ(op1, op2);
+        EXPECT_EQ(pop.value_input_count, op1->ValueInputCount());
+        EXPECT_EQ(pop.control_input_count, op1->ControlInputCount());
+        EXPECT_EQ(pop.value_output_count, op1->ValueOutputCount());
+      }
+    }
+  }
+}
+
+
+// Optional operators.
+
+namespace {
+
+struct OptionalOperatorEntry {
+  const OptionalOperator (MachineOperatorBuilder::*constructor)();
+  MachineOperatorBuilder::Flag enabling_flag;
+  char const* const constructor_name;
+  int value_input_count;
+  int control_input_count;
+  int value_output_count;
+};
+
+
+std::ostream& operator<<(std::ostream& os, OptionalOperatorEntry const& pop) {
+  return os << pop.constructor_name;
+}
+
+const OptionalOperatorEntry kOptionalOperators[] = {
+#define OPTIONAL_ENTRY(Name, value_input_count, control_input_count,       \
+                       value_output_count)                                 \
+  {                                                                        \
+    &MachineOperatorBuilder::Name, MachineOperatorBuilder::k##Name, #Name, \
+        value_input_count, control_input_count, value_output_count         \
+  }
+    OPTIONAL_ENTRY(Float32Max, 2, 0, 1),            // --
+    OPTIONAL_ENTRY(Float32Min, 2, 0, 1),            // --
+    OPTIONAL_ENTRY(Float64Max, 2, 0, 1),            // --
+    OPTIONAL_ENTRY(Float64Min, 2, 0, 1),            // --
+    OPTIONAL_ENTRY(Float64RoundDown, 1, 0, 1),      // --
+    OPTIONAL_ENTRY(Float64RoundTruncate, 1, 0, 1),  // --
+    OPTIONAL_ENTRY(Float64RoundTiesAway, 1, 0, 1),  // --
+#undef OPTIONAL_ENTRY
+};
 }  // namespace
 
 
-TEST_P(MachinePureOperatorTest, InstancesAreGloballyShared) {
-  const PureOperator& pop = GetParam();
-  MachineOperatorBuilder machine1(zone(), type());
-  MachineOperatorBuilder machine2(zone(), type());
-  EXPECT_EQ((machine1.*pop.constructor)(), (machine2.*pop.constructor)());
+class MachineOptionalOperatorTest : public TestWithZone {
+ protected:
+  MachineRepresentation word_rep() {
+    return MachineType::PointerRepresentation();
+  }
+};
+
+
+TEST_F(MachineOptionalOperatorTest, OptionalOperators) {
+  TRACED_FOREACH(OptionalOperatorEntry, pop, kOptionalOperators) {
+    TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) {
+      MachineOperatorBuilder machine1(zone(), machine_rep1, pop.enabling_flag);
+      TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) {
+        MachineOperatorBuilder machine2(zone(), machine_rep2,
+                                        pop.enabling_flag);
+        const Operator* op1 = (machine1.*pop.constructor)().op();
+        const Operator* op2 = (machine2.*pop.constructor)().op();
+        EXPECT_EQ(op1, op2);
+        EXPECT_EQ(pop.value_input_count, op1->ValueInputCount());
+        EXPECT_EQ(pop.control_input_count, op1->ControlInputCount());
+        EXPECT_EQ(pop.value_output_count, op1->ValueOutputCount());
+
+        MachineOperatorBuilder machine3(zone(), word_rep());
+        EXPECT_TRUE((machine1.*pop.constructor)().IsSupported());
+        EXPECT_FALSE((machine3.*pop.constructor)().IsSupported());
+      }
+    }
+  }
 }
 
 
-TEST_P(MachinePureOperatorTest, NumberOfInputsAndOutputs) {
-  MachineOperatorBuilder machine(zone(), type());
-  const PureOperator& pop = GetParam();
-  const Operator* op = (machine.*pop.constructor)();
-
-  EXPECT_EQ(pop.value_input_count, op->ValueInputCount());
-  EXPECT_EQ(0, op->EffectInputCount());
-  EXPECT_EQ(pop.control_input_count, op->ControlInputCount());
-  EXPECT_EQ(pop.value_input_count + pop.control_input_count,
-            OperatorProperties::GetTotalInputCount(op));
-
-  EXPECT_EQ(pop.value_output_count, op->ValueOutputCount());
-  EXPECT_EQ(0, op->EffectOutputCount());
-  EXPECT_EQ(0, op->ControlOutputCount());
-}
-
-
-TEST_P(MachinePureOperatorTest, MarkedAsPure) {
-  MachineOperatorBuilder machine(zone(), type());
-  const PureOperator& pop = GetParam();
-  const Operator* op = (machine.*pop.constructor)();
-  EXPECT_TRUE(op->HasProperty(Operator::kPure));
-}
-
-
-TEST_P(MachinePureOperatorTest, OpcodeIsCorrect) {
-  MachineOperatorBuilder machine(zone(), type());
-  const PureOperator& pop = GetParam();
-  const Operator* op = (machine.*pop.constructor)();
-  EXPECT_EQ(pop.opcode, op->opcode());
-}
-
-
-INSTANTIATE_TEST_CASE_P(
-    MachineOperatorTest, MachinePureOperatorTest,
-    ::testing::Combine(::testing::ValuesIn(kMachineReps),
-                       ::testing::ValuesIn(kPureOperators)));
-
-#endif  // GTEST_HAS_COMBINE
-
-
 // -----------------------------------------------------------------------------
 // Pseudo operators.
 
@@ -277,7 +375,7 @@
 
 
 TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) {
-  MachineOperatorBuilder machine(zone(), kRepWord32);
+  MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord32);
   EXPECT_EQ(machine.Word32And(), machine.WordAnd());
   EXPECT_EQ(machine.Word32Or(), machine.WordOr());
   EXPECT_EQ(machine.Word32Xor(), machine.WordXor());
@@ -299,7 +397,7 @@
 
 
 TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs64Bit) {
-  MachineOperatorBuilder machine(zone(), kRepWord64);
+  MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord64);
   EXPECT_EQ(machine.Word64And(), machine.WordAnd());
   EXPECT_EQ(machine.Word64Or(), machine.WordOr());
   EXPECT_EQ(machine.Word64Xor(), machine.WordXor());