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

Side by Side Diff: test/unittests/compiler/live-range-unittest.cc

Issue 1403163003: Revert of [turbofan] Splinter into one range. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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') | 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 5
6 #include "test/unittests/compiler/live-range-builder.h" 6 #include "test/unittests/compiler/live-range-builder.h"
7 #include "test/unittests/test-utils.h" 7 #include "test/unittests/test-utils.h"
8 8
9 9
10 // TODO(mtrofin): would we want to centralize this definition? 10 // TODO(mtrofin): would we want to centralize this definition?
(...skipping 14 matching lines...) Expand all
25 class LiveRangeUnitTest : public TestWithZone { 25 class LiveRangeUnitTest : public TestWithZone {
26 public: 26 public:
27 // Split helper, to avoid int->LifetimePosition conversion nuisance. 27 // Split helper, to avoid int->LifetimePosition conversion nuisance.
28 LiveRange* Split(LiveRange* range, int pos) { 28 LiveRange* Split(LiveRange* range, int pos) {
29 return range->SplitAt(LifetimePosition::FromInt(pos), zone()); 29 return range->SplitAt(LifetimePosition::FromInt(pos), zone());
30 } 30 }
31 31
32 32
33 TopLevelLiveRange* Splinter(TopLevelLiveRange* top, int start, int end, 33 TopLevelLiveRange* Splinter(TopLevelLiveRange* top, int start, int end,
34 int new_id = 0) { 34 int new_id = 0) {
35 if (top->splinter() == nullptr) { 35 TopLevelLiveRange* ret =
36 TopLevelLiveRange* ret = 36 new (zone()) TopLevelLiveRange(new_id, MachineType::kRepTagged);
37 new (zone()) TopLevelLiveRange(new_id, MachineType::kRepTagged);
38 top->SetSplinter(ret);
39 }
40 top->Splinter(LifetimePosition::FromInt(start), 37 top->Splinter(LifetimePosition::FromInt(start),
41 LifetimePosition::FromInt(end), zone()); 38 LifetimePosition::FromInt(end), ret, zone());
42 return top->splinter(); 39 return ret;
43 } 40 }
44 41
45 // Ranges first and second match structurally. 42 // Ranges first and second match structurally.
46 bool RangesMatch(LiveRange* first, LiveRange* second) { 43 bool RangesMatch(LiveRange* first, LiveRange* second) {
47 if (first->Start() != second->Start() || first->End() != second->End()) { 44 if (first->Start() != second->Start() || first->End() != second->End()) {
48 return false; 45 return false;
49 } 46 }
50 UseInterval* i1 = first->first_interval(); 47 UseInterval* i1 = first->first_interval();
51 UseInterval* i2 = second->first_interval(); 48 UseInterval* i2 = second->first_interval();
52 49
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 EXPECT_EQ(range, splinter->splintered_from()); 370 EXPECT_EQ(range, splinter->splintered_from());
374 371
375 TopLevelLiveRange* expected_source = 372 TopLevelLiveRange* expected_source =
376 TestRangeBuilder(zone()).Add(0, 3).Add(6, 8).Build(); 373 TestRangeBuilder(zone()).Add(0, 3).Add(6, 8).Build();
377 TopLevelLiveRange* expected_splinter = TestRangeBuilder(zone()).Build(5, 6); 374 TopLevelLiveRange* expected_splinter = TestRangeBuilder(zone()).Build(5, 6);
378 EXPECT_TRUE(RangesMatch(expected_source, range)); 375 EXPECT_TRUE(RangesMatch(expected_source, range));
379 EXPECT_TRUE(RangesMatch(expected_splinter, splinter)); 376 EXPECT_TRUE(RangesMatch(expected_splinter, splinter));
380 } 377 }
381 378
382 379
383 TEST_F(LiveRangeUnitTest, SplinterMergeMultipleTimes) {
384 TopLevelLiveRange* range =
385 TestRangeBuilder(zone()).Add(0, 3).Add(5, 10).Add(12, 16).Build();
386 Splinter(range, 4, 6);
387 Splinter(range, 8, 14);
388 TopLevelLiveRange* splinter = range->splinter();
389 EXPECT_EQ(nullptr, range->next());
390 EXPECT_EQ(nullptr, splinter->next());
391 EXPECT_EQ(range, splinter->splintered_from());
392
393 TopLevelLiveRange* expected_source =
394 TestRangeBuilder(zone()).Add(0, 3).Add(6, 8).Add(14, 16).Build();
395 TopLevelLiveRange* expected_splinter =
396 TestRangeBuilder(zone()).Add(5, 6).Add(8, 10).Add(12, 14).Build();
397 EXPECT_TRUE(RangesMatch(expected_source, range));
398 EXPECT_TRUE(RangesMatch(expected_splinter, splinter));
399 }
400
401
402 TEST_F(LiveRangeUnitTest, MergeMultipleIntervalsRight) { 380 TEST_F(LiveRangeUnitTest, MergeMultipleIntervalsRight) {
403 TopLevelLiveRange* original = 381 TopLevelLiveRange* original =
404 TestRangeBuilder(zone()).Add(0, 3).Add(5, 8).Build(); 382 TestRangeBuilder(zone()).Add(0, 3).Add(5, 8).Build();
405 TopLevelLiveRange* splinter = Splinter(original, 4, 6); 383 TopLevelLiveRange* splinter = Splinter(original, 4, 6);
406 original->Merge(splinter, zone()); 384 original->Merge(splinter, zone());
407 385
408 TopLevelLiveRange* result = 386 TopLevelLiveRange* result =
409 TestRangeBuilder(zone()).Add(0, 3).Add(5, 8).Build(); 387 TestRangeBuilder(zone()).Add(0, 3).Add(5, 8).Build();
410 LiveRange* child_1 = Split(result, 5); 388 LiveRange* child_1 = Split(result, 5);
411 Split(child_1, 6); 389 Split(child_1, 6);
(...skipping 19 matching lines...) Expand all
431 } 409 }
432 410
433 411
434 TEST_F(LiveRangeUnitTest, IDGeneration) { 412 TEST_F(LiveRangeUnitTest, IDGeneration) {
435 TopLevelLiveRange* vreg = TestRangeBuilder(zone()).Id(2).Build(0, 100); 413 TopLevelLiveRange* vreg = TestRangeBuilder(zone()).Id(2).Build(0, 100);
436 EXPECT_EQ(2, vreg->vreg()); 414 EXPECT_EQ(2, vreg->vreg());
437 EXPECT_EQ(0, vreg->relative_id()); 415 EXPECT_EQ(0, vreg->relative_id());
438 416
439 TopLevelLiveRange* splinter = 417 TopLevelLiveRange* splinter =
440 new (zone()) TopLevelLiveRange(101, MachineType::kRepTagged); 418 new (zone()) TopLevelLiveRange(101, MachineType::kRepTagged);
441 vreg->SetSplinter(splinter);
442 vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12), 419 vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12),
443 zone()); 420 splinter, zone());
444 421
445 EXPECT_EQ(101, splinter->vreg()); 422 EXPECT_EQ(101, splinter->vreg());
446 EXPECT_EQ(1, splinter->relative_id()); 423 EXPECT_EQ(1, splinter->relative_id());
447 424
448 LiveRange* child = vreg->SplitAt(LifetimePosition::FromInt(50), zone()); 425 LiveRange* child = vreg->SplitAt(LifetimePosition::FromInt(50), zone());
449 426
450 EXPECT_EQ(2, child->relative_id()); 427 EXPECT_EQ(2, child->relative_id());
451 428
452 LiveRange* splinter_child = 429 LiveRange* splinter_child =
453 splinter->SplitAt(LifetimePosition::FromInt(8), zone()); 430 splinter->SplitAt(LifetimePosition::FromInt(8), zone());
454 431
455 EXPECT_EQ(1, splinter->relative_id()); 432 EXPECT_EQ(1, splinter->relative_id());
456 EXPECT_EQ(3, splinter_child->relative_id()); 433 EXPECT_EQ(3, splinter_child->relative_id());
457 434
458 vreg->Merge(splinter, zone()); 435 vreg->Merge(splinter, zone());
459 EXPECT_EQ(1, splinter->relative_id()); 436 EXPECT_EQ(1, splinter->relative_id());
460 } 437 }
461 438
462 } // namespace compiler 439 } // namespace compiler
463 } // namespace internal 440 } // namespace internal
464 } // namespace v8 441 } // namespace v8
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