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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/compiler/test-node-cache.cc
diff --git a/test/cctest/compiler/test-node-cache.cc b/test/cctest/compiler/test-node-cache.cc
index 3569386c85c75ba55669f0f3c4739e5dc8971b28..57bf7faa9f10eb30b8f929c5a3e088e655c3e1cb 100644
--- a/test/cctest/compiler/test-node-cache.cc
+++ b/test/cctest/compiler/test-node-cache.cc
@@ -158,3 +158,63 @@ TEST(PtrConstant_hits) {
}
CHECK_LT(4, hits);
}
+
+
+static bool Contains(NodeVector* nodes, Node* n) {
+ for (size_t i = 0; i < nodes->size(); i++) {
+ if (nodes->at(i) == n) return true;
+ }
+ return false;
+}
+
+
+TEST(NodeCache_GetCachedNodes_int32) {
+ GraphTester graph;
+ Int32NodeCache cache;
+ CommonOperatorBuilder common(graph.zone());
+
+ int32_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11,
+ 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11};
+
+ for (size_t i = 0; i < arraysize(constants); i++) {
+ int32_t k = constants[i];
+ Node** pos = cache.Find(graph.zone(), k);
+ if (*pos != NULL) {
+ NodeVector nodes(graph.zone());
+ cache.GetCachedNodes(&nodes);
+ CHECK(Contains(&nodes, *pos));
+ } else {
+ NodeVector nodes(graph.zone());
+ Node* n = graph.NewNode(common.Int32Constant(k));
+ *pos = n;
+ cache.GetCachedNodes(&nodes);
+ CHECK(Contains(&nodes, n));
+ }
+ }
+}
+
+
+TEST(NodeCache_GetCachedNodes_int64) {
+ GraphTester graph;
+ Int64NodeCache cache;
+ CommonOperatorBuilder common(graph.zone());
+
+ int64_t constants[] = {0, 311, 12, 13, 14, 555, -555, -44, -33, -22, -11,
+ 0, 311, 311, 412, 412, 11, 11, -33, -33, -22, -11};
+
+ for (size_t i = 0; i < arraysize(constants); i++) {
+ int64_t k = constants[i];
+ Node** pos = cache.Find(graph.zone(), k);
+ if (*pos != NULL) {
+ NodeVector nodes(graph.zone());
+ cache.GetCachedNodes(&nodes);
+ CHECK(Contains(&nodes, *pos));
+ } else {
+ NodeVector nodes(graph.zone());
+ Node* n = graph.NewNode(common.Int64Constant(k));
+ *pos = n;
+ cache.GetCachedNodes(&nodes);
+ CHECK(Contains(&nodes, n));
+ }
+ }
+}
« 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