OLD | NEW |
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 TopLevelLiveRange* result = TestRangeBuilder(zone()).Build(0, 8); | 400 TopLevelLiveRange* result = TestRangeBuilder(zone()).Build(0, 8); |
401 LiveRange* child_1 = Split(result, 2); | 401 LiveRange* child_1 = Split(result, 2); |
402 LiveRange* child_2 = Split(child_1, 4); | 402 LiveRange* child_2 = Split(child_1, 4); |
403 LiveRange* child_3 = Split(child_2, 6); | 403 LiveRange* child_3 = Split(child_2, 6); |
404 Split(child_3, 7); | 404 Split(child_3, 7); |
405 | 405 |
406 EXPECT_TRUE(RangesMatch(result, original)); | 406 EXPECT_TRUE(RangesMatch(result, original)); |
407 } | 407 } |
408 | 408 |
409 | 409 |
| 410 TEST_F(LiveRangeUnitTest, IDGeneration) { |
| 411 TopLevelLiveRange* vreg = TestRangeBuilder(zone()).Id(2).Build(0, 100); |
| 412 EXPECT_EQ(2, vreg->vreg()); |
| 413 EXPECT_EQ(0, vreg->relative_id()); |
| 414 |
| 415 TopLevelLiveRange* splinter = |
| 416 new (zone()) TopLevelLiveRange(101, MachineType::kRepTagged); |
| 417 vreg->Splinter(LifetimePosition::FromInt(4), LifetimePosition::FromInt(12), |
| 418 splinter, zone()); |
| 419 |
| 420 EXPECT_EQ(101, splinter->vreg()); |
| 421 EXPECT_EQ(1, splinter->relative_id()); |
| 422 |
| 423 LiveRange* child = vreg->SplitAt(LifetimePosition::FromInt(50), zone()); |
| 424 |
| 425 EXPECT_EQ(2, child->relative_id()); |
| 426 |
| 427 LiveRange* splinter_child = |
| 428 splinter->SplitAt(LifetimePosition::FromInt(8), zone()); |
| 429 |
| 430 EXPECT_EQ(1, splinter->relative_id()); |
| 431 EXPECT_EQ(3, splinter_child->relative_id()); |
| 432 |
| 433 vreg->Merge(splinter, zone()); |
| 434 EXPECT_EQ(1, splinter->relative_id()); |
| 435 } |
| 436 |
410 } // namespace compiler | 437 } // namespace compiler |
411 } // namespace internal | 438 } // namespace internal |
412 } // namespace v8 | 439 } // namespace v8 |
OLD | NEW |