diff options
Diffstat (limited to 'deps/v8/test/unittests/compiler/instruction-selector-unittest.cc')
-rw-r--r-- | deps/v8/test/unittests/compiler/instruction-selector-unittest.cc | 119 |
1 files changed, 59 insertions, 60 deletions
diff --git a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc index 8b182a76ba..89c0a654e9 100644 --- a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc +++ b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc @@ -14,12 +14,6 @@ namespace v8 { namespace internal { namespace compiler { -namespace { - -typedef RawMachineAssembler::Label MLabel; - -} // namespace - InstructionSelectorTest::InstructionSelectorTest() : rng_(FLAG_random_seed) {} @@ -164,7 +158,7 @@ InstructionSelectorTest::StreamBuilder::GetFrameStateFunctionInfo( TARGET_TEST_F(InstructionSelectorTest, ReturnFloat32Constant) { const float kValue = 4.2f; - StreamBuilder m(this, kMachFloat32); + StreamBuilder m(this, MachineType::Float32()); m.Return(m.Float32Constant(kValue)); Stream s = m.Build(kAllInstructions); ASSERT_EQ(3U, s.size()); @@ -177,7 +171,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnFloat32Constant) { TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) { - StreamBuilder m(this, kMachInt32, kMachInt32); + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); m.Return(m.Parameter(0)); Stream s = m.Build(kAllInstructions); ASSERT_EQ(3U, s.size()); @@ -189,7 +183,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) { TARGET_TEST_F(InstructionSelectorTest, ReturnZero) { - StreamBuilder m(this, kMachInt32); + StreamBuilder m(this, MachineType::Int32()); m.Return(m.Int32Constant(0)); Stream s = m.Build(kAllInstructions); ASSERT_EQ(3U, s.size()); @@ -207,7 +201,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnZero) { TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToInt32WithParameter) { - StreamBuilder m(this, kMachInt32, kMachFloat64); + StreamBuilder m(this, MachineType::Int32(), MachineType::Float64()); m.Return( m.TruncateFloat64ToInt32(TruncationMode::kJavaScript, m.Parameter(0))); Stream s = m.Build(kAllInstructions); @@ -225,7 +219,7 @@ TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToInt32WithParameter) { TARGET_TEST_F(InstructionSelectorTest, DoubleParameter) { - StreamBuilder m(this, kMachFloat64, kMachFloat64); + StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); Node* param = m.Parameter(0); m.Return(param); Stream s = m.Build(kAllInstructions); @@ -234,7 +228,7 @@ TARGET_TEST_F(InstructionSelectorTest, DoubleParameter) { TARGET_TEST_F(InstructionSelectorTest, ReferenceParameter) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged()); Node* param = m.Parameter(0); m.Return(param); Stream s = m.Build(kAllInstructions); @@ -247,7 +241,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReferenceParameter) { TARGET_TEST_F(InstructionSelectorTest, FinishRegion) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged()); Node* param = m.Parameter(0); Node* finish = m.AddNode(m.common()->FinishRegion(), param, m.graph()->start()); @@ -283,14 +277,14 @@ TARGET_TEST_P(InstructionSelectorPhiTest, Doubleness) { StreamBuilder m(this, type, type, type); Node* param0 = m.Parameter(0); Node* param1 = m.Parameter(1); - MLabel a, b, c; + RawMachineLabel a, b, c; m.Branch(m.Int32Constant(0), &a, &b); m.Bind(&a); m.Goto(&c); m.Bind(&b); m.Goto(&c); m.Bind(&c); - Node* phi = m.Phi(type, param0, param1); + Node* phi = m.Phi(type.representation(), param0, param1); m.Return(phi); Stream s = m.Build(kAllInstructions); EXPECT_EQ(s.IsDouble(phi), s.IsDouble(param0)); @@ -303,14 +297,14 @@ TARGET_TEST_P(InstructionSelectorPhiTest, Referenceness) { StreamBuilder m(this, type, type, type); Node* param0 = m.Parameter(0); Node* param1 = m.Parameter(1); - MLabel a, b, c; + RawMachineLabel a, b, c; m.Branch(m.Int32Constant(1), &a, &b); m.Bind(&a); m.Goto(&c); m.Bind(&b); m.Goto(&c); m.Bind(&c); - Node* phi = m.Phi(type, param0, param1); + Node* phi = m.Phi(type.representation(), param0, param1); m.Return(phi); Stream s = m.Build(kAllInstructions); EXPECT_EQ(s.IsReference(phi), s.IsReference(param0)); @@ -318,11 +312,14 @@ TARGET_TEST_P(InstructionSelectorPhiTest, Referenceness) { } -INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorPhiTest, - ::testing::Values(kMachFloat64, kMachInt8, kMachUint8, - kMachInt16, kMachUint16, kMachInt32, - kMachUint32, kMachInt64, kMachUint64, - kMachPtr, kMachAnyTagged)); +INSTANTIATE_TEST_CASE_P( + InstructionSelectorTest, InstructionSelectorPhiTest, + ::testing::Values(MachineType::Float64(), MachineType::Int8(), + MachineType::Uint8(), MachineType::Int16(), + MachineType::Uint16(), MachineType::Int32(), + MachineType::Uint32(), MachineType::Int64(), + MachineType::Uint64(), MachineType::Pointer(), + MachineType::AnyTagged())); // ----------------------------------------------------------------------------- @@ -330,15 +327,15 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorPhiTest, TARGET_TEST_F(InstructionSelectorTest, ValueEffect) { - StreamBuilder m1(this, kMachInt32, kMachPtr); + StreamBuilder m1(this, MachineType::Int32(), MachineType::Pointer()); Node* p1 = m1.Parameter(0); - m1.Return(m1.Load(kMachInt32, p1, m1.Int32Constant(0))); + m1.Return(m1.Load(MachineType::Int32(), p1, m1.Int32Constant(0))); Stream s1 = m1.Build(kAllInstructions); - StreamBuilder m2(this, kMachInt32, kMachPtr); + StreamBuilder m2(this, MachineType::Int32(), MachineType::Pointer()); Node* p2 = m2.Parameter(0); - m2.Return( - m2.AddNode(m2.machine()->Load(kMachInt32), p2, m2.Int32Constant(0), - m2.AddNode(m2.common()->BeginRegion(), m2.graph()->start()))); + m2.Return(m2.AddNode( + m2.machine()->Load(MachineType::Int32()), p2, m2.Int32Constant(0), + m2.AddNode(m2.common()->BeginRegion(), m2.graph()->start()))); Stream s2 = m2.Build(kAllInstructions); EXPECT_LE(3U, s1.size()); ASSERT_EQ(s1.size(), s2.size()); @@ -357,8 +354,8 @@ TARGET_TEST_F(InstructionSelectorTest, ValueEffect) { TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged()); BailoutId bailout_id(42); @@ -366,7 +363,7 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) { Node* receiver = m.Parameter(1); Node* context = m.Parameter(2); - ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); + ZoneVector<MachineType> int32_type(1, MachineType::Int32(), zone()); ZoneVector<MachineType> empty_types(zone()); CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( @@ -385,7 +382,7 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) { m.UndefinedConstant()); // Build the call. - Node* args[] = {receiver, m.Int32Constant(1), context}; + Node* args[] = {receiver, m.UndefinedConstant(), m.Int32Constant(1), context}; Node* call = m.CallNWithFrameState(descriptor, function_node, args, state_node); m.Return(call); @@ -408,8 +405,8 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) { TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged()); BailoutId bailout_id_before(42); @@ -418,9 +415,9 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { Node* receiver = m.Parameter(1); Node* context = m.Int32Constant(1); // Context is ignored. - ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); - ZoneVector<MachineType> float64_type(1, kMachFloat64, zone()); - ZoneVector<MachineType> tagged_type(1, kMachAnyTagged, zone()); + ZoneVector<MachineType> int32_type(1, MachineType::Int32(), zone()); + ZoneVector<MachineType> float64_type(1, MachineType::Float64(), zone()); + ZoneVector<MachineType> tagged_type(1, MachineType::AnyTagged(), zone()); Callable callable = CodeFactory::ToObject(isolate()); CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( @@ -486,13 +483,15 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { // We inserted 0 here. EXPECT_EQ(0.5, s.ToFloat64(call_instr->InputAt(5))); EXPECT_TRUE(s.ToHeapObject(call_instr->InputAt(6))->IsUndefined()); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0)); // function is always - // tagged/any. - EXPECT_EQ(kMachInt32, desc_before->GetType(1)); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(2)); // context is always - // tagged/any. - EXPECT_EQ(kMachFloat64, desc_before->GetType(3)); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(4)); + EXPECT_EQ(MachineType::AnyTagged(), + desc_before->GetType(0)); // function is always + // tagged/any. + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(1)); + EXPECT_EQ(MachineType::AnyTagged(), + desc_before->GetType(2)); // context is always + // tagged/any. + EXPECT_EQ(MachineType::Float64(), desc_before->GetType(3)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(4)); // Function. EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(7))); @@ -506,8 +505,8 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { - StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged, kMachAnyTagged, - kMachAnyTagged); + StreamBuilder m(this, MachineType::AnyTagged(), MachineType::AnyTagged(), + MachineType::AnyTagged(), MachineType::AnyTagged()); BailoutId bailout_id_before(42); BailoutId bailout_id_parent(62); @@ -518,9 +517,9 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { Node* context = m.Int32Constant(66); Node* context2 = m.Int32Constant(46); - ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); - ZoneVector<MachineType> int32x2_type(2, kMachInt32, zone()); - ZoneVector<MachineType> float64_type(1, kMachFloat64, zone()); + ZoneVector<MachineType> int32_type(1, MachineType::Int32(), zone()); + ZoneVector<MachineType> int32x2_type(2, MachineType::Int32(), zone()); + ZoneVector<MachineType> float64_type(1, MachineType::Float64(), zone()); Callable callable = CodeFactory::ToObject(isolate()); CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( @@ -592,31 +591,31 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { EXPECT_EQ(1u, desc_before_outer->locals_count()); EXPECT_EQ(1u, desc_before_outer->stack_count()); // Values from parent environment. - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(0)); EXPECT_EQ(63, s.ToInt32(call_instr->InputAt(3))); - EXPECT_EQ(kMachInt32, desc_before_outer->GetType(1)); + EXPECT_EQ(MachineType::Int32(), desc_before_outer->GetType(1)); // Context: EXPECT_EQ(66, s.ToInt32(call_instr->InputAt(4))); - EXPECT_EQ(kMachAnyTagged, desc_before_outer->GetType(2)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before_outer->GetType(2)); EXPECT_EQ(64, s.ToInt32(call_instr->InputAt(5))); - EXPECT_EQ(kMachInt32, desc_before_outer->GetType(3)); + EXPECT_EQ(MachineType::Int32(), desc_before_outer->GetType(3)); EXPECT_EQ(65, s.ToInt32(call_instr->InputAt(6))); - EXPECT_EQ(kMachInt32, desc_before_outer->GetType(4)); + EXPECT_EQ(MachineType::Int32(), desc_before_outer->GetType(4)); // Values from the nested frame. EXPECT_EQ(1u, desc_before->parameters_count()); EXPECT_EQ(1u, desc_before->locals_count()); EXPECT_EQ(2u, desc_before->stack_count()); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(0)); EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(8))); - EXPECT_EQ(kMachInt32, desc_before->GetType(1)); + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(1)); EXPECT_EQ(46, s.ToInt32(call_instr->InputAt(9))); - EXPECT_EQ(kMachAnyTagged, desc_before->GetType(2)); + EXPECT_EQ(MachineType::AnyTagged(), desc_before->GetType(2)); EXPECT_EQ(0.25, s.ToFloat64(call_instr->InputAt(10))); - EXPECT_EQ(kMachFloat64, desc_before->GetType(3)); + EXPECT_EQ(MachineType::Float64(), desc_before->GetType(3)); EXPECT_EQ(44, s.ToInt32(call_instr->InputAt(11))); - EXPECT_EQ(kMachInt32, desc_before->GetType(4)); + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(4)); EXPECT_EQ(45, s.ToInt32(call_instr->InputAt(12))); - EXPECT_EQ(kMachInt32, desc_before->GetType(5)); + EXPECT_EQ(MachineType::Int32(), desc_before->GetType(5)); // Function. EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(13))); |