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

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

Issue 423313004: Remove accidental duplication in cctest suite. (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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/generic-node-inl.h"
9 #include "src/compiler/graph.h"
10 #include "src/compiler/machine-operator.h"
11 #include "src/compiler/node.h"
12 #include "src/compiler/operator.h"
13 #include "src/compiler/schedule.h"
14 #include "test/cctest/cctest.h"
15
16 using namespace v8::internal;
17 using namespace v8::internal::compiler;
18
19 static SimpleOperator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite,
20 0, 0, "dummy");
21
22 TEST(TestScheduleAllocation) {
23 HandleAndZoneScope scope;
24 Schedule schedule(scope.main_zone());
25
26 CHECK_NE(NULL, schedule.entry());
27 CHECK_EQ(schedule.entry(), *(schedule.all_blocks().begin()));
28 }
29
30
31 TEST(TestScheduleAddNode) {
32 HandleAndZoneScope scope;
33 Graph graph(scope.main_zone());
34 Node* n0 = graph.NewNode(&dummy_operator);
35 Node* n1 = graph.NewNode(&dummy_operator);
36
37 Schedule schedule(scope.main_zone());
38
39 BasicBlock* entry = schedule.entry();
40 schedule.AddNode(entry, n0);
41 schedule.AddNode(entry, n1);
42
43 CHECK_EQ(entry, schedule.block(n0));
44 CHECK_EQ(entry, schedule.block(n1));
45 CHECK(schedule.SameBasicBlock(n0, n1));
46
47 Node* n2 = graph.NewNode(&dummy_operator);
48 CHECK_EQ(NULL, schedule.block(n2));
49 }
50
51
52 TEST(TestScheduleAddGoto) {
53 HandleAndZoneScope scope;
54
55 Schedule schedule(scope.main_zone());
56 BasicBlock* entry = schedule.entry();
57 BasicBlock* next = schedule.NewBasicBlock();
58
59 schedule.AddGoto(entry, next);
60
61 CHECK_EQ(0, entry->PredecessorCount());
62 CHECK_EQ(1, entry->SuccessorCount());
63 CHECK_EQ(next, entry->SuccessorAt(0));
64
65 CHECK_EQ(1, next->PredecessorCount());
66 CHECK_EQ(entry, next->PredecessorAt(0));
67 CHECK_EQ(0, next->SuccessorCount());
68 }
69
70
71 TEST(TestScheduleAddBranch) {
72 HandleAndZoneScope scope;
73 Schedule schedule(scope.main_zone());
74
75 BasicBlock* entry = schedule.entry();
76 BasicBlock* tblock = schedule.NewBasicBlock();
77 BasicBlock* fblock = schedule.NewBasicBlock();
78
79 Graph graph(scope.main_zone());
80 CommonOperatorBuilder common(scope.main_zone());
81 Node* n0 = graph.NewNode(&dummy_operator);
82 Node* b = graph.NewNode(common.Branch(), n0);
83
84 schedule.AddBranch(entry, b, tblock, fblock);
85
86 CHECK_EQ(0, entry->PredecessorCount());
87 CHECK_EQ(2, entry->SuccessorCount());
88 CHECK_EQ(tblock, entry->SuccessorAt(0));
89 CHECK_EQ(fblock, entry->SuccessorAt(1));
90
91 CHECK_EQ(1, tblock->PredecessorCount());
92 CHECK_EQ(entry, tblock->PredecessorAt(0));
93 CHECK_EQ(0, tblock->SuccessorCount());
94
95 CHECK_EQ(1, fblock->PredecessorCount());
96 CHECK_EQ(entry, fblock->PredecessorAt(0));
97 CHECK_EQ(0, fblock->SuccessorCount());
98 }
99
100
101 TEST(TestScheduleAddReturn) {
102 HandleAndZoneScope scope;
103 Schedule schedule(scope.main_zone());
104 Graph graph(scope.main_zone());
105 Node* n0 = graph.NewNode(&dummy_operator);
106 BasicBlock* entry = schedule.entry();
107 schedule.AddReturn(entry, n0);
108
109 CHECK_EQ(0, entry->PredecessorCount());
110 CHECK_EQ(1, entry->SuccessorCount());
111 CHECK_EQ(schedule.exit(), entry->SuccessorAt(0));
112 }
113
114
115 TEST(TestScheduleAddThrow) {
116 HandleAndZoneScope scope;
117 Schedule schedule(scope.main_zone());
118 Graph graph(scope.main_zone());
119 Node* n0 = graph.NewNode(&dummy_operator);
120 BasicBlock* entry = schedule.entry();
121 schedule.AddThrow(entry, n0);
122
123 CHECK_EQ(0, entry->PredecessorCount());
124 CHECK_EQ(1, entry->SuccessorCount());
125 CHECK_EQ(schedule.exit(), entry->SuccessorAt(0));
126 }
127
128
129 TEST(TestScheduleAddDeopt) {
130 HandleAndZoneScope scope;
131 Schedule schedule(scope.main_zone());
132 Graph graph(scope.main_zone());
133 Node* n0 = graph.NewNode(&dummy_operator);
134 BasicBlock* entry = schedule.entry();
135 schedule.AddDeoptimize(entry, n0);
136
137 CHECK_EQ(0, entry->PredecessorCount());
138 CHECK_EQ(1, entry->SuccessorCount());
139 CHECK_EQ(schedule.exit(), entry->SuccessorAt(0));
140 }
141
142
143 TEST(BuildMulNodeGraph) {
144 HandleAndZoneScope scope;
145 Schedule schedule(scope.main_zone());
146 Graph graph(scope.main_zone());
147 CommonOperatorBuilder common(scope.main_zone());
148 MachineOperatorBuilder machine(scope.main_zone(), kMachineWord32);
149
150 Node* start = graph.NewNode(common.Start());
151 graph.SetStart(start);
152 Node* param0 = graph.NewNode(common.Parameter(0));
153 Node* param1 = graph.NewNode(common.Parameter(1));
154
155 Node* mul = graph.NewNode(machine.Int32Mul(), param0, param1);
156 Node* ret = graph.NewNode(common.Return(), mul, start);
157
158 USE(ret);
159 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/compiler/test-run-variables.cc ('k') | test/cctest/compiler/compiler/test-scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698