OLD | NEW |
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/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, | 27 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, |
28 bool loops_allowed) { | 28 bool loops_allowed) { |
29 CHECK(expected == order->size()); | 29 CHECK(expected == order->size()); |
30 for (int i = 0; i < static_cast<int>(order->size()); i++) { | 30 for (int i = 0; i < static_cast<int>(order->size()); i++) { |
31 CHECK(order->at(i)->rpo_number() == i); | 31 CHECK(order->at(i)->rpo_number() == i); |
32 if (!loops_allowed) { | 32 if (!loops_allowed) { |
33 CHECK_EQ(NULL, order->at(i)->loop_end()); | 33 CHECK_EQ(NULL, order->at(i)->loop_end()); |
34 CHECK_EQ(NULL, order->at(i)->loop_header()); | 34 CHECK_EQ(NULL, order->at(i)->loop_header()); |
35 } | 35 } |
36 } | 36 } |
| 37 int number = 0; |
| 38 for (auto const block : *order) { |
| 39 if (block->deferred()) continue; |
| 40 CHECK_EQ(number, block->ao_number()); |
| 41 ++number; |
| 42 } |
| 43 for (auto const block : *order) { |
| 44 if (!block->deferred()) continue; |
| 45 CHECK_EQ(number, block->ao_number()); |
| 46 ++number; |
| 47 } |
37 } | 48 } |
38 | 49 |
39 | 50 |
40 static void CheckLoop(BasicBlockVector* order, BasicBlock** blocks, | 51 static void CheckLoop(BasicBlockVector* order, BasicBlock** blocks, |
41 int body_size) { | 52 int body_size) { |
42 BasicBlock* header = blocks[0]; | 53 BasicBlock* header = blocks[0]; |
43 BasicBlock* end = header->loop_end(); | 54 BasicBlock* end = header->loop_end(); |
44 CHECK_NE(NULL, end); | 55 CHECK_NE(NULL, end); |
45 CHECK_GT(end->rpo_number(), 0); | 56 CHECK_GT(end->rpo_number(), 0); |
46 CHECK_EQ(body_size, end->rpo_number() - header->rpo_number()); | 57 CHECK_EQ(body_size, end->rpo_number() - header->rpo_number()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 159 |
149 TEST(RPOLine) { | 160 TEST(RPOLine) { |
150 HandleAndZoneScope scope; | 161 HandleAndZoneScope scope; |
151 | 162 |
152 for (int i = 0; i < 10; i++) { | 163 for (int i = 0; i < 10; i++) { |
153 Schedule schedule(scope.main_zone()); | 164 Schedule schedule(scope.main_zone()); |
154 | 165 |
155 BasicBlock* last = schedule.start(); | 166 BasicBlock* last = schedule.start(); |
156 for (int j = 0; j < i; j++) { | 167 for (int j = 0; j < i; j++) { |
157 BasicBlock* block = schedule.NewBasicBlock(); | 168 BasicBlock* block = schedule.NewBasicBlock(); |
| 169 block->set_deferred(i & 1); |
158 schedule.AddGoto(last, block); | 170 schedule.AddGoto(last, block); |
159 last = block; | 171 last = block; |
160 } | 172 } |
161 ZonePool zone_pool(scope.main_isolate()); | 173 ZonePool zone_pool(scope.main_isolate()); |
162 BasicBlockVector* order = | 174 BasicBlockVector* order = |
163 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); | 175 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); |
164 CheckRPONumbers(order, 1 + i, false); | 176 CheckRPONumbers(order, 1 + i, false); |
165 | 177 |
166 for (size_t i = 0; i < schedule.BasicBlockCount(); i++) { | 178 for (size_t i = 0; i < schedule.BasicBlockCount(); i++) { |
167 BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i)); | 179 BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i)); |
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 graph.SetEnd(end); | 1970 graph.SetEnd(end); |
1959 | 1971 |
1960 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); | 1972 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); |
1961 BasicBlock* block = schedule->block(loop); | 1973 BasicBlock* block = schedule->block(loop); |
1962 CHECK_NE(NULL, loop); | 1974 CHECK_NE(NULL, loop); |
1963 CHECK_EQ(block, schedule->block(effect)); | 1975 CHECK_EQ(block, schedule->block(effect)); |
1964 CHECK_GE(block->rpo_number(), 0); | 1976 CHECK_GE(block->rpo_number(), 0); |
1965 } | 1977 } |
1966 | 1978 |
1967 #endif | 1979 #endif |
OLD | NEW |