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

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

Issue 656103002: Add JSGraph::GetCachedNodes and NodeCache::GetCachedNodes. These routines are necessary in the dead… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 for (size_t i = 0; i < arraysize(buffer); i++) { 151 for (size_t i = 0; i < arraysize(buffer); i++) {
152 int32_t* p = &buffer[i]; 152 int32_t* p = &buffer[i];
153 Node** pos = cache.Find(graph.zone(), p); 153 Node** pos = cache.Find(graph.zone(), p);
154 if (*pos != NULL) { 154 if (*pos != NULL) {
155 CHECK_EQ(nodes[i], *pos); 155 CHECK_EQ(nodes[i], *pos);
156 hits++; 156 hits++;
157 } 157 }
158 } 158 }
159 CHECK_LT(4, hits); 159 CHECK_LT(4, hits);
160 } 160 }
161
162
163 static bool Contains(NodeVector* nodes, Node* n) {
164 for (size_t i = 0; i < nodes->size(); i++) {
165 if (nodes->at(i) == n) return true;
166 }
167 return false;
168 }
169
170
171 TEST(NodeCache_GetCachedNodes_int32) {
172 GraphTester graph;
173 Int32NodeCache cache;
174 CommonOperatorBuilder common(graph.zone());
175
176 int32_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11,
177 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11};
178
179 for (size_t i = 0; i < arraysize(constants); i++) {
180 int32_t k = constants[i];
181 Node** pos = cache.Find(graph.zone(), k);
182 if (*pos != NULL) {
183 NodeVector nodes(graph.zone());
184 cache.GetCachedNodes(&nodes);
185 CHECK(Contains(&nodes, *pos));
186 } else {
187 NodeVector nodes(graph.zone());
188 Node* n = graph.NewNode(common.Int32Constant(k));
189 *pos = n;
190 cache.GetCachedNodes(&nodes);
191 CHECK(Contains(&nodes, n));
192 }
193 }
194 }
195
196
197 TEST(NodeCache_GetCachedNodes_int64) {
198 GraphTester graph;
199 Int64NodeCache cache;
200 CommonOperatorBuilder common(graph.zone());
201
202 int64_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11,
203 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11};
204
205 for (size_t i = 0; i < arraysize(constants); i++) {
206 int64_t k = constants[i];
207 Node** pos = cache.Find(graph.zone(), k);
208 if (*pos != NULL) {
209 NodeVector nodes(graph.zone());
210 cache.GetCachedNodes(&nodes);
211 CHECK(Contains(&nodes, *pos));
212 } else {
213 NodeVector nodes(graph.zone());
214 Node* n = graph.NewNode(common.Int64Constant(k));
215 *pos = n;
216 cache.GetCachedNodes(&nodes);
217 CHECK(Contains(&nodes, n));
218 }
219 }
220 }
OLDNEW
« src/compiler/node-cache.h ('K') | « test/cctest/compiler/test-js-constant-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698