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

Unified Diff: test/cctest/compiler/test-node-cache.cc

Issue 1114903002: [test] Turn compiler/test-node-cache into a unit test. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-test-node-algorithm
Patch Set: Created 5 years, 8 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/unittests/compiler/node-cache-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index b11e859cbc13eebea7456116cf0e685d613c8afb..0000000000000000000000000000000000000000
--- a/test/cctest/compiler/test-node-cache.cc
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/v8.h"
-
-#include "graph-tester.h"
-#include "src/compiler/common-operator.h"
-#include "src/compiler/node-cache.h"
-
-using namespace v8::internal;
-using namespace v8::internal::compiler;
-
-TEST(Int32Constant_back_to_back) {
- GraphTester graph;
- Int32NodeCache cache;
-
- for (int i = -2000000000; i < 2000000000; i += 3315177) {
- Node** pos = cache.Find(graph.zone(), i);
- CHECK(pos);
- for (int j = 0; j < 3; j++) {
- Node** npos = cache.Find(graph.zone(), i);
- CHECK_EQ(pos, npos);
- }
- }
-}
-
-
-TEST(Int32Constant_five) {
- GraphTester graph;
- Int32NodeCache cache;
- CommonOperatorBuilder common(graph.zone());
-
- int32_t constants[] = {static_cast<int32_t>(0x80000000), -77, 0, 1, -1};
-
- Node* nodes[arraysize(constants)];
-
- for (size_t i = 0; i < arraysize(constants); i++) {
- int32_t k = constants[i];
- Node* node = graph.NewNode(common.Int32Constant(k));
- *cache.Find(graph.zone(), k) = nodes[i] = node;
- }
-
- for (size_t i = 0; i < arraysize(constants); i++) {
- int32_t k = constants[i];
- CHECK_EQ(nodes[i], *cache.Find(graph.zone(), k));
- }
-}
-
-
-TEST(Int32Constant_hits) {
- GraphTester graph;
- Int32NodeCache cache;
- const int32_t kSize = 1500;
- Node** nodes = graph.zone()->NewArray<Node*>(kSize);
- CommonOperatorBuilder common(graph.zone());
-
- for (int i = 0; i < kSize; i++) {
- int32_t v = i * -55;
- nodes[i] = graph.NewNode(common.Int32Constant(v));
- *cache.Find(graph.zone(), v) = nodes[i];
- }
-
- int hits = 0;
- for (int i = 0; i < kSize; i++) {
- int32_t v = i * -55;
- Node** pos = cache.Find(graph.zone(), v);
- if (*pos != NULL) {
- CHECK_EQ(nodes[i], *pos);
- hits++;
- }
- }
- CHECK_LT(4, hits);
-}
-
-
-TEST(Int64Constant_back_to_back) {
- GraphTester graph;
- Int64NodeCache cache;
-
- for (int64_t i = -2000000000; i < 2000000000; i += 3315177) {
- Node** pos = cache.Find(graph.zone(), i);
- CHECK(pos);
- for (int j = 0; j < 3; j++) {
- Node** npos = cache.Find(graph.zone(), i);
- CHECK_EQ(pos, npos);
- }
- }
-}
-
-
-TEST(Int64Constant_hits) {
- GraphTester graph;
- Int64NodeCache cache;
- const int32_t kSize = 1500;
- Node** nodes = graph.zone()->NewArray<Node*>(kSize);
- CommonOperatorBuilder common(graph.zone());
-
- for (int i = 0; i < kSize; i++) {
- int64_t v = static_cast<int64_t>(i) * static_cast<int64_t>(5003001);
- nodes[i] = graph.NewNode(common.Int32Constant(i));
- *cache.Find(graph.zone(), v) = nodes[i];
- }
-
- int hits = 0;
- for (int i = 0; i < kSize; i++) {
- int64_t v = static_cast<int64_t>(i) * static_cast<int64_t>(5003001);
- Node** pos = cache.Find(graph.zone(), v);
- if (*pos != NULL) {
- CHECK_EQ(nodes[i], *pos);
- hits++;
- }
- }
- CHECK_LT(4, hits);
-}
-
-
-static bool Contains(ZoneVector<Node*>* 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) {
- ZoneVector<Node*> nodes(graph.zone());
- cache.GetCachedNodes(&nodes);
- CHECK(Contains(&nodes, *pos));
- } else {
- ZoneVector<Node*> 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) {
- ZoneVector<Node*> nodes(graph.zone());
- cache.GetCachedNodes(&nodes);
- CHECK(Contains(&nodes, *pos));
- } else {
- ZoneVector<Node*> nodes(graph.zone());
- Node* n = graph.NewNode(common.Int64Constant(k));
- *pos = n;
- cache.GetCachedNodes(&nodes);
- CHECK(Contains(&nodes, n));
- }
- }
-}
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/unittests/compiler/node-cache-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698