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

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

Issue 501323002: Replace our homegrown ARRAY_SIZE() with Chrome's arraysize(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 15 matching lines...) Expand all
26 } 26 }
27 27
28 28
29 TEST(Int32Constant_five) { 29 TEST(Int32Constant_five) {
30 GraphTester graph; 30 GraphTester graph;
31 Int32NodeCache cache; 31 Int32NodeCache cache;
32 CommonOperatorBuilder common(graph.zone()); 32 CommonOperatorBuilder common(graph.zone());
33 33
34 int32_t constants[] = {static_cast<int32_t>(0x80000000), -77, 0, 1, -1}; 34 int32_t constants[] = {static_cast<int32_t>(0x80000000), -77, 0, 1, -1};
35 35
36 Node* nodes[ARRAY_SIZE(constants)]; 36 Node* nodes[arraysize(constants)];
37 37
38 for (size_t i = 0; i < ARRAY_SIZE(constants); i++) { 38 for (size_t i = 0; i < arraysize(constants); i++) {
39 int32_t k = constants[i]; 39 int32_t k = constants[i];
40 Node* node = graph.NewNode(common.Int32Constant(k)); 40 Node* node = graph.NewNode(common.Int32Constant(k));
41 *cache.Find(graph.zone(), k) = nodes[i] = node; 41 *cache.Find(graph.zone(), k) = nodes[i] = node;
42 } 42 }
43 43
44 for (size_t i = 0; i < ARRAY_SIZE(constants); i++) { 44 for (size_t i = 0; i < arraysize(constants); i++) {
45 int32_t k = constants[i]; 45 int32_t k = constants[i];
46 CHECK_EQ(nodes[i], *cache.Find(graph.zone(), k)); 46 CHECK_EQ(nodes[i], *cache.Find(graph.zone(), k));
47 } 47 }
48 } 48 }
49 49
50 50
51 TEST(Int32Constant_hits) { 51 TEST(Int32Constant_hits) {
52 GraphTester graph; 52 GraphTester graph;
53 Int32NodeCache cache; 53 Int32NodeCache cache;
54 const int32_t kSize = 1500; 54 const int32_t kSize = 1500;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 CHECK_LT(4, hits); 114 CHECK_LT(4, hits);
115 } 115 }
116 116
117 117
118 TEST(PtrConstant_back_to_back) { 118 TEST(PtrConstant_back_to_back) {
119 GraphTester graph; 119 GraphTester graph;
120 PtrNodeCache cache; 120 PtrNodeCache cache;
121 int32_t buffer[50]; 121 int32_t buffer[50];
122 122
123 for (int32_t* p = buffer; 123 for (int32_t* p = buffer;
124 (p - buffer) < static_cast<ptrdiff_t>(ARRAY_SIZE(buffer)); p++) { 124 (p - buffer) < static_cast<ptrdiff_t>(arraysize(buffer)); p++) {
125 Node** pos = cache.Find(graph.zone(), p); 125 Node** pos = cache.Find(graph.zone(), p);
126 CHECK_NE(NULL, pos); 126 CHECK_NE(NULL, pos);
127 for (int j = 0; j < 3; j++) { 127 for (int j = 0; j < 3; j++) {
128 Node** npos = cache.Find(graph.zone(), p); 128 Node** npos = cache.Find(graph.zone(), p);
129 CHECK_EQ(pos, npos); 129 CHECK_EQ(pos, npos);
130 } 130 }
131 } 131 }
132 } 132 }
133 133
134 134
135 TEST(PtrConstant_hits) { 135 TEST(PtrConstant_hits) {
136 GraphTester graph; 136 GraphTester graph;
137 PtrNodeCache cache; 137 PtrNodeCache cache;
138 const int32_t kSize = 50; 138 const int32_t kSize = 50;
139 int32_t buffer[kSize]; 139 int32_t buffer[kSize];
140 Node* nodes[kSize]; 140 Node* nodes[kSize];
141 CommonOperatorBuilder common(graph.zone()); 141 CommonOperatorBuilder common(graph.zone());
142 142
143 for (size_t i = 0; i < ARRAY_SIZE(buffer); i++) { 143 for (size_t i = 0; i < arraysize(buffer); i++) {
144 int k = static_cast<int>(i); 144 int k = static_cast<int>(i);
145 int32_t* p = &buffer[i]; 145 int32_t* p = &buffer[i];
146 nodes[i] = graph.NewNode(common.Int32Constant(k)); 146 nodes[i] = graph.NewNode(common.Int32Constant(k));
147 *cache.Find(graph.zone(), p) = nodes[i]; 147 *cache.Find(graph.zone(), p) = nodes[i];
148 } 148 }
149 149
150 int hits = 0; 150 int hits = 0;
151 for (size_t i = 0; i < ARRAY_SIZE(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698