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

Side by Side Diff: src/compiler/value-numbering-reducer.cc

Issue 2585713002: [turbofan] Use Node input iterators where possible (Closed)
Patch Set: Use == instead of DCHECK_EQ because of missing operator<< for iterators Created 3 years, 12 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
« no previous file with comments | « src/compiler/node.h ('k') | no next file » | 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/compiler/value-numbering-reducer.h" 5 #include "src/compiler/value-numbering-reducer.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "src/base/functional.h" 9 #include "src/base/functional.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
11 #include "src/compiler/node.h" 11 #include "src/compiler/node.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 namespace { 17 namespace {
18 18
19 size_t HashCode(Node* node) { 19 size_t HashCode(Node* node) {
20 size_t h = base::hash_combine(node->op()->HashCode(), node->InputCount()); 20 size_t h = base::hash_combine(node->op()->HashCode(), node->InputCount());
21 for (int j = 0; j < node->InputCount(); ++j) { 21 for (Node* input : node->inputs()) {
22 h = base::hash_combine(h, node->InputAt(j)->id()); 22 h = base::hash_combine(h, input->id());
23 } 23 }
24 return h; 24 return h;
25 } 25 }
26 26
27 27
28 bool Equals(Node* a, Node* b) { 28 bool Equals(Node* a, Node* b) {
29 DCHECK_NOT_NULL(a); 29 DCHECK_NOT_NULL(a);
30 DCHECK_NOT_NULL(b); 30 DCHECK_NOT_NULL(b);
31 DCHECK_NOT_NULL(a->op()); 31 DCHECK_NOT_NULL(a->op());
32 DCHECK_NOT_NULL(b->op()); 32 DCHECK_NOT_NULL(b->op());
33 if (!a->op()->Equals(b->op())) return false; 33 if (!a->op()->Equals(b->op())) return false;
34 if (a->InputCount() != b->InputCount()) return false; 34 if (a->InputCount() != b->InputCount()) return false;
35 for (int j = 0; j < a->InputCount(); ++j) { 35 Node::Inputs aInputs = a->inputs();
36 DCHECK_NOT_NULL(a->InputAt(j)); 36 Node::Inputs bInputs = b->inputs();
37 DCHECK_NOT_NULL(b->InputAt(j)); 37
38 if (a->InputAt(j)->id() != b->InputAt(j)->id()) return false; 38 auto aIt = aInputs.begin();
39 auto bIt = bInputs.begin();
40 auto aEnd = aInputs.end();
41
42 for (; aIt != aEnd; ++aIt, ++bIt) {
43 DCHECK_NOT_NULL(*aIt);
44 DCHECK_NOT_NULL(*bIt);
45 if ((*aIt)->id() != (*bIt)->id()) return false;
39 } 46 }
40 return true; 47 return true;
41 } 48 }
42 49
43 } // namespace 50 } // namespace
44 51
45 ValueNumberingReducer::ValueNumberingReducer(Zone* temp_zone, Zone* graph_zone) 52 ValueNumberingReducer::ValueNumberingReducer(Zone* temp_zone, Zone* graph_zone)
46 : entries_(nullptr), 53 : entries_(nullptr),
47 capacity_(0), 54 capacity_(0),
48 size_(0), 55 size_(0),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 size_++; 208 size_++;
202 break; 209 break;
203 } 210 }
204 } 211 }
205 } 212 }
206 } 213 }
207 214
208 } // namespace compiler 215 } // namespace compiler
209 } // namespace internal 216 } // namespace internal
210 } // namespace v8 217 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698