| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/instruction-selector-unittest.h" | 5 #include "src/compiler/instruction-selector-unittest.h" |
| 6 | 6 |
| 7 #include "src/compiler/compiler-test-utils.h" | 7 #include "src/compiler/compiler-test-utils.h" |
| 8 #include "src/flags.h" | 8 #include "src/flags.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 m.Return(param); | 175 m.Return(param); |
| 176 Stream s = m.Build(kAllInstructions); | 176 Stream s = m.Build(kAllInstructions); |
| 177 EXPECT_TRUE(s.IsReference(param->id())); | 177 EXPECT_TRUE(s.IsReference(param->id())); |
| 178 } | 178 } |
| 179 | 179 |
| 180 | 180 |
| 181 // ----------------------------------------------------------------------------- | 181 // ----------------------------------------------------------------------------- |
| 182 // Finish. | 182 // Finish. |
| 183 | 183 |
| 184 | 184 |
| 185 TARGET_TEST_F(InstructionSelectorTest, Parameter) { | 185 TARGET_TEST_F(InstructionSelectorTest, Finish) { |
| 186 StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); | 186 StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); |
| 187 Node* param = m.Parameter(0); | 187 Node* param = m.Parameter(0); |
| 188 Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start()); | 188 Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start()); |
| 189 m.Return(finish); | 189 m.Return(finish); |
| 190 Stream s = m.Build(kAllInstructions); | 190 Stream s = m.Build(kAllInstructions); |
| 191 ASSERT_EQ(3U, s.size()); | 191 ASSERT_EQ(3U, s.size()); |
| 192 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); | 192 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); |
| 193 ASSERT_EQ(1U, s[0]->OutputCount()); | 193 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 194 ASSERT_TRUE(s[0]->Output()->IsUnallocated()); | 194 ASSERT_TRUE(s[0]->Output()->IsUnallocated()); |
| 195 EXPECT_EQ(param->id(), s.ToVreg(s[0]->Output())); | 195 EXPECT_EQ(param->id(), s.ToVreg(s[0]->Output())); |
| 196 EXPECT_EQ(kArchNop, s[1]->arch_opcode()); | 196 EXPECT_EQ(kArchNop, s[1]->arch_opcode()); |
| 197 ASSERT_EQ(1U, s[1]->InputCount()); | 197 ASSERT_EQ(1U, s[1]->InputCount()); |
| 198 ASSERT_TRUE(s[1]->InputAt(0)->IsUnallocated()); | 198 ASSERT_TRUE(s[1]->InputAt(0)->IsUnallocated()); |
| 199 EXPECT_EQ(param->id(), s.ToVreg(s[1]->InputAt(0))); | 199 EXPECT_EQ(param->id(), s.ToVreg(s[1]->InputAt(0))); |
| 200 ASSERT_EQ(1U, s[1]->OutputCount()); | 200 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 201 ASSERT_TRUE(s[1]->Output()->IsUnallocated()); | 201 ASSERT_TRUE(s[1]->Output()->IsUnallocated()); |
| 202 EXPECT_TRUE(UnallocatedOperand::cast(s[1]->Output())->HasSameAsInputPolicy()); | 202 EXPECT_TRUE(UnallocatedOperand::cast(s[1]->Output())->HasSameAsInputPolicy()); |
| 203 EXPECT_EQ(finish->id(), s.ToVreg(s[1]->Output())); | 203 EXPECT_EQ(finish->id(), s.ToVreg(s[1]->Output())); |
| 204 EXPECT_TRUE(s.IsReference(finish->id())); |
| 204 } | 205 } |
| 205 | 206 |
| 206 | 207 |
| 207 // ----------------------------------------------------------------------------- | 208 // ----------------------------------------------------------------------------- |
| 208 // Phi. | 209 // Phi. |
| 209 | 210 |
| 210 | 211 |
| 211 typedef InstructionSelectorTestWithParam<MachineType> | 212 typedef InstructionSelectorTestWithParam<MachineType> |
| 212 InstructionSelectorPhiTest; | 213 InstructionSelectorPhiTest; |
| 213 | 214 |
| 214 | 215 |
| 215 TARGET_TEST_P(InstructionSelectorPhiTest, PropagateDoubleness) { | 216 TARGET_TEST_P(InstructionSelectorPhiTest, Doubleness) { |
| 216 const MachineType type = GetParam(); | 217 const MachineType type = GetParam(); |
| 217 StreamBuilder m(this, type, type, type); | 218 StreamBuilder m(this, type, type, type); |
| 218 Node* param0 = m.Parameter(0); | 219 Node* param0 = m.Parameter(0); |
| 219 Node* param1 = m.Parameter(1); | 220 Node* param1 = m.Parameter(1); |
| 220 MLabel a, b, c; | 221 MLabel a, b, c; |
| 221 m.Branch(m.Int32Constant(0), &a, &b); | 222 m.Branch(m.Int32Constant(0), &a, &b); |
| 222 m.Bind(&a); | 223 m.Bind(&a); |
| 223 m.Goto(&c); | 224 m.Goto(&c); |
| 224 m.Bind(&b); | 225 m.Bind(&b); |
| 225 m.Goto(&c); | 226 m.Goto(&c); |
| 226 m.Bind(&c); | 227 m.Bind(&c); |
| 227 Node* phi = m.Phi(param0, param1); | 228 Node* phi = m.Phi(type, param0, param1); |
| 228 m.Return(phi); | 229 m.Return(phi); |
| 229 Stream s = m.Build(kAllInstructions); | 230 Stream s = m.Build(kAllInstructions); |
| 230 EXPECT_EQ(s.IsDouble(phi->id()), s.IsDouble(param0->id())); | 231 EXPECT_EQ(s.IsDouble(phi->id()), s.IsDouble(param0->id())); |
| 231 EXPECT_EQ(s.IsDouble(phi->id()), s.IsDouble(param1->id())); | 232 EXPECT_EQ(s.IsDouble(phi->id()), s.IsDouble(param1->id())); |
| 232 } | 233 } |
| 233 | 234 |
| 234 | 235 |
| 235 TARGET_TEST_P(InstructionSelectorPhiTest, PropagateReferenceness) { | 236 TARGET_TEST_P(InstructionSelectorPhiTest, Referenceness) { |
| 236 const MachineType type = GetParam(); | 237 const MachineType type = GetParam(); |
| 237 StreamBuilder m(this, type, type, type); | 238 StreamBuilder m(this, type, type, type); |
| 238 Node* param0 = m.Parameter(0); | 239 Node* param0 = m.Parameter(0); |
| 239 Node* param1 = m.Parameter(1); | 240 Node* param1 = m.Parameter(1); |
| 240 MLabel a, b, c; | 241 MLabel a, b, c; |
| 241 m.Branch(m.Int32Constant(1), &a, &b); | 242 m.Branch(m.Int32Constant(1), &a, &b); |
| 242 m.Bind(&a); | 243 m.Bind(&a); |
| 243 m.Goto(&c); | 244 m.Goto(&c); |
| 244 m.Bind(&b); | 245 m.Bind(&b); |
| 245 m.Goto(&c); | 246 m.Goto(&c); |
| 246 m.Bind(&c); | 247 m.Bind(&c); |
| 247 Node* phi = m.Phi(param0, param1); | 248 Node* phi = m.Phi(type, param0, param1); |
| 248 m.Return(phi); | 249 m.Return(phi); |
| 249 Stream s = m.Build(kAllInstructions); | 250 Stream s = m.Build(kAllInstructions); |
| 250 EXPECT_EQ(s.IsReference(phi->id()), s.IsReference(param0->id())); | 251 EXPECT_EQ(s.IsReference(phi->id()), s.IsReference(param0->id())); |
| 251 EXPECT_EQ(s.IsReference(phi->id()), s.IsReference(param1->id())); | 252 EXPECT_EQ(s.IsReference(phi->id()), s.IsReference(param1->id())); |
| 252 } | 253 } |
| 253 | 254 |
| 254 | 255 |
| 255 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorPhiTest, | 256 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorPhiTest, |
| 256 ::testing::Values(kMachFloat64, kMachInt8, kMachUint8, | 257 ::testing::Values(kMachFloat64, kMachInt8, kMachUint8, |
| 257 kMachInt16, kMachUint16, kMachInt32, | 258 kMachInt16, kMachUint16, kMachInt32, |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 EXPECT_EQ(context2->id(), s.ToVreg(call_instr->InputAt(11))); | 487 EXPECT_EQ(context2->id(), s.ToVreg(call_instr->InputAt(11))); |
| 487 // Continuation. | 488 // Continuation. |
| 488 | 489 |
| 489 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); | 490 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); |
| 490 EXPECT_EQ(index, s.size()); | 491 EXPECT_EQ(index, s.size()); |
| 491 } | 492 } |
| 492 | 493 |
| 493 } // namespace compiler | 494 } // namespace compiler |
| 494 } // namespace internal | 495 } // namespace internal |
| 495 } // namespace v8 | 496 } // namespace v8 |
| OLD | NEW |