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

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

Issue 822923002: [turbofan] Cache float32 constants on the JSGraph level. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/compiler/node-cache.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 TEST(PtrConstant_back_to_back) {
119 GraphTester graph;
120 PtrNodeCache cache;
121 int32_t buffer[50];
122
123 for (int32_t* p = buffer;
124 (p - buffer) < static_cast<ptrdiff_t>(arraysize(buffer)); p++) {
125 Node** pos = cache.Find(graph.zone(), p);
126 CHECK_NE(NULL, pos);
127 for (int j = 0; j < 3; j++) {
128 Node** npos = cache.Find(graph.zone(), p);
129 CHECK_EQ(pos, npos);
130 }
131 }
132 }
133
134
135 TEST(PtrConstant_hits) {
136 GraphTester graph;
137 PtrNodeCache cache;
138 const int32_t kSize = 50;
139 int32_t buffer[kSize];
140 Node* nodes[kSize];
141 CommonOperatorBuilder common(graph.zone());
142
143 for (size_t i = 0; i < arraysize(buffer); i++) {
144 int k = static_cast<int>(i);
145 int32_t* p = &buffer[i];
146 nodes[i] = graph.NewNode(common.Int32Constant(k));
147 *cache.Find(graph.zone(), p) = nodes[i];
148 }
149
150 int hits = 0;
151 for (size_t i = 0; i < arraysize(buffer); i++) {
152 int32_t* p = &buffer[i];
153 Node** pos = cache.Find(graph.zone(), p);
154 if (*pos != NULL) {
155 CHECK_EQ(nodes[i], *pos);
156 hits++;
157 }
158 }
159 CHECK_LT(4, hits);
160 }
161
162
163 static bool Contains(NodeVector* nodes, Node* n) { 118 static bool Contains(NodeVector* nodes, Node* n) {
164 for (size_t i = 0; i < nodes->size(); i++) { 119 for (size_t i = 0; i < nodes->size(); i++) {
165 if (nodes->at(i) == n) return true; 120 if (nodes->at(i) == n) return true;
166 } 121 }
167 return false; 122 return false;
168 } 123 }
169 124
170 125
171 TEST(NodeCache_GetCachedNodes_int32) { 126 TEST(NodeCache_GetCachedNodes_int32) {
172 GraphTester graph; 127 GraphTester graph;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 CHECK(Contains(&nodes, *pos)); 166 CHECK(Contains(&nodes, *pos));
212 } else { 167 } else {
213 NodeVector nodes(graph.zone()); 168 NodeVector nodes(graph.zone());
214 Node* n = graph.NewNode(common.Int64Constant(k)); 169 Node* n = graph.NewNode(common.Int64Constant(k));
215 *pos = n; 170 *pos = n;
216 cache.GetCachedNodes(&nodes); 171 cache.GetCachedNodes(&nodes);
217 CHECK(Contains(&nodes, n)); 172 CHECK(Contains(&nodes, n));
218 } 173 }
219 } 174 }
220 } 175 }
OLDNEW
« no previous file with comments | « src/compiler/node-cache.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698