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

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

Issue 1513543003: [turbofan] Make MachineType a pair of enums. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moar rebase Created 5 years 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
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 15 matching lines...) Expand all
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 if (top->splinter() == nullptr) {
36 TopLevelLiveRange* ret = 36 TopLevelLiveRange* ret = new (zone())
37 new (zone()) TopLevelLiveRange(new_id, MachineType::kRepTagged); 37 TopLevelLiveRange(new_id, MachineRepresentation::kTagged);
38 top->SetSplinter(ret); 38 top->SetSplinter(ret);
39 } 39 }
40 top->Splinter(LifetimePosition::FromInt(start), 40 top->Splinter(LifetimePosition::FromInt(start),
41 LifetimePosition::FromInt(end), zone()); 41 LifetimePosition::FromInt(end), zone());
42 return top->splinter(); 42 return top->splinter();
43 } 43 }
44 44
45 // Ranges first and second match structurally. 45 // Ranges first and second match structurally.
46 bool RangesMatch(LiveRange* first, LiveRange* second) { 46 bool RangesMatch(LiveRange* first, LiveRange* second) {
47 if (first->Start() != second->Start() || first->End() != second->End()) { 47 if (first->Start() != second->Start() || first->End() != second->End()) {
(...skipping 19 matching lines...) Expand all
67 } 67 }
68 if (p1 != nullptr || p2 != nullptr) return false; 68 if (p1 != nullptr || p2 != nullptr) return false;
69 return true; 69 return true;
70 } 70 }
71 }; 71 };
72 72
73 73
74 TEST_F(LiveRangeUnitTest, InvalidConstruction) { 74 TEST_F(LiveRangeUnitTest, InvalidConstruction) {
75 // Build a range manually, because the builder guards against empty cases. 75 // Build a range manually, because the builder guards against empty cases.
76 TopLevelLiveRange* range = 76 TopLevelLiveRange* range =
77 new (zone()) TopLevelLiveRange(1, MachineType::kRepTagged); 77 new (zone()) TopLevelLiveRange(1, MachineRepresentation::kTagged);
78 V8_ASSERT_DEBUG_DEATH( 78 V8_ASSERT_DEBUG_DEATH(
79 range->AddUseInterval(LifetimePosition::FromInt(0), 79 range->AddUseInterval(LifetimePosition::FromInt(0),
80 LifetimePosition::FromInt(0), zone()), 80 LifetimePosition::FromInt(0), zone()),
81 ".*"); 81 ".*");
82 } 82 }
83 83
84 84
85 TEST_F(LiveRangeUnitTest, SplitInvalidStart) { 85 TEST_F(LiveRangeUnitTest, SplitInvalidStart) {
86 TopLevelLiveRange* range = TestRangeBuilder(zone()).Build(0, 1); 86 TopLevelLiveRange* range = TestRangeBuilder(zone()).Build(0, 1);
87 V8_ASSERT_DEBUG_DEATH(Split(range, 0), ".*"); 87 V8_ASSERT_DEBUG_DEATH(Split(range, 0), ".*");
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 EXPECT_TRUE(RangesMatch(result, original)); 430 EXPECT_TRUE(RangesMatch(result, original));
431 } 431 }
432 432
433 433
434 TEST_F(LiveRangeUnitTest, IDGeneration) { 434 TEST_F(LiveRangeUnitTest, IDGeneration) {
435 TopLevelLiveRange* vreg = TestRangeBuilder(zone()).Id(2).Build(0, 100); 435 TopLevelLiveRange* vreg = TestRangeBuilder(zone()).Id(2).Build(0, 100);
436 EXPECT_EQ(2, vreg->vreg()); 436 EXPECT_EQ(2, vreg->vreg());
437 EXPECT_EQ(0, vreg->relative_id()); 437 EXPECT_EQ(0, vreg->relative_id());
438 438
439 TopLevelLiveRange* splinter = 439 TopLevelLiveRange* splinter =
440 new (zone()) TopLevelLiveRange(101, MachineType::kRepTagged); 440 new (zone()) TopLevelLiveRange(101, MachineRepresentation::kTagged);
441 vreg->SetSplinter(splinter); 441 vreg->SetSplinter(splinter);
442 vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12), 442 vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12),
443 zone()); 443 zone());
444 444
445 EXPECT_EQ(101, splinter->vreg()); 445 EXPECT_EQ(101, splinter->vreg());
446 EXPECT_EQ(1, splinter->relative_id()); 446 EXPECT_EQ(1, splinter->relative_id());
447 447
448 LiveRange* child = vreg->SplitAt(LifetimePosition::FromInt(50), zone()); 448 LiveRange* child = vreg->SplitAt(LifetimePosition::FromInt(50), zone());
449 449
450 EXPECT_EQ(2, child->relative_id()); 450 EXPECT_EQ(2, child->relative_id());
451 451
452 LiveRange* splinter_child = 452 LiveRange* splinter_child =
453 splinter->SplitAt(LifetimePosition::FromInt(8), zone()); 453 splinter->SplitAt(LifetimePosition::FromInt(8), zone());
454 454
455 EXPECT_EQ(1, splinter->relative_id()); 455 EXPECT_EQ(1, splinter->relative_id());
456 EXPECT_EQ(3, splinter_child->relative_id()); 456 EXPECT_EQ(3, splinter_child->relative_id());
457 457
458 vreg->Merge(splinter, zone()); 458 vreg->Merge(splinter, zone());
459 EXPECT_EQ(1, splinter->relative_id()); 459 EXPECT_EQ(1, splinter->relative_id());
460 } 460 }
461 461
462 } // namespace compiler 462 } // namespace compiler
463 } // namespace internal 463 } // namespace internal
464 } // namespace v8 464 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/live-range-builder.h ('k') | test/unittests/compiler/liveness-analyzer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698