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

Side by Side Diff: test/cctest/compiler/test-node-cache.cc

Issue 838783002: [turbofan] Cleanup Graph and related classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Parameter pack causes compile errors. Created 5 years, 11 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
OLDNEW
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 6
7 #include "graph-tester.h" 7 #include "graph-tester.h"
8 #include "src/compiler/common-operator.h" 8 #include "src/compiler/common-operator.h"
9 #include "src/compiler/node-cache.h" 9 #include "src/compiler/node-cache.h"
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Node** pos = cache.Find(graph.zone(), v); 108 Node** pos = cache.Find(graph.zone(), v);
109 if (*pos != NULL) { 109 if (*pos != NULL) {
110 CHECK_EQ(nodes[i], *pos); 110 CHECK_EQ(nodes[i], *pos);
111 hits++; 111 hits++;
112 } 112 }
113 } 113 }
114 CHECK_LT(4, hits); 114 CHECK_LT(4, hits);
115 } 115 }
116 116
117 117
118 static bool Contains(NodeVector* nodes, Node* n) { 118 static bool Contains(ZoneVector<Node*>* nodes, Node* n) {
119 for (size_t i = 0; i < nodes->size(); i++) { 119 for (size_t i = 0; i < nodes->size(); i++) {
120 if (nodes->at(i) == n) return true; 120 if (nodes->at(i) == n) return true;
121 } 121 }
122 return false; 122 return false;
123 } 123 }
124 124
125 125
126 TEST(NodeCache_GetCachedNodes_int32) { 126 TEST(NodeCache_GetCachedNodes_int32) {
127 GraphTester graph; 127 GraphTester graph;
128 Int32NodeCache cache; 128 Int32NodeCache cache;
129 CommonOperatorBuilder common(graph.zone()); 129 CommonOperatorBuilder common(graph.zone());
130 130
131 int32_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11, 131 int32_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11,
132 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11}; 132 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11};
133 133
134 for (size_t i = 0; i < arraysize(constants); i++) { 134 for (size_t i = 0; i < arraysize(constants); i++) {
135 int32_t k = constants[i]; 135 int32_t k = constants[i];
136 Node** pos = cache.Find(graph.zone(), k); 136 Node** pos = cache.Find(graph.zone(), k);
137 if (*pos != NULL) { 137 if (*pos != NULL) {
138 NodeVector nodes(graph.zone()); 138 ZoneVector<Node*> nodes(graph.zone());
139 cache.GetCachedNodes(&nodes); 139 cache.GetCachedNodes(&nodes);
140 CHECK(Contains(&nodes, *pos)); 140 CHECK(Contains(&nodes, *pos));
141 } else { 141 } else {
142 NodeVector nodes(graph.zone()); 142 ZoneVector<Node*> nodes(graph.zone());
143 Node* n = graph.NewNode(common.Int32Constant(k)); 143 Node* n = graph.NewNode(common.Int32Constant(k));
144 *pos = n; 144 *pos = n;
145 cache.GetCachedNodes(&nodes); 145 cache.GetCachedNodes(&nodes);
146 CHECK(Contains(&nodes, n)); 146 CHECK(Contains(&nodes, n));
147 } 147 }
148 } 148 }
149 } 149 }
150 150
151 151
152 TEST(NodeCache_GetCachedNodes_int64) { 152 TEST(NodeCache_GetCachedNodes_int64) {
153 GraphTester graph; 153 GraphTester graph;
154 Int64NodeCache cache; 154 Int64NodeCache cache;
155 CommonOperatorBuilder common(graph.zone()); 155 CommonOperatorBuilder common(graph.zone());
156 156
157 int64_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11, 157 int64_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11,
158 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11}; 158 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11};
159 159
160 for (size_t i = 0; i < arraysize(constants); i++) { 160 for (size_t i = 0; i < arraysize(constants); i++) {
161 int64_t k = constants[i]; 161 int64_t k = constants[i];
162 Node** pos = cache.Find(graph.zone(), k); 162 Node** pos = cache.Find(graph.zone(), k);
163 if (*pos != NULL) { 163 if (*pos != NULL) {
164 NodeVector nodes(graph.zone()); 164 ZoneVector<Node*> nodes(graph.zone());
165 cache.GetCachedNodes(&nodes); 165 cache.GetCachedNodes(&nodes);
166 CHECK(Contains(&nodes, *pos)); 166 CHECK(Contains(&nodes, *pos));
167 } else { 167 } else {
168 NodeVector nodes(graph.zone()); 168 ZoneVector<Node*> nodes(graph.zone());
169 Node* n = graph.NewNode(common.Int64Constant(k)); 169 Node* n = graph.NewNode(common.Int64Constant(k));
170 *pos = n; 170 *pos = n;
171 cache.GetCachedNodes(&nodes); 171 cache.GetCachedNodes(&nodes);
172 CHECK(Contains(&nodes, n)); 172 CHECK(Contains(&nodes, n));
173 } 173 }
174 } 174 }
175 } 175 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-graph-reducer.cc ('k') | test/unittests/compiler/common-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698