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

Side by Side Diff: test/cctest/compiler/test-schedule.cc

Issue 484653002: Finish TODO in Schedule. s/entry/start/g and s/exit/end/g to be more regular. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/test-instruction.cc ('k') | test/cctest/compiler/test-scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/generic-node-inl.h" 8 #include "src/compiler/generic-node-inl.h"
9 #include "src/compiler/graph.h" 9 #include "src/compiler/graph.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
11 #include "src/compiler/node.h" 11 #include "src/compiler/node.h"
12 #include "src/compiler/operator.h" 12 #include "src/compiler/operator.h"
13 #include "src/compiler/schedule.h" 13 #include "src/compiler/schedule.h"
14 #include "test/cctest/cctest.h" 14 #include "test/cctest/cctest.h"
15 15
16 using namespace v8::internal; 16 using namespace v8::internal;
17 using namespace v8::internal::compiler; 17 using namespace v8::internal::compiler;
18 18
19 static SimpleOperator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite, 19 static SimpleOperator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite,
20 0, 0, "dummy"); 20 0, 0, "dummy");
21 21
22 TEST(TestScheduleAllocation) { 22 TEST(TestScheduleAllocation) {
23 HandleAndZoneScope scope; 23 HandleAndZoneScope scope;
24 Schedule schedule(scope.main_zone()); 24 Schedule schedule(scope.main_zone());
25 25
26 CHECK_NE(NULL, schedule.entry()); 26 CHECK_NE(NULL, schedule.start());
27 CHECK_EQ(schedule.entry(), *(schedule.all_blocks().begin())); 27 CHECK_EQ(schedule.start(), *(schedule.all_blocks().begin()));
28 } 28 }
29 29
30 30
31 TEST(TestScheduleAddNode) { 31 TEST(TestScheduleAddNode) {
32 HandleAndZoneScope scope; 32 HandleAndZoneScope scope;
33 Graph graph(scope.main_zone()); 33 Graph graph(scope.main_zone());
34 Node* n0 = graph.NewNode(&dummy_operator); 34 Node* n0 = graph.NewNode(&dummy_operator);
35 Node* n1 = graph.NewNode(&dummy_operator); 35 Node* n1 = graph.NewNode(&dummy_operator);
36 36
37 Schedule schedule(scope.main_zone()); 37 Schedule schedule(scope.main_zone());
38 38
39 BasicBlock* entry = schedule.entry(); 39 BasicBlock* entry = schedule.start();
40 schedule.AddNode(entry, n0); 40 schedule.AddNode(entry, n0);
41 schedule.AddNode(entry, n1); 41 schedule.AddNode(entry, n1);
42 42
43 CHECK_EQ(entry, schedule.block(n0)); 43 CHECK_EQ(entry, schedule.block(n0));
44 CHECK_EQ(entry, schedule.block(n1)); 44 CHECK_EQ(entry, schedule.block(n1));
45 CHECK(schedule.SameBasicBlock(n0, n1)); 45 CHECK(schedule.SameBasicBlock(n0, n1));
46 46
47 Node* n2 = graph.NewNode(&dummy_operator); 47 Node* n2 = graph.NewNode(&dummy_operator);
48 CHECK_EQ(NULL, schedule.block(n2)); 48 CHECK_EQ(NULL, schedule.block(n2));
49 } 49 }
50 50
51 51
52 TEST(TestScheduleAddGoto) { 52 TEST(TestScheduleAddGoto) {
53 HandleAndZoneScope scope; 53 HandleAndZoneScope scope;
54 54
55 Schedule schedule(scope.main_zone()); 55 Schedule schedule(scope.main_zone());
56 BasicBlock* entry = schedule.entry(); 56 BasicBlock* entry = schedule.start();
57 BasicBlock* next = schedule.NewBasicBlock(); 57 BasicBlock* next = schedule.NewBasicBlock();
58 58
59 schedule.AddGoto(entry, next); 59 schedule.AddGoto(entry, next);
60 60
61 CHECK_EQ(0, entry->PredecessorCount()); 61 CHECK_EQ(0, entry->PredecessorCount());
62 CHECK_EQ(1, entry->SuccessorCount()); 62 CHECK_EQ(1, entry->SuccessorCount());
63 CHECK_EQ(next, entry->SuccessorAt(0)); 63 CHECK_EQ(next, entry->SuccessorAt(0));
64 64
65 CHECK_EQ(1, next->PredecessorCount()); 65 CHECK_EQ(1, next->PredecessorCount());
66 CHECK_EQ(entry, next->PredecessorAt(0)); 66 CHECK_EQ(entry, next->PredecessorAt(0));
67 CHECK_EQ(0, next->SuccessorCount()); 67 CHECK_EQ(0, next->SuccessorCount());
68 } 68 }
69 69
70 70
71 TEST(TestScheduleAddBranch) { 71 TEST(TestScheduleAddBranch) {
72 HandleAndZoneScope scope; 72 HandleAndZoneScope scope;
73 Schedule schedule(scope.main_zone()); 73 Schedule schedule(scope.main_zone());
74 74
75 BasicBlock* entry = schedule.entry(); 75 BasicBlock* entry = schedule.start();
76 BasicBlock* tblock = schedule.NewBasicBlock(); 76 BasicBlock* tblock = schedule.NewBasicBlock();
77 BasicBlock* fblock = schedule.NewBasicBlock(); 77 BasicBlock* fblock = schedule.NewBasicBlock();
78 78
79 Graph graph(scope.main_zone()); 79 Graph graph(scope.main_zone());
80 CommonOperatorBuilder common(scope.main_zone()); 80 CommonOperatorBuilder common(scope.main_zone());
81 Node* n0 = graph.NewNode(&dummy_operator); 81 Node* n0 = graph.NewNode(&dummy_operator);
82 Node* b = graph.NewNode(common.Branch(), n0); 82 Node* b = graph.NewNode(common.Branch(), n0);
83 83
84 schedule.AddBranch(entry, b, tblock, fblock); 84 schedule.AddBranch(entry, b, tblock, fblock);
85 85
(...skipping 10 matching lines...) Expand all
96 CHECK_EQ(entry, fblock->PredecessorAt(0)); 96 CHECK_EQ(entry, fblock->PredecessorAt(0));
97 CHECK_EQ(0, fblock->SuccessorCount()); 97 CHECK_EQ(0, fblock->SuccessorCount());
98 } 98 }
99 99
100 100
101 TEST(TestScheduleAddReturn) { 101 TEST(TestScheduleAddReturn) {
102 HandleAndZoneScope scope; 102 HandleAndZoneScope scope;
103 Schedule schedule(scope.main_zone()); 103 Schedule schedule(scope.main_zone());
104 Graph graph(scope.main_zone()); 104 Graph graph(scope.main_zone());
105 Node* n0 = graph.NewNode(&dummy_operator); 105 Node* n0 = graph.NewNode(&dummy_operator);
106 BasicBlock* entry = schedule.entry(); 106 BasicBlock* entry = schedule.start();
107 schedule.AddReturn(entry, n0); 107 schedule.AddReturn(entry, n0);
108 108
109 CHECK_EQ(0, entry->PredecessorCount()); 109 CHECK_EQ(0, entry->PredecessorCount());
110 CHECK_EQ(1, entry->SuccessorCount()); 110 CHECK_EQ(1, entry->SuccessorCount());
111 CHECK_EQ(schedule.exit(), entry->SuccessorAt(0)); 111 CHECK_EQ(schedule.end(), entry->SuccessorAt(0));
112 } 112 }
113 113
114 114
115 TEST(TestScheduleAddThrow) { 115 TEST(TestScheduleAddThrow) {
116 HandleAndZoneScope scope; 116 HandleAndZoneScope scope;
117 Schedule schedule(scope.main_zone()); 117 Schedule schedule(scope.main_zone());
118 Graph graph(scope.main_zone()); 118 Graph graph(scope.main_zone());
119 Node* n0 = graph.NewNode(&dummy_operator); 119 Node* n0 = graph.NewNode(&dummy_operator);
120 BasicBlock* entry = schedule.entry(); 120 BasicBlock* entry = schedule.start();
121 schedule.AddThrow(entry, n0); 121 schedule.AddThrow(entry, n0);
122 122
123 CHECK_EQ(0, entry->PredecessorCount()); 123 CHECK_EQ(0, entry->PredecessorCount());
124 CHECK_EQ(1, entry->SuccessorCount()); 124 CHECK_EQ(1, entry->SuccessorCount());
125 CHECK_EQ(schedule.exit(), entry->SuccessorAt(0)); 125 CHECK_EQ(schedule.end(), entry->SuccessorAt(0));
126 } 126 }
127 127
128 128
129 TEST(TestScheduleAddDeopt) { 129 TEST(TestScheduleAddDeopt) {
130 HandleAndZoneScope scope; 130 HandleAndZoneScope scope;
131 Schedule schedule(scope.main_zone()); 131 Schedule schedule(scope.main_zone());
132 Graph graph(scope.main_zone()); 132 Graph graph(scope.main_zone());
133 Node* n0 = graph.NewNode(&dummy_operator); 133 Node* n0 = graph.NewNode(&dummy_operator);
134 BasicBlock* entry = schedule.entry(); 134 BasicBlock* entry = schedule.start();
135 schedule.AddDeoptimize(entry, n0); 135 schedule.AddDeoptimize(entry, n0);
136 136
137 CHECK_EQ(0, entry->PredecessorCount()); 137 CHECK_EQ(0, entry->PredecessorCount());
138 CHECK_EQ(1, entry->SuccessorCount()); 138 CHECK_EQ(1, entry->SuccessorCount());
139 CHECK_EQ(schedule.exit(), entry->SuccessorAt(0)); 139 CHECK_EQ(schedule.end(), entry->SuccessorAt(0));
140 } 140 }
141 141
142 142
143 TEST(BuildMulNodeGraph) { 143 TEST(BuildMulNodeGraph) {
144 HandleAndZoneScope scope; 144 HandleAndZoneScope scope;
145 Schedule schedule(scope.main_zone()); 145 Schedule schedule(scope.main_zone());
146 Graph graph(scope.main_zone()); 146 Graph graph(scope.main_zone());
147 CommonOperatorBuilder common(scope.main_zone()); 147 CommonOperatorBuilder common(scope.main_zone());
148 MachineOperatorBuilder machine(scope.main_zone()); 148 MachineOperatorBuilder machine(scope.main_zone());
149 149
150 Node* start = graph.NewNode(common.Start(0)); 150 Node* start = graph.NewNode(common.Start(0));
151 graph.SetStart(start); 151 graph.SetStart(start);
152 Node* param0 = graph.NewNode(common.Parameter(0), graph.start()); 152 Node* param0 = graph.NewNode(common.Parameter(0), graph.start());
153 Node* param1 = graph.NewNode(common.Parameter(1), graph.start()); 153 Node* param1 = graph.NewNode(common.Parameter(1), graph.start());
154 154
155 Node* mul = graph.NewNode(machine.Int32Mul(), param0, param1); 155 Node* mul = graph.NewNode(machine.Int32Mul(), param0, param1);
156 Node* ret = graph.NewNode(common.Return(), mul, start); 156 Node* ret = graph.NewNode(common.Return(), mul, start);
157 157
158 USE(ret); 158 USE(ret);
159 } 159 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-instruction.cc ('k') | test/cctest/compiler/test-scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698