Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1929)

Side by Side Diff: test/cctest/compiler/test-instruction.cc

Issue 710323002: [turbofan] put gaps before instructions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 R.schedule.AddReturn(b0, R.Int32Constant(1)); 207 R.schedule.AddReturn(b0, R.Int32Constant(1));
208 208
209 R.allocCode(); 209 R.allocCode();
210 TestInstr* i0 = TestInstr::New(R.zone(), 100); 210 TestInstr* i0 = TestInstr::New(R.zone(), 100);
211 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 211 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
212 R.code->StartBlock(b0->GetRpoNumber()); 212 R.code->StartBlock(b0->GetRpoNumber());
213 R.code->AddInstruction(i0); 213 R.code->AddInstruction(i0);
214 R.code->AddInstruction(g); 214 R.code->AddInstruction(g);
215 R.code->EndBlock(b0->GetRpoNumber()); 215 R.code->EndBlock(b0->GetRpoNumber());
216 216
217 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 217 CHECK(R.code->instructions().size() == 8);
218 218 CHECK_EQ(true, R.code->InstructionAt(1)->IsBlockStart());
219 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 219 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
220 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap 220 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
221 CHECK_EQ(false, R.code->IsGapAt(2)); // i0 221 }
222 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap
223 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap
224 CHECK_EQ(false, R.code->IsGapAt(5)); // g
225 } 222 }
226 223
227 224
228 TEST(InstructionIsGapAt2) { 225 TEST(InstructionIsGapAt2) {
229 InstructionTester R; 226 InstructionTester R;
230 227
231 BasicBlock* b0 = R.schedule.start(); 228 BasicBlock* b0 = R.schedule.start();
232 BasicBlock* b1 = R.schedule.end(); 229 BasicBlock* b1 = R.schedule.end();
233 R.schedule.AddGoto(b0, b1); 230 R.schedule.AddGoto(b0, b1);
234 R.schedule.AddReturn(b1, R.Int32Constant(1)); 231 R.schedule.AddReturn(b1, R.Int32Constant(1));
235 232
236 R.allocCode(); 233 R.allocCode();
237 TestInstr* i0 = TestInstr::New(R.zone(), 100); 234 TestInstr* i0 = TestInstr::New(R.zone(), 100);
238 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 235 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
239 R.code->StartBlock(b0->GetRpoNumber()); 236 R.code->StartBlock(b0->GetRpoNumber());
240 R.code->AddInstruction(i0); 237 R.code->AddInstruction(i0);
241 R.code->AddInstruction(g); 238 R.code->AddInstruction(g);
242 R.code->EndBlock(b0->GetRpoNumber()); 239 R.code->EndBlock(b0->GetRpoNumber());
243 240
244 TestInstr* i1 = TestInstr::New(R.zone(), 102); 241 TestInstr* i1 = TestInstr::New(R.zone(), 102);
245 TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl(); 242 TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl();
246 R.code->StartBlock(b1->GetRpoNumber()); 243 R.code->StartBlock(b1->GetRpoNumber());
247 R.code->AddInstruction(i1); 244 R.code->AddInstruction(i1);
248 R.code->AddInstruction(g1); 245 R.code->AddInstruction(g1);
249 R.code->EndBlock(b1->GetRpoNumber()); 246 R.code->EndBlock(b1->GetRpoNumber());
250 247
251 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 248 CHECK(R.code->instructions().size() == 16);
252 249 CHECK_EQ(true, R.code->InstructionAt(1)->IsBlockStart());
253 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 250 CHECK_EQ(true, R.code->InstructionAt(9)->IsBlockStart());
254 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap 251 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
255 CHECK_EQ(false, R.code->IsGapAt(2)); // i0 252 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
256 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap 253 }
257 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap
258 CHECK_EQ(false, R.code->IsGapAt(5)); // g
259
260 CHECK_EQ(true, R.code->InstructionAt(6)->IsBlockStart());
261
262 CHECK_EQ(true, R.code->IsGapAt(6)); // Label
263 CHECK_EQ(true, R.code->IsGapAt(7)); // Gap
264 CHECK_EQ(false, R.code->IsGapAt(8)); // i1
265 CHECK_EQ(true, R.code->IsGapAt(9)); // Gap
266 CHECK_EQ(true, R.code->IsGapAt(10)); // Gap
267 CHECK_EQ(false, R.code->IsGapAt(11)); // g1
268 } 254 }
269 255
270 256
271 TEST(InstructionAddGapMove) { 257 TEST(InstructionAddGapMove) {
272 InstructionTester R; 258 InstructionTester R;
273 259
274 BasicBlock* b0 = R.schedule.start(); 260 BasicBlock* b0 = R.schedule.start();
275 R.schedule.AddReturn(b0, R.Int32Constant(1)); 261 R.schedule.AddReturn(b0, R.Int32Constant(1));
276 262
277 R.allocCode(); 263 R.allocCode();
278 TestInstr* i0 = TestInstr::New(R.zone(), 100); 264 TestInstr* i0 = TestInstr::New(R.zone(), 100);
279 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 265 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
280 R.code->StartBlock(b0->GetRpoNumber()); 266 R.code->StartBlock(b0->GetRpoNumber());
281 R.code->AddInstruction(i0); 267 R.code->AddInstruction(i0);
282 R.code->AddInstruction(g); 268 R.code->AddInstruction(g);
283 R.code->EndBlock(b0->GetRpoNumber()); 269 R.code->EndBlock(b0->GetRpoNumber());
284 270
285 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 271 CHECK(R.code->instructions().size() == 8);
272 CHECK_EQ(true, R.code->InstructionAt(1)->IsBlockStart());
273 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
274 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
275 }
286 276
287 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 277 int indexes[] = {0, 2, 4, 6, -1};
288 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap
289 CHECK_EQ(false, R.code->IsGapAt(2)); // i0
290 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap
291 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap
292 CHECK_EQ(false, R.code->IsGapAt(5)); // g
293
294 int indexes[] = {0, 1, 3, 4, -1};
295 for (int i = 0; indexes[i] >= 0; i++) { 278 for (int i = 0; indexes[i] >= 0; i++) {
296 int index = indexes[i]; 279 int index = indexes[i];
297 280
298 UnallocatedOperand* op1 = R.NewUnallocated(index + 6); 281 UnallocatedOperand* op1 = R.NewUnallocated(index + 6);
299 UnallocatedOperand* op2 = R.NewUnallocated(index + 12); 282 UnallocatedOperand* op2 = R.NewUnallocated(index + 12);
300 283
301 R.code->AddGapMove(index, op1, op2); 284 R.code->AddGapMove(index, op1, op2);
302 GapInstruction* gap = R.code->GapAt(index); 285 GapInstruction* gap = R.code->GapAt(index);
303 ParallelMove* move = gap->GetParallelMove(GapInstruction::START); 286 ParallelMove* move = gap->GetParallelMove(GapInstruction::START);
304 CHECK_NE(NULL, move); 287 CHECK_NE(NULL, move);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 CHECK_EQ(inputs[z], m->InputAt(z)); 339 CHECK_EQ(inputs[z], m->InputAt(z));
357 } 340 }
358 341
359 for (size_t z = 0; z < k; z++) { 342 for (size_t z = 0; z < k; z++) {
360 CHECK_EQ(temps[z], m->TempAt(z)); 343 CHECK_EQ(temps[z], m->TempAt(z));
361 } 344 }
362 } 345 }
363 } 346 }
364 } 347 }
365 } 348 }
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698