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

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

Issue 854703002: Reland "[turbofan] simplify gap ordering" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months 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
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | test/cctest/compiler/test-jump-threading.cc » ('j') | 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() == 4);
218 218 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
219 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 219 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
220 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap 220 }
221 CHECK_EQ(false, R.code->IsGapAt(2)); // i0
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 } 221 }
226 222
227 223
228 TEST(InstructionIsGapAt2) { 224 TEST(InstructionIsGapAt2) {
229 InstructionTester R; 225 InstructionTester R;
230 226
231 BasicBlock* b0 = R.schedule.start(); 227 BasicBlock* b0 = R.schedule.start();
232 BasicBlock* b1 = R.schedule.end(); 228 BasicBlock* b1 = R.schedule.end();
233 R.schedule.AddGoto(b0, b1); 229 R.schedule.AddGoto(b0, b1);
234 R.schedule.AddReturn(b1, R.Int32Constant(1)); 230 R.schedule.AddReturn(b1, R.Int32Constant(1));
235 231
236 R.allocCode(); 232 R.allocCode();
237 TestInstr* i0 = TestInstr::New(R.zone(), 100); 233 TestInstr* i0 = TestInstr::New(R.zone(), 100);
238 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 234 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
239 R.code->StartBlock(b0->GetRpoNumber()); 235 R.code->StartBlock(b0->GetRpoNumber());
240 R.code->AddInstruction(i0); 236 R.code->AddInstruction(i0);
241 R.code->AddInstruction(g); 237 R.code->AddInstruction(g);
242 R.code->EndBlock(b0->GetRpoNumber()); 238 R.code->EndBlock(b0->GetRpoNumber());
243 239
244 TestInstr* i1 = TestInstr::New(R.zone(), 102); 240 TestInstr* i1 = TestInstr::New(R.zone(), 102);
245 TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl(); 241 TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl();
246 R.code->StartBlock(b1->GetRpoNumber()); 242 R.code->StartBlock(b1->GetRpoNumber());
247 R.code->AddInstruction(i1); 243 R.code->AddInstruction(i1);
248 R.code->AddInstruction(g1); 244 R.code->AddInstruction(g1);
249 R.code->EndBlock(b1->GetRpoNumber()); 245 R.code->EndBlock(b1->GetRpoNumber());
250 246
251 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 247 CHECK(R.code->instructions().size() == 8);
252 248 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
253 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 249 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
254 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap 250 }
255 CHECK_EQ(false, R.code->IsGapAt(2)); // i0
256 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap
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 } 251 }
269 252
270 253
271 TEST(InstructionAddGapMove) { 254 TEST(InstructionAddGapMove) {
272 InstructionTester R; 255 InstructionTester R;
273 256
274 BasicBlock* b0 = R.schedule.start(); 257 BasicBlock* b0 = R.schedule.start();
275 R.schedule.AddReturn(b0, R.Int32Constant(1)); 258 R.schedule.AddReturn(b0, R.Int32Constant(1));
276 259
277 R.allocCode(); 260 R.allocCode();
278 TestInstr* i0 = TestInstr::New(R.zone(), 100); 261 TestInstr* i0 = TestInstr::New(R.zone(), 100);
279 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 262 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
280 R.code->StartBlock(b0->GetRpoNumber()); 263 R.code->StartBlock(b0->GetRpoNumber());
281 R.code->AddInstruction(i0); 264 R.code->AddInstruction(i0);
282 R.code->AddInstruction(g); 265 R.code->AddInstruction(g);
283 R.code->EndBlock(b0->GetRpoNumber()); 266 R.code->EndBlock(b0->GetRpoNumber());
284 267
285 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 268 CHECK(R.code->instructions().size() == 4);
269 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
270 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
271 }
286 272
287 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 273 int indexes[] = {0, 2, -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++) { 274 for (int i = 0; indexes[i] >= 0; i++) {
296 int index = indexes[i]; 275 int index = indexes[i];
297 276
298 UnallocatedOperand* op1 = R.NewUnallocated(index + 6); 277 UnallocatedOperand* op1 = R.NewUnallocated(index + 6);
299 UnallocatedOperand* op2 = R.NewUnallocated(index + 12); 278 UnallocatedOperand* op2 = R.NewUnallocated(index + 12);
300 279
301 R.code->AddGapMove(index, op1, op2); 280 R.code->AddGapMove(index, op1, op2);
302 GapInstruction* gap = R.code->GapAt(index); 281 GapInstruction* gap = R.code->GapAt(index);
303 ParallelMove* move = gap->GetParallelMove(GapInstruction::START); 282 ParallelMove* move = gap->GetParallelMove(GapInstruction::START);
304 CHECK_NE(NULL, move); 283 CHECK_NE(NULL, move);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 CHECK_EQ(inputs[z], m->InputAt(z)); 335 CHECK_EQ(inputs[z], m->InputAt(z));
357 } 336 }
358 337
359 for (size_t z = 0; z < k; z++) { 338 for (size_t z = 0; z < k; z++) {
360 CHECK_EQ(temps[z], m->TempAt(z)); 339 CHECK_EQ(temps[z], m->TempAt(z));
361 } 340 }
362 } 341 }
363 } 342 }
364 } 343 }
365 } 344 }
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | test/cctest/compiler/test-jump-threading.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698