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/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/compiler/code-generator.h" | 8 #include "src/compiler/code-generator.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 | 194 |
195 TEST(InstructionIsGapAt) { | 195 TEST(InstructionIsGapAt) { |
196 InstructionTester R; | 196 InstructionTester R; |
197 | 197 |
198 BasicBlock* b0 = R.schedule.start(); | 198 BasicBlock* b0 = R.schedule.start(); |
199 R.schedule.AddReturn(b0, R.Int32Constant(1)); | 199 R.schedule.AddReturn(b0, R.Int32Constant(1)); |
200 | 200 |
201 R.allocCode(); | 201 R.allocCode(); |
202 TestInstr* i0 = TestInstr::New(R.zone(), 100); | 202 TestInstr* i0 = TestInstr::New(R.zone(), 100); |
203 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); | 203 TestInstr* g = TestInstr::New(R.zone(), 103); |
204 R.code->StartBlock(R.RpoFor(b0)); | 204 R.code->StartBlock(R.RpoFor(b0)); |
205 R.code->AddInstruction(i0); | 205 R.code->AddInstruction(i0); |
206 R.code->AddInstruction(g); | 206 R.code->AddInstruction(g); |
207 R.code->EndBlock(R.RpoFor(b0)); | 207 R.code->EndBlock(R.RpoFor(b0)); |
208 | 208 |
209 CHECK(R.code->instructions().size() == 4); | 209 CHECK(R.code->instructions().size() == 4); |
210 for (size_t i = 0; i < R.code->instructions().size(); ++i) { | 210 for (size_t i = 0; i < R.code->instructions().size(); ++i) { |
211 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves()); | 211 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves()); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 TEST(InstructionIsGapAt2) { | 216 TEST(InstructionIsGapAt2) { |
217 InstructionTester R; | 217 InstructionTester R; |
218 | 218 |
219 BasicBlock* b0 = R.schedule.start(); | 219 BasicBlock* b0 = R.schedule.start(); |
220 BasicBlock* b1 = R.schedule.end(); | 220 BasicBlock* b1 = R.schedule.end(); |
221 R.schedule.AddGoto(b0, b1); | 221 R.schedule.AddGoto(b0, b1); |
222 R.schedule.AddReturn(b1, R.Int32Constant(1)); | 222 R.schedule.AddReturn(b1, R.Int32Constant(1)); |
223 | 223 |
224 R.allocCode(); | 224 R.allocCode(); |
225 TestInstr* i0 = TestInstr::New(R.zone(), 100); | 225 TestInstr* i0 = TestInstr::New(R.zone(), 100); |
226 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); | 226 TestInstr* g = TestInstr::New(R.zone(), 103); |
227 R.code->StartBlock(R.RpoFor(b0)); | 227 R.code->StartBlock(R.RpoFor(b0)); |
228 R.code->AddInstruction(i0); | 228 R.code->AddInstruction(i0); |
229 R.code->AddInstruction(g); | 229 R.code->AddInstruction(g); |
230 R.code->EndBlock(R.RpoFor(b0)); | 230 R.code->EndBlock(R.RpoFor(b0)); |
231 | 231 |
232 TestInstr* i1 = TestInstr::New(R.zone(), 102); | 232 TestInstr* i1 = TestInstr::New(R.zone(), 102); |
233 TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl(); | 233 TestInstr* g1 = TestInstr::New(R.zone(), 104); |
234 R.code->StartBlock(R.RpoFor(b1)); | 234 R.code->StartBlock(R.RpoFor(b1)); |
235 R.code->AddInstruction(i1); | 235 R.code->AddInstruction(i1); |
236 R.code->AddInstruction(g1); | 236 R.code->AddInstruction(g1); |
237 R.code->EndBlock(R.RpoFor(b1)); | 237 R.code->EndBlock(R.RpoFor(b1)); |
238 | 238 |
239 CHECK(R.code->instructions().size() == 8); | 239 CHECK(R.code->instructions().size() == 8); |
240 for (size_t i = 0; i < R.code->instructions().size(); ++i) { | 240 for (size_t i = 0; i < R.code->instructions().size(); ++i) { |
241 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves()); | 241 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves()); |
242 } | 242 } |
243 } | 243 } |
244 | 244 |
245 | 245 |
246 TEST(InstructionAddGapMove) { | 246 TEST(InstructionAddGapMove) { |
247 InstructionTester R; | 247 InstructionTester R; |
248 | 248 |
249 BasicBlock* b0 = R.schedule.start(); | 249 BasicBlock* b0 = R.schedule.start(); |
250 R.schedule.AddReturn(b0, R.Int32Constant(1)); | 250 R.schedule.AddReturn(b0, R.Int32Constant(1)); |
251 | 251 |
252 R.allocCode(); | 252 R.allocCode(); |
253 TestInstr* i0 = TestInstr::New(R.zone(), 100); | 253 TestInstr* i0 = TestInstr::New(R.zone(), 100); |
254 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); | 254 TestInstr* g = TestInstr::New(R.zone(), 103); |
255 R.code->StartBlock(R.RpoFor(b0)); | 255 R.code->StartBlock(R.RpoFor(b0)); |
256 R.code->AddInstruction(i0); | 256 R.code->AddInstruction(i0); |
257 R.code->AddInstruction(g); | 257 R.code->AddInstruction(g); |
258 R.code->EndBlock(R.RpoFor(b0)); | 258 R.code->EndBlock(R.RpoFor(b0)); |
259 | 259 |
260 CHECK(R.code->instructions().size() == 4); | 260 CHECK(R.code->instructions().size() == 4); |
261 for (size_t i = 0; i < R.code->instructions().size(); ++i) { | 261 for (size_t i = 0; i < R.code->instructions().size(); ++i) { |
262 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves()); | 262 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves()); |
263 } | 263 } |
264 | 264 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 CHECK(inputs[z].Equals(m->InputAt(z))); | 328 CHECK(inputs[z].Equals(m->InputAt(z))); |
329 } | 329 } |
330 | 330 |
331 for (size_t z = 0; z < k; z++) { | 331 for (size_t z = 0; z < k; z++) { |
332 CHECK(temps[z].Equals(m->TempAt(z))); | 332 CHECK(temps[z].Equals(m->TempAt(z))); |
333 } | 333 } |
334 } | 334 } |
335 } | 335 } |
336 } | 336 } |
337 } | 337 } |
OLD | NEW |