| OLD | NEW |
| 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.h" | 10 #include "src/compiler/node.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 | 44 |
| 45 ValueNumberingReducer::ValueNumberingReducer(Zone* zone) | 45 ValueNumberingReducer::ValueNumberingReducer(Zone* zone) |
| 46 : entries_(nullptr), capacity_(0), size_(0), zone_(zone) {} | 46 : entries_(nullptr), capacity_(0), size_(0), zone_(zone) {} |
| 47 | 47 |
| 48 | 48 |
| 49 ValueNumberingReducer::~ValueNumberingReducer() {} | 49 ValueNumberingReducer::~ValueNumberingReducer() {} |
| 50 | 50 |
| 51 | 51 |
| 52 Reduction ValueNumberingReducer::Reduce(Node* node) { | 52 Reduction ValueNumberingReducer::Reduce(Node* node) { |
| 53 if (!node->op()->HasProperty(Operator::kEliminatable)) return NoChange(); | 53 if (!node->op()->HasProperty(Operator::kIdempotent)) return NoChange(); |
| 54 | 54 |
| 55 const size_t hash = HashCode(node); | 55 const size_t hash = HashCode(node); |
| 56 if (!entries_) { | 56 if (!entries_) { |
| 57 DCHECK(size_ == 0); | 57 DCHECK(size_ == 0); |
| 58 DCHECK(capacity_ == 0); | 58 DCHECK(capacity_ == 0); |
| 59 // Allocate the initial entries and insert the first entry. | 59 // Allocate the initial entries and insert the first entry. |
| 60 capacity_ = kInitialCapacity; | 60 capacity_ = kInitialCapacity; |
| 61 entries_ = zone()->NewArray<Node*>(kInitialCapacity); | 61 entries_ = zone()->NewArray<Node*>(kInitialCapacity); |
| 62 memset(entries_, 0, sizeof(*entries_) * kInitialCapacity); | 62 memset(entries_, 0, sizeof(*entries_) * kInitialCapacity); |
| 63 entries_[hash & (kInitialCapacity - 1)] = node; | 63 entries_[hash & (kInitialCapacity - 1)] = node; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 size_++; | 155 size_++; |
| 156 break; | 156 break; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace compiler | 162 } // namespace compiler |
| 163 } // namespace internal | 163 } // namespace internal |
| 164 } // namespace v8 | 164 } // namespace v8 |
| OLD | NEW |