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 12 matching lines...) Expand all Loading... |
23 using namespace v8::internal; | 23 using namespace v8::internal; |
24 using namespace v8::internal::compiler; | 24 using namespace v8::internal::compiler; |
25 | 25 |
26 // TODO(titzer): pull RPO tests out to their own file. | 26 // TODO(titzer): pull RPO tests out to their own file. |
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_LT(order->at(i)->loop_end(), 0); | 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 } | 37 } |
38 | 38 |
39 | 39 |
40 static void CheckLoop(BasicBlockVector* order, BasicBlock** blocks, | 40 static void CheckLoop(BasicBlockVector* order, BasicBlock** blocks, |
41 int body_size) { | 41 int body_size) { |
42 BasicBlock* header = blocks[0]; | 42 BasicBlock* header = blocks[0]; |
43 CHECK_GT(header->loop_end(), 0); | 43 BasicBlock* end = header->loop_end(); |
44 CHECK_EQ(body_size, (header->loop_end() - header->rpo_number())); | 44 CHECK_NE(NULL, end); |
| 45 CHECK_GT(end->rpo_number(), 0); |
| 46 CHECK_EQ(body_size, end->rpo_number() - header->rpo_number()); |
45 for (int i = 0; i < body_size; i++) { | 47 for (int i = 0; i < body_size; i++) { |
46 int num = blocks[i]->rpo_number(); | 48 CHECK_GE(blocks[i]->rpo_number(), header->rpo_number()); |
47 CHECK(num >= header->rpo_number() && num < header->loop_end()); | 49 CHECK_LT(blocks[i]->rpo_number(), end->rpo_number()); |
48 CHECK(header->LoopContains(blocks[i])); | 50 CHECK(header->LoopContains(blocks[i])); |
49 CHECK(header->IsLoopHeader() || blocks[i]->loop_header() == header); | 51 CHECK(header->IsLoopHeader() || blocks[i]->loop_header() == header); |
50 } | 52 } |
51 if (header->rpo_number() > 0) { | 53 if (header->rpo_number() > 0) { |
52 CHECK_NE(order->at(header->rpo_number() - 1)->loop_header(), header); | 54 CHECK_NE(order->at(header->rpo_number() - 1)->loop_header(), header); |
53 } | 55 } |
54 if (header->loop_end() < static_cast<int>(order->size())) { | 56 if (end->rpo_number() < static_cast<int>(order->size())) { |
55 CHECK_NE(order->at(header->loop_end())->loop_header(), header); | 57 CHECK_NE(order->at(end->rpo_number())->loop_header(), header); |
56 } | 58 } |
57 } | 59 } |
58 | 60 |
59 | 61 |
60 struct TestLoop { | 62 struct TestLoop { |
61 int count; | 63 int count; |
62 BasicBlock** nodes; | 64 BasicBlock** nodes; |
63 BasicBlock* header() { return nodes[0]; } | 65 BasicBlock* header() { return nodes[0]; } |
64 BasicBlock* last() { return nodes[count - 1]; } | 66 BasicBlock* last() { return nodes[count - 1]; } |
65 ~TestLoop() { delete[] nodes; } | 67 ~TestLoop() { delete[] nodes; } |
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 graph.SetEnd(end); | 1958 graph.SetEnd(end); |
1957 | 1959 |
1958 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); | 1960 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); |
1959 BasicBlock* block = schedule->block(loop); | 1961 BasicBlock* block = schedule->block(loop); |
1960 CHECK_NE(NULL, loop); | 1962 CHECK_NE(NULL, loop); |
1961 CHECK_EQ(block, schedule->block(effect)); | 1963 CHECK_EQ(block, schedule->block(effect)); |
1962 CHECK_GE(block->rpo_number(), 0); | 1964 CHECK_GE(block->rpo_number(), 0); |
1963 } | 1965 } |
1964 | 1966 |
1965 #endif | 1967 #endif |
OLD | NEW |